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__MoopCases__FormPanel.f39...

366 lines
938 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[187,6,7],{"+NIl":function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){"use strict";oe.defineMode("stex",function(Z,D){"use strict";function $(L,C){L.cmdState.push(C)}function B(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function M(L){var C=L.cmdState.pop();C&&C.closeBracket()}function z(L){for(var C=L.cmdState,T=C.length-1;T>=0;T--){var h=C[T];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function W(L,C,T){return function(){this.name=L,this.bracketNo=0,this.style=C,this.styles=T,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var P={};P.importmodule=W("importmodule","tag",["string","builtin"]),P.documentclass=W("documentclass","tag",["","atom"]),P.usepackage=W("usepackage","tag",["atom"]),P.begin=W("begin","tag",["atom"]),P.end=W("end","tag",["atom"]),P.label=W("label","tag",["atom"]),P.ref=W("ref","tag",["atom"]),P.eqref=W("eqref","tag",["atom"]),P.cite=W("cite","tag",["atom"]),P.bibitem=W("bibitem","tag",["atom"]),P.Bibitem=W("Bibitem","tag",["atom"]),P.RBibitem=W("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function R(L,C){L.f=C}function y(L,C){var T;if(L.match(/^\\[a-zA-Z@]+/)){var h=L.current().slice(1);return T=P.hasOwnProperty(h)?P[h]:P.DEFAULT,T=new T,$(C,T),R(C,O),T.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return R(C,function(l,d){return A(l,d,"\\]")}),"keyword";if(L.match("\\("))return R(C,function(l,d){return A(l,d,"\\)")}),"keyword";if(L.match("$$"))return R(C,function(l,d){return A(l,d,"$$")}),"keyword";if(L.match("$"))return R(C,function(l,d){return A(l,d,"$")}),"keyword";var o=L.next();if(o=="%")return L.skipToEnd(),"comment";if(o=="}"||o=="]"){if(T=B(C),T)T.closeBracket(o),R(C,O);else return"error";return"bracket"}else return o=="{"||o=="["?(T=P.DEFAULT,T=new T,$(C,T),"bracket"):/\d/.test(o)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),T=z(C),T.name=="begin"&&(T.argument=L.current()),T.styleIdentifier())}function A(L,C,T){if(L.eatSpace())return null;if(T&&L.match(T))return R(C,y),"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 h=L.next();return h=="{"||h=="}"||h=="["||h=="]"||h=="("||h==")"?"bracket":h=="%"?(L.skipToEnd(),"comment"):"error"}function O(L,C){var T=L.peek(),h;return T=="{"||T=="["?(h=B(C),h.openBracket(T),L.eat(T),R(C,y),"bracket"):/[ \t\r]/.test(T)?(L.eat(T),null):(R(C,y),M(C),y(L,C))}return{startState:function(){var L=D.inMathMode?function(C,T){return A(C,T)}:y;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,C){return C.f(L,C)},blankLine:function(L){L.f=y,L.cmdState.length=0},lineComment:"%"}}),oe.defineMIME("text/x-stex","stex"),oe.defineMIME("text/x-latex","stex")})},"19Vz":function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){oe.defineOption("placeholder","",function(W,P,R){var y=R&&R!=oe.Init;if(P&&!y)W.on("blur",B),W.on("change",M),W.on("swapDoc",M),oe.on(W.getInputField(),"compositionupdate",W.state.placeholderCompose=function(){$(W)}),M(W);else if(!P&&y){W.off("blur",B),W.off("change",M),W.off("swapDoc",M),oe.off(W.getInputField(),"compositionupdate",W.state.placeholderCompose),Z(W);var A=W.getWrapperElement();A.className=A.className.replace(" CodeMirror-empty","")}P&&!W.hasFocus()&&B(W)});function Z(W){W.state.placeholder&&(W.state.placeholder.parentNode.removeChild(W.state.placeholder),W.state.placeholder=null)}function D(W){Z(W);var P=W.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=W.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var R=W.getOption("placeholder");typeof R=="string"&&(R=document.createTextNode(R)),P.appendChild(R),W.display.lineSpace.insertBefore(P,W.display.lineSpace.firstChild)}function $(W){setTimeout(function(){var P=!1,R=W.getInputField();R.nodeName=="TEXTAREA"?P=!R.value:W.lineCount()==1&&(P=!/[^\u200b]/.test(R.querySelector(".CodeMirror-line").textContent)),P?D(W):Z(W)},20)}function B(W){z(W)&&D(W)}function M(W){var P=W.getWrapperElement(),R=z(W);P.className=P.className.replace(" CodeMirror-empty","")+(R?" CodeMirror-empty":""),R?D(W):Z(W)}function z(W){return W.lineCount()===1&&W.getLine(0)===""}})},"1eCo":function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){"use strict";var Z={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};oe.defineMode("xml",function($,B){var M=$.indentUnit,z={},W=B.htmlMode?Z:D;for(var P in W)z[P]=W[P];for(var P in B)z[P]=B[P];var R,y;function A(a,b){function m(U){return b.tokenize=U,U(a,b)}var x=a.next();if(x=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?m(C("atom","]]>")):null:a.match("--")?m(C("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),m(T(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=C("meta","?>"),"meta"):(R=a.eat("/")?"closeTag":"openTag",b.tokenize=O,"tag bracket");if(x=="&"){var F;return a.eat("#")?a.eat("x")?F=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):F=a.eatWhile(/[\d]/)&&a.eat(";"):F=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),F?"atom":"error"}else return a.eatWhile(/[^&<]/),null}A.isInText=!0;function O(a,b){var m=a.next();if(m==">"||m=="/"&&a.eat(">"))return b.tokenize=A,R=m==">"?"endTag":"selfcloseTag","tag bracket";if(m=="=")return R="equals",null;if(m=="<"){b.tokenize=A,b.state=d,b.tagName=b.tagStart=null;var x=b.tokenize(a,b);return x?x+" tag error":"tag error"}else return/[\'\"]/.test(m)?(b.tokenize=L(m),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(a){var b=function(m,x){for(;!m.eol();)if(m.next()==a){x.tokenize=O;break}return"string"};return b.isInAttribute=!0,b}function C(a,b){return function(m,x){for(;!m.eol();){if(m.match(b)){x.tokenize=A;break}m.next()}return a}}function T(a){return function(b,m){for(var x;(x=b.next())!=null;){if(x=="<")return m.tokenize=T(a+1),m.tokenize(b,m);if(x==">")if(a==1){m.tokenize=A;break}else return m.tokenize=T(a-1),m.tokenize(b,m)}return"meta"}}function h(a,b,m){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=m,(z.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,b){for(var m;;){if(!a.context)return;if(m=a.context.tagName,!z.contextGrabbers.hasOwnProperty(m)||!z.contextGrabbers[m].hasOwnProperty(b))return;o(a)}}function d(a,b,m){return a=="openTag"?(m.tagStart=b.column(),w):a=="closeTag"?v:d}function w(a,b,m){return a=="word"?(m.tagName=b.current(),y="tag",E):z.allowMissingTagName&&a=="endTag"?(y="tag bracket",E(a,b,m)):(y="error",w)}function v(a,b,m){if(a=="word"){var x=b.current();return m.context&&m.context.tagName!=x&&z.implicitlyClosed.hasOwnProperty(m.context.tagName)&&o(m),m.context&&m.context.tagName==x||z.matchClosing===!1?(y="tag",g):(y="tag error",k)}else return z.allowMissingTagName&&a=="endTag"?(y="tag bracket",g(a,b,m)):(y="error",k)}function g(a,b,m){return a!="endTag"?(y="error",g):(o(m),d)}function k(a,b,m){return y="error",g(a,b,m)}function E(a,b,m){if(a=="word")return y="attribute",p;if(a=="endTag"||a=="selfcloseTag"){var x=m.tagName,F=m.tagStart;return m.tagName=m.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(x)?l(m,x):(l(m,x),m.context=new h(m,x,F==m.indented)),d}return y="error",E}function p(a,b,m){return a=="equals"?c:(z.allowMissing||(y="error"),E(a,b,m))}function c(a,b,m){return a=="string"?u:a=="word"&&z.allowUnquoted?(y="string",E):(y="error",E(a,b,m))}function u(a,b,m){return a=="string"?u:E(a,b,m)}return{startState:function(a){var b={tokenize:A,state:d,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;R=null;var m=b.tokenize(a,b);return(m||R)&&m!="comment"&&(y=null,b.state=b.state(R||m,a,b),y&&(m=y=="error"?m+" error":y)),m},indent:function(a,b,m){var x=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+M;if(x&&x.noIndent)return oe.Pass;if(a.tokenize!=O&&a.tokenize!=A)return m?m.match(/^(\s*)/)[0].length:0;if(a.tagName)return z.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+M*(z.multilineTagIndentFactor||1);if(z.alignCDATA&&/<!\[CDATA\[/.test(b))return 0;var F=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);if(F&&F[1])for(;x;)if(x.tagName==F[2]){x=x.prev;break}else if(z.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(F)for(;x;){var U=z.contextGrabbers[x.tagName];if(U&&U.hasOwnProperty(F[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.indent+M:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=E)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],m=a.context;m;m=m.prev)m.tagName&&b.push(m.tagName);return b.reverse()}}}),oe.defineMIME("text/xml","xml"),oe.defineMIME("application/xml","xml"),oe.mimeModes.hasOwnProperty("text/html")||oe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(xt,it,se){"use strict";se.d(it,"a",function(){return l});var oe=se("Ty5D"),Z=se("dI71"),D=se("q1tI"),$=se.n(D),B=se("YS25"),M=se("17x9"),z=se.n(M),W=se("wx14"),P=se("zLVn"),R=se("9R94"),y=function(c){Object(Z.a)(u,c);function u(){for(var b,m=arguments.length,x=new Array(m),F=0;F<m;F++)x[F]=arguments[F];return b=c.call.apply(c,[this].concat(x))||this,b.history=Object(B.a)(b.props),b}var a=u.prototype;return a.render=function(){return $.a.createElement(oe.c,{history:this.history,children:this.props.children})},u}($.a.Component),A=function(c){Object(Z.a)(u,c);function u(){for(var b,m=arguments.length,x=new Array(m),F=0;F<m;F++)x[F]=arguments[F];return b=c.call.apply(c,[this].concat(x))||this,b.history=Object(B.b)(b.props),b}var a=u.prototype;return a.render=function(){return $.a.createElement(oe.c,{history:this.history,children:this.props.children})},u}($.a.Component),O=function(u,a){return typeof u=="function"?u(a):u},L=function(u,a){return typeof u=="string"?Object(B.c)(u,null,null,a):u},C=function(u){return u},T=$.a.forwardRef;typeof T=="undefined"&&(T=C);function h(c){return!!(c.metaKey||c.altKey||c.ctrlKey||c.shiftKey)}var o=T(function(c,u){var a=c.innerRef,b=c.navigate,m=c.onClick,x=Object(P.a)(c,["innerRef","navigate","onClick"]),F=x.target,U=Object(W.a)({},x,{onClick:function(V){try{m&&m(V)}catch(_){throw V.preventDefault(),_}!V.defaultPrevented&&V.button===0&&(!F||F==="_self")&&!h(V)&&(V.preventDefault(),b())}});return C!==T?U.ref=u||a:U.ref=a,$.a.createElement("a",U)}),l=T(function(c,u){var a=c.component,b=a===void 0?o:a,m=c.replace,x=c.to,F=c.innerRef,U=Object(P.a)(c,["component","replace","to","innerRef"]);return $.a.createElement(oe.e.Consumer,null,function(K){K||Object(R.a)(!1);var V=K.history,_=L(O(x,K.location),K.location),I=_?V.createHref(_):"",Y=Object(W.a)({},U,{href:I,navigate:function(){var ae=O(x,K.location),de=m?V.replace:V.push;de(ae)}});return C!==T?Y.ref=u||F:Y.innerRef=F,$.a.createElement(b,Y)})});if(!1)var d,w;var v=function(u){return u},g=$.a.forwardRef;typeof g=="undefined"&&(g=v);function k(){for(var c=arguments.length,u=new Array(c),a=0;a<c;a++)u[a]=arguments[a];return u.filter(function(b){return b}).join(" ")}var E=g(function(c,u){var a=c["aria-current"],b=a===void 0?"page":a,m=c.activeClassName,x=m===void 0?"active":m,F=c.activeStyle,U=c.className,K=c.exact,V=c.isActive,_=c.location,I=c.sensitive,Y=c.strict,ee=c.style,ae=c.to,de=c.innerRef,De=Object(P.a)(c,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return $.a.createElement(oe.e.Consumer,null,function(Se){Se||Object(R.a)(!1);var we=_||Se.location,Ce=L(O(ae,we),we),Te=Ce.pathname,ge=Te&&Te.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),le=ge?Object(oe.f)(we.pathname,{path:ge,exact:K,sensitive:I,strict:Y}):null,te=!!(V?V(le,we):le),ce=te?k(U,x):U,ne=te?Object(W.a)({},ee,{},F):ee,Le=Object(W.a)({"aria-current":te&&b||null,className:ce,style:ne,to:Ce},De);return v!==g?Le.ref=u||de:Le.innerRef=de,$.a.createElement(l,Le)})});if(!1)var p},"7Cbv":function(xt,it,se){"use strict";var oe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Z=new Uint8Array(16);function D(){if(!oe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oe(Z)}var $=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function B(O){return typeof O=="string"&&$.test(O)}for(var M=B,z=[],W=0;W<256;++W)z.push((W+256).toString(16).substr(1));function P(O){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,C=(z[O[L+0]]+z[O[L+1]]+z[O[L+2]]+z[O[L+3]]+"-"+z[O[L+4]]+z[O[L+5]]+"-"+z[O[L+6]]+z[O[L+7]]+"-"+z[O[L+8]]+z[O[L+9]]+"-"+z[O[L+10]]+z[O[L+11]]+z[O[L+12]]+z[O[L+13]]+z[O[L+14]]+z[O[L+15]]).toLowerCase();if(!M(C))throw TypeError("Stringified UUID is invalid");return C}var R=P;function y(O,L,C){O=O||{};var T=O.random||(O.rng||D)();if(T[6]=T[6]&15|64,T[8]=T[8]&63|128,L){C=C||0;for(var h=0;h<16;++h)L[C+h]=T[h];return L}return R(T)}var A=it.a=y},"7ahc":function(xt,it,se){"use strict";se.d(it,"a",function(){return w});var oe=se("k1fw"),Z=se("0Owb"),D=se("+L6B"),$=se("2/Rp"),B=se("y8nQ"),M=se("Vl3Y"),z=se("tJVT"),W=se("OaEy"),P=se("2fM7"),R=se("q1tI"),y=se.n(R),A=se("VrN/"),O=se.n(A),L=se("p77/"),C=se.n(L),T=se("c5Ni"),h=se.n(T),o=P.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},d={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"]};it.b=function(v){var g=v.callback,k=v.onCancel,E=Object(R.useState)("python"),p=Object(z.a)(E,2),c=p[0],u=p[1];function a(m){u(d[m][1])}function b(m){g(m)}return y.a.createElement(M.a,Object(Z.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),y.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},y.a.createElement(P.a,{onChange:a},Object.keys(d).map(function(m){return y.a.createElement(o,{key:m,value:m},d[m][0])}))),y.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},y.a.createElement(w,{mode:c})),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement($.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement($.a,{type:"ghost",onClick:k},"\u53D6\u6D88")))};function w(v){var g=v.value,k=v.onChange,E=v.mode,p=v.options,c=p===void 0?{}:p,u=Object(R.useRef)(),a=Object(R.useState)(),b=Object(z.a)(a,2),m=b[0],x=b[1];return Object(R.useEffect)(function(){if(m){function F(U){var K=U.getValue();k&&k(K)}return m.on("change",F),function(){m.off("change",F)}}},[m,k]),Object(R.useEffect)(function(){m&&m.setOption("mode",E)},[m,E]),Object(R.useEffect)(function(){m&&((g!==m.getValue()||g==="")&&setTimeout(function(){m.setValue(g||" ")},300))},[m,g]),Object(R.useEffect)(function(){if(u.current&&!m){var F=O.a.fromTextArea(u.current,Object(oe.a)({mode:E,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));x(F)}},[u.current,m]),y.a.createElement("div",{className:"my-codemirror-container"},y.a.createElement("textarea",{ref:u}))}},"7ixt":function(xt,it,se){"use strict";se.d(it,"a",function(){return D});var oe={adjustX:1,adjustY:1},Z=[0,0],D={left:{points:["cr","cl"],overflow:oe,offset:[-4,0],targetOffset:Z},right:{points:["cl","cr"],overflow:oe,offset:[4,0],targetOffset:Z},top:{points:["bc","tc"],overflow:oe,offset:[0,-4],targetOffset:Z},bottom:{points:["tc","bc"],overflow:oe,offset:[0,4],targetOffset:Z},topLeft:{points:["bl","tl"],overflow:oe,offset:[0,-4],targetOffset:Z},leftTop:{points:["tr","tl"],overflow:oe,offset:[-4,0],targetOffset:Z},topRight:{points:["br","tr"],overflow:oe,offset:[0,-4],targetOffset:Z},rightTop:{points:["tl","tr"],overflow:oe,offset:[4,0],targetOffset:Z},bottomRight:{points:["tr","br"],overflow:oe,offset:[0,4],targetOffset:Z},rightBottom:{points:["bl","br"],overflow:oe,offset:[4,0],targetOffset:Z},bottomLeft:{points:["tl","bl"],overflow:oe,offset:[0,4],targetOffset:Z},leftBottom:{points:["br","bl"],overflow:oe,offset:[-4,0],targetOffset:Z}},$=D},"8EBN":function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){"use strict";oe.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 Z=0;Z<oe.modeInfo.length;Z++){var D=oe.modeInfo[Z];D.mimes&&(D.mime=D.mimes[0])}oe.findModeByMIME=function($){$=$.toLowerCase();for(var B=0;B<oe.modeInfo.length;B++){var M=oe.modeInfo[B];if(M.mime==$)return M;if(M.mimes){for(var z=0;z<M.mimes.length;z++)if(M.mimes[z]==$)return M}}if(/\+xml$/.test($))return oe.findModeByMIME("application/xml");if(/\+json$/.test($))return oe.findModeByMIME("application/json")},oe.findModeByExtension=function($){$=$.toLowerCase();for(var B=0;B<oe.modeInfo.length;B++){var M=oe.modeInfo[B];if(M.ext){for(var z=0;z<M.ext.length;z++)if(M.ext[z]==$)return M}}},oe.findModeByFileName=function($){for(var B=0;B<oe.modeInfo.length;B++){var M=oe.modeInfo[B];if(M.file&&M.file.test($))return M}var z=$.lastIndexOf("."),W=z>-1&&$.substring(z+1,$.length);if(W)return oe.findModeByExtension(W)},oe.findModeByName=function($){$=$.toLowerCase();for(var B=0;B<oe.modeInfo.length;B++){var M=oe.modeInfo[B];if(M.name.toLowerCase()==$)return M;if(M.alias){for(var z=0;z<M.alias.length;z++)if(M.alias[z].toLowerCase()==$)return M}}}})},"8hTe":function(xt,it,se){xt.exports={button:"button___1wy9m"}},"9Bee":function(xt,it,se){"use strict";var oe=se("DYRE"),Z=se("zeV3"),D=se("+L6B"),$=se("2/Rp"),B=se("k1fw"),M=se("9og8"),z=se("tJVT"),W=se("WmNS"),P=se.n(W),R=se("q1tI"),y=se.n(R),A=se("vg9a"),O=se("DlQD"),L=se.n(O),C=se("rUJ1");function T(G,s){var f=G.match(/^(\s+)(?:```)/);if(f===null)return s;var N=f[1];return s.split(`
`).map(function(Q){var H=Q.match(/^\s+/);if(H===null)return Q;var me=Object(z.a)(H,1),We=me[0];return We.length>=N.length?Q.slice(N.length):Q}).join(`
`)}var h=[],o=["<ul>"],l=new L.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function w(){h.length=0,o=["<ul>"]}var v={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function g(G,s,f,N){if(s>=G.length||G[s].level<=f)return s;var Q=G[s];N.push("<li><a href='#"+Q.anchor+"'>"+Q.text+"</a>"),s++;var H=[];return s=g(G,s,Q.level,H),H.length>0&&(N.push("<ul>"),H.forEach(function(me){N.push(me)}),N.push("</ul>")),N.push("</li>"),s=g(G,s,f,N),s}function k(){return g(h,0,0,o),o.push("</ul>"),o.join("")}var E={heading:function(s){var f=d.exec(s);if(f)return{type:"heading",raw:f[0],depth:f[1].length,text:f[2]}},fences:function(s){var f=this.rules.block.fences.exec(s);if(f){var N=f[0],Q=T(N,f[3]||""),H=f[2]?f[2].trim():f[2];if(["latex","katex","math"].indexOf(H)>=0){var me=u(),We=Q;Q=me,a[me]={type:"block",expression:We}}return{type:"code",raw:N,lang:H,text:Q}}}},p=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,u=function(){return"__special_katext_id_".concat(c++,"__")},a={};function b(){return a}function m(){c=0,a={}}function x(G){return G=G.replace(p,function(s,f){var N=u();return a[N]={type:"inline",expression:f},N}),G}var F=l.listitem;l.listitem=function(G){return F(x(G))};var U=l.paragraph;l.paragraph=function(G){return U(x(G))};var K=l.tablecell;l.tablecell=function(G,s){return K(x(G),s)},l.code=function(G,s,f){var N=(s||"").match(/\S*/)[0];return N?["latex","katex","math"].indexOf(N)>=0?"<p class='editormd-tex'>".concat(G,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(f?G:Object(C.escape)(G,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(f?G:Object(C.escape)(G,!0))+"</code></pre>"},l.heading=function(G,s,f){var N=this.options.headerPrefix+f.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:N,level:s,text:G}),"<h"+s+' id="'+N+'">'+G+"</h"+s+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:E,renderer:l});var V=L.a,_=se("SJMd"),I=se("ulZh"),Y=se.n(I),ee=se("m3rI"),ae=se("Oy/b"),de=se("p5ED"),De=se("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 Se=function(G,s){return(Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,N){f.__proto__=N}||function(f,N){for(var Q in N)Object.prototype.hasOwnProperty.call(N,Q)&&(f[Q]=N[Q])})(G,s)};function we(G,s){function f(){this.constructor=G}Se(G,s),G.prototype=s===null?Object.create(s):(f.prototype=s.prototype,new f)}function Ce(G,s,f,N){return new(f||(f=Promise))(function(Q,H){function me(ct){try{Je(N.next(ct))}catch(Ge){H(Ge)}}function We(ct){try{Je(N.throw(ct))}catch(Ge){H(Ge)}}function Je(ct){var Ge;ct.done?Q(ct.value):(Ge=ct.value,Ge instanceof f?Ge:new f(function(vt){vt(Ge)})).then(me,We)}Je((N=N.apply(G,s||[])).next())})}function Te(G,s){var f,N,Q,H,me={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:We(0),throw:We(1),return:We(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function We(Je){return function(ct){return function(Ge){if(f)throw new TypeError("Generator is already executing.");for(;me;)try{if(f=1,N&&(Q=2&Ge[0]?N.return:Ge[0]?N.throw||((Q=N.return)&&Q.call(N),0):N.next)&&!(Q=Q.call(N,Ge[1])).done)return Q;switch(N=0,Q&&(Ge=[2&Ge[0],Q.value]),Ge[0]){case 0:case 1:Q=Ge;break;case 4:return me.label++,{value:Ge[1],done:!1};case 5:me.label++,N=Ge[1],Ge=[0];continue;case 7:Ge=me.ops.pop(),me.trys.pop();continue;default:if(!(Q=me.trys,(Q=Q.length>0&&Q[Q.length-1])||Ge[0]!==6&&Ge[0]!==2)){me=0;continue}if(Ge[0]===3&&(!Q||Ge[1]>Q[0]&&Ge[1]<Q[3])){me.label=Ge[1];break}if(Ge[0]===6&&me.label<Q[1]){me.label=Q[1],Q=Ge;break}if(Q&&me.label<Q[2]){me.label=Q[2],me.ops.push(Ge);break}Q[2]&&me.ops.pop(),me.trys.pop();continue}Ge=s.call(G,me)}catch(vt){Ge=[6,vt],N=0}finally{f=Q=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([Je,ct])}}}function ge(){for(var G=0,s=0,f=arguments.length;s<f;s++)G+=arguments[s].length;var N=Array(G),Q=0;for(s=0;s<f;s++)for(var H=arguments[s],me=0,We=H.length;me<We;me++,Q++)N[Q]=H[me];return N}var le=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,f){for(var N=0,Q=f;N<Q.length;N++){var H=Q[N],me=H[0],We=H[1];s.setAttribute(me,We)}},G.createRect=function(s,f,N){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",f.toString()),N&&G.setAttributes(Q,N),Q},G.createLine=function(s,f,N,Q,H){var me=document.createElementNS("http://www.w3.org/2000/svg","line");return me.setAttribute("x1",s.toString()),me.setAttribute("y1",f.toString()),me.setAttribute("x2",N.toString()),me.setAttribute("y2",Q.toString()),H&&G.setAttributes(me,H),me},G.createPolygon=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","polygon");return N.setAttribute("points",s),f&&G.setAttributes(N,f),N},G.createCircle=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","circle");return N.setAttribute("cx",(s/2).toString()),N.setAttribute("cy",(s/2).toString()),N.setAttribute("r",s.toString()),f&&G.setAttributes(N,f),N},G.createEllipse=function(s,f,N){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(f/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(f/2).toString()),N&&G.setAttributes(Q,N),Q},G.createGroup=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(f,s),f},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,f,N,Q,H,me,We){var Je=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Je,[["id",s],["orient",f],["markerWidth",N.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",me.toString()]]),Je.appendChild(We),Je},G.createText=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","text");return f.setAttribute("x","0"),f.setAttribute("y","0"),s&&G.setAttributes(f,s),f},G.createTSpan=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","tspan");return N.textContent=s,f&&G.setAttributes(N,f),N},G.createImage=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(f,s),f},G.createPoint=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return N.x=s,N.y=f,N},G.createPath=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","path");return N.setAttribute("d",s),f&&G.setAttributes(N,f),N},G}(),te=function(){function G(){}return G.addKey=function(s){G.key=s},Object.defineProperty(G,"isLicensed",{get:function(){return!!G.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(G.key)},enumerable:!1,configurable:!0}),G}(),ce=function(){function G(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return G.prototype.rasterize=function(s,f,N){var Q=this;return new Promise(function(H){var me=N!==void 0?N:document.createElement("canvas");s===null&&(Q.markersOnly=!0,Q.naturalSize=!1);var We=document.createElementNS("http://www.w3.org/2000/svg","svg");We.setAttribute("xmlns","http://www.w3.org/2000/svg"),We.setAttribute("width",f.width.baseVal.valueAsString),We.setAttribute("height",f.height.baseVal.valueAsString),We.setAttribute("viewBox","0 0 "+f.viewBox.baseVal.width.toString()+" "+f.viewBox.baseVal.height.toString()),We.innerHTML=f.innerHTML,Q.naturalSize===!0?(We.width.baseVal.value=s.naturalWidth,We.height.baseVal.value=s.naturalHeight):Q.width!==void 0&&Q.height!==void 0&&(We.width.baseVal.value=Q.width,We.height.baseVal.value=Q.height),me.width=We.width.baseVal.value,me.height=We.height.baseVal.value;var Je=We.outerHTML,ct=me.getContext("2d");Q.markersOnly!==!0&&ct.drawImage(s,0,0,me.width,me.height);var Ge=window.URL,vt=new Image(me.width,me.height);vt.setAttribute("crossOrigin","anonymous");var Nt=new Blob([Je],{type:"image/svg+xml"}),Kt=Ge.createObjectURL(Nt);vt.onload=function(){ct.drawImage(vt,0,0),Ge.revokeObjectURL(Kt);var Or=me.toDataURL(Q.imageType,Q.imageQuality);H(Or)},vt.src=Kt})},G}(),ne=function(){},Le=function(){function G(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(G.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),G.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},G.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)},G.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 Oe("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Oe("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Oe("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new Ee("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new Ee("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},G.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},G}(),Oe=function(G,s){this.selector=G,this.style=s},Ee=function(G,s){this.localName=G,this.style=s},Re=function(){function G(s,f,N,Q,H){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=f,this.markerItems=N,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 G.prototype.show=function(s){var f=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 N=document.createElement("div");N.className=this.toolbarBlockStyleClass.name,N.style.whiteSpace="nowrap",this.uiContainer.appendChild(N),this.addActionButton(N,'<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(N,'<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(N,'<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(N,'<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(N,'<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(N,'<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(N,'<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(N,'<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 me=document.createElement("div");me.className=""+f.toolbarButtonStyleClass.name,me.setAttribute("data-type-name",H.typeName),me.innerHTML=H.icon,me.addEventListener("click",function(){f.markerToolbarButtonClicked(me,H)}),f.buttons.push(me),f.markerButtons.push(me)}),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()},G.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},G.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},G.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},G.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 f=0;f<this.markerButtons.length;f++)f<s||f===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[f]):(f===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[f]))}},G.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")},G.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(f){f.className=f.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),f.className=f.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),f.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},G.prototype.addActionButton=function(s,f,N){var Q=this,H=document.createElement("div");switch(H.className=""+this.toolbarButtonStyleClass.name,H.innerHTML=f,H.setAttribute("data-action",N),H.addEventListener("click",function(){Q.actionToolbarButtonClicked(H,N)}),N){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)},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Ee("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ee("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Oe("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Oe("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},G.prototype.markerToolbarButtonClicked=function(s,f){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(N){return N("marker",f)}),this.markerButtonOverflowBlock.style.display="none"},G.prototype.actionToolbarButtonClicked=function(s,f){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(N){return N("action",f)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},G.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)},G.prototype.setActiveMarkerButton=function(s){var f=this.markerButtons.find(function(N){return N.getAttribute("data-type-name")===s});f&&this.setActiveButton(f)},G.prototype.setCurrentMarker=function(s){var f=this;this.currentMarker=s,this.buttons.filter(function(N){return/delete|notes/.test(N.getAttribute("data-action"))}).forEach(function(N){f.currentMarker===void 0?(N.style.fillOpacity="0.4",N.style.pointerEvents="none"):(N.style.fillOpacity="1",N.style.pointerEvents="all")})},G}(),Ne=function(){function G(s,f,N,Q){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=f,this.uiStyleSettings=N,this.styles=Q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return G.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Ee("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 Ee("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var f=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Ee("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Ee("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Ee("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 Ee("toolbox-panel-row_colors",`
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Ee("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*f)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*f)+`px;
padding: `+f+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Ee("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Ee("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Oe("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Oe("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},G.prototype.show=function(s){var f;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((f=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&f!==void 0?f:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},G.prototype.setPanelButtons=function(s){var f,N,Q=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((f=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&f!==void 0?f:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((N=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&N!==void 0?N:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(H){var me;H.uiStyleSettings=Q.uiStyleSettings;var We=document.createElement("div");We.className=Q.toolboxButtonStyleClass.name+" "+((me=Q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&me!==void 0?me:Q.toolboxButtonStyleColorsClass.name),We.innerHTML=H.icon,We.title=H.title,We.addEventListener("click",function(){Q.panelButtonClick(H)}),Q.panelButtons.push(We),Q.buttonRow.appendChild(We)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},G.prototype.panelButtonClick=function(s){var f=this,N=-1;if(s!==this.activePanel){N=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(){f.displayMode==="inline"?f.panelRow.style.display="none":f.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(H,me){var We,Je;H.className=f.toolboxButtonStyleClass.name+" "+(me===N?""+((We=f.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&We!==void 0?We:f.toolboxActiveButtonStyleColorsClass.name):""+((Je=f.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Je!==void 0?Je:f.toolboxButtonStyleColorsClass.name))})},G}(),je=function(G,s){this.title=G,this.icon=s},Ue=function(G){function s(f,N,Q,H){var me=G.call(this,f,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 me.colors=[],me.addTransparent=!1,me.colorBoxes=[],me.colors=N,me.currentColor=Q,me.setCurrentColor=me.setCurrentColor.bind(me),me.getColorBox=me.getColorBox.bind(me),me}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");return N.style.overflow="hidden",N.style.whiteSpace="nowrap",this.colors.forEach(function(Q){var H=f.getColorBox(Q);N.appendChild(H),f.colorBoxes.push(H)}),N},s.prototype.getColorBox=function(f){var N=this,Q=this.uiStyleSettings.toolbarHeight/4,H=this.uiStyleSettings.toolbarHeight-Q,me=document.createElement("div");me.style.display="inline-block",me.style.boxSizing="content-box",me.style.width=H-2+"px",me.style.height=H-2+"px",me.style.padding="1px",me.style.marginRight="2px",me.style.marginBottom="2px",me.style.borderWidth="2px",me.style.borderStyle="solid",me.style.borderRadius=(H+2)/2+"px",me.style.borderColor=f===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",me.addEventListener("click",function(){N.setCurrentColor(f,me)});var We=document.createElement("div");return We.style.display="inline-block",We.style.width=H-2+"px",We.style.height=H-2+"px",We.style.backgroundColor=f,We.style.borderRadius=H/2+"px",f==="transparent"&&(We.style.fill=this.uiStyleSettings.toolboxAccentColor,We.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>`),me.appendChild(We),me},s.prototype.setCurrentColor=function(f,N){var Q=this;this.currentColor=f,this.colorBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(f)},s}(je),Ie=function(){function G(s,f,N){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=f,this.globalSettings=N,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(G.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),G.prototype.ownsTarget=function(s){return!1},Object.defineProperty(G.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),G.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},G.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},G.prototype.pointerDown=function(s,f){},G.prototype.dblClick=function(s,f){},G.prototype.manipulate=function(s){},G.prototype.pointerUp=function(s){this.stateChanged()},G.prototype.dispose=function(){},G.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},G.prototype.getState=function(){return{typeName:G.typeName,state:this.state,notes:this.notes}},G.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},G.prototype.scale=function(s,f){},G.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},G.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},G.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)}},G.typeName="MarkerBase",G}(),Me=function(){function G(){this.findGripByVisual=this.findGripByVisual.bind(this)}return G.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},G}(),Ke=function(){function G(){this.GRIP_SIZE=10,this.visual=le.createGroup(),this.visual.appendChild(le.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(le.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return G.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},G}(),Ze=function(){function G(){}return G.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},G.toSVGMatrix=function(s,f){return s.a=f.a,s.b=f.b,s.c=f.c,s.d=f.d,s.e=f.e,s.f=f.f,s},G}(),$e=function(G){function s(f,N,Q){var H=G.call(this,f,N,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(le.createTransform()),H.setupControlBox(),H}return we(s,G),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(f){this._visual=f;var N=le.createTransform();this._visual.transform.baseVal.appendItem(N)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(f){return!!G.prototype.ownsTarget.call(this,f)||!!(this.controlGrips.findGripByVisual(f)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(f))},s.prototype.pointerDown=function(f,N){G.prototype.pointerDown.call(this,f,N),this.state==="new"&&(this.left=f.x,this.top=f.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var Q=this.unrotatePoint(f);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(N),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(N)){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 me=this.container.transform.baseVal.getItem(0);me.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(me,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(f){var N=this.state;G.prototype.pointerUp.call(this,f),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(f),this._state="select",N==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(f){this.visual.style.transform="translate("+f.x+"px, "+f.y+"px)"},s.prototype.manipulate=function(f){var N=this.unrotatePoint(f);this.state==="creating"?this.resize(f):this.state==="move"?(this.left=this.manipulationStartLeft+(N.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(N.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(N):this.state==="rotate"&&this.rotate(f)},s.prototype.resize=function(f){var N=this.manipulationStartLeft,Q=this.manipulationStartWidth,H=this.manipulationStartTop,me=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:N=this.manipulationStartLeft+f.x-this.manipulationStartX,Q=this.manipulationStartWidth+this.manipulationStartLeft-N;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Q=this.manipulationStartWidth+f.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:H=this.manipulationStartTop+f.y-this.manipulationStartY,me=this.manipulationStartHeight+this.manipulationStartTop-H;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:me=this.manipulationStartHeight+f.y-this.manipulationStartY}Q>=0?(this.left=N,this.width=Q):(this.left=N+Q,this.width=-Q),me>=0?(this.top=H,this.height=me):(this.top=H+me,this.height=-me),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(f){if(Math.abs(f.x-this.centerX)>.1){var N=Math.sign(f.x-this.centerX);this.rotationAngle=180*Math.atan((f.y-this.centerY)/(f.x-this.centerX))/Math.PI+90*N,this.applyRotation()}},s.prototype.applyRotation=function(){var f=this.container.transform.baseVal.getItem(0);f.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(f,0)},s.prototype.rotatePoint=function(f){if(this.rotationAngle===0)return f;var N=this.container.getCTM(),Q=le.createPoint(f.x,f.y);return{x:(Q=Q.matrixTransform(N)).x,y:Q.y}},s.prototype.unrotatePoint=function(f){if(this.rotationAngle===0)return f;var N=this.container.getCTM();N=N.inverse();var Q=le.createPoint(f.x,f.y);return{x:(Q=Q.matrixTransform(N)).x,y:Q.y}},s.prototype.select=function(){G.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){G.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.createGroup();var f=le.createTransform();f.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(f),this.container.appendChild(this.controlBox),this.controlRect=le.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=le.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 Me,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var f=this.controlBox.transform.baseVal.getItem(0);f.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(f,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 f=new Ke;return f.visual.transform.baseVal.appendItem(le.createTransform()),this.controlBox.appendChild(f.visual),f},s.prototype.positionGrips=function(){var f=this.controlGrips.topLeft.GRIP_SIZE,N=-f/2,Q=N,H=(this.width+this.CB_DISTANCE)/2-f/2,me=(this.height+this.CB_DISTANCE)/2-f/2,We=this.height+this.CB_DISTANCE-f/2,Je=this.width+this.CB_DISTANCE-f/2;this.positionGrip(this.controlGrips.topLeft.visual,N,Q),this.positionGrip(this.controlGrips.topCenter.visual,H,Q),this.positionGrip(this.controlGrips.topRight.visual,Je,Q),this.positionGrip(this.controlGrips.centerLeft.visual,N,me),this.positionGrip(this.controlGrips.centerRight.visual,Je,me),this.positionGrip(this.controlGrips.bottomLeft.visual,N,We),this.positionGrip(this.controlGrips.bottomCenter.visual,H,We),this.positionGrip(this.controlGrips.bottomRight.visual,Je,We),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,H,Q-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(f,N,Q){var H=f.transform.baseVal.getItem(0);H.setTranslate(N,Q),f.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:Ze.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Ze.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},G.prototype.getState.call(this))},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f);var N=f;this.left=N.left,this.top=N.top,this.width=N.width,this.height=N.height,this.rotationAngle=N.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Ze.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,N.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Ze.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,N.containerTransformMatrix))},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N);var Q=this.rotatePoint({x:this.left,y:this.top}),H=this.unrotatePoint({x:Q.x*f,y:Q.y*N});this.left=H.x,this.top=H.y,this.width=this.width*f,this.height=this.height*N,this.adjustControlBox()},s}(Ie),Qe=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.visual)},s.prototype.createVisual=function(){this.visual=le.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(f,N){G.prototype.pointerDown.call(this,f,N),this.state==="new"&&(this.createVisual(),this.moveVisual(f),this._state="creating")},s.prototype.manipulate=function(f){G.prototype.manipulate.call(this,f)},s.prototype.resize=function(f){G.prototype.resize.call(this,f),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(f){G.prototype.pointerUp.call(this,f),this.setSize()},s.prototype.setStrokeColor=function(f){this.strokeColor=f,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(f),this.stateChanged()},s.prototype.setFillColor=function(f){this.fillColor=f,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(f){this.strokeWidth=f,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(f){this.strokeDasharray=f,this.visual&&le.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},G.prototype.getState.call(this))},s.prototype.restoreState=function(f){var N=f;this.fillColor=N.fillColor,this.strokeColor=N.strokeColor,this.strokeWidth=N.strokeWidth,this.strokeDasharray=N.strokeDasharray,this.opacity=N.opacity,this.createVisual(),G.prototype.restoreState.call(this,f),this.setSize()},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),this.setSize()},s.title="Rectangle marker",s}($e),lt=function(G){function s(f,N,Q,H){var me=G.call(this,f,H||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return me.widths=[],me.widthBoxes=[],me.widths=N,me.currentWidth=Q,me.setCurrentWidth=me.setCurrentWidth.bind(me),me}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");return N.style.display="flex",N.style.overflow="hidden",N.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===f.currentWidth?f.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){f.setCurrentWidth(Q,H)}),N.appendChild(H);var me=document.createElement("div");me.innerText=Q.toString(),me.style.marginRight="5px",H.appendChild(me);var We=document.createElement("div");We.style.minHeight="20px",We.style.flexGrow="2",We.style.display="flex",We.style.alignItems="center";var Je=document.createElement("hr");Je.style.minWidth="20px",Je.style.border="0px",Je.style.borderTop=Q+"px solid "+f.uiStyleSettings.toolboxColor,Je.style.flexGrow="2",We.appendChild(Je),H.appendChild(We),f.widthBoxes.push(H)}),N},s.prototype.setCurrentWidth=function(f,N){var Q=this;this.currentWidth=f,this.widthBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(je),tt=function(G){function s(f,N,Q,H){var me=G.call(this,f,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 me.styles=[],me.styleBoxes=[],me.styles=N,me.currentStyle=Q,me.setCurrentStyle=me.setCurrentStyle.bind(me),me}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");return N.style.display="flex",N.style.overflow="hidden",N.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/f.styles.length-5+"%",H.style.borderColor=Q===f.currentStyle?f.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){f.setCurrentStyle(Q,H)}),N.appendChild(H);var me=document.createElement("div");me.style.minHeight="20px",me.style.flexGrow="2",me.style.overflow="hidden";var We=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+f.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Q!==""?'stroke-dasharray="'+Q+'"':"")+` />
</svg>`;me.innerHTML=We,H.appendChild(me),f.styleBoxes.push(H)}),N},s.prototype.setCurrentStyle=function(f,N){var Q=this;this.currentStyle=f,this.styleBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(je),rt=function(G){function s(f,N,Q){var H=G.call(this,f,N,Q)||this;return H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Ue("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new tt("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var f=G.prototype.getState.call(this);return f.typeName=s.typeName,f},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(Qe),Pe=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},ht=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 we(s,G),s.prototype.ownsTarget=function(f){return!!G.prototype.ownsTarget.call(this,f)||!(!this.grip1.ownsTarget(f)&&!this.grip2.ownsTarget(f))},s.prototype.pointerDown=function(f,N){G.prototype.pointerDown.call(this,f,N),this.manipulationStartX=f.x,this.manipulationStartY=f.y,this.state==="new"&&(this.x1=f.x,this.y1=f.y,this.x2=f.x,this.y2=f.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(N)?this.activeGrip=this.grip1:this.grip2.ownsTarget(N)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(f){var N=this.state;G.prototype.pointerUp.call(this,f),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(f),this._state="select",N==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(f){this.state==="creating"?this.resize(f):this.state==="move"?(this.x1=this.manipulationStartX1+f.x-this.manipulationStartX,this.y1=this.manipulationStartY1+f.y-this.manipulationStartY,this.x2=this.manipulationStartX2+f.x-this.manipulationStartX,this.y2=this.manipulationStartY2+f.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(f)},s.prototype.resize=function(f){switch(this.activeGrip){case this.grip1:this.x1=f.x,this.y1=f.y;break;case this.grip2:case void 0:this.x2=f.x,this.y2=f.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){G.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){G.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.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 f=new Ke;return f.visual.transform.baseVal.appendItem(le.createTransform()),this.controlBox.appendChild(f.visual),f},s.prototype.positionGrips=function(){var f=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-f/2,this.y1-f/2),this.positionGrip(this.grip2.visual,this.x2-f/2,this.y2-f/2)},s.prototype.positionGrip=function(f,N,Q){var H=f.transform.baseVal.getItem(0);H.setTranslate(N,Q),f.transform.baseVal.replaceItem(H,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},G.prototype.getState.call(this))},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f);var N=f;this.x1=N.x1,this.y1=N.y1,this.x2=N.x2,this.y2=N.y2},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),this.x1=this.x1*f,this.y1=this.y1*N,this.x2=this.x2*f,this.y2=this.y2*N,this.adjustVisual(),this.adjustControlBox()},s}(Ie),at=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new tt("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.visual&&f!==this.selectorLine&&f!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.selectorLine=le.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=le.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(f,N){G.prototype.pointerDown.call(this,f,N),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()),le.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(f){this.strokeColor=f,this.adjustVisual(),this.colorChanged(f)},s.prototype.setStrokeWidth=function(f){this.strokeWidth=f,this.adjustVisual()},s.prototype.setStrokeDasharray=function(f){this.strokeDasharray=f,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 f=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f);var N=f;this.strokeColor=N.strokeColor,this.strokeWidth=N.strokeWidth,this.strokeDasharray=N.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}(ht),Fe=function(G){function s(f,N,Q,H){var me=G.call(this,f,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 me.fonts=[],me.fontBoxes=[],me.fonts=N,me.currentFont=Q,me.setCurrentFont=me.setCurrentFont.bind(me),me}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");return N.style.overflow="hidden",N.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/f.fonts.length-5+"%",H.style.borderColor=Q===f.currentFont?f.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){f.setCurrentFont(Q,H)}),N.appendChild(H);var me=document.createElement("div");me.style.display="flex",me.style.minHeight="20px",me.style.flexGrow="2",me.style.fontFamily=Q,me.style.overflow="hidden";var We=document.createElement("div");We.style.whiteSpace="nowrap",We.style.overflow="hidden",We.style.textOverflow="ellipsis",We.innerHTML="The quick brown fox jumps over the lazy dog",me.appendChild(We),H.appendChild(me),f.fontBoxes.push(H)}),N},s.prototype.setCurrentFont=function(f,N){var Q=this;this.currentFont=f,this.fontBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(je),Ve=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.fontFamilyPanel=new Fe("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H}return we(s,G),s.prototype.ownsTarget=function(f){if(G.prototype.ownsTarget.call(this,f)||f===this.visual||f===this.textElement||f===this.bgRectangle)return!0;var N=!1;return this.textElement.childNodes.forEach(function(Q){Q===f&&(N=!0)}),N},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.bgRectangle=le.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=le.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(f,N){G.prototype.pointerDown.call(this,f,N),this.isMoved=!1,this.pointerDownPoint=f,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(f),this._state="creating")},s.prototype.renderText=function(){var f=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(N){f.textElement.appendChild(le.createTSpan(N.trim()===""?" ":N.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var f=this.textElement.getBBox(),N=1;if(f.width>0&&f.height>0){var Q=(1*this.width-this.width*this.padding*2/100)/f.width,H=(1*this.height-this.height*this.padding*2/100)/f.height;N=Math.min(Q,H)}return N},s.prototype.getTextPosition=function(f){var N=this.textElement.getBBox(),Q=0,H=0;return N.width>0&&N.height>0&&(Q=(this.width-N.width*f)/2,H=this.height/2-N.height*f/2),{x:Q,y:H}},s.prototype.sizeText=function(){var f=this.textElement.getBBox(),N=this.getTextScale(),Q=this.getTextPosition(N);Q.y-=f.y*N,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Q.x+"px, "+Q.y+"px) scale("+N+", "+N+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Q.x,Q.y),this.textElement.transform.baseVal.getItem(1).setScale(N,N))},s.prototype.manipulate=function(f){G.prototype.manipulate.call(this,f),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(f.x-this.pointerDownPoint.x)>5||Math.abs(f.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(f){G.prototype.resize.call(this,f),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){G.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(f){var N=this.state;N==="creating"&&(this._suppressMarkerCreateEvent=!0),G.prototype.pointerUp.call(this,f),this.setSize(),(N==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var f=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(N){N.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var N=Number.parseFloat(f.textEditor.style.fontSize);f.textEditor.clientWidth>=Number.parseInt(f.textEditor.style.maxWidth)&&N>.9;)N-=.1,f.textEditor.style.fontSize=Math.max(N,.9)+"em"}),this.textEditor.addEventListener("keyup",function(N){N.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(N){if(N.clipboardData){var Q=N.clipboardData.getData("text"),H=window.getSelection();if(!H.rangeCount)return!1;H.deleteFromDocument(),H.getRangeAt(0).insertNode(document.createTextNode(Q)),N.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){f.textEditDivClicked(f.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 f=this.getTextScale(),N=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Q=this.textElement.getBBox(),H={x:Q.width*f,y:Q.height*f};N.x-=H.x/2,N.y-=H.y/2,this.textEditor.style.top=N.y+"px",this.textEditor.style.left=N.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-N.x+"px",this.textEditor.style.fontSize=Math.max(16*f,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(f){this.text=f.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){G.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),G.prototype.deselect.call(this)},s.prototype.dblClick=function(f,N){G.prototype.dblClick.call(this,f,N),this.showTextEditor()},s.prototype.setColor=function(f){this.textElement&&le.setAttributes(this.textElement,[["fill",f]]),this.color=f,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(f)},s.prototype.setFont=function(f){this.textElement&&le.setAttributes(this.textElement,[["font-family",f]]),this.fontFamily=f,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 f=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){var N=f;this.color=N.color,this.fontFamily=N.fontFamily,this.padding=N.padding,this.text=N.text,this.createVisual(),G.prototype.restoreState.call(this,f),this.setSize()},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),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}($e),xe=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.lineWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.lineWidthPanel.onWidthChanged=H.setLineWidth,H}return we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.visual&&f!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.drawingImage=le.createImage(),this.visual.appendChild(this.drawingImage);var f=le.createTransform();this.visual.transform.baseVal.appendItem(f),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(f,N){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(f.x,f.y),this.drawing=!0):G.prototype.pointerDown.call(this,f,N)},s.prototype.manipulate=function(f){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(f.x,f.y),this.canvasContext.stroke()):G.prototype.manipulate.call(this,f)},s.prototype.resize=function(f){G.prototype.resize.call(this,f),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(f){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):G.prototype.pointerUp.call(this,f)},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(),G.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),G.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var f=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),N=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Q=N[0],H=N[1],me=N[2],We=N[3],Je=!1,ct=0;ct<this.canvasElement.height;ct++)for(var Ge=0;Ge<this.canvasElement.width;Ge++)f.data[ct*this.canvasElement.width*4+4*Ge+3]>0&&(Je=!0,ct<H&&(H=ct),Ge<Q&&(Q=Ge),ct>We&&(We=ct),Ge>me&&(me=Ge));if(Je){this.left=Q/this.pixelRatio,this.top=H/this.pixelRatio,this.width=(me-Q)/this.pixelRatio,this.height=(We-H)/this.pixelRatio;var vt=document.createElement("canvas");vt.width=me-Q,vt.height=We-H,vt.getContext("2d").putImageData(this.canvasContext.getImageData(Q,H,me-Q,We-H),0,0),this.drawingImgUrl=vt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(f){this.color=f,this.colorChanged(f)},s.prototype.setLineWidth=function(f){this.lineWidth=f},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 f=Object.assign({drawingImgUrl:this.drawingImgUrl},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){this.createVisual(),G.prototype.restoreState.call(this,f),this.drawingImgUrl=f.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),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}($e),ve=function(G){function s(f,N,Q){var H=G.call(this,f,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=N,H.setCurrentType=H.setCurrentType.bind(H),H}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");N.style.display="flex",N.style.overflow="hidden",N.style.flexGrow="2";for(var Q=function(We){var Je="both";switch(We){case 0:Je="both";break;case 1:Je="start";break;case 2:Je="end";break;case 3:Je="none"}var ct=document.createElement("div");if(ct.style.display="flex",ct.style.flexGrow="2",ct.style.alignItems="center",ct.style.justifyContent="space-between",ct.style.padding="5px",ct.style.borderWidth="2px",ct.style.borderStyle="solid",ct.style.borderColor=Je===H.currentType?H.uiStyleSettings.toolboxAccentColor:"transparent",ct.addEventListener("click",function(){f.setCurrentType(Je,ct)}),N.appendChild(ct),Je==="both"||Je==="start"){var Ge=document.createElement("div");Ge.style.display="flex",Ge.style.alignItems="center",Ge.style.minHeight="20px",Ge.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>`,Ge.style.marginLeft="5px",ct.appendChild(Ge)}var vt=document.createElement("div");vt.style.display="flex",vt.style.alignItems="center",vt.style.minHeight="20px",vt.style.flexGrow="2";var Nt=document.createElement("hr");if(Nt.style.minWidth="20px",Nt.style.border="0px",Nt.style.borderTop="3px solid "+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee"),Nt.style.flexGrow="2",vt.appendChild(Nt),ct.appendChild(vt),Je==="both"||Je==="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",ct.appendChild(Kt)}H.typeBoxes.push(ct)},H=this,me=0;me<4;me++)Q(me);return N},s.prototype.setCurrentType=function(f,N){var Q=this;this.currentType=f,this.typeBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings!==void 0?Q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(je),ye=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 ve("Arrow type","end"),H.arrowTypePanel.onArrowTypeChanged=H.setArrowType,H}return we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.arrow1&&f!==this.arrow2)},s.prototype.getArrowPoints=function(f,N){var Q=this.arrowBaseWidth+2*this.strokeWidth,H=this.arrowBaseHeight+2*this.strokeWidth;return f-Q/2+","+(N+H/2)+" "+f+","+(N-H/2)+" "+(f+Q/2)+","+(N+H/2)},s.prototype.createTips=function(){this.arrow1=le.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=le.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(f,N){G.prototype.pointerDown.call(this,f,N),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(G.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",le.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),le.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var f=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),N=this.arrow1.transform.baseVal.getItem(0);N.setRotate(f,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(N,0);var Q=this.arrow2.transform.baseVal.getItem(0);Q.setRotate(f+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Q,0)}},s.prototype.setArrowType=function(f){this.arrowType=f,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 f=Object.assign({arrowType:this.arrowType},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f);var N=f;this.arrowType=N.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}(at),re=function(G){function s(f,N,Q){var H=G.call(this,f,N,Q)||this;return H.fillColor=Q.defaultFillColor,H.strokeWidth=0,H.fillPanel=new Ue("Color",Q.defaultColorSet,Q.defaultFillColor),H.fillPanel.onColorChanged=H.setFillColor,H}return we(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var f=G.prototype.getState.call(this);return f.typeName=s.typeName,f},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(Qe),ie=function(G){function s(f,N,Q,H){var me=G.call(this,f,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 me.opacities=[],me.opacityBoxes=[],me.opacities=N,me.currentOpacity=Q,me.setCurrentOpacity=me.setCurrentOpacity.bind(me),me}return we(s,G),s.prototype.getUi=function(){var f=this,N=document.createElement("div");return N.style.display="flex",N.style.overflow="hidden",N.style.flexGrow="2",N.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===f.currentOpacity?f.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){f.setCurrentOpacity(Q,H)}),N.appendChild(H);var me=document.createElement("div");me.innerText=100*Q+"%",H.appendChild(me),f.opacityBoxes.push(H)}),N},s.prototype.setCurrentOpacity=function(f,N){var Q=this;this.currentOpacity=f,this.opacityBoxes.forEach(function(H){H.style.borderColor=H===N?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(je),ue=function(G){function s(f,N,Q){var H=G.call(this,f,N,Q)||this;return H.setOpacity=H.setOpacity.bind(H),H.fillColor=Q.defaultHighlightColor,H.strokeWidth=0,H.opacity=Q.defaultHighlightOpacity,H.fillPanel=new Ue("Color",Q.defaultColorSet,H.fillColor),H.fillPanel.onColorChanged=H.setFillColor,H.opacityPanel=new ie("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return we(s,G),s.prototype.setOpacity=function(f){this.opacity=f,this.visual&&le.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 f=G.prototype.getState.call(this);return f.typeName=s.typeName,f},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}(re),pe='<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>',be=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("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 Ue("Fill color",Q.defaultColorSet,H.bgColor,pe),H.bgColorPanel.onColorChanged=H.setBgColor,H.fontFamilyPanel=new Fe("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H.tipGrip=new Ke,H.tipGrip.visual.transform.baseVal.appendItem(le.createTransform()),H.controlBox.appendChild(H.tipGrip.visual),H}return we(s,G),s.prototype.ownsTarget=function(f){return G.prototype.ownsTarget.call(this,f)||this.tipGrip.ownsTarget(f)||this.tip===f},s.prototype.createTip=function(){le.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=le.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(f,N){this.state==="new"&&G.prototype.pointerDown.call(this,f,N),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(N)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):G.prototype.pointerDown.call(this,f,N)},s.prototype.pointerUp=function(f){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,G.prototype.pointerUp.call(this,f);else{var N=this.state==="creating";G.prototype.pointerUp.call(this,f),this.setTipPoints(N),this.positionTip()}},s.prototype.manipulate=function(f){if(this.tipMoving){var N=this.unrotatePoint(f);this.tipPosition={x:N.x-this.manipulationStartLeft,y:N.y-this.manipulationStartTop},this.positionTip()}else G.prototype.manipulate.call(this,f)},s.prototype.setBgColor=function(f){this.bgRectangle&&this.tip&&(le.setAttributes(this.bgRectangle,[["fill",f]]),le.setAttributes(this.tip,[["fill",f]])),this.bgColor=f,this.fillColorChanged(f)},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(f){f===void 0&&(f=!1);var N=Math.min(this.height/2,15),Q=this.height/5;f&&(this.tipPosition={x:N+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,N=Math.min(this.width/2,15),this.tipBase1Position={x:N,y:0},this.tipBase2Position={x:N+Q,y:0}):(this.tipBase1Position={x:0,y:N},this.tipBase2Position={x:0,y:N+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,N=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-N-Q,y:0},this.tipBase2Position={x:this.width-N,y:0}):(this.tipBase1Position={x:this.width,y:N},this.tipBase2Position={x:this.width,y:N+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,N=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-N-Q,y:this.height},this.tipBase2Position={x:this.width-N,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-N-Q},this.tipBase2Position={x:this.width,y:this.height-N}):H<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,N=Math.min(this.width/2,15),this.tipBase1Position={x:N,y:this.height},this.tipBase2Position={x:N+Q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-N},this.tipBase2Position={x:0,y:this.height-N-Q})},s.prototype.resize=function(f){G.prototype.resize.call(this,f),this.positionTip()},s.prototype.positionTip=function(){le.setAttributes(this.tip,[["points",this.getTipPoints()]]);var f=this.tipGrip.visual.transform.baseVal.getItem(0);f.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(f,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(),G.prototype.select.call(this)},s.prototype.getState=function(){var f=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){var N=f;this.bgColor=N.bgColor,this.tipPosition=N.tipPosition,G.prototype.restoreState.call(this,f),this.createTip(),this.setTipPoints()},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),this.tipPosition={x:this.tipPosition.x*f,y:this.tipPosition.y*N},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}(Ve),_e=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("Line color",ge(Q.defaultColorSet,["transparent"]),Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.fillPanel=new Ue("Fill color",ge(Q.defaultColorSet,["transparent"]),H.fillColor,pe),H.fillPanel.onColorChanged=H.setFillColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new tt("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H.opacityPanel=new ie("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.visual)},s.prototype.createVisual=function(){this.visual=le.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(f,N){G.prototype.pointerDown.call(this,f,N),this.state==="new"&&(this.createVisual(),this.moveVisual(f),this._state="creating")},s.prototype.manipulate=function(f){G.prototype.manipulate.call(this,f)},s.prototype.resize=function(f){G.prototype.resize.call(this,f),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),le.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(f){G.prototype.pointerUp.call(this,f),this.setSize()},s.prototype.setStrokeColor=function(f){this.strokeColor=f,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(f),this.stateChanged()},s.prototype.setFillColor=function(f){this.fillColor=f,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(f),this.stateChanged()},s.prototype.setStrokeWidth=function(f){this.strokeWidth=f,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(f){this.strokeDasharray=f,this.visual&&le.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(f){this.opacity=f,this.visual&&le.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 f=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){var N=f;this.fillColor=N.fillColor,this.strokeColor=N.strokeColor,this.strokeWidth=N.strokeWidth,this.strokeDasharray=N.strokeDasharray,this.opacity=N.opacity,this.createVisual(),G.prototype.restoreState.call(this,f),this.setSize()},s.prototype.scale=function(f,N){G.prototype.scale.call(this,f,N),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}($e),He=function(G){function s(f,N,Q){return G.call(this,f,N,Q)||this}return we(s,G),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.tip1&&f!==this.tip2)},s.prototype.createTips=function(){this.tip1=le.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(le.createTransform()),this.visual.appendChild(this.tip1),this.tip2=le.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(le.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(f,N){G.prototype.pointerDown.call(this,f,N),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(G.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(le.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()]]),le.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 f=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),N=this.tip1.transform.baseVal.getItem(0);N.setRotate(f,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(N,0);var Q=this.tip2.transform.baseVal.getItem(0);Q.setRotate(f+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 f=G.prototype.getState.call(this);return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f),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}(at),nt=function(G){function s(f,N,Q){var H=G.call(this,f,N,Q)||this;return H.strokePanel.colors=Q.defaultColorSet,H.fillColor="transparent",H}return we(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var f=G.prototype.getState.call(this);return f.typeName=s.typeName,f},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}(_e),mt=function(){function G(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(G.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),G.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))},G.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},G.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},G.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}},G.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},G}(),ft=function(G){function s(f,N,Q){var H=G.call(this,f,N,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 Ue("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new tt("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,G),s.prototype.ownsTarget=function(f){return!(!G.prototype.ownsTarget.call(this,f)&&f!==this.visual&&f!==this.selectorCurve&&f!==this.visibleCurve&&!this.curveGrip.ownsTarget(f))},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=le.createGroup(),this.selectorCurve=le.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=le.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(f,N){G.prototype.pointerDown.call(this,f,N),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=f.x,this.curveY=f.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(N)&&(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()),le.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){G.prototype.setupControlBox.call(this),this.curveControlLine1=le.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=le.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,G.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){G.prototype.positionGrips.call(this);var f=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-f/2,this.curveY-f/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(f){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+f.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+f.y-this.manipulationStartY),G.prototype.manipulate.call(this,f)},s.prototype.resize=function(f){this.activeGrip===this.curveGrip&&(this.curveX=f.x,this.curveY=f.y),G.prototype.resize.call(this,f),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(f){this.strokeColor=f,this.adjustVisual(),this.colorChanged(f)},s.prototype.setStrokeWidth=function(f){this.strokeWidth=f,this.adjustVisual()},s.prototype.setStrokeDasharray=function(f){this.strokeDasharray=f,this.adjustVisual()},s.prototype.scale=function(f,N){this.curveX=this.curveX*f,this.curveY=this.curveY*N,G.prototype.scale.call(this,f,N)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var f=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},G.prototype.getState.call(this));return f.typeName=s.typeName,f},s.prototype.restoreState=function(f){G.prototype.restoreState.call(this,f);var N=f;this.strokeColor=N.strokeColor,this.strokeWidth=N.strokeWidth,this.strokeDasharray=N.strokeDasharray,this.curveX=N.curveX,this.curveY=N.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}(ht),wt=function(){function G(s,f){f===void 0&&(f=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=f}return Object.defineProperty(G.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),G.prototype.preventDefault=function(){this._defaultPrevented=!0},G}(),Tt=function(G){function s(f,N,Q){var H=G.call(this,f,!1)||this;return H.dataUrl=N,H.state=Q,H}return we(s,G),s}(wt),ut=function(G){function s(f,N,Q){Q===void 0&&(Q=!1);var H=G.call(this,f,Q)||this;return H.marker=N,H}return we(s,G),s}(wt),Bt=function(){function G(){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 G.prototype.addEventListener=function(s,f){this[s].push(f)},G.prototype.removeEventListener=function(s,f){var N=this[s].indexOf(f);N>-1&&this[s].splice(N,1)},G}(),_t=function(){function G(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 Pe,this._isOpen=!1,this.undoRedoManager=new mt,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 Bt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=G.instanceCounter++,this.styles=new Le(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(G.prototype,"ALL_MARKER_TYPES",{get:function(){return[rt,xe,ye,Ve,nt,_e,ue,be,He,re,at,ft]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[rt,xe,ye,Ve,_e,ue,be]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"BASIC_MARKER_TYPES",{get:function(){return[rt,xe,ye,Ve,ue]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var f=this;this._availableMarkerTypes.splice(0),s.forEach(function(N){if(typeof N=="string"){var Q=f.ALL_MARKER_TYPES.find(function(H){return H.typeName===N});Q!==void 0&&f._availableMarkerTypes.push(Q)}else f._availableMarkerTypes.push(N)})},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),G.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),te.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},G.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&ne.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=ne.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(f){return f(new wt(s))})},G.prototype.render=function(){return Ce(this,void 0,void 0,function(){var s;return Te(this,function(f){switch(f.label){case 0:return this.setCurrentMarker(),(s=new ce).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 f.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,f.sent()]}})})},G.prototype.close=function(s){var f=this;if(s===void 0&&(s=!1),this.isOpen){var N=!1;s||this.eventListeners.beforeclose.forEach(function(Q){var H=new wt(f,!0);Q(H),H.defaultPrevented&&(N=!0)}),N||(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 wt(f))}),this.detachEvents(),this._isOpen=!1)}},G.prototype.addMarkersToToolbar=function(){for(var s,f=[],N=0;N<arguments.length;N++)f[N]=arguments[N];(s=this._availableMarkerTypes).push.apply(s,f)},G.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(f){s(f.dataUrl,f.state)})},G.prototype.removeRenderEventListener=function(s){},G.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},G.prototype.removeCloseEventListener=function(s){},G.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))},G.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,f=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,N=f<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(f,N)},G.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},G.prototype.resize=function(s,f){this._isResizing=!0;var N=s/this.imageWidth,Q=f/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(f),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(N,Q),this._isResizing=!1},G.prototype.scaleMarkers=function(s,f){var N,Q=this;this._currentMarker&&this._currentMarker instanceof Ve?this._currentMarker.scale(s,f):(N=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(H){H!==Q._currentMarker&&H.scale(s,f)}),N!==void 0&&this.setCurrentMarker(N)},G.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"},G.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),f=this.editorCanvas.getBoundingClientRect();this.left=s.left-f.left,this.top=s.top-f.top},G.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)},G.prototype.addDefs=function(){for(var s,f=[],N=0;N<arguments.length;N++)f[N]=arguments[N];this.defs=le.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,f)},G.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},G.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)},G.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},G.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},G.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)},G.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},G.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)},G.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()},G.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")},G.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"},G.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},G.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 Re(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 Ne(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},G.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},G.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},G.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())},G.prototype.toolbarButtonClicked=function(s,f){if(s==="marker"&&f!==void 0)this.createNewMarker(f);else if(s==="action")switch(f){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()}},G.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var f=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Q){var H=new ut(s,s._currentMarker,!0);Q(H),H.defaultPrevented&&(f=!0)}),!f){var N=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 ut(s,N))})}}},G.prototype.clear=function(){var s=this,f=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(me){var We=new ut(s,void 0,!0);me(We),We.defaultPrevented&&(f=!0)}),!f)){this.setCurrentMarker();for(var N=function(me){var We=Q.markers[me];Q.setCurrentMarker(Q.markers[me]),Q._currentMarker.dispose(),Q.markerImage.removeChild(Q._currentMarker.container),Q.markers.splice(Q.markers.indexOf(Q._currentMarker),1),Q.eventListeners.markerdelete.forEach(function(Je){return Je(new ut(s,We))})},Q=this,H=this.markers.length-1;H>=0;H--)N(H);this.addUndoStep()}},Object.defineProperty(G.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),G.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))},G.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)},G.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},G.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var f=this.getState(),N=this.undoRedoManager.getLastUndoStep();if(!N||N.width===f.width&&N.height===f.height){var Q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(f),Q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}else this.undoRedoManager.replaceLastUndoStep(f),this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}},G.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},G.prototype.undoStep=function(){var s=this,f=this.undoRedoManager.undo();f!==void 0&&(this.restoreState(f),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(N){return N(new wt(s))}))},G.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},G.prototype.redoStep=function(){var s=this,f=this.undoRedoManager.redo();f!==void 0&&(this.restoreState(f),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(N){return N(new wt(s))}))},G.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},G.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},G.prototype.startRenderAndClose=function(){return Ce(this,void 0,void 0,function(){var s,f,N=this;return Te(this,function(Q){switch(Q.label){case 0:return[4,this.render()];case 1:return s=Q.sent(),f=this.getState(),this.eventListeners.render.forEach(function(H){return H(new Tt(N,s,f))}),this.close(!0),[2]}})})},G.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var f={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(N){return f.markers.push(N.getState())}),f},G.prototype.restoreState=function(s){var f=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(N){var Q=f._availableMarkerTypes.find(function(me){return me.typeName===N.typeName});if(Q!==void 0){var H=f.addNewMarker(Q);H.restoreState(N),f.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(N){return N(new wt(f))})},G.prototype.addNewMarker=function(s){var f=le.createGroup();return this.markerImage.appendChild(f),new s(f,this.overlayContainer,this.settings)},G.prototype.createNewMarker=function(s){var f,N=this;(f=typeof s=="string"?this._availableMarkerTypes.find(function(Q){return Q.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(f),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(f.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(Q){return Q(new ut(N,N._currentMarker))}))},G.prototype.markerCreated=function(s){var f=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof xe&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(xe):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(N){return N(new ut(f,f._currentMarker))})},G.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},G.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},G.prototype.markerStateChanged=function(s){var f=this;this.eventListeners.markerchange.forEach(function(N){return N(new ut(f,s))})},G.prototype.setCurrentMarker=function(s){var f=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(N){return N(new ut(f,f._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(N){return N(new ut(f,f._currentMarker))}))},G.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 f=this.markers.find(function(N){return N.ownsTarget(s.target)});f!==void 0?(this.setCurrentMarker(f),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))},G.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var f=this.markers.find(function(N){return N.ownsTarget(s.target)});f!==void 0&&f!==this._currentMarker&&this.setCurrentMarker(f),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},G.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}))},G.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()},G.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},G.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},G.prototype.clientToLocalCoordinates=function(s,f){var N=this.markerImage.getBoundingClientRect();return{x:(s-N.left)/this.zoomLevel,y:(f-N.top)/this.zoomLevel}},G.prototype.onWindowResize=function(){this.positionUI()},G.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()},G.prototype.addLicenseKey=function(s){te.addKey(s)},G.prototype.addEventListener=function(s,f){this.eventListeners.addEventListener(s,f)},G.prototype.removeEventListener=function(s,f){this.eventListeners.removeEventListener(s,f)},G.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(G.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),G.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(f){return f(new wt(s))}))},G.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(f){return f(new wt(s))}))},G.instanceCounter=0,G}();/* **********************************
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 Zt=function(G,s){return(Zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,N){f.__proto__=N}||function(f,N){for(var Q in N)Object.prototype.hasOwnProperty.call(N,Q)&&(f[Q]=N[Q])})(G,s)};function Xt(G,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function f(){this.constructor=G}Zt(G,s),G.prototype=s===null?Object.create(s):(f.prototype=s.prototype,new f)}function Ot(G,s,f,N){return new(f||(f=Promise))(function(Q,H){function me(ct){try{Je(N.next(ct))}catch(Ge){H(Ge)}}function We(ct){try{Je(N.throw(ct))}catch(Ge){H(Ge)}}function Je(ct){var Ge;ct.done?Q(ct.value):(Ge=ct.value,Ge instanceof f?Ge:new f(function(vt){vt(Ge)})).then(me,We)}Je((N=N.apply(G,s||[])).next())})}function Ir(G,s){var f,N,Q,H,me={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:We(0),throw:We(1),return:We(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function We(Je){return function(ct){return function(Ge){if(f)throw new TypeError("Generator is already executing.");for(;me;)try{if(f=1,N&&(Q=2&Ge[0]?N.return:Ge[0]?N.throw||((Q=N.return)&&Q.call(N),0):N.next)&&!(Q=Q.call(N,Ge[1])).done)return Q;switch(N=0,Q&&(Ge=[2&Ge[0],Q.value]),Ge[0]){case 0:case 1:Q=Ge;break;case 4:return me.label++,{value:Ge[1],done:!1};case 5:me.label++,N=Ge[1],Ge=[0];continue;case 7:Ge=me.ops.pop(),me.trys.pop();continue;default:if(!(Q=me.trys,(Q=Q.length>0&&Q[Q.length-1])||Ge[0]!==6&&Ge[0]!==2)){me=0;continue}if(Ge[0]===3&&(!Q||Ge[1]>Q[0]&&Ge[1]<Q[3])){me.label=Ge[1];break}if(Ge[0]===6&&me.label<Q[1]){me.label=Q[1],Q=Ge;break}if(Q&&me.label<Q[2]){me.label=Q[2],me.ops.push(Ge);break}Q[2]&&me.ops.pop(),me.trys.pop();continue}Ge=s.call(G,me)}catch(vt){Ge=[6,vt],N=0}finally{f=Q=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([Je,ct])}}}var Kr=function(){function G(){}return G.addKey=function(s){G.key=s},Object.defineProperty(G,"isLicensed",{get:function(){return!!G.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(G.key)},enumerable:!1,configurable:!0}),G}(),bt=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,f){for(var N=0,Q=f;N<Q.length;N++){var H=Q[N],me=H[0],We=H[1];s.setAttribute(me,We)}},G.createRect=function(s,f,N){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",f.toString()),N&&G.setAttributes(Q,N),Q},G.createLine=function(s,f,N,Q,H){var me=document.createElementNS("http://www.w3.org/2000/svg","line");return me.setAttribute("x1",s.toString()),me.setAttribute("y1",f.toString()),me.setAttribute("x2",N.toString()),me.setAttribute("y2",Q.toString()),H&&G.setAttributes(me,H),me},G.createPolygon=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","polygon");return N.setAttribute("points",s),f&&G.setAttributes(N,f),N},G.createCircle=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","circle");return N.setAttribute("cx",(s/2).toString()),N.setAttribute("cy",(s/2).toString()),N.setAttribute("r",s.toString()),f&&G.setAttributes(N,f),N},G.createEllipse=function(s,f,N){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(f/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(f/2).toString()),N&&G.setAttributes(Q,N),Q},G.createGroup=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(f,s),f},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,f,N,Q,H,me,We){var Je=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Je,[["id",s],["orient",f],["markerWidth",N.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",me.toString()]]),Je.appendChild(We),Je},G.createText=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","text");return f.setAttribute("x","0"),f.setAttribute("y","0"),s&&G.setAttributes(f,s),f},G.createTSpan=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","tspan");return N.textContent=s,f&&G.setAttributes(N,f),N},G.createImage=function(s){var f=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(f,s),f},G.createPoint=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return N.x=s,N.y=f,N},G.createPath=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg","path");return N.setAttribute("d",s),f&&G.setAttributes(N,f),N},G.createElement=function(s,f){var N=document.createElementNS("http://www.w3.org/2000/svg",s);return f&&G.setAttributes(N,f),N},G.getHollowRectanglePath=function(s,f,N,Q,H,me,We,Je){return"M"+s+","+f+"V"+(f+Q)+"H"+(s+N)+"V"+f+"H"+H+"V"+me+"H"+(H+We)+"V"+(me+Je)+"H"+H+"V"+f+"Z"},G}(),Nr=function(){function G(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(G.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),G.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},G.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)},G.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 hr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new pr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new pr("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},G.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},G}(),hr=function(G,s){this.selector=G,this.style=s},pr=function(G,s){this.localName=G,this.style=s},Fr=function(){function G(){this.blocks=[],this.display=""}return G.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},G.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},G.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(f){return s.appendChild(f.getUI())}),s},G}(),ci=function(){function G(){}return G.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},G}(),qr=function(G){function s(){var f=G!==null&&G.apply(this,arguments)||this;return f.buttons=[],f}return Xt(s,G),s.prototype.addButton=function(f){f.className=this.buttonClassName,f.colorsClassName=this.buttonColorsClassName,f.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(f)},s.prototype.getUI=function(){var f=G.prototype.getUI.call(this);return this.buttons.forEach(function(N){return f.appendChild(N.getUI())}),f},s}(ci),It=function(){function G(s,f){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=f,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(G.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),G.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},G.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,"")))},G.prototype.hide=function(){this._isHidden=!0},G}(),dt=function(G){function s(){var f=G!==null&&G.apply(this,arguments)||this;return f.elements=[],f}return Xt(s,G),s.prototype.addElement=function(f){this.elements.push(f)},s.prototype.getUI=function(){var f=G.prototype.getUI.call(this);return this.elements.forEach(function(N){return f.appendChild(N)}),f},s}(ci),Hr=function(){function G(s,f){this.horizontal=s,this.vertical=f}return Object.defineProperty(G.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),G.prototype.getVerticalLength=function(s){return s/this.ratio},G.prototype.getHorizontalLength=function(s){return s*this.ratio},G}(),ei=function(){function G(){}return G.getIcon=function(s,f){if(s>0&&f>0){var N=new Hr(s,f),Q=N.ratio>=1?20:N.getHorizontalLength(20),H=N.ratio<1?20:N.getVerticalLength(20),me=document.createElementNS("http://www.w3.org/2000/svg","svg");me.setAttribute("xmlns","http://www.w3.org/2000/svg"),me.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(me);var We=bt.createDefs();me.appendChild(We);var Je=bt.createElement("clipPath",[["id","text-bg-clip"]]);We.appendChild(Je);var ct=bt.createPath(bt.getHollowRectanglePath((24-Q)/2,(24-H)/2,Q,H,(24-Q)/2+2,(24-H)/2+2,Q-4,H-4));me.appendChild(ct);var Ge=bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ge.appendChild(bt.createTSpan(s+":"+f)),me.appendChild(Ge);var vt=Ge.getBBox();bt.setAttributes(Ge,[["x",((24-vt.width)/2).toString()],["y",((24-vt.height)/2-vt.y).toString()]]);var Nt=bt.createPath(bt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(vt.width))/2,(24-Math.ceil(vt.height))/2,Math.ceil(vt.width),Math.ceil(vt.height)));return Je.appendChild(Nt),bt.setAttributes(ct,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(me),me.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>'},G}(),mr=function(G){function s(f,N,Q){var H=G.call(this,f,N)||this;return H.isDropdownOpen=!1,H.onClick=H.dropdownButtonClicked,H.dropdownButtons=Q,H}return Xt(s,G),s.prototype.setupDropdown=function(){var f=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(N){N.className=f.className,N.colorsClassName=f.colorsClassName,f.dropdownBlock.appendChild(N.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}(It),kt=function(){function G(s,f){this.GRIP_SIZE=10,this.color=s,this.fillColor=f,this.visual=bt.createGroup(),this.visual.appendChild(bt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(bt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return G.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},G.prototype.setCenter=function(s,f){this.visual.childNodes.forEach(function(N){return bt.setAttributes(N,[["cx",s.toString()],["cy",f.toString()]])})},G}(),Br=function(){function G(s,f,N,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=f,this.margin=N,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(G.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(G.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&bt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),G.prototype.open=function(){var s=this;this.cropShadeElement=bt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=bt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var f=0;f<this.numberOfGridLines;f++)this.horizontalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(N){return s.gridContainer.appendChild(N)}),this.verticalGridLines.forEach(function(N){return s.gridContainer.appendChild(N)}),this.cropRectElement=bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},G.prototype.setCropRectangle=function(s){this.cropRect=s;var f=Object.assign({},this.cropRect);this.zoomFactor!==1&&(f.width=this.cropRect.width*this.zoomFactor,f.height=this.cropRect.height*this.zoomFactor,f.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-f.width/2,f.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-f.height/2),bt.setAttributes(this.cropRectElement,[["x",f.x.toString()],["y",f.y.toString()],["width",f.width.toString()],["height",f.height.toString()]]);var N=f.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(H,me){var We=f.y+N*(me+1);bt.setAttributes(H,[["x1",""+f.x],["y1",""+We],["x2",""+(f.x+f.width)],["y2",""+We]])});var Q=f.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(H,me){var We=f.x+Q*(me+1);bt.setAttributes(H,[["x1",""+We],["y1",""+f.y],["x2",""+We],["y2",""+(f.y+f.height)]])}),bt.setAttributes(this.cropShadeElement,[["d",bt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,f.x,f.y,f.width,f.height)]]),this.topLeftGrip.setCenter(f.x,f.y),this.topRightGrip.setCenter(f.x+f.width,f.y),this.bottomLeftGrip.setCenter(f.x,f.y+f.height),this.bottomRightGrip.setCenter(f.x+f.width,f.y+f.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},G.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)},G.prototype.clientToLocalCoordinates=function(s,f){var N=this.container.getBoundingClientRect();return{x:s-N.left+this.margin,y:f-N.top+this.margin}},G.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)},G.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var f=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(f)}s.preventDefault()},G.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},G.prototype.move=function(s){var f=s.x-this.previousPoint.x,N=s.y-this.previousPoint.y;this.zoomFactor!==1&&(f=-f/this.zoomFactor,N=-N/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+f),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+N),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},G.prototype.resize=function(s){var f=Object.assign({},this.cropRect),N=s.x-this.previousPoint.x,Q=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:f.x+N<this.margin&&(N=this.margin-f.x),f.x+=N,f.width=this.cropRect.x+this.cropRect.width-f.x;break;case this.bottomRightGrip:case this.topRightGrip:f.width+N>this.canvasWidth*this.zoomFactor&&(N=this.canvasWidth*this.zoomFactor-f.width),f.width+=N}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(f.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(N),f.height=this.aspectRatio.getVerticalLength(f.width)):(f.y+=Q,f.height=this.cropRect.y+this.cropRect.height-f.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?f.height=this.aspectRatio.getVerticalLength(f.width):f.height+=Q}f.width<10&&(f.x=this.cropRect.x,f.width=10),f.height<10&&(f.y=this.cropRect.y,f.height=10),this.previousPoint=s,f.x>=this.margin&&f.y>=this.margin&&f.x-this.margin+f.width<=this.canvasWidth&&f.y-this.margin+f.height<=this.canvasHeight&&(this.cropRect=f,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},G.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,f=this.cropRect.y+this.cropRect.height/2,N=this.aspectRatio.getHorizontalLength(this.cropRect.height),Q=this.aspectRatio.getVerticalLength(this.cropRect.width);N/this.canvasWidth<Q/this.canvasHeight?this.cropRect.width=N: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=f-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)}},G.prototype.getRescaledRect=function(s,f,N,Q,H,me){var We=N/s,Je=Q/f;return{x:(H.x-me)*We+me,y:(H.y-me)*Je+me,width:H.width*We,height:H.height*Je}},G.prototype.scaleCanvas=function(s,f){var N=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,f,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=f,this.onCropChange&&this.onCropChange(N),this.setCropRectangle(N)},G}(),Vr=function(){function G(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(G.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),G.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},G.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},G.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},G.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},G.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();bt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},G.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)}},G.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 f="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,N=1;N<=this.width/5+10;N++){var Q=N%5==0?this.height/3:this.height/6;f+="h4v"+-Q+"h1v"+Q}f+="v1H0Z",this.scaleShape=bt.createPath(f);var H=bt.createTransform();this.scaleShape.transform.baseVal.appendItem(H),s.appendChild(this.scaleShape),this.angleLabelElement=bt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=bt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var me=bt.createTSpan("");return me.innerHTML="&deg;",this.angleLabelElement.appendChild(me),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},G}(),fi=function(){function G(){this.naturalSize=!1,this.imageType="image/png"}return G.prototype.rasterize=function(s,f,N,Q,H,me,We){var Je=this;return new Promise(function(ct){var Ge=document.createElement("canvas");Ge.width=s.width.baseVal.value-2*Q,Ge.height=s.height.baseVal.value-2*Q;var vt=1,Nt=1;Je.naturalSize===!0?(vt=f.naturalWidth/(s.width.baseVal.value-2*Q)/me,Nt=f.naturalHeight/(s.height.baseVal.value-2*Q)/We,Ge.width=f.naturalWidth/me,Ge.height=f.naturalHeight/We):Je.width!==void 0&&Je.height!==void 0&&(vt=Je.width/N.width,Nt=Je.height/N.height,Ge.width*=vt,Ge.height*=Nt);var Kt=Ge.getContext("2d");Kt.translate(Ge.width/2,Ge.height/2),Kt.rotate(H*Math.PI/180),Kt.scale(me,We),Kt.translate(-Ge.width/2,-Ge.height/2),Kt.drawImage(f,0,0,Ge.width,Ge.height);var Or=document.createElement("canvas");Or.width=N.width*vt,Or.height=N.height*Nt,Or.getContext("2d").putImageData(Kt.getImageData((N.x-Q)*vt,(N.y-Q)*Nt,N.width*vt,N.height*Nt),0,0),ct(Or.toDataURL(Je.imageType,Je.imageQuality))})},G}(),Xe=function(){function G(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=G.instanceCounter++,this.styles=new Nr(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(G.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.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(G.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(G.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(G.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}),G.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},G.prototype.show=function(){this.showUI(),this.open()},G.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(f){return f()}),this._isOpen=!1)},G.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},G.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},G.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},G.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},G.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))},G.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,f=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,N=f+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(f,N)}},G.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},G.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",bt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},G.prototype.resize=function(s,f){this.imageWidth=Math.round(s),this.imageHeight=Math.round(f),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()},G.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 f=s.toDataURL();bt.setAttributes(this.editingTarget,[["href",f]]),this.setEditingTargetSize()},G.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),f=this.editorCanvas.getBoundingClientRect();this.left=s.left-f.left-this.CANVAS_MARGIN,this.top=s.top-f.top-this.CANVAS_MARGIN},G.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=bt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=bt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=bt.createGroup(),this.editingTargetRotationScaleContainer=bt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=bt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var f=bt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(f),this.editingTargetContainer=bt.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)},G.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},G.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=bt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Br(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()},G.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,f=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 "+f+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-f+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},G.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)},G.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},G.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},G.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"},G.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},G.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,f=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=f+"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},G.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},G.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Fr,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 f=new qr;f.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(f);var N=[];this.aspectRatios.forEach(function(Nt){var Kt=new It(ei.getIcon(Nt.horizontal,Nt.vertical),Nt.horizontal===0&&Nt.vertical===0?"FREE":Nt.horizontal+":"+Nt.vertical);Kt.onClick=function(){return s.ratioButtonClicked(Nt)},N.push(Kt)}),this.aspectRatioButton=new mr(ei.getIcon(0,0),"Aspect ratio",N),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,f.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var Q=new It('<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},f.addButton(Q);var H=new It('<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},f.addButton(H),!Kr.isLicensed){var me=new dt;this.topToolbar.addElementBlock(me);var We=document.createElement("div");We.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Je=document.createElement("a");Je.style.color="currentColor",Je.href="https://markerjs.com/products/cropro",Je.target="_blank",Je.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>',We.appendChild(Je),me.addElement(We)}var ct=new qr;ct.minWidth=3*this.toolbarHeight+"px",ct.contentAlign="end",this.topToolbar.addButtonBlock(ct);var Ge=new It('<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");Ge.onClick=this.startRenderAndClose,ct.addButton(Ge),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ge.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var vt=new It('<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");vt.onClick=this.close,ct.addButton(vt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(vt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},G.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Fr,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 f=new qr;f.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(f);var N=new It('<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");N.onClick=this.rotateLeftButtonClicked,f.addButton(N);var Q=new It('<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,f.addButton(Q);var H=new dt;H.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(H),this.straightener=new Vr("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(ct){s.rotateBy(ct),s.straightener.angle=s.rotationAngle},H.addElement(this.straightener.getUI());var me=new qr;me.minWidth=2*this.toolbarHeight+"px",me.contentAlign="end",this.bottomToolbar.addButtonBlock(me);var We=new It('<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");We.onClick=this.flipHorizontallyButtonClicked,me.addButton(We);var Je=new It('<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");Je.onClick=this.flipVerticallyButtonClicked,me.addButton(Je)},G.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},G.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},G.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Hr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},G.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},G.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},G.prototype.restoreState=function(s){if(s){var f=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(f),this.cropRectChanged(f),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},G.prototype.clientToLocalCoordinates=function(s,f){var N=this.cropImage.getBoundingClientRect();return{x:s-N.left,y:f-N.top}},G.prototype.onWindowResize=function(){this.positionUI()},G.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()},G.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)},G.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)},G.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},G.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},G.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 f=this.editingTargetRotationContainer.transform.baseVal.getItem(0);f.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(f,0);var N=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/N.width,this.imageHeight/N.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},G.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},G.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},G.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},G.prototype.startRenderAndClose=function(){return Ot(this,void 0,void 0,function(){var s,f;return Ir(this,function(N){switch(N.label){case 0:return[4,this.render()];case 1:return s=N.sent(),f=this.getState(),this.renderEventListeners.forEach(function(Q){return Q(s,f)}),this.close(!0),[2]}})})},G.prototype.render=function(){return Ot(this,void 0,void 0,function(){var s;return Ir(this,function(f){switch(f.label){case 0:return(s=new fi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),bt.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 f.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,f.sent()]}})})},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new pr("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 pr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new pr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new pr("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 pr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new pr("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 pr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new pr("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 pr("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 pr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},G.instanceCounter=0,G}(),St=se("8hTe"),pi=se.n(St),mi=/<pre[^>]*>/g;function gi(G){var s=document.createElement("div");return s.innerHTML=G,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=it.a=function(G){var s=G.value,f=s===void 0?"":s,N=G.edit,Q=N===void 0?!1:N,H=G.className,me=G.showTextOnly,We=G.showLines,Je=G.replaces,ct=G.zoomImg,Ge=G.hasMask,vt=G.style,Nt=vt===void 0?{}:vt,Kt=G.stylesPrev,Or=Kt===void 0?{}:Kt,gr=String(f),vr=Object(R.useRef)(),Xr=Object(R.useRef)(),Oi=Object(R.useState)(""),nr=Object(z.a)(Oi,2),Ur=nr[0],oi=nr[1],si=Object(R.useState)("office"),_r=Object(z.a)(si,2),_i=_r[0],yi=_r[1],zi=function(){var Ft=new Xe(Xr.current);Ft.displayMode="popup",Ft.addRenderEventListener(function(){var dr=Object(M.a)(P.a.mark(function Dt(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return vr.current.style.display="none",ar.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:Wt=ar.sent,Wt!=null&&Wt.id&&Je(Xr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 5:case"end":return ar.stop()}},Dt)}));return function(Dt){return dr.apply(this,arguments)}}()),Ft.show()},Ki=function(){var Ft=new _t(Xr.current);Ft.settings.displayMode="popup",Ft.addEventListener("render",function(){var dr=Object(M.a)(P.a.mark(function Dt(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:if(vr.current.style.display="none",!Xr.current){ar.next=6;break}return ar.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:Wt=ar.sent,Wt!=null&&Wt.id&&Je(Xr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 6:case"end":return ar.stop()}},Dt)}));return function(Dt){return dr.apply(this,arguments)}}()),Ft.show(),window.markerArea=Ft},Yr=Object(R.useMemo)(function(){vr.current&&(vr.current.style.zIndex=-1);try{var Jt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Ft=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gr=gr.replace(Jt,"("+ee.a.API_SERVER+"/api/attachments/").replace(Ft,'"'+ee.a.API_SERVER+"/api/attachments/").replace(dr,'"'+ee.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
`)}catch(ti){}var Dt=V(gr),qt=b();if(gr.match(/\[TOC\]/)&&(Dt=Dt.replace("<p>[TOC]</p>",k()),w()),Dt=Dt.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var Er=qt[ar],Vi=Er.type,Ei=Er.expression;return Object(ae.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Dt=Dt.replace(/▁/g,"\u2581\u2581\u2581"),m(),me){var Wt=document.createElement("div");return Wt.innerHTML=Dt,Wt.innerText}return setTimeout(function(){return dn()},500),Dt},[gr]),Gr=Object(R.useRef)();v.WebkitLineClamp=We,We&&(Nt=Object(B.a)(Object(B.a)({},Nt),v));function bi(Jt){var Ft=Jt.target;if(Ft.tagName.toUpperCase()==="IMG"){if(ct){var dr=Ft.getAttribute("src");oi(dr),yi("image")}}else if(Ft.tagName.toUpperCase()==="A"){var Dt=Ft.getAttribute("href");if(Dt.indexOf("office")>-1)Jt.preventDefault(),oi(Dt),yi("office");else if(Dt.indexOf("application/pdf")>-1)Jt.preventDefault(),oi(Dt),yi("pdf");else if(Dt.indexOf("text/html")>-1)Jt.preventDefault(),oi(Dt),yi("html");else if(Dt.startsWith("#")){Jt.preventDefault();var qt=document.getElementById(Dt.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var dn=function(){var Ft,dr=(Ft=Gr.current)===null||Ft===void 0?void 0:Ft.querySelectorAll("video");dr==null||dr.forEach(function(Dt){if(Dt.oncontextmenu=function(){return!1},Dt.src.indexOf(".m3u8")>-1&&!Dt.canPlayType("application/vnd.apple.mpegurl")){if(Y.a.isSupported()){var qt=new Y.a;qt.loadSource(Dt.src),qt.attachMedia(Dt)}}})};Object(R.useEffect)(function(){if(Gr.current&&Yr&&(Yr.match(mi)&&window.PR.prettyPrint()),Gr.current)return Gr.current.addEventListener("click",bi),function(){Gr.current.removeEventListener("click",bi),m(),w()}},[Yr,Gr.current,bi]);var xi=function(Ft){if(!Q)return;Ft.target.nodeName==="IMG"?(vr.current.style.zIndex=1,vr.current.style.display="flex",vr.current.style.width=Ft.target.clientWidth+"px",vr.current.style.height=Ft.target.clientHeight+"px",vr.current.style.top=Ft.target.offsetTop+"px",vr.current.style.left=Ft.target.offsetLeft+"px",Xr.current.src=Ft.target.getAttribute("src")):vr.current.style.display="none"};return y.a.createElement("div",{style:{position:"relative"}},y.a.createElement("div",{ref:Gr,style:Object(B.a)({},Nt),className:"".concat(H||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),y.a.createElement("div",{ref:vr,className:pi.a.button},y.a.createElement(Z.a,null,y.a.createElement($.a,{onClick:function(){return zi()}},"\u88C1\u526A"),y.a.createElement($.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),y.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),y.a.createElement(de.a,{close:!0,data:Ur,type:Ur!=null&&Ur.length?_i:"",style:Object(B.a)({},Or),onClose:function(){return oi("")}}))}},"9VGf":function(xt,it,se){"use strict";se.d(it,"a",function(){return D});var oe=se("q1tI"),Z=se.n(oe);function D($,B){var M=Object(oe.useRef)();Object(oe.useEffect)(function(){M.current=$}),Object(oe.useEffect)(function(){function z(){M.current()}if(B!==null){var W=setInterval(z,B);return function(){return clearInterval(W)}}},[B])}},Bd2K:function(xt,it,se){(function(oe){oe(se("VrN/"),se("osHv"))})(function(oe){oe.defineOption("autoCloseTags",!1,function(P,R,y){if(y!=oe.Init&&y&&P.removeKeyMap("autoCloseTags"),!R)return;var A={name:"autoCloseTags"};(typeof R!="object"||R.whenClosing!==!1)&&(A["'/'"]=function(O){return M(O)}),(typeof R!="object"||R.whenOpening!==!1)&&(A["'>'"]=function(O){return $(O)}),P.addKeyMap(A)});var Z=["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 $(P){if(P.getOption("disableInput"))return oe.Pass;for(var R=P.listSelections(),y=[],A=P.getOption("autoCloseTags"),O=0;O<R.length;O++){if(!R[O].empty())return oe.Pass;var L=R[O].head,C=P.getTokenAt(L),T=oe.innerMode(P.getMode(),C.state),h=T.state,o=T.mode.xmlCurrentTag&&T.mode.xmlCurrentTag(h),l=o&&o.name;if(!l)return oe.Pass;var d=T.mode.configuration=="html",w=typeof A=="object"&&A.dontCloseTags||d&&Z,v=typeof A=="object"&&A.indentTags||d&&D;C.end>L.ch&&(l=l.slice(0,l.length-C.end+L.ch));var g=l.toLowerCase();if(!l||C.type=="string"&&(C.end!=L.ch||!/[\"\']/.test(C.string.charAt(C.string.length-1))||C.string.length==1)||C.type=="tag"&&o.close||C.string.indexOf("/")==L.ch-C.start-1||w&&z(w,g)>-1||W(P,T.mode.xmlCurrentContext&&T.mode.xmlCurrentContext(h)||[],l,L,!0))return oe.Pass;var k=typeof A=="object"&&A.emptyTags;if(k&&z(k,l)>-1){y[O]={text:"/>",newPos:oe.Pos(L.line,L.ch+2)};continue}var E=v&&z(v,g)>-1;y[O]={indent:E,text:">"+(E?`
`:"")+"</"+l+">",newPos:E?oe.Pos(L.line+1,0):oe.Pos(L.line,L.ch+1)}}for(var p=typeof A=="object"&&A.dontIndentOnAutoClose,O=R.length-1;O>=0;O--){var c=y[O];P.replaceRange(c.text,R[O].head,R[O].anchor,"+insert");var u=P.listSelections().slice(0);u[O]={head:c.newPos,anchor:c.newPos},P.setSelections(u),!p&&c.indent&&(P.indentLine(c.newPos.line,null,!0),P.indentLine(c.newPos.line+1,null,!0))}}function B(P,R){for(var y=P.listSelections(),A=[],O=R?"/":"</",L=P.getOption("autoCloseTags"),C=typeof L=="object"&&L.dontIndentOnSlash,T=0;T<y.length;T++){if(!y[T].empty())return oe.Pass;var h=y[T].head,o=P.getTokenAt(h),l=oe.innerMode(P.getMode(),o.state),d=l.state;if(R&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=h.ch-1))return oe.Pass;var w,v=l.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(v&&l.mode.name=="javascript")w=O+"script";else if(v&&l.mode.name=="css")w=O+"style";else{var g=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(d);if(!g||g.length&&W(P,g,g[g.length-1],h))return oe.Pass;w=O+g[g.length-1]}P.getLine(h.line).charAt(o.end)!=">"&&(w+=">"),A[T]=w}if(P.replaceSelections(A),y=P.listSelections(),!C)for(var T=0;T<y.length;T++)(T==y.length-1||y[T].head.line<y[T+1].head.line)&&P.indentLine(y[T].head.line)}function M(P){return P.getOption("disableInput")?oe.Pass:B(P,!0)}oe.commands.closeTag=function(P){return B(P)};function z(P,R){if(P.indexOf)return P.indexOf(R);for(var y=0,A=P.length;y<A;++y)if(P[y]==R)return y;return-1}function W(P,R,y,A,O){if(!oe.scanForClosingTag)return!1;var L=Math.min(P.lastLine()+1,A.line+500),C=oe.scanForClosingTag(P,A,null,L);if(!C||C.tag!=y)return!1;for(var T=O?1:0,h=R.length-1;h>=0&&R[h]==y;h--)++T;A=C.to;for(var h=1;h<T;h++){var o=oe.scanForClosingTag(P,A,null,L);if(!o||o.tag!=y)return!1;A=o.to}return!0}})},BjJ7:function(xt,it,se){"use strict";se.d(it,"d",function(){return Z}),se.d(it,"c",function(){return D}),se.d(it,"e",function(){return $}),se.d(it,"b",function(){return B}),se.d(it,"a",function(){return z});var oe=se("m3rI");function Z(W){var P=!0;if(W.length>0){for(var R=0;R<W.length;R++)if(W[R].compile_success==0||!W[R].compile_success){P=!1;break}}else P=!1;return P}function D(W){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",R=[],y=0;y<W.length;y++){var A=W[y],O=P?"".concat(P,"/").concat(A.name):"".concat(A.name);R.push({title:A.name,isLeaf:!(A.type==="tree"),key:O})}return R}function $(W,P,R){for(var y=0;y<W.length;y++){var A=W[y];if(A.key===P){A.children=R;break}A.children&&$(A.children,P,R)}return W}function B(W,P,R){var y;return function(){var A=this,O=arguments,L=function(){y=null,R||W.apply(A,O)},C=R&&!y;clearTimeout(y),y=setTimeout(L,P),C&&W.apply(A,O)}}var M=!0,z=oe.a.API_SERVER},"C+DQ":function(xt,it,se){},DlQD:function(xt,it,se){(function(oe,Z){xt.exports=Z()})(this,function(){"use strict";function oe(xe,ve){for(var ye=0;ye<ve.length;ye++){var re=ve[ye];re.enumerable=re.enumerable||!1,re.configurable=!0,"value"in re&&(re.writable=!0),Object.defineProperty(xe,re.key,re)}}function Z(xe,ve,ye){return ve&&oe(xe.prototype,ve),ye&&oe(xe,ye),xe}function D(xe,ve){if(!xe)return;if(typeof xe=="string")return $(xe,ve);var ye=Object.prototype.toString.call(xe).slice(8,-1);if(ye==="Object"&&xe.constructor&&(ye=xe.constructor.name),ye==="Map"||ye==="Set")return Array.from(xe);if(ye==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ye))return $(xe,ve)}function $(xe,ve){(ve==null||ve>xe.length)&&(ve=xe.length);for(var ye=0,re=new Array(ve);ye<ve;ye++)re[ye]=xe[ye];return re}function B(xe,ve){var ye;if(typeof Symbol=="undefined"||xe[Symbol.iterator]==null){if(Array.isArray(xe)||(ye=D(xe))||ve&&xe&&typeof xe.length=="number"){ye&&(xe=ye);var re=0;return function(){return re>=xe.length?{done:!0}:{done:!1,value:xe[re++]}}}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 ye=xe[Symbol.iterator](),ye.next.bind(ye)}function M(xe,ve){return ve={exports:{}},xe(ve,ve.exports),ve.exports}var z=M(function(xe){function ve(){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 ye(re){xe.exports.defaults=re}xe.exports={defaults:ve(),getDefaults:ve,changeDefaults:ye}}),W=z.defaults,P=z.getDefaults,R=z.changeDefaults,y=/[&<>"']/,A=/[&<>"']/g,O=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},T=function(ve){return C[ve]};function h(xe,ve){if(ve){if(y.test(xe))return xe.replace(A,T)}else if(O.test(xe))return xe.replace(L,T);return xe}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(xe){return xe.replace(o,function(ve,ye){return ye=ye.toLowerCase(),ye==="colon"?":":ye.charAt(0)==="#"?ye.charAt(1)==="x"?String.fromCharCode(parseInt(ye.substring(2),16)):String.fromCharCode(+ye.substring(1)):""})}var d=/(^|[^\[])\^/g;function w(xe,ve){xe=xe.source||xe,ve=ve||"";var ye={replace:function(ie,ue){return ue=ue.source||ue,ue=ue.replace(d,"$1"),xe=xe.replace(ie,ue),ye},getRegex:function(){return new RegExp(xe,ve)}};return ye}var v=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(xe,ve,ye){if(xe){var re;try{re=decodeURIComponent(l(ye)).replace(v,"").toLowerCase()}catch(ie){return null}if(re.indexOf("javascript:")===0||re.indexOf("vbscript:")===0||re.indexOf("data:")===0)return null}ve&&!g.test(ye)&&(ye=a(ve,ye));try{ye=encodeURI(ye).replace(/%25/g,"%")}catch(ie){return null}return ye}var E={},p=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(xe,ve){E[" "+xe]||(p.test(xe)?E[" "+xe]=xe+"/":E[" "+xe]=F(xe,"/",!0)),xe=E[" "+xe];var ye=xe.indexOf(":")===-1;return ve.substring(0,2)==="//"?ye?ve:xe.replace(c,"$1")+ve:ve.charAt(0)==="/"?ye?ve:xe.replace(u,"$1")+ve:xe+ve}var b={exec:function(){}};function m(xe){for(var ve=1,ye,re;ve<arguments.length;ve++){ye=arguments[ve];for(re in ye)Object.prototype.hasOwnProperty.call(ye,re)&&(xe[re]=ye[re])}return xe}function x(xe,ve){var ye=xe.replace(/\|/g,function(ue,pe,be){for(var _e=!1,He=pe;--He>=0&&be[He]==="\\";)_e=!_e;return _e?"|":" |"}),re=ye.split(/ \|/),ie=0;if(re.length>ve)re.splice(ve);else for(;re.length<ve;)re.push("");for(;ie<re.length;ie++)re[ie]=re[ie].trim().replace(/\\\|/g,"|");return re}function F(xe,ve,ye){var re=xe.length;if(re===0)return"";for(var ie=0;ie<re;){var ue=xe.charAt(re-ie-1);if(ue===ve&&!ye)ie++;else if(ue!==ve&&ye)ie++;else break}return xe.substr(0,re-ie)}function U(xe,ve){if(xe.indexOf(ve[1])===-1)return-1;for(var ye=xe.length,re=0,ie=0;ie<ye;ie++)if(xe[ie]==="\\")ie++;else if(xe[ie]===ve[0])re++;else if(xe[ie]===ve[1]&&(re--,re<0))return ie;return-1}function K(xe){xe&&xe.sanitize&&!xe.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 V={escape:h,unescape:l,edit:w,cleanUrl:k,resolveUrl:a,noopTest:b,merge:m,splitCells:x,rtrim:F,findClosingBracket:U,checkSanitizeDeprecation:K},_=z.defaults,I=V.rtrim,Y=V.splitCells,ee=V.escape,ae=V.findClosingBracket;function de(xe,ve,ye){var re=ve.href,ie=ve.title?ee(ve.title):null,ue=xe[1].replace(/\\([\[\]])/g,"$1");return xe[0].charAt(0)!=="!"?{type:"link",raw:ye,href:re,title:ie,text:ue}:{type:"image",raw:ye,href:re,title:ie,text:ee(ue)}}function De(xe,ve){var ye=xe.match(/^(\s+)(?:```)/);if(ye===null)return ve;var re=ye[1];return ve.split(`
`).map(function(ie){var ue=ie.match(/^\s+/);if(ue===null)return ie;var pe=ue[0];return pe.length>=re.length?ie.slice(re.length):ie}).join(`
`)}var Se=function(){function xe(ye){this.options=ye||_}var ve=xe.prototype;return ve.space=function(re){var ie=this.rules.block.newline.exec(re);if(ie)return ie[0].length>1?{type:"space",raw:ie[0]}:{raw:`
`}},ve.code=function(re,ie){var ue=this.rules.block.code.exec(re);if(ue){var pe=ie[ie.length-1];if(pe&&pe.type==="paragraph")return{raw:ue[0],text:ue[0].trimRight()};var be=ue[0].replace(/^ {4}/gm,"");return{type:"code",raw:ue[0],codeBlockStyle:"indented",text:this.options.pedantic?be:I(be,`
`)}}},ve.fences=function(re){var ie=this.rules.block.fences.exec(re);if(ie){var ue=ie[0],pe=De(ue,ie[3]||"");return{type:"code",raw:ue,lang:ie[2]?ie[2].trim():ie[2],text:pe}}},ve.heading=function(re){var ie=this.rules.block.heading.exec(re);if(ie)return{type:"heading",raw:ie[0],depth:ie[1].length,text:ie[2]}},ve.nptable=function(re){var ie=this.rules.block.nptable.exec(re);if(ie){var ue={type:"table",header:Y(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[],raw:ie[0]};if(ue.header.length===ue.align.length){var pe=ue.align.length,be;for(be=0;be<pe;be++)/^ *-+: *$/.test(ue.align[be])?ue.align[be]="right":/^ *:-+: *$/.test(ue.align[be])?ue.align[be]="center":/^ *:-+ *$/.test(ue.align[be])?ue.align[be]="left":ue.align[be]=null;for(pe=ue.cells.length,be=0;be<pe;be++)ue.cells[be]=Y(ue.cells[be],ue.header.length);return ue}}},ve.hr=function(re){var ie=this.rules.block.hr.exec(re);if(ie)return{type:"hr",raw:ie[0]}},ve.blockquote=function(re){var ie=this.rules.block.blockquote.exec(re);if(ie){var ue=ie[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:ie[0],text:ue}}},ve.list=function(re){var ie=this.rules.block.list.exec(re);if(ie){for(var ue=ie[0],pe=ie[2],be=pe.length>1,_e=pe[pe.length-1]===")",He={type:"list",raw:ue,ordered:be,start:be?+pe.slice(0,-1):"",loose:!1,items:[]},nt=ie[0].match(this.rules.block.item),mt=!1,ft,wt,Tt,ut,Bt,_t,Zt,Xt=nt.length,Ot=0;Ot<Xt;Ot++)ft=nt[Ot],ue=ft,wt=ft.length,ft=ft.replace(/^ *([*+-]|\d+[.)]) */,""),~ft.indexOf(`
`)&&(wt-=ft.length,ft=this.options.pedantic?ft.replace(/^ {1,4}/gm,""):ft.replace(new RegExp("^ {1,"+wt+"}","gm"),"")),Ot!==Xt-1&&(Tt=this.rules.block.bullet.exec(nt[Ot+1])[0],(be?Tt.length===1||!_e&&Tt[Tt.length-1]===")":Tt.length>1||this.options.smartLists&&Tt!==pe)&&(ut=nt.slice(Ot+1).join(`
`),He.raw=He.raw.substring(0,He.raw.length-ut.length),Ot=Xt-1)),Bt=mt||/\n\n(?!\s*$)/.test(ft),Ot!==Xt-1&&(mt=ft.charAt(ft.length-1)===`
`,Bt||(Bt=mt)),Bt&&(He.loose=!0),_t=/^\[[ xX]\] /.test(ft),Zt=void 0,_t&&(Zt=ft[1]!==" ",ft=ft.replace(/^\[[ xX]\] +/,"")),He.items.push({type:"list_item",raw:ue,task:_t,checked:Zt,loose:Bt,text:ft});return He}},ve.html=function(re){var ie=this.rules.block.html.exec(re);if(ie)return{type:this.options.sanitize?"paragraph":"html",raw:ie[0],pre:!this.options.sanitizer&&(ie[1]==="pre"||ie[1]==="script"||ie[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ie[0]):ee(ie[0]):ie[0]}},ve.def=function(re){var ie=this.rules.block.def.exec(re);if(ie){ie[3]&&(ie[3]=ie[3].substring(1,ie[3].length-1));var ue=ie[1].toLowerCase().replace(/\s+/g," ");return{tag:ue,raw:ie[0],href:ie[2],title:ie[3]}}},ve.table=function(re){var ie=this.rules.block.table.exec(re);if(ie){var ue={type:"table",header:Y(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[]};if(ue.header.length===ue.align.length){ue.raw=ie[0];var pe=ue.align.length,be;for(be=0;be<pe;be++)/^ *-+: *$/.test(ue.align[be])?ue.align[be]="right":/^ *:-+: *$/.test(ue.align[be])?ue.align[be]="center":/^ *:-+ *$/.test(ue.align[be])?ue.align[be]="left":ue.align[be]=null;for(pe=ue.cells.length,be=0;be<pe;be++)ue.cells[be]=Y(ue.cells[be].replace(/^ *\| *| *\| *$/g,""),ue.header.length);return ue}}},ve.lheading=function(re){var ie=this.rules.block.lheading.exec(re);if(ie)return{type:"heading",raw:ie[0],depth:ie[2].charAt(0)==="="?1:2,text:ie[1]}},ve.paragraph=function(re){var ie=this.rules.block.paragraph.exec(re);if(ie)return{type:"paragraph",raw:ie[0],text:ie[1].charAt(ie[1].length-1)===`
`?ie[1].slice(0,-1):ie[1]}},ve.text=function(re,ie){var ue=this.rules.block.text.exec(re);if(ue){var pe=ie[ie.length-1];return pe&&pe.type==="text"?{raw:ue[0],text:ue[0]}:{type:"text",raw:ue[0],text:ue[0]}}},ve.escape=function(re){var ie=this.rules.inline.escape.exec(re);if(ie)return{type:"escape",raw:ie[0],text:ee(ie[1])}},ve.tag=function(re,ie,ue){var pe=this.rules.inline.tag.exec(re);if(pe)return!ie&&/^<a /i.test(pe[0])?ie=!0:ie&&/^<\/a>/i.test(pe[0])&&(ie=!1),!ue&&/^<(pre|code|kbd|script)(\s|>)/i.test(pe[0])?ue=!0:ue&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(pe[0])&&(ue=!1),{type:this.options.sanitize?"text":"html",raw:pe[0],inLink:ie,inRawBlock:ue,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(pe[0]):ee(pe[0]):pe[0]}},ve.link=function(re){var ie=this.rules.inline.link.exec(re);if(ie){var ue=ae(ie[2],"()");if(ue>-1){var pe=ie[0].indexOf("!")===0?5:4,be=pe+ie[1].length+ue;ie[2]=ie[2].substring(0,ue),ie[0]=ie[0].substring(0,be).trim(),ie[3]=""}var _e=ie[2],He="";if(this.options.pedantic){var nt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(_e);nt?(_e=nt[1],He=nt[3]):He=""}else He=ie[3]?ie[3].slice(1,-1):"";_e=_e.trim().replace(/^<([\s\S]*)>$/,"$1");var mt=de(ie,{href:_e&&_e.replace(this.rules.inline._escapes,"$1"),title:He&&He.replace(this.rules.inline._escapes,"$1")},ie[0]);return mt}},ve.reflink=function(re,ie){var ue;if((ue=this.rules.inline.reflink.exec(re))||(ue=this.rules.inline.nolink.exec(re))){var pe=(ue[2]||ue[1]).replace(/\s+/g," ");if(pe=ie[pe.toLowerCase()],!pe||!pe.href){var be=ue[0].charAt(0);return{type:"text",raw:be,text:be}}var _e=de(ue,pe,ue[0]);return _e}},ve.strong=function(re,ie,ue){ue===void 0&&(ue="");var pe=this.rules.inline.strong.start.exec(re);if(pe&&(!pe[1]||pe[1]&&(ue===""||this.rules.inline.punctuation.exec(ue)))){ie=ie.slice(-1*re.length);var be=pe[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;be.lastIndex=0;for(var _e;(pe=be.exec(ie))!=null;)if(_e=this.rules.inline.strong.middle.exec(ie.slice(0,pe.index+3)),_e)return{type:"strong",raw:re.slice(0,_e[0].length),text:re.slice(2,_e[0].length-2)}}},ve.em=function(re,ie,ue){ue===void 0&&(ue="");var pe=this.rules.inline.em.start.exec(re);if(pe&&(!pe[1]||pe[1]&&(ue===""||this.rules.inline.punctuation.exec(ue)))){ie=ie.slice(-1*re.length);var be=pe[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;be.lastIndex=0;for(var _e;(pe=be.exec(ie))!=null;)if(_e=this.rules.inline.em.middle.exec(ie.slice(0,pe.index+2)),_e)return{type:"em",raw:re.slice(0,_e[0].length),text:re.slice(1,_e[0].length-1)}}},ve.codespan=function(re){var ie=this.rules.inline.code.exec(re);if(ie){var ue=ie[2].replace(/\n/g," "),pe=/[^ ]/.test(ue),be=ue.startsWith(" ")&&ue.endsWith(" ");return pe&&be&&(ue=ue.substring(1,ue.length-1)),ue=ee(ue,!0),{type:"codespan",raw:ie[0],text:ue}}},ve.br=function(re){var ie=this.rules.inline.br.exec(re);if(ie)return{type:"br",raw:ie[0]}},ve.del=function(re){var ie=this.rules.inline.del.exec(re);if(ie)return{type:"del",raw:ie[0],text:ie[1]}},ve.autolink=function(re,ie){var ue=this.rules.inline.autolink.exec(re);if(ue){var pe,be;return ue[2]==="@"?(pe=ee(this.options.mangle?ie(ue[1]):ue[1]),be="mailto:"+pe):(pe=ee(ue[1]),be=pe),{type:"link",raw:ue[0],text:pe,href:be,tokens:[{type:"text",raw:pe,text:pe}]}}},ve.url=function(re,ie){var ue;if(ue=this.rules.inline.url.exec(re)){var pe,be;if(ue[2]==="@")pe=ee(this.options.mangle?ie(ue[0]):ue[0]),be="mailto:"+pe;else{var _e;do _e=ue[0],ue[0]=this.rules.inline._backpedal.exec(ue[0])[0];while(_e!==ue[0]);pe=ee(ue[0]),ue[1]==="www."?be="http://"+pe:be=pe}return{type:"link",raw:ue[0],text:pe,href:be,tokens:[{type:"text",raw:pe,text:pe}]}}},ve.inlineText=function(re,ie,ue){var pe=this.rules.inline.text.exec(re);if(pe){var be;return ie?be=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(pe[0]):ee(pe[0]):pe[0]:be=ee(this.options.smartypants?ue(pe[0]):pe[0]),{type:"text",raw:pe[0],text:be}}},xe}(),we=V.noopTest,Ce=V.edit,Te=V.merge,ge={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:we,table:we,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ge._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ge._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ge.def=Ce(ge.def).replace("label",ge._label).replace("title",ge._title).getRegex(),ge.bullet=/(?:[*+-]|\d{1,9}[.)])/,ge.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ge.item=Ce(ge.item,"gm").replace(/bull/g,ge.bullet).getRegex(),ge.list=Ce(ge.list).replace(/bull/g,ge.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ge.def.source+")").getRegex(),ge._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",ge._comment=/<!--(?!-?>)[\s\S]*?-->/,ge.html=Ce(ge.html,"i").replace("comment",ge._comment).replace("tag",ge._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge.paragraph=Ce(ge._paragraph).replace("hr",ge.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",ge._tag).getRegex(),ge.blockquote=Ce(ge.blockquote).replace("paragraph",ge.paragraph).getRegex(),ge.normal=Te({},ge),ge.gfm=Te({},ge.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*|$)"}),ge.gfm.nptable=Ce(ge.gfm.nptable).replace("hr",ge.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",ge._tag).getRegex(),ge.gfm.table=Ce(ge.gfm.table).replace("hr",ge.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",ge._tag).getRegex(),ge.pedantic=Te({},ge.normal,{html:Ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ge._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:we,paragraph:Ce(ge.normal._paragraph).replace("hr",ge.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",ge.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var le={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:we,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:we,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};le._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",le.punctuation=Ce(le.punctuation).replace(/punctuation/g,le._punctuation).getRegex(),le._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",le._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",le.em.start=Ce(le.em.start).replace(/punctuation/g,le._punctuation).getRegex(),le.em.middle=Ce(le.em.middle).replace(/punctuation/g,le._punctuation).replace(/overlapSkip/g,le._overlapSkip).getRegex(),le.em.endAst=Ce(le.em.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.em.endUnd=Ce(le.em.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.start=Ce(le.strong.start).replace(/punctuation/g,le._punctuation).getRegex(),le.strong.middle=Ce(le.strong.middle).replace(/punctuation/g,le._punctuation).replace(/blockSkip/g,le._blockSkip).getRegex(),le.strong.endAst=Ce(le.strong.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.endUnd=Ce(le.strong.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.blockSkip=Ce(le._blockSkip,"g").getRegex(),le.overlapSkip=Ce(le._overlapSkip,"g").getRegex(),le._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,le._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,le._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])?)+(?![-_])/,le.autolink=Ce(le.autolink).replace("scheme",le._scheme).replace("email",le._email).getRegex(),le._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,le.tag=Ce(le.tag).replace("comment",ge._comment).replace("attribute",le._attribute).getRegex(),le._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,le._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,le._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,le.link=Ce(le.link).replace("label",le._label).replace("href",le._href).replace("title",le._title).getRegex(),le.reflink=Ce(le.reflink).replace("label",le._label).getRegex(),le.reflinkSearch=Ce(le.reflinkSearch,"g").replace("reflink",le.reflink).replace("nolink",le.nolink).getRegex(),le.normal=Te({},le),le.pedantic=Te({},le.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ce(/^!?\[(label)\]\((.*?)\)/).replace("label",le._label).getRegex(),reflink:Ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",le._label).getRegex()}),le.gfm=Te({},le.normal,{escape:Ce(le.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),le.gfm.url=Ce(le.gfm.url,"i").replace("email",le.gfm._extended_email).getRegex(),le.breaks=Te({},le.gfm,{br:Ce(le.br).replace("{2,}","*").getRegex(),text:Ce(le.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var te={block:ge,inline:le},ce=z.defaults,ne=te.block,Le=te.inline;function Oe(xe){return xe.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 Ee(xe){var ve="",ye,re,ie=xe.length;for(ye=0;ye<ie;ye++)re=xe.charCodeAt(ye),Math.random()>.5&&(re="x"+re.toString(16)),ve+="&#"+re+";";return ve}var Re=function(){function xe(ye){this.tokens=[],this.tokens.links=Object.create(null),this.options=ye||ce,this.options.tokenizer=this.options.tokenizer||new Se,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var re={block:ne.normal,inline:Le.normal};this.options.pedantic?(re.block=ne.pedantic,re.inline=Le.pedantic):this.options.gfm&&(re.block=ne.gfm,this.options.breaks?re.inline=Le.breaks:re.inline=Le.gfm),this.tokenizer.rules=re}xe.lex=function(re,ie){var ue=new xe(ie);return ue.lex(re)};var ve=xe.prototype;return ve.lex=function(re){return re=re.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(re,this.tokens,!0),this.inline(this.tokens),this.tokens},ve.blockTokens=function(re,ie,ue){ie===void 0&&(ie=[]),ue===void 0&&(ue=!0),re=re.replace(/^ +$/gm,"");for(var pe,be,_e,He;re;){if(pe=this.tokenizer.space(re)){re=re.substring(pe.raw.length),pe.type&&ie.push(pe);continue}if(pe=this.tokenizer.code(re,ie)){re=re.substring(pe.raw.length),pe.type?ie.push(pe):(He=ie[ie.length-1],He.raw+=`
`+pe.raw,He.text+=`
`+pe.text);continue}if(pe=this.tokenizer.fences(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.heading(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.nptable(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.hr(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.blockquote(re)){re=re.substring(pe.raw.length),pe.tokens=this.blockTokens(pe.text,[],ue),ie.push(pe);continue}if(pe=this.tokenizer.list(re)){for(re=re.substring(pe.raw.length),_e=pe.items.length,be=0;be<_e;be++)pe.items[be].tokens=this.blockTokens(pe.items[be].text,[],!1);ie.push(pe);continue}if(pe=this.tokenizer.html(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(ue&&(pe=this.tokenizer.def(re))){re=re.substring(pe.raw.length),this.tokens.links[pe.tag]||(this.tokens.links[pe.tag]={href:pe.href,title:pe.title});continue}if(pe=this.tokenizer.table(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.lheading(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(ue&&(pe=this.tokenizer.paragraph(re))){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.text(re,ie)){re=re.substring(pe.raw.length),pe.type?ie.push(pe):(He=ie[ie.length-1],He.raw+=`
`+pe.raw,He.text+=`
`+pe.text);continue}if(re){var nt="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error(nt);break}else throw new Error(nt)}}return ie},ve.inline=function(re){var ie,ue,pe,be,_e,He,nt=re.length;for(ie=0;ie<nt;ie++){He=re[ie];switch(He.type){case"paragraph":case"text":case"heading":{He.tokens=[],this.inlineTokens(He.text,He.tokens);break}case"table":{for(He.tokens={header:[],cells:[]},be=He.header.length,ue=0;ue<be;ue++)He.tokens.header[ue]=[],this.inlineTokens(He.header[ue],He.tokens.header[ue]);for(be=He.cells.length,ue=0;ue<be;ue++)for(_e=He.cells[ue],He.tokens.cells[ue]=[],pe=0;pe<_e.length;pe++)He.tokens.cells[ue][pe]=[],this.inlineTokens(_e[pe],He.tokens.cells[ue][pe]);break}case"blockquote":{this.inline(He.tokens);break}case"list":{for(be=He.items.length,ue=0;ue<be;ue++)this.inline(He.items[ue].tokens);break}}}return re},ve.inlineTokens=function(re,ie,ue,pe,be){ie===void 0&&(ie=[]),ue===void 0&&(ue=!1),pe===void 0&&(pe=!1),be===void 0&&(be="");var _e,He=re,nt;if(this.tokens.links){var mt=Object.keys(this.tokens.links);if(mt.length>0)for(;(nt=this.tokenizer.rules.inline.reflinkSearch.exec(He))!=null;)mt.includes(nt[0].slice(nt[0].lastIndexOf("[")+1,-1))&&(He=He.slice(0,nt.index)+"["+"a".repeat(nt[0].length-2)+"]"+He.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(nt=this.tokenizer.rules.inline.blockSkip.exec(He))!=null;)He=He.slice(0,nt.index)+"["+"a".repeat(nt[0].length-2)+"]"+He.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;re;){if(_e=this.tokenizer.escape(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.tag(re,ue,pe)){re=re.substring(_e.raw.length),ue=_e.inLink,pe=_e.inRawBlock,ie.push(_e);continue}if(_e=this.tokenizer.link(re)){re=re.substring(_e.raw.length),_e.type==="link"&&(_e.tokens=this.inlineTokens(_e.text,[],!0,pe)),ie.push(_e);continue}if(_e=this.tokenizer.reflink(re,this.tokens.links)){re=re.substring(_e.raw.length),_e.type==="link"&&(_e.tokens=this.inlineTokens(_e.text,[],!0,pe)),ie.push(_e);continue}if(_e=this.tokenizer.strong(re,He,be)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],ue,pe),ie.push(_e);continue}if(_e=this.tokenizer.em(re,He,be)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],ue,pe),ie.push(_e);continue}if(_e=this.tokenizer.codespan(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.br(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.del(re)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],ue,pe),ie.push(_e);continue}if(_e=this.tokenizer.autolink(re,Ee)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(!ue&&(_e=this.tokenizer.url(re,Ee))){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.inlineText(re,pe,Oe)){re=re.substring(_e.raw.length),be=_e.raw.slice(-1),ie.push(_e);continue}if(re){var ft="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error(ft);break}else throw new Error(ft)}}return ie},Z(xe,null,[{key:"rules",get:function(){return{block:ne,inline:Le}}}]),xe}(),Ne=z.defaults,je=V.cleanUrl,Ue=V.escape,Ie=function(){function xe(ye){this.options=ye||Ne}var ve=xe.prototype;return ve.code=function(re,ie,ue){var pe=(ie||"").match(/\S*/)[0];if(this.options.highlight){var be=this.options.highlight(re,pe);be!=null&&be!==re&&(ue=!0,re=be)}return pe?'<pre><code class="'+this.options.langPrefix+Ue(pe,!0)+'">'+(ue?re:Ue(re,!0))+`</code></pre>
`:"<pre><code>"+(ue?re:Ue(re,!0))+`</code></pre>
`},ve.blockquote=function(re){return`<blockquote>
`+re+`</blockquote>
`},ve.html=function(re){return re},ve.heading=function(re,ie,ue,pe){return this.options.headerIds?"<h"+ie+' id="'+this.options.headerPrefix+pe.slug(ue)+'">'+re+"</h"+ie+`>
`:"<h"+ie+">"+re+"</h"+ie+`>
`},ve.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},ve.list=function(re,ie,ue){var pe=ie?"ol":"ul",be=ie&&ue!==1?' start="'+ue+'"':"";return"<"+pe+be+`>
`+re+"</"+pe+`>
`},ve.listitem=function(re){return"<li>"+re+`</li>
`},ve.checkbox=function(re){return"<input "+(re?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ve.paragraph=function(re){return"<p>"+re+`</p>
`},ve.table=function(re,ie){return ie&&(ie="<tbody>"+ie+"</tbody>"),`<table>
<thead>
`+re+`</thead>
`+ie+`</table>
`},ve.tablerow=function(re){return`<tr>
`+re+`</tr>
`},ve.tablecell=function(re,ie){var ue=ie.header?"th":"td",pe=ie.align?"<"+ue+' align="'+ie.align+'">':"<"+ue+">";return pe+re+"</"+ue+`>
`},ve.strong=function(re){return"<strong>"+re+"</strong>"},ve.em=function(re){return"<em>"+re+"</em>"},ve.codespan=function(re){return"<code>"+re+"</code>"},ve.br=function(){return this.options.xhtml?"<br/>":"<br>"},ve.del=function(re){return"<del>"+re+"</del>"},ve.link=function(re,ie,ue){if(re=je(this.options.sanitize,this.options.baseUrl,re),re===null)return ue;var pe='<a href="'+Ue(re)+'"';return ie&&(pe+=' title="'+ie+'"'),pe+=">"+ue+"</a>",pe},ve.image=function(re,ie,ue){if(re=je(this.options.sanitize,this.options.baseUrl,re),re===null)return ue;var pe='<img src="'+re+'" alt="'+ue+'"';return ie&&(pe+=' title="'+ie+'"'),pe+=this.options.xhtml?"/>":">",pe},ve.text=function(re){return re},xe}(),Me=function(){function xe(){}var ve=xe.prototype;return ve.strong=function(re){return re},ve.em=function(re){return re},ve.codespan=function(re){return re},ve.del=function(re){return re},ve.html=function(re){return re},ve.text=function(re){return re},ve.link=function(re,ie,ue){return""+ue},ve.image=function(re,ie,ue){return""+ue},ve.br=function(){return""},xe}(),Ke=function(){function xe(){this.seen={}}var ve=xe.prototype;return ve.slug=function(re){var ie=re.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(ie)){var ue=ie;do this.seen[ue]++,ie=ue+"-"+this.seen[ue];while(this.seen.hasOwnProperty(ie))}return this.seen[ie]=0,ie},xe}(),Ze=z.defaults,$e=V.unescape,Qe=function(){function xe(ye){this.options=ye||Ze,this.options.renderer=this.options.renderer||new Ie,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Me,this.slugger=new Ke}xe.parse=function(re,ie){var ue=new xe(ie);return ue.parse(re)};var ve=xe.prototype;return ve.parse=function(re,ie){ie===void 0&&(ie=!0);var ue="",pe,be,_e,He,nt,mt,ft,wt,Tt,ut,Bt,_t,Zt,Xt,Ot,Ir,Kr,bt,Nr=re.length;for(pe=0;pe<Nr;pe++){ut=re[pe];switch(ut.type){case"space":continue;case"hr":{ue+=this.renderer.hr();continue}case"heading":{ue+=this.renderer.heading(this.parseInline(ut.tokens),ut.depth,$e(this.parseInline(ut.tokens,this.textRenderer)),this.slugger);continue}case"code":{ue+=this.renderer.code(ut.text,ut.lang,ut.escaped);continue}case"table":{for(wt="",ft="",He=ut.header.length,be=0;be<He;be++)ft+=this.renderer.tablecell(this.parseInline(ut.tokens.header[be]),{header:!0,align:ut.align[be]});for(wt+=this.renderer.tablerow(ft),Tt="",He=ut.cells.length,be=0;be<He;be++){for(mt=ut.tokens.cells[be],ft="",nt=mt.length,_e=0;_e<nt;_e++)ft+=this.renderer.tablecell(this.parseInline(mt[_e]),{header:!1,align:ut.align[_e]});Tt+=this.renderer.tablerow(ft)}ue+=this.renderer.table(wt,Tt);continue}case"blockquote":{Tt=this.parse(ut.tokens),ue+=this.renderer.blockquote(Tt);continue}case"list":{for(Bt=ut.ordered,_t=ut.start,Zt=ut.loose,He=ut.items.length,Tt="",be=0;be<He;be++)Ot=ut.items[be],Ir=Ot.checked,Kr=Ot.task,Xt="",Ot.task&&(bt=this.renderer.checkbox(Ir),Zt?Ot.tokens.length>0&&Ot.tokens[0].type==="text"?(Ot.tokens[0].text=bt+" "+Ot.tokens[0].text,Ot.tokens[0].tokens&&Ot.tokens[0].tokens.length>0&&Ot.tokens[0].tokens[0].type==="text"&&(Ot.tokens[0].tokens[0].text=bt+" "+Ot.tokens[0].tokens[0].text)):Ot.tokens.unshift({type:"text",text:bt}):Xt+=bt),Xt+=this.parse(Ot.tokens,Zt),Tt+=this.renderer.listitem(Xt,Kr,Ir);ue+=this.renderer.list(Tt,Bt,_t);continue}case"html":{ue+=this.renderer.html(ut.text);continue}case"paragraph":{ue+=this.renderer.paragraph(this.parseInline(ut.tokens));continue}case"text":{for(Tt=ut.tokens?this.parseInline(ut.tokens):ut.text;pe+1<Nr&&re[pe+1].type==="text";)ut=re[++pe],Tt+=`
`+(ut.tokens?this.parseInline(ut.tokens):ut.text);ue+=ie?this.renderer.paragraph(Tt):Tt;continue}default:{var hr='Token with "'+ut.type+'" type was not found.';if(this.options.silent){console.error(hr);return}else throw new Error(hr)}}}return ue},ve.parseInline=function(re,ie){ie=ie||this.renderer;var ue="",pe,be,_e=re.length;for(pe=0;pe<_e;pe++){be=re[pe];switch(be.type){case"escape":{ue+=ie.text(be.text);break}case"html":{ue+=ie.html(be.text);break}case"link":{ue+=ie.link(be.href,be.title,this.parseInline(be.tokens,ie));break}case"image":{ue+=ie.image(be.href,be.title,be.text);break}case"strong":{ue+=ie.strong(this.parseInline(be.tokens,ie));break}case"em":{ue+=ie.em(this.parseInline(be.tokens,ie));break}case"codespan":{ue+=ie.codespan(be.text);break}case"br":{ue+=ie.br();break}case"del":{ue+=ie.del(this.parseInline(be.tokens,ie));break}case"text":{ue+=ie.text(be.text);break}default:{var He='Token with "'+be.type+'" type was not found.';if(this.options.silent){console.error(He);return}else throw new Error(He)}}}return ue},xe}(),lt=V.merge,tt=V.checkSanitizeDeprecation,rt=V.escape,Pe=z.getDefaults,ht=z.changeDefaults,at=z.defaults;function Fe(xe,ve,ye){if(typeof xe=="undefined"||xe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof xe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(xe)+", string expected");if(typeof ve=="function"&&(ye=ve,ve=null),ve=lt({},Fe.defaults,ve||{}),tt(ve),ye){var re=ve.highlight,ie;try{ie=Re.lex(xe,ve)}catch(_e){return ye(_e)}var ue=function(He){var nt;if(!He)try{nt=Qe.parse(ie,ve)}catch(mt){He=mt}return ve.highlight=re,He?ye(He):ye(null,nt)};if(!re||re.length<3)return ue();if(delete ve.highlight,!ie.length)return ue();var pe=0;Fe.walkTokens(ie,function(_e){_e.type==="code"&&(pe++,setTimeout(function(){re(_e.text,_e.lang,function(He,nt){if(He)return ue(He);nt!=null&&nt!==_e.text&&(_e.text=nt,_e.escaped=!0),pe--,pe===0&&ue()})},0))}),pe===0&&ue();return}try{var be=Re.lex(xe,ve);return ve.walkTokens&&Fe.walkTokens(be,ve.walkTokens),Qe.parse(be,ve)}catch(_e){if(_e.message+=`
Please report this to https://github.com/markedjs/marked.`,ve.silent)return"<p>An error occurred:</p><pre>"+rt(_e.message+"",!0)+"</pre>";throw _e}}Fe.options=Fe.setOptions=function(xe){return lt(Fe.defaults,xe),ht(Fe.defaults),Fe},Fe.getDefaults=Pe,Fe.defaults=at,Fe.use=function(xe){var ve=lt({},xe);if(xe.renderer&&function(){var re=Fe.defaults.renderer||new Ie,ie=function(be){var _e=re[be];re[be]=function(){for(var He=arguments.length,nt=new Array(He),mt=0;mt<He;mt++)nt[mt]=arguments[mt];var ft=xe.renderer[be].apply(re,nt);return ft===!1&&(ft=_e.apply(re,nt)),ft}};for(var ue in xe.renderer)ie(ue);ve.renderer=re}(),xe.tokenizer&&function(){var re=Fe.defaults.tokenizer||new Se,ie=function(be){var _e=re[be];re[be]=function(){for(var He=arguments.length,nt=new Array(He),mt=0;mt<He;mt++)nt[mt]=arguments[mt];var ft=xe.tokenizer[be].apply(re,nt);return ft===!1&&(ft=_e.apply(re,nt)),ft}};for(var ue in xe.tokenizer)ie(ue);ve.tokenizer=re}(),xe.walkTokens){var ye=Fe.defaults.walkTokens;ve.walkTokens=function(re){xe.walkTokens(re),ye&&ye(re)}}Fe.setOptions(ve)},Fe.walkTokens=function(xe,ve){for(var ye=B(xe),re;!(re=ye()).done;){var ie=re.value;ve(ie);switch(ie.type){case"table":{for(var ue=B(ie.tokens.header),pe;!(pe=ue()).done;){var be=pe.value;Fe.walkTokens(be,ve)}for(var _e=B(ie.tokens.cells),He;!(He=_e()).done;)for(var nt=He.value,mt=B(nt),ft;!(ft=mt()).done;){var wt=ft.value;Fe.walkTokens(wt,ve)}break}case"list":{Fe.walkTokens(ie.items,ve);break}default:ie.tokens&&Fe.walkTokens(ie.tokens,ve)}}},Fe.Parser=Qe,Fe.parser=Qe.parse,Fe.Renderer=Ie,Fe.TextRenderer=Me,Fe.Lexer=Re,Fe.lexer=Re.lex,Fe.Tokenizer=Se,Fe.Slugger=Ke,Fe.parse=Fe;var Ve=Fe;return Ve})},ELLl:function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){var Z={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=oe.Pos;oe.defineOption("autoCloseBrackets",!1,function(C,T,h){h&&h!=oe.Init&&(C.removeKeyMap(B),C.state.closeBrackets=null),T&&(M($(T,"pairs")),C.state.closeBrackets=T,C.addKeyMap(B))});function $(C,T){return T=="pairs"&&typeof C=="string"?C:typeof C=="object"&&C[T]!=null?C[T]:Z[T]}var B={Backspace:P,Enter:R};function M(C){for(var T=0;T<C.length;T++){var h=C.charAt(T),o="'"+h+"'";B[o]||(B[o]=z(h))}}M(Z.pairs+"`");function z(C){return function(T){return A(T,C)}}function W(C){var T=C.state.closeBrackets;if(!T||T.override)return T;var h=C.getModeAt(C.getCursor());return h.closeBrackets||T}function P(C){var T=W(C);if(!T||C.getOption("disableInput"))return oe.Pass;for(var h=$(T,"pairs"),o=C.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var d=O(C,o[l].head);if(!d||h.indexOf(d)%2!=0)return oe.Pass}for(var l=o.length-1;l>=0;l--){var w=o[l].head;C.replaceRange("",D(w.line,w.ch-1),D(w.line,w.ch+1),"+delete")}}function R(C){var T=W(C),h=T&&$(T,"explode");if(!h||C.getOption("disableInput"))return oe.Pass;for(var o=C.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var d=O(C,o[l].head);if(!d||h.indexOf(d)%2!=0)return oe.Pass}C.operation(function(){var w=C.lineSeparator()||`
`;C.replaceSelection(w+w,null),C.execCommand("goCharLeft"),o=C.listSelections();for(var v=0;v<o.length;v++){var g=o[v].head.line;C.indentLine(g,null,!0),C.indentLine(g+1,null,!0)}})}function y(C){var T=oe.cmpPos(C.anchor,C.head)>0;return{anchor:new D(C.anchor.line,C.anchor.ch+(T?-1:1)),head:new D(C.head.line,C.head.ch+(T?1:-1))}}function A(C,T){var h=W(C);if(!h||C.getOption("disableInput"))return oe.Pass;var o=$(h,"pairs"),l=o.indexOf(T);if(l==-1)return oe.Pass;for(var d=$(h,"closeBefore"),w=$(h,"triples"),v=o.charAt(l+1)==T,g=C.listSelections(),k=l%2==0,E,p=0;p<g.length;p++){var c=g[p],u=c.head,a,b=C.getRange(u,D(u.line,u.ch+1));if(k&&!c.empty())a="surround";else if((v||!k)&&b==T)v&&L(C,u)?a="both":w.indexOf(T)>=0&&C.getRange(u,D(u.line,u.ch+3))==T+T+T?a="skipThree":a="skip";else if(v&&u.ch>1&&w.indexOf(T)>=0&&C.getRange(D(u.line,u.ch-2),u)==T+T){if(u.ch>2&&/\bstring/.test(C.getTokenTypeAt(D(u.line,u.ch-2))))return oe.Pass;a="addFour"}else if(v){var m=u.ch==0?" ":C.getRange(D(u.line,u.ch-1),u);if(!oe.isWordChar(b)&&m!=T&&!oe.isWordChar(m))a="both";else return oe.Pass}else if(k&&(b.length===0||/\s/.test(b)||d.indexOf(b)>-1))a="both";else return oe.Pass;if(!E)E=a;else if(E!=a)return oe.Pass}var x=l%2?o.charAt(l-1):T,F=l%2?T:o.charAt(l+1);C.operation(function(){if(E=="skip")C.execCommand("goCharRight");else if(E=="skipThree")for(var U=0;U<3;U++)C.execCommand("goCharRight");else if(E=="surround"){for(var K=C.getSelections(),U=0;U<K.length;U++)K[U]=x+K[U]+F;C.replaceSelections(K,"around"),K=C.listSelections().slice();for(var U=0;U<K.length;U++)K[U]=y(K[U]);C.setSelections(K)}else E=="both"?(C.replaceSelection(x+F,null),C.triggerElectric(x+F),C.execCommand("goCharLeft")):E=="addFour"&&(C.replaceSelection(x+x+x+x,"before"),C.execCommand("goCharRight"))})}function O(C,T){var h=C.getRange(D(T.line,T.ch-1),D(T.line,T.ch+1));return h.length==2?h:null}function L(C,T){var h=C.getTokenAt(D(T.line,T.ch+1));return/\bstring/.test(h.type)&&h.start==T.ch&&(T.ch==0||!/\bstring/.test(C.getTokenTypeAt(T)))}})},GfqC:function(xt,it,se){"use strict";var oe=se("q1tI"),Z=se.n(oe),D=se("TSYQ"),$=se.n(D);function B(V,_){var I="cannot "+V.method+" "+V.action+" "+_.status+"'",Y=new Error(I);return Y.status=_.status,Y.method=V.method,Y.url=V.action,Y}function M(V){var _=V.responseText||V.response;if(!_)return _;try{return JSON.parse(_)}catch(I){return _}}function z(V){var _=new XMLHttpRequest;V.onProgress&&_.upload&&(_.upload.onprogress=function(ae){ae.total>0&&(ae.percent=ae.loaded/ae.total*100),V.onProgress(ae)});var I=new FormData;V.data&&Object.keys(V.data).forEach(function(ee){var ae=V.data[ee];if(Array.isArray(ae)){ae.forEach(function(de){I.append(ee+"[]",de)});return}I.append(ee,V.data[ee])}),V.file instanceof Blob?I.append(V.filename,V.file,V.file.name):I.append(V.filename,V.file),_.onerror=function(ae){V.onError(ae)},_.onload=function(){return _.status<200||_.status>=300?V.onError(B(V,_),M(_)):V.onSuccess(M(_),_)},_.open(V.method,V.action,!0),V.withCredentials&&"withCredentials"in _&&(_.withCredentials=!0);var Y=V.headers||{};return Y["X-Requested-With"]!==null&&_.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(Y).forEach(function(ee){Y[ee]!==null&&_.setRequestHeader(ee,Y[ee])}),_.send(I),{abort:function(){_.abort()}}}var W=+new Date,P=0;function R(){return"rc-upload-"+W+"-"+ ++P}function y(V,_){return V.indexOf(_,V.length-_.length)!==-1}var A=function(V,_){if(V&&_){var I=Array.isArray(_)?_:_.split(","),Y=V.name||"",ee=V.type||"",ae=ee.replace(/\/.*$/,"");return I.some(function(de){var De=de.trim();return De.charAt(0)==="."?y(Y.toLowerCase(),De.toLowerCase()):/\/\*$/.test(De)?ae===De.replace(/\/.*$/,""):ee===De})}return!0};function O(V,_){var I=V.createReader(),Y=[];function ee(){I.readEntries(function(ae){var de=Array.prototype.slice.apply(ae);Y=Y.concat(de);var De=!de.length;De?_(Y):ee()})}ee()}var L=function(_,I,Y){var ee=function ae(de,De){De=De||"",de.isFile?de.file(function(Se){Y(Se)&&(de.fullPath&&!Se.webkitRelativePath&&(Object.defineProperties(Se,{webkitRelativePath:{writable:!0}}),Se.webkitRelativePath=de.fullPath.replace(/^\//,""),Object.defineProperties(Se,{webkitRelativePath:{writable:!1}})),I([Se]))}):de.isDirectory&&O(de,function(Se){Se.forEach(function(we){ae(we,""+De+de.name+"/")})})};_.forEach(function(ae){ee(ae.webkitGetAsEntry())})},C=L,T=Object.assign||function(V){for(var _=1;_<arguments.length;_++){var I=arguments[_];for(var Y in I)Object.prototype.hasOwnProperty.call(I,Y)&&(V[Y]=I[Y])}return V},h=function(){function V(_,I){var Y=[],ee=!0,ae=!1,de=void 0;try{for(var De=_[Symbol.iterator](),Se;!(ee=(Se=De.next()).done)&&!(Y.push(Se.value),I&&Y.length===I);ee=!0);}catch(we){ae=!0,de=we}finally{try{!ee&&De.return&&De.return()}finally{if(ae)throw de}}return Y}return function(_,I){if(Array.isArray(_))return _;if(Symbol.iterator in Object(_))return V(_,I);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function V(_,I){for(var Y=0;Y<I.length;Y++){var ee=I[Y];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(_,ee.key,ee)}}return function(_,I,Y){return I&&V(_.prototype,I),Y&&V(_,Y),_}}();function l(V,_,I){return _ in V?Object.defineProperty(V,_,{value:I,enumerable:!0,configurable:!0,writable:!0}):V[_]=I,V}function d(V,_){var I={};for(var Y in V){if(_.indexOf(Y)>=0)continue;if(!Object.prototype.hasOwnProperty.call(V,Y))continue;I[Y]=V[Y]}return I}function w(V,_){if(!(V instanceof _))throw new TypeError("Cannot call a class as a function")}function v(V,_){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:V}function g(V,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);V.prototype=Object.create(_&&_.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(V,_):V.__proto__=_)}var k=function(_){return Object.keys(_).reduce(function(I,Y){return(Y.substr(0,5)==="data-"||Y.substr(0,5)==="aria-"||Y==="role")&&(I[Y]=_[Y]),I},{})},E=function(V){g(_,V);function _(){var I,Y,ee,ae;w(this,_);for(var de=arguments.length,De=Array(de),Se=0;Se<de;Se++)De[Se]=arguments[Se];return ae=(Y=(ee=v(this,(I=_.__proto__||Object.getPrototypeOf(_)).call.apply(I,[this].concat(De))),ee),ee.state={uid:R()},ee.reqs={},ee.onChange=function(we){var Ce=we.target.files;ee.uploadFiles(Ce),ee.reset()},ee.onClick=function(we){var Ce=ee.fileInput;if(!Ce)return;var Te=ee.props,ge=Te.children,le=Te.onClick;ge&&ge.type==="button"&&(Ce.parentNode.focus(),Ce.parentNode.querySelector("button").blur()),Ce.click(),le&&le(we)},ee.onKeyDown=function(we){we.key==="Enter"&&ee.onClick()},ee.onFileDrop=function(we){var Ce=ee.props.multiple;if(we.preventDefault(),we.type==="dragover")return;if(ee.props.directory)C(Array.prototype.slice.call(we.dataTransfer.items),ee.uploadFiles,function(ge){return A(ge,ee.props.accept)});else{var Te=Array.prototype.slice.call(we.dataTransfer.files).filter(function(ge){return A(ge,ee.props.accept)});Ce===!1&&(Te=Te.slice(0,1)),ee.uploadFiles(Te)}},ee.uploadFiles=function(we){var Ce=Array.prototype.slice.call(we);Ce.map(function(Te){return Te.uid=R(),Te}).forEach(function(Te){ee.upload(Te,Ce)})},ee.saveFileInput=function(we){ee.fileInput=we},Y),v(ee,ae)}return o(_,[{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.abort()}},{key:"upload",value:function(Y,ee){var ae=this,de=this.props;if(!de.beforeUpload)return setTimeout(function(){return ae.post(Y)},0);var De=de.beforeUpload(Y,ee);De&&De.then?De.then(function(Se){var we=Object.prototype.toString.call(Se);return we==="[object File]"||we==="[object Blob]"?ae.post(Se):ae.post(Y)}).catch(function(Se){console.log(Se)}):De!==!1&&setTimeout(function(){return ae.post(Y)},0);return}},{key:"post",value:function(Y){var ee=this;if(!this._isMounted)return;var ae=this.props,de=ae.onStart,De=ae.onProgress,Se=ae.transformFile,we=Se===void 0?function(Ce){return Ce}:Se;new Promise(function(Ce){var Te=ae.action;return typeof Te=="function"&&(Te=Te(Y)),Ce(Te)}).then(function(Ce){var Te=Y.uid,ge=ae.customRequest||z,le=Promise.resolve(we(Y)).then(function(te){var ce=ae.data;return typeof ce=="function"&&(ce=ce(te)),Promise.all([te,ce])}).catch(function(te){console.error(te)});le.then(function(te){var ce=h(te,2),ne=ce[0],Le=ce[1],Oe={action:Ce,filename:ae.name,data:Le,file:ne,headers:ae.headers,withCredentials:ae.withCredentials,method:ae.method||"post",onProgress:De?function(Ee){De(Ee,Y)}:null,onSuccess:function(Re,Ne){delete ee.reqs[Te],ae.onSuccess(Re,Y,Ne)},onError:function(Re,Ne){delete ee.reqs[Te],ae.onError(Re,Ne,Y)}};de(Y),ee.reqs[Te]=ge(Oe)})})}},{key:"reset",value:function(){this.setState({uid:R()})}},{key:"abort",value:function(Y){var ee=this.reqs;if(Y){var ae=Y;Y&&Y.uid&&(ae=Y.uid),ee[ae]&&ee[ae].abort&&ee[ae].abort(),delete ee[ae]}else Object.keys(ee).forEach(function(de){ee[de]&&ee[de].abort&&ee[de].abort(),delete ee[de]})}},{key:"render",value:function(){var Y,ee=this.props,ae=ee.component,de=ee.prefixCls,De=ee.className,Se=ee.disabled,we=ee.id,Ce=ee.style,Te=ee.multiple,ge=ee.accept,le=ee.children,te=ee.directory,ce=ee.openFileDialogOnClick,ne=ee.onMouseEnter,Le=ee.onMouseLeave,Oe=d(ee,["component","prefixCls","className","disabled","id","style","multiple","accept","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"]),Ee=$()((Y={},l(Y,de,!0),l(Y,de+"-disabled",Se),l(Y,De,De),Y)),Re=Se?{}:{onClick:ce?this.onClick:function(){},onKeyDown:ce?this.onKeyDown:function(){},onMouseEnter:ne,onMouseLeave:Le,onDrop:this.onFileDrop,onDragOver:this.onFileDrop,tabIndex:"0"};return Z.a.createElement(ae,T({},Re,{className:Ee,role:"button",style:Ce}),Z.a.createElement("input",T({},k(Oe),{id:we,type:"file",ref:this.saveFileInput,onClick:function(je){return je.stopPropagation()},key:this.state.uid,style:{display:"none"},accept:ge,directory:te?"directory":null,webkitdirectory:te?"webkitdirectory":null,multiple:Te,onChange:this.onChange})),le)}}]),_}(oe.Component),p=E,c=Object.assign||function(V){for(var _=1;_<arguments.length;_++){var I=arguments[_];for(var Y in I)Object.prototype.hasOwnProperty.call(I,Y)&&(V[Y]=I[Y])}return V},u=function(){function V(_,I){for(var Y=0;Y<I.length;Y++){var ee=I[Y];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(_,ee.key,ee)}}return function(_,I,Y){return I&&V(_.prototype,I),Y&&V(_,Y),_}}();function a(V,_){if(!(V instanceof _))throw new TypeError("Cannot call a class as a function")}function b(V,_){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:V}function m(V,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);V.prototype=Object.create(_&&_.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(V,_):V.__proto__=_)}function x(){}var F=function(V){m(_,V);function _(){var I,Y,ee,ae;a(this,_);for(var de=arguments.length,De=Array(de),Se=0;Se<de;Se++)De[Se]=arguments[Se];return ae=(Y=(ee=b(this,(I=_.__proto__||Object.getPrototypeOf(_)).call.apply(I,[this].concat(De))),ee),ee.saveUploader=function(we){ee.uploader=we},Y),b(ee,ae)}return u(_,[{key:"abort",value:function(Y){this.uploader.abort(Y)}},{key:"render",value:function(){return Z.a.createElement(p,c({},this.props,{ref:this.saveUploader}))}}]),_}(oe.Component);F.defaultProps={component:"span",prefixCls:"rc-upload",data:{},headers:{},name:"file",multipart:!1,onStart:x,onError:x,onSuccess:x,multiple:!1,beforeUpload:null,customRequest:null,withCredentials:!1,openFileDialogOnClick:!0};var U=F,K=it.a=U},Gytx:function(xt,it){xt.exports=function(oe,Z,D,$){var B=D?D.call($,oe,Z):void 0;if(B!==void 0)return!!B;if(oe===Z)return!0;if(typeof oe!="object"||!oe||typeof Z!="object"||!Z)return!1;var M=Object.keys(oe),z=Object.keys(Z);if(M.length!==z.length)return!1;for(var W=Object.prototype.hasOwnProperty.bind(Z),P=0;P<M.length;P++){var R=M[P];if(!W(R))return!1;var y=oe[R],A=Z[R];if(B=D?D.call($,y,A,R):void 0,B===!1||B===void 0&&y!==A)return!1}return!0}},HmJG:function(xt,it,se){},LdHM:function(xt,it,se){"use strict";se.d(it,"b",function(){return d}),se.d(it,"a",function(){return v});var oe=se("1OyB"),Z=se("vuIU"),D=se("Ji7U"),$=se("LK+K"),B=se("q1tI"),M=se("rePB"),z=se("Ff2n"),W=se("ODXe"),P=se("4IlW"),R=se("bX4T"),y=se("YrtM"),A=se("TSYQ"),O=se.n(A),L=se("+nKL"),C=se("8OUc"),T=function(Y,ee){var ae=Y.prefixCls,de=Y.id,De=Y.flattenOptions,Se=Y.childrenAsData,we=Y.values,Ce=Y.searchValue,Te=Y.multiple,ge=Y.defaultActiveFirstOption,le=Y.height,te=Y.itemHeight,ce=Y.notFoundContent,ne=Y.open,Le=Y.menuItemSelectedIcon,Oe=Y.virtual,Ee=Y.onSelect,Re=Y.onToggleOpen,Ne=Y.onActiveValue,je=Y.onScroll,Ue=Y.onMouseEnter,Ie="".concat(ae,"-item"),Me=Object(y.a)(function(){return De},[ne,De],function(Ve,xe){return xe[0]&&Ve[1]!==xe[1]}),Ke=B.useRef(null),Ze=function(xe){xe.preventDefault()},$e=function(xe){Ke.current&&Ke.current.scrollTo({index:xe})},Qe=function(xe){for(var ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ye=Me.length,re=0;re<ye;re+=1){var ie=(xe+re*ve+ye)%ye,ue=Me[ie],pe=ue.group,be=ue.data;if(!pe&&!be.disabled)return ie}return-1},lt=B.useState(function(){return Qe(0)}),tt=Object(W.a)(lt,2),rt=tt[0],Pe=tt[1],ht=function(xe){Pe(xe);var ve=Me[xe];if(!ve){Ne(null,-1);return}Ne(ve.data.value,xe)};B.useEffect(function(){ht(ge!==!1?Qe(0):-1)},[Me.length,Ce]),B.useEffect(function(){var Ve=setTimeout(function(){if(!Te&&ne&&we.size===1){var xe=Array.from(we)[0],ve=Me.findIndex(function(ye){var re=ye.data;return re.value===xe});ht(ve),$e(ve)}});return function(){return clearTimeout(Ve)}},[ne]);var at=function(xe){xe!==void 0&&Ee(xe,{selected:!we.has(xe)}),Te||Re(!1)};if(B.useImperativeHandle(ee,function(){return{onKeyDown:function(xe){var ve=xe.which;switch(ve){case P.a.UP:case P.a.DOWN:{var ye=0;if(ve===P.a.UP?ye=-1:ve===P.a.DOWN&&(ye=1),ye!==0){var re=Qe(rt+ye,ye);$e(re),ht(re)}break}case P.a.ENTER:{var ie=Me[rt];ie&&!ie.data.disabled?at(ie.data.value):at(void 0),ne&&xe.preventDefault();break}case P.a.ESC:Re(!1)}},onKeyUp:function(){},scrollTo:function(xe){$e(xe)}}}),Me.length===0)return B.createElement("div",{role:"listbox",id:"".concat(de,"_list"),className:"".concat(Ie,"-empty"),onMouseDown:Ze},ce);function Fe(Ve){var xe=Me[Ve];if(!xe)return null;var ve=xe.data||{},ye=ve.value,re=ve.label,ie=ve.children,ue=Object(R.a)(ve,!0),pe=Se?ie:re;return xe?B.createElement("div",Object.assign({"aria-label":typeof pe=="string"?pe:null},ue,{key:Ve,role:"option",id:"".concat(de,"_list_").concat(Ve),"aria-selected":we.has(ye)}),ye):null}return B.createElement(B.Fragment,null,B.createElement("div",{role:"listbox",id:"".concat(de,"_list"),style:{height:0,width:0,overflow:"hidden"}},Fe(rt-1),Fe(rt),Fe(rt+1)),B.createElement(L.a,{itemKey:"key",ref:Ke,data:Me,height:le,itemHeight:te,fullHeight:!1,onMouseDown:Ze,onScroll:je,virtual:Oe,onMouseEnter:Ue},function(Ve,xe){var ve,ye=Ve.group,re=Ve.groupOption,ie=Ve.data,ue=ie.label,pe=ie.key;if(ye)return B.createElement("div",{className:O()(Ie,"".concat(Ie,"-group"))},ue!==void 0?ue:pe);var be=ie.disabled,_e=ie.value,He=ie.title,nt=ie.children,mt=ie.style,ft=ie.className,wt=Object(z.a)(ie,["disabled","value","title","children","style","className"]),Tt=we.has(_e),ut="".concat(Ie,"-option"),Bt=O()(Ie,ut,ft,(ve={},Object(M.a)(ve,"".concat(ut,"-grouped"),re),Object(M.a)(ve,"".concat(ut,"-active"),rt===xe&&!be),Object(M.a)(ve,"".concat(ut,"-disabled"),be),Object(M.a)(ve,"".concat(ut,"-selected"),Tt),ve)),_t=Se?nt:ue,Zt=!Le||typeof Le=="function"||Tt;return B.createElement("div",Object.assign({},wt,{"aria-selected":Tt,className:Bt,title:He,onMouseMove:function(){if(rt===xe||be)return;ht(xe)},onClick:function(){be||at(_e)},style:mt}),B.createElement("div",{className:"".concat(ut,"-content")},_t||_e),B.isValidElement(Le)||Tt,Zt&&B.createElement(C.a,{className:"".concat(Ie,"-option-state"),customizeIcon:Le,customizeIconProps:{isSelected:Tt}},Tt?"\u2713":null))}))},h=B.forwardRef(T);h.displayName="OptionList";var o=h,l=function(){return null};l.isSelectOption=!0;var d=l,w=function(){return null};w.isSelectOptGroup=!0;var v=w,g=se("VTBJ"),k=se("Zm9Q");function E(I){var Y=I.key,ee=I.props,ae=ee.children,de=ee.value,De=Object(z.a)(ee,["children","value"]);return Object(g.a)({key:Y,value:de!==void 0?de:Y,children:ae},De)}function p(I){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(k.a)(I).map(function(ee,ae){if(!B.isValidElement(ee)||!ee.type)return null;var de=ee.type.isSelectOptGroup,De=ee.key,Se=ee.props,we=Se.children,Ce=Object(z.a)(Se,["children"]);return Y||!de?E(ee):Object(g.a)(Object(g.a)({key:"__RC_SELECT_GRP__".concat(De===null?ae:De,"__"),label:De},Ce),{},{options:p(we)})}).filter(function(ee){return ee})}var c=se("2Qr1"),u=se("qNPg"),a=se("U8pU"),b=se("Kwbf"),m=se("WKfj");function x(I){var Y=I.mode,ee=I.options,ae=I.children,de=I.backfill,De=I.allowClear,Se=I.placeholder,we=I.getInputElement,Ce=I.showSearch,Te=I.onSearch,ge=I.defaultOpen,le=I.autoFocus,te=I.labelInValue,ce=I.value,ne=I.inputValue,Le=I.optionLabelProp,Oe=Y==="multiple"||Y==="tags",Ee=Ce!==void 0?Ce:Oe||Y==="combobox",Re=ee||p(ae);if(Object(b.a)(Y!=="tags"||Re.every(function(Ie){return!Ie.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),Y==="tags"||Y==="combobox"){var Ne=Re.some(function(Ie){return Ie.options?Ie.options.some(function(Me){return typeof("value"in Me?Me.value:Me.key)=="number"}):typeof("value"in Ie?Ie.value:Ie.key)=="number"});Object(b.a)(!Ne,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(Y!=="combobox"||!Le,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(Y==="combobox"||!de,"`backfill` only works with `combobox` mode."),Object(b.a)(Y==="combobox"||!we,"`getInputElement` only work with `combobox` mode."),Object(b.b)(Y!=="combobox"||!we||!De||!Se,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Te&&!Ee&&Y!=="combobox"&&Y!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!ge||le,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),ce!=null){var je=Object(m.d)(ce);Object(b.a)(!te||je.every(function(Ie){return Object(a.a)(Ie)==="object"&&("key"in Ie||"value"in Ie)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Oe||Array.isArray(ce),"`value` should be array when `mode` is `multiple` or `tags`")}if(ae){var Ue=null;Object(k.a)(ae).some(function(Ie){if(!B.isValidElement(Ie)||!Ie.type)return!1;var Me=Ie.type;if(Me.isSelectOption)return!1;if(Me.isSelectOptGroup){var Ke=Object(k.a)(Ie.props.children).every(function(Ze){return!B.isValidElement(Ze)||!Ie.type||Ze.type.isSelectOption?!0:(Ue=Ze.type,!1)});return!Ke}return Ue=Me,!0}),Ue&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Ue.displayName||Ue.name||Ue,"`.")),Object(b.a)(ne===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var F=x,U=Object(u.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:p,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:F,fillOptionsWithMissingValue:c.a}),K=function(I){Object(D.a)(ee,I);var Y=Object($.a)(ee);function ee(){var ae;return Object(oe.a)(this,ee),ae=Y.apply(this,arguments),ae.selectRef=B.createRef(),ae.focus=function(){ae.selectRef.current.focus()},ae.blur=function(){ae.selectRef.current.blur()},ae}return Object(Z.a)(ee,[{key:"render",value:function(){return B.createElement(U,Object.assign({ref:this.selectRef},this.props))}}]),ee}(B.Component);K.Option=d,K.OptGroup=v;var V=K,_=it.c=V},M8RZ:function(xt,it,se){"use strict";se.d(it,"a",function(){return P});var oe=se("fWQN"),Z=se("mtLc"),D=se("yKVA"),$=se("879j"),B=se("q1tI"),M=se.n(B),z=se("i8i4"),W=se.n(z),P=function(R){Object(D.a)(A,R);var y=Object($.a)(A);function A(O){var L;Object(oe.a)(this,A),L=y.call(this,O);var C=window.document;return L.node=C.createElement("div"),C.body.appendChild(L.node),L}return Object(Z.a)(A,[{key:"render",value:function(){var L=this.props.children;return Object(z.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),A}(M.a.Component)},OLES:function(xt,it,se){"use strict";var oe=se("U8pU"),Z=se("VTBJ"),D=se("Ff2n"),$=se("q1tI"),B=se("uciX"),M=se("7ixt"),z=function(O){var L=O.overlay,C=O.prefixCls,T=O.id,h=O.overlayInnerStyle;return $.createElement("div",{className:"".concat(C,"-inner"),id:T,role:"tooltip",style:h},typeof L=="function"?L():L)},W=z,P=function(O,L){var C=O.overlayClassName,T=O.trigger,h=T===void 0?["hover"]:T,o=O.mouseEnterDelay,l=o===void 0?0:o,d=O.mouseLeaveDelay,w=d===void 0?.1:d,v=O.overlayStyle,g=O.prefixCls,k=g===void 0?"rc-tooltip":g,E=O.children,p=O.onVisibleChange,c=O.afterVisibleChange,u=O.transitionName,a=O.animation,b=O.placement,m=b===void 0?"right":b,x=O.align,F=x===void 0?{}:x,U=O.destroyTooltipOnHide,K=U===void 0?!1:U,V=O.defaultVisible,_=O.getTooltipContainer,I=O.overlayInnerStyle,Y=Object(D.a)(O,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ee=Object($.useRef)(null);Object($.useImperativeHandle)(L,function(){return ee.current});var ae=Object(Z.a)({},Y);"visible"in O&&(ae.popupVisible=O.visible);var de=function(){var Te=O.arrowContent,ge=Te===void 0?null:Te,le=O.overlay,te=O.id;return[$.createElement("div",{className:"".concat(k,"-arrow"),key:"arrow"},ge),$.createElement(W,{key:"content",prefixCls:k,id:te,overlay:le,overlayInnerStyle:I})]},De=!1,Se=!1;if(typeof K=="boolean")De=K;else if(K&&Object(oe.a)(K)==="object"){var we=K.keepParent;De=we===!0,Se=we===!1}return $.createElement(B.a,Object.assign({popupClassName:C,prefixCls:k,popup:de,action:h,builtinPlacements:M.a,popupPlacement:m,ref:ee,popupAlign:F,getPopupContainer:_,onPopupVisibleChange:p,afterPopupVisibleChange:c,popupTransitionName:u,popupAnimation:a,defaultPopupVisible:V,destroyPopupOnHide:De,autoDestroy:Se,mouseLeaveDelay:w,popupStyle:v,mouseEnterDelay:l},ae),E)},R=Object($.forwardRef)(P),y=it.a=R},Ot1p:function(xt,it,se){"use strict";var oe=se("2qtc"),Z=se("kLXV"),D=se("rAM+"),$=se("miYZ"),B=se("tsqr"),M=se("9og8"),z=se("tJVT"),W=se("jrin"),P=se("WmNS"),R=se.n(P),y=se("q1tI"),A=se.n(y),O=se("VrN/"),L=se.n(O),C=se("bdgK"),T=se("p77/"),h=se("Bd2K"),o=se("ELLl"),l=se("19Vz"),d=se("lZu9"),w=se("+NIl"),v=se("kSUc"),g=se("9Bee"),k=function(be){var _e=be.value,He=_e===void 0?"":_e,nt=be.className,mt=be.showTextOnly,ft=be.showLines,wt=be.style,Tt=wt===void 0?{}:wt,ut=Object(y.useMemo)(function(){return""},[He]);return A.a.createElement(A.a.Fragment,null,A.a.createElement("div",{dangerouslySetInnerHTML:{__html:ut}}))},E=se("0Owb"),p=se("dejd"),c=se("C+DQ"),u=se("1vsH"),a=se("m3rI"),b=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function m(be){var _e=be.onActionCallback,He=be.title,nt=be.icon,mt=be.actionName,ft=be.className,wt=ft===void 0?"":ft,Tt=be.children;function ut(){_e(mt)}return A.a.createElement("a",{title:He,className:wt,onClick:ut},A.a.createElement("i",{className:"md-iconfont ".concat(nt)}),Tt)}var x=function(be){var _e=be.watch,He=be.showNullButton,nt=be.onActionCallback,mt=be.fullScreen,ft=be.insertTemp,wt=be.hidetoolBar,Tt=be.uuid,ut=be.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(u.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(u.F)("_educoder_session"),"&key=").concat(Tt,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Bt=[].concat(b,[{title:"".concat(_e?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(_e?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return A.a.createElement("ul",{className:"markdown-toolbar-container"},!wt&&Bt.map(function(_t,Zt){return A.a.createElement("li",{key:Zt},_t.actionName?A.a.createElement(m,Object(E.a)({},_t,{onActionCallback:nt})):A.a.createElement("span",{className:"v-line"}))}),He?A.a.createElement("li",null,A.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:nt},A.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,ft&&A.a.createElement("li",null,A.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(ft),onActionCallback:nt},A.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),A.a.createElement("li",{className:"btn-full-screen"},A.a.createElement(m,{icon:"".concat(mt?"icon-shrink":"icon-enlarge"),title:mt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:nt})))},F=se("M8RZ"),U=se("+L6B"),K=se("2/Rp"),V=se("y8nQ"),_=se("Vl3Y"),I=se("5NDa"),Y=se("5rEg"),ee={labelCol:{span:4},wrapperCol:{span:20}},ae=function(be){var _e=be.callback,He=be.onCancel;function nt(mt){_e(mt)}return A.a.createElement(_.a,Object(E.a)({},ee,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:nt}),A.a.createElement(_.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},A.a.createElement(Y.a,null)),A.a.createElement(_.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},A.a.createElement(Y.a,null)),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(K.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))},de=se("7ahc"),De=se("HmJG"),Se=se("BjJ7"),we=_.a.useForm,Ce={width:280,marginRight:10},Te={labelCol:{span:5},wrapperCol:{span:19}},ge=function(be){var _e=be.callback,He=be.onCancel,nt=we(),mt=Object(z.a)(nt,1),ft=mt[0];function wt(Bt){_e(Bt)}function Tt(Bt,_t){if(Bt.status===-1){B.b.error(Bt.message);return}ft.setFieldsValue({src:"/api/attachments/".concat(Bt.id),type:_t.type})}function ut(Bt){var _t=Bt.target.files[0];te(_t,Tt)}return A.a.createElement(_.a,Object(E.a)({form:ft},Te,{className:"upload-image-panel",onFinish:wt}),A.a.createElement(_.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},A.a.createElement("div",{className:"flex-container"},A.a.createElement(_.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},A.a.createElement(Y.a,{style:Ce})),A.a.createElement(le,{onFileChange:ut}))),A.a.createElement(_.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},A.a.createElement(Y.a,{style:{width:264}})),A.a.createElement(_.a.Item,{style:{textAlign:"right"}},A.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(K.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))};function le(be){var _e=be.onFileChange;return A.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",A.a.createElement("input",{type:"file",onChange:_e}))}function te(be,_e){if(!be)throw new String("\u6CA1\u6709\u6587\u4EF6");var He=new FormData;He.append("editormd-image-file",be),He.append("file_param_name","editormd-image-file"),He.append("byxhr","true");var nt=new window.XMLHttpRequest;nt.withCredentials=!0,nt.addEventListener("load",function(mt){_e(JSON.parse(mt.target.responseText),be)},!1),nt.addEventListener("error",function(mt){console.error(mt)},!1),nt.open("POST","".concat(Se.a,"/api/attachments.json")),nt.send(He)}var ce=se("giR+"),ne=se("fyUT"),Le=se("7Kak"),Oe=se("9yH6"),Ee=Oe.a.Group,Re={margin:"0 8px"},Ne=function(be){var _e=be.callback,He=be.onCancel;function nt(mt){_e(mt)}return A.a.createElement(_.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:nt},A.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},A.a.createElement("span",{style:Re},"\u5355\u5143\u683C\u6570\uFF1A"),A.a.createElement("span",{style:Re},"\u884C\u6570"),A.a.createElement(_.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},A.a.createElement(ne.a,null)),A.a.createElement("span",{style:Re},"\u5217\u6570"),A.a.createElement(_.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},A.a.createElement(ne.a,null))),A.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},A.a.createElement("span",{style:Re},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),A.a.createElement(_.a.Item,{name:"align"},A.a.createElement(Ee,null,A.a.createElement(Oe.a,{value:"default"},A.a.createElement("i",{className:"fa fa-align-justify"})),A.a.createElement(Oe.a,{value:"left"},A.a.createElement("i",{className:"fa fa-align-left"})),A.a.createElement(Oe.a,{value:"center"},A.a.createElement("i",{className:"fa fa-align-center"})),A.a.createElement(Oe.a,{value:"right"},A.a.createElement("i",{className:"fa fa-align-right"}))))),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(K.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))},je=se("ErOA"),Ue=se("7Cbv"),Ie="link",Me="upload-image",Ke="code-block",Ze="add-table",$e="------------",Qe={default:$e,left:":".concat($e),center:":".concat($e,":"),right:"".concat($e,":")},lt=se("9VGf"),tt,rt;function Pe(){}var ht=0,at=1e4,Fe="\u2581",Ve=`
**\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 xe(be){return/^\d+$/.test(be)?"".concat(be,"px"):be}var ve=navigator.platform.toUpperCase().indexOf("MAC")>=0,ye=ve?"Cmd":"Ctrl",re=["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=(tt={},Object(W.a)(tt,ye+"-B","bold"),Object(W.a)(tt,ye+"-I","italic"),tt),ue=(rt={},Object(W.a)(rt,Ie,"\u6DFB\u52A0\u94FE\u63A5"),Object(W.a)(rt,Ke,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(W.a)(rt,Me,"\u6DFB\u52A0\u6587\u4EF6"),Object(W.a)(rt,Ze,"\u6DFB\u52A0\u8868\u683C"),rt),pe=it.a=function(be){var _e=be.defaultValue,He=_e===void 0?"":_e,nt=be.onChange,mt=be.width,ft=mt===void 0?"100%":mt,wt=be.height,Tt=wt===void 0?400:wt,ut=be.miniToolbar,Bt=ut===void 0?!1:ut,_t=be.isFocus,Zt=_t===void 0?!1:_t,Xt=be.watch,Ot=be.insertTemp,Ir=be.mode,Kr=Ir===void 0?"markdown":Ir,bt=be.id,Nr=bt===void 0?"markdown-editor-id":bt,hr=be.showResizeBar,pr=hr===void 0?!1:hr,Fr=be.noStorage,ci=Fr===void 0?!1:Fr,qr=be.showNullButton,It=qr===void 0?!1:qr,dt=be.hidetoolBar,Hr=dt===void 0?!1:dt,ei=be.fullScreen,mr=ei===void 0?!1:ei,kt=be.onBlur,Br=be.onCMBeforeChange,Vr=be.onFullScreen,fi=be.className,Xe=fi===void 0?"":fi,St=be.disablePaste,pi=St===void 0?!1:St,mi=be.placeholder,gi=mi===void 0?"":mi,vi=be.values,G=vi===void 0?"":vi,s=Object(y.useState)(null),f=Object(z.a)(s,2),N=f[0],Q=f[1],H=Object(y.useState)(He),me=Object(z.a)(H,2),We=me[0],Je=me[1],ct=Object(y.useState)(Xt),Ge=Object(z.a)(ct,2),vt=Ge[0],Nt=Ge[1],Kt=Object(y.useState)(mr),Or=Object(z.a)(Kt,2),gr=Or[0],vr=Or[1],Xr=Object(y.useState)(""),Oi=Object(z.a)(Xr,2),nr=Oi[0],Ur=Oi[1],oi=Object(y.useState)(0),si=Object(z.a)(oi,2),_r=si[0],_i=si[1],yi=Object(y.useState)(Tt),zi=Object(z.a)(yi,2),Ki=zi[0],Yr=zi[1],Gr=Object(y.useState)(!1),bi=Object(z.a)(Gr,2),dn=bi[0],xi=bi[1],Jt=Object(y.useRef)(Object(Ue.a)()),Ft=Object(y.useRef)(!1),dr=Object(y.useRef)(),Dt=Object(y.useRef)(),qt=Object(y.useRef)(),Wt=Object(y.useRef)(),ti=Object(y.useRef)(),ar=function(){var pt=Object(M.a)(R.a.mark(function Ct(){var yt,Lt;return R.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return Gt.next=2,Object(je.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:Lt=Gt.sent,Lt!=null&&(yt=Lt.attachments)!==null&&yt!==void 0&&yt.length&&(console.log("cm:",N,Dt),Lt.attachments.map(function(Pt){Pt.content_type.indexOf("image")>-1?N.replaceSelection("![,](/api/attachments/".concat(Pt.id,"?type=").concat(Pt.content_type,")")):Pt.content_type.indexOf("video")>-1?N.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Pt.content_type.indexOf("pdf")>-1?N.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,'&disposition=inline" target="_blank">').concat(Pt.name,"</a>")):N.replaceSelection("[".concat(Pt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,")"))}));case 4:case"end":return Gt.stop()}},Ct)}));return function(){return pt.apply(this,arguments)}}();Object(y.useEffect)(function(){Je(G),N==null||N.setValue(G)},[G]),Object(y.useEffect)(function(){Vr==null||Vr(gr)},[gr]),Object(y.useEffect)(function(){if(Dt.current){var pt=L.a.fromTextArea(Dt.current,{mode:Kr,lineNumbers:!Bt,lineWrapping:!0,value:He,autoCloseTags:!0,autoCloseBrackets:!0});Zt&&pt.focus();function Ct(yt,Lt){if(pi){Lt.preventDefault();return}var Mt=Lt.clipboardData;if(Mt){var Gt=Mt.types.toString(),Pt=Mt.items;if(Gt==="Files"||Mt.types.indexOf("Files")>-1){if(Lt.preventDefault(),Kr=="stex")return;try{var rr,Cr=Pt[1];((rr=Pt[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(Cr=Pt[0]);var Rt=Cr.getAsFile(),li=Rt.name.split(".").pop();te(Rt,function(Ut){if(Ut.id){var wr,yr,zr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?pt.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?pt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?pt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):re.includes(li)?pt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):pt.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})}catch(Ut){B.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return pt.on("paste",Ct),pt.on("dragleave",function(yt,Lt){qt.current.classList.remove("mouse-hover-md")}),pt.on("dragover",function(yt,Lt){qt.current.classList.add("mouse-hover-md")}),pt.on("drop",function(yt,Lt){qt.current.classList.add("mouse-hover-md");var Mt;if(Mt=Lt.dataTransfer.files,Mt.length>0){Lt.preventDefault(),Lt.stopPropagation();for(var Gt=function(Cr){var Rt=Mt[Cr],li=Rt.name.split(".").pop();te(Rt,function(Ut){if(Ut.id){var wr,yr,zr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?pt.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?pt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?pt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):re.includes(li)?pt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):pt.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})},Pt=0;Pt<Mt.length;Pt++)Gt(Pt)}}),Q(pt),function(){pt.off("paste",Ct)}}},[]);var Er=Object(y.useCallback)(function(){if(qt.current)try{}catch(pt){console.log(pt,"---- to set md editor body height")}},[Ki,qt,gr]);Object(y.useEffect)(function(){function pt(){var yt=new C.default(function(Lt){var Mt=Object(D.a)(Lt),Gt;try{for(Mt.s();!(Gt=Mt.n()).done;){var Pt=Gt.value;(Pt.target.offsetHeight>0||Pt.target.offsetWidth>0)&&(Er(),N.setSize("100%","100%"),N.refresh())}}catch(rr){Mt.e(rr)}finally{Mt.f()}});return yt.observe(Dt.current.parentElement),yt}if(N){var Ct=pt();return function(){Ct.unobserve(Dt.current.parentElement)}}},[N,Er]),Object(y.useEffect)(function(){if(N){for(var pt=[],Ct=function(){var Pt=Lt[yt];Mt=Object(z.a)(Pt,2);var rr=Mt[0],Cr=Mt[1],Rt=Object(W.a)({},rr,function(){Vi(Cr)});pt.push(Rt),N.addKeyMap(Rt)},yt=0,Lt=Object.entries(ie);yt<Lt.length;yt++){var Mt;Ct()}return dr.current=setInterval(function(){Ft.current&&ar()},4e3),function(){clearInterval(dr.current);var Gt=Object(D.a)(pt),Pt;try{for(Gt.s();!(Pt=Gt.n()).done;){var rr=Pt.value;N.removeKeyMap(rr)}}catch(Cr){Gt.e(Cr)}finally{Gt.f()}}}},[N]),Object(y.useEffect)(function(){mr!==gr&&vr(mr)},[mr]),Object(lt.a)(function(){if(!ci&&_r>0){var pt=new Date().getTime(),Ct=window.sessionStorage.getItem(Nr);pt>=_r+at&&(!Ct||Ct!==We)&&(window.sessionStorage.setItem(Nr,We),xi(!0))}},at),Object(y.useEffect)(function(){Nt(Xt)},[N,Xt]),Object(y.useEffect)(function(){N&&(Zt&&N.focus())},[N,Zt]),Object(y.useEffect)(function(){if(vt&&N){var pt=N.getScrollerElement();function Ct(yt){var Lt=yt.target;if(ti.current){var Mt=Lt.scrollTop/Lt.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Mt}}return pt.addEventListener("scroll",Ct),function(){pt.removeEventListener("scroll",Ct)}}},[N,vt]),Object(y.useEffect)(function(){if(N&&Br){function pt(Ct,yt){Br(Ct,yt)}return N.on("beforeChange",pt),function(){N.off("beforeChange",pt)}}},[N,Br]),Object(y.useEffect)(function(){if(N&&kt){function pt(){kt(N.getValue())}return N.on("blur",pt),function(){N.off("blur",pt)}}},[N,kt]),Object(y.useEffect)(function(){if(N){function pt(Ct){var yt=Ct.getValue();Je(yt),_i(new Date().getTime()),Ct.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),nt&&nt(yt)}return N.on("change",pt),function(){N.off("change",pt)}}},[N,nt]),Object(y.useEffect)(function(){N&&(He==null?(N.setValue(""),Je("")):He!==N.getValue()&&(N.setValue(He),Je(He),N.setCursor(N.lineCount(),0)))},[N,He]);var Vi=Object(y.useCallback)(function(pt){var Ct=N.getCursor(),yt=N.getSelection(),Lt=yt.split(`
`);switch(pt){case"bold":return N.replaceSelection("**"+yt+"**"),yt===""&&N.setCursor(Ct.line,Ct.ch+2),N.focus();case"italic":return N.replaceSelection("*"+yt+"*"),yt===""&&N.setCursor(Ct.line,Ct.ch+1),N.focus();case"code":return N.replaceSelection("`"+yt+"`"),yt===""&&N.setCursor(Ct.line,Ct.ch+1),N.focus();case"inline-latex":return N.replaceSelection("`$$"+yt+"$$`"),yt===""&&N.setCursor(Ct.line,Ct.ch+3),N.focus();case"latex":return N.replaceSelection("```latex\n"+yt+"\n```"),N.setCursor(Ct.line+1,yt.length+1),N.focus();case"line-break":return N.replaceSelection(`<br/>
`),N.focus();case"list-ul":return yt===""?N.replaceSelection("- "+yt):N.replaceSelection(Lt.map(function(Mt){return Mt===""?"":"- ".concat(Mt)}).join(`
`)),N.focus();case"list-ol":return yt===""?N.replaceSelection("1. "+yt):N.replaceSelection(Lt.map(function(Mt,Gt){return Mt===""?"":"".concat(Gt+1,". ").concat(Mt)}).join(`
`)),N.focus();case"add-null-ch":return yt===""&&N.setCursor(Ct.line,Ct.ch+1),N.replaceSelection(Fe),N.focus();case"inster-template-1":return yt===""&&N.setCursor(Ct.line,Ct.ch),N.replaceSelection(Ve),N.focus();case"eraser":return N.setValue(""),N.focus();case"trigger-watch":return Nt(!vt),N.focus();case"trigger-full-screen":return vr(!gr),N.focus();case Ie:Ur(Ie);return;case Ke:Ur(Ke);return;case Me:Ur(Me);return;case Ze:Ur(Ze);return;default:throw new Error}},[N,vt,gr]),Ei=Object(y.useCallback)(function(pt){Ur("");switch(nr){case Ie:var Ct=pt.title,yt=pt.link;return N.replaceSelection("[".concat(Ct,"](").concat(yt,")")),N.focus();case Ke:var Lt=pt.language,Mt=pt.content;return N.replaceSelection(["```"+Lt,Mt,"```"].join(`
`)),N.focus();case Me:var Gt=pt.src,Pt=pt.alt;return Pt?N.replaceSelection("![ ".concat(Pt," ]( ").concat(Gt,' "').concat(Pt,'" )')):N.replaceSelection("![,](".concat(Gt,")")),N.focus();case Ze:for(var rr=pt.row,Cr=pt.col,Rt=pt.align,li=`
`,Ut=0;Ut<rr;Ut++){for(var wr=[],yr=[],zr=0;zr<Cr;zr++)Ut===1&&yr.push(Qe[Rt]),wr.push(" ");Ut===1&&(li+="| ".concat(yr.join(" | "),` |
`)),li+="| ".concat(wr.join(Cr===1?"":" | "),` |
`)}return N.replaceSelection(li+`
`),N.focus();default:throw new Error}},[N,nr]),cn=Object(y.useMemo)(function(){switch(nr){case Ie:return A.a.createElement(ae,{callback:Ei,onCancel:Si});case Ke:return A.a.createElement(de.b,{callback:Ei,onCancel:Si});case Me:return A.a.createElement(ge,{callback:Ei,onCancel:Si});case Ze:return A.a.createElement(Ne,{callback:Ei,onCancel:Si});default:return null}},[nr]);function Si(){Ur("")}Object(y.useEffect)(function(){if(Wt.current){var pt=Wt.current,Ct=!1,yt=0;function Lt(Pt){Ct=!0,yt=Pt.pageY}function Mt(){Ct=!1}function Gt(Pt){if(Ct){var rr=Pt.pageY-yt;rr<0&&(rr=0),rr>300&&(rr=300);var Cr=Tt+rr+"px";Yr(Cr)}}return pt.addEventListener("mousedown",Lt),document.addEventListener("mousemove",Gt),document.addEventListener("mouseup",Mt),function(){pt.removeEventListener("mousedown",Lt),document.removeEventListener("mousemove",Gt),document.removeEventListener("mouseup",Mt)}}},[N,Wt]),Object(y.useEffect)(function(){Yr(Tt)},[Tt]);var ri=xe(ft),fn=xe(Ki),$r={width:ri,height:fn},pn=Object(y.useMemo)(function(){if(_r){var pt=new Date(_r),Ct=pt.getHours(),yt=pt.getMinutes(),Lt=pt.getSeconds();return Ct=Ct<10?"0"+Ct:Ct,yt=yt<10?"0"+yt:yt,Lt=Lt<10?"0"+Lt:Lt,"".concat(Ct,":").concat(yt,":").concat(Lt)}return 0},[_r]);function jn(){window.sessionStorage.removeItem(Nr),xi(!1),_i(0)}function Pi(){xi(!1),_i(0),N.setValue(window.sessionStorage.getItem(Nr))}function ua(pt,Ct){var yt=N.getValue();yt=yt.replace(pt,Ct),Je(yt),N==null||N.setValue(yt)}return A.a.createElement(y.Fragment,null,A.a.createElement("div",{className:"markdown-editor-wrapper",ref:qt},A.a.createElement("div",{className:"markdown-editor-container ".concat(Xe," ").concat(vt?"on-preview":""," ").concat(Bt?"mini":""," ").concat(gr?"full-screen":""),style:$r},A.a.createElement(x,{insertTemp:Ot,watch:vt,fullScreen:gr,showNullButton:It,onActionCallback:Vi,hidetoolBar:Hr,uuid:Jt.current,setOpenPhones:function(){Ft.current=!0}}),A.a.createElement("div",{className:"markdown-editor-body"},A.a.createElement("div",{className:"codemirror-container"},A.a.createElement("textarea",{ref:Dt,placeholder:gi})),vt?A.a.createElement("div",{ref:ti,className:"preview-container"},Kr==="stex"&&A.a.createElement(k,{value:We}),Kr!=="stex"&&A.a.createElement(g.a,{edit:!0,value:We,replaces:ua})):null))),pr?A.a.createElement("a",{ref:Wt,className:"editor-resize"}):null,A.a.createElement(F.a,null,ue[nr]?A.a.createElement(Z.a,{centered:!0,title:ue[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(xt,it){/**
* @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 se,oe,Z,D=!1,$,B;window.PR_SHOULD_USE_CONTINUATION=!0;var M,z;(function(){var W=window,P=["break,continue,do,else,for,if,return,while"],R=[P,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],y=[R,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],A=[y,"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"],O=[y,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[y,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],C="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",T=[y,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],d=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],w=[A,L,O,T,h,o,l,d],v=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,g="str",k="kwd",E="com",p="typ",c="lit",u="pun",a="pln",b="tag",m="dec",x="src",F="atn",U="atv",K="nocode",V="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function _(Ee){for(var Re=0,Ne=!1,je=!1,Ue=0,Ie=Ee.length;Ue<Ie;++Ue){var Me=Ee[Ue];if(Me.ignoreCase)je=!0;else if(/[a-z]/i.test(Me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Ne=!0,je=!1;break}}var Ke={b:8,t:9,n:10,v:11,f:12,r:13};function Ze(rt){var Pe=rt.charCodeAt(0);if(Pe!==92)return Pe;var ht=rt.charAt(1);return Pe=Ke[ht],Pe||("0"<=ht&&ht<="7"?parseInt(rt.substring(1),8):ht==="u"||ht==="x"?parseInt(rt.substring(2),16):rt.charCodeAt(1))}function $e(rt){if(rt<32)return(rt<16?"\\x0":"\\x")+rt.toString(16);var Pe=String.fromCharCode(rt);return Pe==="\\"||Pe==="-"||Pe==="]"||Pe==="^"?"\\"+Pe:Pe}function Qe(rt){var Pe=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")),ht=[],at=Pe[0]==="^",Fe=["["];at&&Fe.push("^");for(var Ve=at?1:0,xe=Pe.length;Ve<xe;++Ve){var ve=Pe[Ve];if(/\\[bdsw]/i.test(ve))Fe.push(ve);else{var ye=Ze(ve),re;Ve+2<xe&&Pe[Ve+1]==="-"?(re=Ze(Pe[Ve+2]),Ve+=2):re=ye,ht.push([ye,re]),re<65||ye>122||(re<65||ye>90||ht.push([Math.max(65,ye)|32,Math.min(re,90)|32]),re<97||ye>122||ht.push([Math.max(97,ye)&~32,Math.min(re,122)&~32]))}}ht.sort(function(be,_e){return be[0]-_e[0]||_e[1]-be[1]});for(var ie=[],ue=[],Ve=0;Ve<ht.length;++Ve){var pe=ht[Ve];pe[0]<=ue[1]+1?ue[1]=Math.max(ue[1],pe[1]):ie.push(ue=pe)}for(var Ve=0;Ve<ie.length;++Ve){var pe=ie[Ve];Fe.push($e(pe[0])),pe[1]>pe[0]&&(pe[1]+1>pe[0]&&Fe.push("-"),Fe.push($e(pe[1])))}return Fe.push("]"),Fe.join("")}function lt(rt){for(var Pe=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")),ht=Pe.length,at=[],Fe=0,Ve=0;Fe<ht;++Fe){var xe=Pe[Fe];if(xe==="(")++Ve;else if(xe.charAt(0)==="\\"){var ve=+xe.substring(1);ve&&(ve<=Ve?at[ve]=-1:Pe[Fe]=$e(ve))}}for(var Fe=1;Fe<at.length;++Fe)at[Fe]===-1&&(at[Fe]=++Re);for(var Fe=0,Ve=0;Fe<ht;++Fe){var xe=Pe[Fe];if(xe==="(")++Ve,at[Ve]||(Pe[Fe]="(?:");else if(xe.charAt(0)==="\\"){var ve=+xe.substring(1);ve&&ve<=Ve&&(Pe[Fe]="\\"+at[ve])}}for(var Fe=0;Fe<ht;++Fe)Pe[Fe]==="^"&&Pe[Fe+1]!=="^"&&(Pe[Fe]="");if(rt.ignoreCase&&Ne)for(var Fe=0;Fe<ht;++Fe){var xe=Pe[Fe],ye=xe.charAt(0);xe.length>=2&&ye==="["?Pe[Fe]=Qe(xe):ye!=="\\"&&(Pe[Fe]=xe.replace(/[a-zA-Z]/g,function(ue){var pe=ue.charCodeAt(0);return"["+String.fromCharCode(pe&~32,pe|32)+"]"}))}return Pe.join("")}for(var tt=[],Ue=0,Ie=Ee.length;Ue<Ie;++Ue){var Me=Ee[Ue];if(Me.global||Me.multiline)throw new Error(""+Me);tt.push("(?:"+lt(Me)+")")}return new RegExp(tt.join("|"),je?"gi":"g")}function I(Ee,Re){var Ne=/(?:^|\s)nocode(?:\s|$)/,je=[],Ue=0,Ie=[],Me=0;function Ke(Ze){var $e=Ze.nodeType;if($e==1){if(Ne.test(Ze.className))return;for(var Qe=Ze.firstChild;Qe;Qe=Qe.nextSibling)Ke(Qe);var lt=Ze.nodeName.toLowerCase();(lt==="br"||lt==="li")&&(je[Me]=`
`,Ie[Me<<1]=Ue++,Ie[Me++<<1|1]=Ze)}else if($e==3||$e==4){var tt=Ze.nodeValue;tt.length&&(Re?tt=tt.replace(/\r\n?/g,`
`):tt=tt.replace(/[ \t\r\n]+/g," "),je[Me]=tt,Ie[Me<<1]=Ue,Ue+=tt.length,Ie[Me++<<1|1]=Ze)}}return Ke(Ee),{sourceCode:je.join("").replace(/\n$/,""),spans:Ie}}function Y(Ee,Re,Ne,je,Ue){if(!Ne)return;var Ie={sourceNode:Ee,pre:1,langExtension:null,numberLines:null,sourceCode:Ne,spans:null,basePos:Re,decorations:null};je(Ie),Ue.push.apply(Ue,Ie.decorations)}var ee=/\S/;function ae(Ee){for(var Re=void 0,Ne=Ee.firstChild;Ne;Ne=Ne.nextSibling){var je=Ne.nodeType;Re=je===1?Re?Ee:Ne:je===3&&ee.test(Ne.nodeValue)?Ee:Re}return Re===Ee?void 0:Re}function de(Ee,Re){var Ne={},je;(function(){for(var Me=Ee.concat(Re),Ke=[],Ze={},$e=0,Qe=Me.length;$e<Qe;++$e){var lt=Me[$e],tt=lt[3];if(tt)for(var rt=tt.length;--rt>=0;)Ne[tt.charAt(rt)]=lt;var Pe=lt[1],ht=""+Pe;Ze.hasOwnProperty(ht)||(Ke.push(Pe),Ze[ht]=null)}Ke.push(/[\0-\uffff]/),je=_(Ke)})();var Ue=Re.length,Ie=function(Me){for(var Ke=Me.sourceCode,Ze=Me.basePos,$e=Me.sourceNode,Qe=[Ze,a],lt=0,tt=Ke.match(je)||[],rt={},Pe=0,ht=tt.length;Pe<ht;++Pe){var at=tt[Pe],Fe=rt[at],Ve=void 0,xe;if(typeof Fe=="string")xe=!1;else{var ve=Ne[at.charAt(0)];if(ve)Ve=at.match(ve[1]),Fe=ve[0];else{for(var ye=0;ye<Ue;++ye)if(ve=Re[ye],Ve=at.match(ve[1]),Ve){Fe=ve[0];break}Ve||(Fe=a)}xe=Fe.length>=5&&Fe.substring(0,5)==="lang-",xe&&!(Ve&&typeof Ve[1]=="string")&&(xe=!1,Fe=x),xe||(rt[at]=Fe)}var re=lt;if(lt+=at.length,!xe)Qe.push(Ze+re,Fe);else{var ie=Ve[1],ue=at.indexOf(ie),pe=ue+ie.length;Ve[2]&&(pe=at.length-Ve[2].length,ue=pe-ie.length);var be=Fe.substring(5);Y($e,Ze+re,at.substring(0,ue),Ie,Qe),Y($e,Ze+re+ue,ie,le(be,ie),Qe),Y($e,Ze+re+pe,at.substring(pe),Ie,Qe)}}Me.decorations=Qe};return Ie}function De(Ee){var Re=[],Ne=[];Ee.tripleQuotedStrings?Re.push([g,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Ee.multiLineStrings?Re.push([g,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Re.push([g,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Ee.verbatimStrings&&Ne.push([g,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var je=Ee.hashComments;je&&(Ee.cStyleComments?(je>1?Re.push([E,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Re.push([E,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Ne.push([g,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Re.push([E,/^#[^\r\n]*/,null,"#"])),Ee.cStyleComments&&(Ne.push([E,/^\/\/[^\r\n]*/,null]),Ne.push([E,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ue=Ee.regexLiterals;if(Ue){var Ie=Ue>1?"":`
\r`,Me=Ie?".":"[\\S\\s]",Ke="/(?=[^/*"+Ie+"])(?:[^/\\x5B\\x5C"+Ie+"]|\\x5C"+Me+"|\\x5B(?:[^\\x5C\\x5D"+Ie+"]|\\x5C"+Me+")*(?:\\x5D|$))+/";Ne.push(["lang-regex",RegExp("^"+V+"("+Ke+")")])}var Ze=Ee.types;Ze&&Ne.push([p,Ze]);var $e=(""+Ee.keywords).replace(/^ | $/g,"");$e.length&&Ne.push([k,new RegExp("^(?:"+$e.replace(/[\s,]+/g,"|")+")\\b"),null]),Re.push([a,/^\s+/,null,` \r
\xA0`]);var Qe="^.[^\\s\\w.$@'\"`/\\\\]*";return Ee.regexLiterals&&(Qe+="(?!s*/)"),Ne.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[p,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[u,new RegExp(Qe),null]),de(Re,Ne)}var Se=De({keywords:w,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function we(Ee,Re,Ne){for(var je=/(?:^|\s)nocode(?:\s|$)/,Ue=/\r\n?|\n/,Ie=Ee.ownerDocument,Me=Ie.createElement("li");Ee.firstChild;)Me.appendChild(Ee.firstChild);var Ke=[Me];function Ze(Pe){var ht=Pe.nodeType;if(ht==1&&!je.test(Pe.className))if(Pe.nodeName==="br")$e(Pe),Pe.parentNode&&Pe.parentNode.removeChild(Pe);else for(var at=Pe.firstChild;at;at=at.nextSibling)Ze(at);else if((ht==3||ht==4)&&Ne){var Fe=Pe.nodeValue,Ve=Fe.match(Ue);if(Ve){var xe=Fe.substring(0,Ve.index);Pe.nodeValue=xe;var ve=Fe.substring(Ve.index+Ve[0].length);if(ve){var ye=Pe.parentNode;ye.insertBefore(Ie.createTextNode(ve),Pe.nextSibling)}$e(Pe),xe||Pe.parentNode.removeChild(Pe)}}}function $e(Pe){for(;!Pe.nextSibling;)if(Pe=Pe.parentNode,!Pe)return;function ht(Ve,xe){var ve=xe?Ve.cloneNode(!1):Ve,ye=Ve.parentNode;if(ye){var re=ht(ye,1),ie=Ve.nextSibling;re.appendChild(ve);for(var ue=ie;ue;ue=ie)ie=ue.nextSibling,re.appendChild(ue)}return ve}for(var at=ht(Pe.nextSibling,0),Fe;(Fe=at.parentNode)&&Fe.nodeType===1;)at=Fe;Ke.push(at)}for(var Qe=0;Qe<Ke.length;++Qe)Ze(Ke[Qe]);Re===(Re|0)&&Ke[0].setAttribute("value",Re);var lt=Ie.createElement("ol");lt.className="linenums";for(var tt=Math.max(0,Re-1|0)||0,Qe=0,rt=Ke.length;Qe<rt;++Qe)Me=Ke[Qe],Me.className="L"+(Qe+tt)%10,Me.firstChild||Me.appendChild(Ie.createTextNode("\xA0")),lt.appendChild(Me);Ee.appendChild(lt)}function Ce(Ee){var Re=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Re=Re&&+Re[1]<=8;var Ne=/\n/g,je=Ee.sourceCode,Ue=je.length,Ie=0,Me=Ee.spans,Ke=Me.length,Ze=0,$e=Ee.decorations,Qe=$e.length,lt=0;$e[Qe]=Ue;var tt,rt;for(rt=tt=0;rt<Qe;)$e[rt]!==$e[rt+2]?($e[tt++]=$e[rt++],$e[tt++]=$e[rt++]):rt+=2;for(Qe=tt,rt=tt=0;rt<Qe;){for(var Pe=$e[rt],ht=$e[rt+1],at=rt+2;at+2<=Qe&&$e[at+1]===ht;)at+=2;$e[tt++]=Pe,$e[tt++]=ht,rt=at}Qe=$e.length=tt;var Fe=Ee.sourceNode,Ve="";Fe&&(Ve=Fe.style.display,Fe.style.display="none");try{for(var xe=null;Ze<Ke;){var ve=Me[Ze],ye=Me[Ze+2]||Ue,re=$e[lt+2]||Ue,at=Math.min(ye,re),ie=Me[Ze+1],ue;if(ie.nodeType!==1&&(ue=je.substring(Ie,at))){Re&&(ue=ue.replace(Ne,"\r")),ie.nodeValue=ue;var pe=ie.ownerDocument,be=pe.createElement("span");be.className=$e[lt+1];var _e=ie.parentNode;_e.replaceChild(be,ie),be.appendChild(ie),Ie<ye&&(Me[Ze+1]=ie=pe.createTextNode(je.substring(at,ye)),_e.insertBefore(ie,be.nextSibling))}Ie=at,Ie>=ye&&(Ze+=2),Ie>=re&&(lt+=2)}}finally{Fe&&(Fe.style.display=Ve)}}var Te={};function ge(Ee,Re){for(var Ne=Re.length;--Ne>=0;){var je=Re[Ne];Te.hasOwnProperty(je)?W.console&&console.warn("cannot override language handler %s",je):Te[je]=Ee}}function le(Ee,Re){return Ee&&Te.hasOwnProperty(Ee)||(Ee=/^\s*</.test(Re)?"default-markup":"default-code"),Te[Ee]}ge(Se,["default-code"]),ge(de([],[[a,/^[^<?]+/],[m,/^<!\w[^>]*(?:>|$)/],[E,/^<\!--[\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"]),ge(de([[a,/^[\s]+/,null,` \r
`],[U,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[F,/^(?!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"]),ge(de([],[[U,/^[\s\S]+/]]),["uq.val"]),ge(De({keywords:A,hashComments:!0,cStyleComments:!0,types:v}),["c","cc","cpp","cxx","cyc","m"]),ge(De({keywords:"null,true,false"}),["json"]),ge(De({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:v}),["cs"]),ge(De({keywords:O,cStyleComments:!0}),["java"]),ge(De({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ge(De({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ge(De({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ge(De({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ge(De({keywords:T,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ge(De({keywords:C,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ge(de([],[[g,/^[\s\S]+/]]),["regex"]);function te(Ee){var Re=Ee.langExtension;try{var Ne=I(Ee.sourceNode,Ee.pre),je=Ne.sourceCode;Ee.sourceCode=je,Ee.spans=Ne.spans,Ee.basePos=0,le(Re,je)(Ee),Ce(Ee)}catch(Ue){W.console&&console.log(Ue&&Ue.stack||Ue)}}function ce(Ee,Re,Ne){var je=Ne||!1,Ue=Re||null,Ie=document.createElement("div");Ie.innerHTML="<pre>"+Ee+"</pre>",Ie=Ie.firstChild,je&&we(Ie,je,!0);var Me={langExtension:Ue,numberLines:je,sourceNode:Ie,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return te(Me),Ie.innerHTML}function ne(Ee,Re){var Ne=Re||document.body,je=Ne.ownerDocument||document;function Ue(ve){return Ne.getElementsByTagName(ve)}for(var Ie=[Ue("pre"),Ue("code"),Ue("xmp")],Me=[],Ke=0;Ke<Ie.length;++Ke)for(var Ze=0,$e=Ie[Ke].length;Ze<$e;++Ze)Me.push(Ie[Ke][Ze]);Ie=null;var Qe=Date;Qe.now||(Qe={now:function(){return+new Date}});var lt=0,tt=/\blang(?:uage)?-([\w.]+)(?!\S)/,rt=/\bprettyprint\b/,Pe=/\bprettyprinted\b/,ht=/pre|xmp/i,at=/^code$/i,Fe=/^(?:pre|code|xmp)$/i,Ve={};function xe(){for(var ve=W.PR_SHOULD_USE_CONTINUATION?Qe.now()+250:Infinity;lt<Me.length&&Qe.now()<ve;lt++){for(var ye=Me[lt],re=Ve,ie=ye;ie=ie.previousSibling;){var ue=ie.nodeType,pe=(ue===7||ue===8)&&ie.nodeValue;if(pe?!/^\??prettify\b/.test(pe):ue!==3||/\S/.test(ie.nodeValue))break;if(pe){re={},pe.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Xt,Ot,Ir){re[Ot]=Ir});break}}var be=ye.className;if((re!==Ve||rt.test(be))&&!Pe.test(be)){for(var _e=!1,He=ye.parentNode;He;He=He.parentNode){var nt=He.tagName;if(Fe.test(nt)&&He.className&&rt.test(He.className)){_e=!0;break}}if(!_e){ye.className+=" prettyprinted";var mt=re.lang;if(!mt){mt=be.match(tt);var ft;!mt&&(ft=ae(ye))&&at.test(ft.tagName)&&(mt=ft.className.match(tt)),mt&&(mt=mt[1])}var wt;if(ht.test(ye.tagName))wt=1;else{var Tt=ye.currentStyle,ut=je.defaultView,Bt=Tt?Tt.whiteSpace:ut&&ut.getComputedStyle?ut.getComputedStyle(ye,null).getPropertyValue("white-space"):0;wt=Bt&&Bt.substring(0,3)==="pre"}var _t=re.linenums;(_t=_t==="true"||+_t)||(_t=be.match(/\blinenums\b(?::(\d+))?/),_t=_t?_t[1]&&_t[1].length?+_t[1]:!0:!1),_t&&we(ye,_t,wt);var Zt={langExtension:mt,sourceNode:ye,numberLines:_t,pre:wt,sourceCode:null,basePos:null,spans:null,decorations:null};te(Zt)}}}lt<Me.length?W.setTimeout(xe,250):typeof Ee=="function"&&Ee()}xe()}var Le=W.PR={createSimpleLexer:de,registerLangHandler:ge,sourceDecorator:De,PR_ATTRIB_NAME:F,PR_ATTRIB_VALUE:U,PR_COMMENT:E,PR_DECLARATION:m,PR_KEYWORD:k,PR_LITERAL:c,PR_NOCODE:K,PR_PLAIN:a,PR_PUNCTUATION:u,PR_SOURCE:x,PR_STRING:g,PR_TAG:b,PR_TYPE:p,prettyPrintOne:D?W.prettyPrintOne=ce:M=ce,prettyPrint:z=D?W.prettyPrint=ne:z=ne},Oe=W.define;typeof Oe=="function"&&Oe.amd&&Oe("google-code-prettify",[],function(){return Le})})()},"VrN/":function(xt,it,se){(function(oe,Z){xt.exports=Z()})(this,function(){"use strict";var oe=navigator.userAgent,Z=navigator.platform,D=/gecko\/\d/i.test(oe),$=/MSIE \d/.test(oe),B=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oe),M=/Edge\/(\d+)/.exec(oe),z=$||B||M,W=z&&($?document.documentMode||6:+(M||B)[1]),P=!M&&/WebKit\//.test(oe),R=P&&/Qt\/\d+\.\d+/.test(oe),y=!M&&/Chrome\//.test(oe),A=/Opera\//.test(oe),O=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(oe),C=/PhantomJS/.test(oe),T=!M&&/AppleWebKit/.test(oe)&&/Mobile\/\w+/.test(oe),h=/Android/.test(oe),o=T||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(oe),l=T||/Mac/.test(Z),d=/\bCrOS\b/.test(oe),w=/win/i.test(Z),v=A&&oe.match(/Version\/(\d*\.\d*)/);v&&(v=Number(v[1])),v&&v>=15&&(A=!1,P=!0);var g=l&&(R||A&&(v==null||v<12.11)),k=D||z&&W>=9;function E(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var p=function(e,t){var i=e.className,r=E(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 a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var S=0;S<t.length;++S)n.appendChild(t[S]);return n}function b(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var m;document.createRange?m=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:m=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 x(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function F(){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 U(e,t){var i=e.className;E(t).test(i)||(e.className+=(i?" ":"")+t)}function K(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!E(i[r]).test(t)&&(t+=" "+i[r]);return t}var V=function(e){e.select()};T?V=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:z&&(V=function(e){try{e.select()}catch(t){}});function _(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function I(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 Y(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var S=r||0,j=n||0;;){var X=e.indexOf(" ",S);if(X<0||X>=t)return j+(t-S);j+=X-S,j+=i-j%i,S=X+1}}var ee=function(){this.id=null,this.f=null,this.time=0,this.handler=_(this.onTimeout,this)};ee.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ee.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 ae(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var de=50,De={toString:function(){return"CodeMirror.Pass"}},Se={scroll:!1},we={origin:"*mouse"},Ce={origin:"+move"};function Te(e,t,i){for(var r=0,n=0;;){var S=e.indexOf(" ",r);S==-1&&(S=e.length);var j=S-r;if(S==e.length||n+j>=t)return r+Math.min(j,t-n);if(n+=S-r,n+=i-n%i,r=S+1,n>=t)return r}}var ge=[""];function le(e){for(;ge.length<=e;)ge.push(te(ge)+" ");return ge[e]}function te(e){return e[e.length-1]}function ce(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function ne(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function Le(){}function Oe(e,t){var i;return Object.create?i=Object.create(e):(Le.prototype=e,i=new Le),t&&I(t,i),i}var Ee=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Re(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ee.test(e))}function Ne(e,t){return t?t.source.indexOf("\\w")>-1&&Re(e)?!0:t.test(e):Re(e)}function je(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Ue=/[\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 Ie(e){return e.charCodeAt(0)>=768&&Ue.test(e)}function Me(e,t,i){for(;(i<0?t>0:t<e.length)&&Ie(e.charAt(t));)t+=i;return t}function Ke(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,S=r<0?Math.ceil(n):Math.floor(n);if(S==t)return e(S)?t:i;e(S)?i=S:t=S+r}}function Ze(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,S=0;S<e.length;++S){var j=e[S];(j.from<i&&j.to>t||t==i&&j.to==t)&&(r(Math.max(j.from,t),Math.min(j.to,i),j.level==1?"rtl":"ltr",S),n=!0)}n||r(t,i,"ltr")}var $e=null;function Qe(e,t,i){var r;$e=null;for(var n=0;n<e.length;++n){var S=e[n];if(S.from<t&&S.to>t)return n;S.to==t&&(S.from!=S.to&&i=="before"?r=n:$e=n),S.from==t&&(S.from!=S.to&&i!="before"?r=n:$e=n)}return r!=null?r:$e}var lt=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(q){return q<=247?e.charAt(q):1424<=q&&q<=1524?"R":1536<=q&&q<=1785?t.charAt(q-1536):1774<=q&&q<=2220?"r":8192<=q&&q<=8203?"w":q==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,S=/[LRr]/,j=/[Lb1n]/,X=/[1n]/;function J(q,he,fe){this.level=q,this.from=he,this.to=fe}return function(q,he){var fe=he=="ltr"?"L":"R";if(q.length==0||he=="ltr"&&!r.test(q))return!1;for(var ke=q.length,Ae=[],Be=0;Be<ke;++Be)Ae.push(i(q.charCodeAt(Be)));for(var ze=0,Ye=fe;ze<ke;++ze){var qe=Ae[ze];qe=="m"?Ae[ze]=Ye:Ye=qe}for(var ot=0,et=fe;ot<ke;++ot){var st=Ae[ot];st=="1"&&et=="r"?Ae[ot]="n":S.test(st)&&(et=st,st=="r"&&(Ae[ot]="R"))}for(var Et=1,gt=Ae[0];Et<ke-1;++Et){var At=Ae[Et];At=="+"&&gt=="1"&&Ae[Et+1]=="1"?Ae[Et]="1":At==","&&gt==Ae[Et+1]&&(gt=="1"||gt=="n")&&(Ae[Et]=gt),gt=At}for(var zt=0;zt<ke;++zt){var lr=Ae[zt];if(lr==",")Ae[zt]="N";else if(lr=="%"){var Yt=void 0;for(Yt=zt+1;Yt<ke&&Ae[Yt]=="%";++Yt);for(var Mr=zt&&Ae[zt-1]=="!"||Yt<ke&&Ae[Yt]=="1"?"1":"N",kr=zt;kr<Yt;++kr)Ae[kr]=Mr;zt=Yt-1}}for(var er=0,Dr=fe;er<ke;++er){var fr=Ae[er];Dr=="L"&&fr=="1"?Ae[er]="L":S.test(fr)&&(Dr=fr)}for(var ir=0;ir<ke;++ir)if(n.test(Ae[ir])){var tr=void 0;for(tr=ir+1;tr<ke&&n.test(Ae[tr]);++tr);for(var $t=(ir?Ae[ir-1]:fe)=="L",Rr=(tr<ke?Ae[tr]:fe)=="L",un=$t==Rr?$t?"L":"R":fe,Ri=ir;Ri<tr;++Ri)Ae[Ri]=un;ir=tr-1}for(var xr=[],ai,ur=0;ur<ke;)if(j.test(Ae[ur])){var Va=ur;for(++ur;ur<ke&&j.test(Ae[ur]);++ur);xr.push(new J(0,Va,ur))}else{var di=ur,Hi=xr.length,Gi=he=="rtl"?1:0;for(++ur;ur<ke&&Ae[ur]!="L";++ur);for(var Tr=di;Tr<ur;)if(X.test(Ae[Tr])){di<Tr&&(xr.splice(Hi,0,new J(1,di,Tr)),Hi+=Gi);var hn=Tr;for(++Tr;Tr<ur&&X.test(Ae[Tr]);++Tr);xr.splice(Hi,0,new J(2,hn,Tr)),Hi+=Gi,di=Tr}else++Tr;di<ur&&xr.splice(Hi,0,new J(1,di,ur))}return he=="ltr"&&(xr[0].level==1&&(ai=q.match(/^\s+/))&&(xr[0].from=ai[0].length,xr.unshift(new J(0,0,ai[0].length))),te(xr).level==1&&(ai=q.match(/\s+$/))&&(te(xr).to-=ai[0].length,xr.push(new J(0,ke-ai[0].length,ke)))),he=="rtl"?xr.reverse():xr}}();function tt(e,t){var i=e.order;return i==null&&(i=e.order=lt(e.text,t)),i}var rt=[],Pe=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 ht(e,t){return e._handlers&&e._handlers[t]||rt}function at(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 S=ae(n,i);S>-1&&(r[t]=n.slice(0,S).concat(n.slice(S+1)))}}}function Fe(e,t){var i=ht(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 Ve(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Fe(e,i||t.type,e,t),ue(t)||t.codemirrorIgnore}function xe(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)ae(i,t[r])==-1&&i.push(t[r])}function ve(e,t){return ht(e,t).length>0}function ye(e){e.prototype.on=function(t,i){Pe(this,t,i)},e.prototype.off=function(t,i){at(this,t,i)}}function re(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function ie(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ue(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function pe(e){re(e),ie(e)}function be(e){return e.target||e.srcElement}function _e(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 He=function(){if(z&&W<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),nt;function mt(e){if(nt==null){var t=a("span","\u200B");u(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(nt=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&W<8))}var i=nt?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var ft;function wt(e){if(ft!=null)return ft;var t=u(e,document.createTextNode("A\u062EA")),i=m(t,0,1).getBoundingClientRect(),r=m(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:ft=r.right-i.right<3}var Tt=`
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 S=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),j=S.indexOf("\r");j!=-1?(i.push(S.slice(0,j)),t+=j+1):(i.push(S),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},ut=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},Bt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),_t=null;function Zt(e){if(_t!=null)return _t;var t=u(e,a("span","x")),i=t.getBoundingClientRect(),r=m(t,0,1).getBoundingClientRect();return _t=Math.abs(i.left-r.left)>1}var Xt={},Ot={};function Ir(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Xt[e]=t}function Kr(e,t){Ot[e]=t}function bt(e){if(typeof e=="string"&&Ot.hasOwnProperty(e))e=Ot[e];else if(e&&typeof e.name=="string"&&Ot.hasOwnProperty(e.name)){var t=Ot[e.name];typeof t=="string"&&(t={name:t}),e=Oe(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return bt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return bt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Nr(e,t){t=bt(t);var i=Xt[t.name];if(!i)return Nr(e,"text/plain");var r=i(e,t);if(hr.hasOwnProperty(t.name)){var n=hr[t.name];for(var S in n){if(!n.hasOwnProperty(S))continue;r.hasOwnProperty(S)&&(r["_"+S]=r[S]),r[S]=n[S]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var j in t.modeProps)r[j]=t.modeProps[j];return r}var hr={};function pr(e,t){var i=hr.hasOwnProperty(e)?hr[e]:hr[e]={};I(t,i)}function Fr(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 ci(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 qr(e,t,i){return e.startState?e.startState(t,i):!0}var It=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};It.prototype.eol=function(){return this.pos>=this.string.length},It.prototype.sol=function(){return this.pos==this.lineStart},It.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},It.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},It.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},It.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},It.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},It.prototype.skipToEnd=function(){this.pos=this.string.length},It.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},It.prototype.backUp=function(e){this.pos-=e},It.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Y(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},It.prototype.indentation=function(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},It.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(j){return i?j.toLowerCase():j},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var S=this.string.slice(this.pos).match(e);return S&&S.index>0?null:(S&&t!==!1&&(this.pos+=S[0].length),S)}},It.prototype.current=function(){return this.string.slice(this.start,this.pos)},It.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},It.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},It.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function dt(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],S=n.chunkSize();if(t<S){i=n;break}t-=S}return i.lines[t]}function Hr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(S){var j=S.text;n==i.line&&(j=j.slice(0,i.ch)),n==t.line&&(j=j.slice(t.ch)),r.push(j),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function mr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function kt(e){if(e.parent==null)return null;for(var t=e.parent,i=ae(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 Br(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],S=n.height;if(t<S){e=n;continue e}t-=S,i+=n.chunkSize()}return i}while(!e.lines);for(var j=0;j<e.lines.length;++j){var X=e.lines[j],J=X.height;if(t<J)break;t-=J}return i+j}function Vr(e,t){return t>=e.first&&t<e.first+e.size}function fi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Xe(e,t,i){if(i===void 0&&(i=null),!(this instanceof Xe))return new Xe(e,t,i);this.line=e,this.ch=t,this.sticky=i}function St(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&St(e,t)==0}function mi(e){return Xe(e.line,e.ch)}function gi(e,t){return St(e,t)<0?t:e}function vi(e,t){return St(e,t)<0?e:t}function G(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 Xe(e.first,0);var i=e.first+e.size-1;return t.line>i?Xe(i,dt(e,i).text.length):f(t,dt(e,t.line).text.length)}function f(e,t){var i=e.ch;return i==null||i>t?Xe(e.line,t):i<0?Xe(e.line,0):e}function N(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,Fr(e.mode,t.state),i,t.lookAhead):new H(e,Fr(e.mode,t),i)},H.prototype.save=function(e){var t=e!==!1?Fr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Q(t,this.maxLookAhead):t};function me(e,t,i,r){var n=[e.state.modeGen],S={};gr(e,t.text,e.doc.mode,i,function(q,he){return n.push(q,he)},S,r);for(var j=i.state,X=function(q){i.baseTokens=n;var he=e.state.overlays[q],fe=1,ke=0;i.state=!0,gr(e,t.text,he.mode,i,function(Ae,Be){for(var ze=fe;ke<Ae;){var Ye=n[fe];Ye>Ae&&n.splice(fe,1,Ae,n[fe+1],Ye),fe+=2,ke=Math.min(Ae,Ye)}if(!Be)return;if(he.opaque)n.splice(ze,fe-ze,Ae,"overlay "+Be),fe=ze+2;else for(;ze<fe;ze+=2){var qe=n[ze+1];n[ze+1]=(qe?qe+" ":"")+"overlay "+Be}},S),i.state=j,i.baseTokens=null,i.baseTokenPos=1},J=0;J<e.state.overlays.length;++J)X(J);return{styles:n,classes:S.bgClass||S.textClass?S:null}}function We(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Je(e,kt(t)),n=t.text.length>e.options.maxHighlightLength&&Fr(e.doc.mode,r.state),S=me(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=S.styles,S.classes?t.styleClasses=S.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 Je(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new H(r,!0,t);var S=vr(e,t,i),j=S>r.first&&dt(r,S-1).stateAfter,X=j?H.fromSaved(r,j,S):new H(r,qr(r.mode),S);return r.iter(S,t,function(J){ct(e,J.text,X);var q=X.line;J.stateAfter=q==t-1||q%5==0||q>=n.viewFrom&&q<n.viewTo?X.save():null,X.nextLine()}),i&&(r.modeFrontier=X.line),X}function ct(e,t,i,r){var n=e.doc.mode,S=new It(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&Ge(n,i.state);!S.eol();)vt(n,S,i.state),S.start=S.pos}function Ge(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function vt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var S=e.token(t,i);if(t.pos>t.start)return S}throw new Error("Mode "+e.name+" failed to advance stream.")}var Nt=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,S=n.mode,j;t=s(n,t);var X=dt(n,t.line),J=Je(e,t.line,i),q=new It(X.text,e.options.tabSize,J),he;for(r&&(he=[]);(r||q.pos<t.ch)&&!q.eol();)q.start=q.pos,j=vt(S,q,J.state),r&&he.push(new Nt(q,j,Fr(n.mode,J.state)));return r?he:new Nt(q,j,J.state)}function Or(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 gr(e,t,i,r,n,S,j){var X=i.flattenSpans;X==null&&(X=e.options.flattenSpans);var J=0,q=null,he=new It(t,e.options.tabSize,r),fe,ke=e.options.addModeClass&&[null];for(t==""&&Or(Ge(i,r.state),S);!he.eol();){if(he.pos>e.options.maxHighlightLength?(X=!1,j&&ct(e,t,r,he.pos),he.pos=t.length,fe=null):fe=Or(vt(i,he,r.state,ke),S),ke){var Ae=ke[0].name;Ae&&(fe="m-"+(fe?Ae+" "+fe:Ae))}if(!X||q!=fe){for(;J<he.start;)J=Math.min(he.start,J+5e3),n(J,q);q=fe}he.start=he.pos}for(;J<he.pos;){var Be=Math.min(he.pos,J+5e3);n(Be,q),J=Be}}function vr(e,t,i){for(var r,n,S=e.doc,j=i?-1:t-(e.doc.mode.innerMode?1e3:100),X=t;X>j;--X){if(X<=S.first)return S.first;var J=dt(S,X-1),q=J.stateAfter;if(q&&(!i||X+(q instanceof Q?q.lookAhead:0)<=S.modeFrontier))return X;var he=Y(J.text,null,e.options.tabSize);(n==null||r>he)&&(n=X-1,r=he)}return n}function Xr(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=dt(e,r).stateAfter;if(n&&(!(n instanceof Q)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Oi=!1,nr=!1;function Ur(){Oi=!0}function oi(){nr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function _r(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function _i(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function yi(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function zi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],j=S.marker,X=S.from==null||(j.inclusiveLeft?S.from<=t:S.from<t);if(X||S.from==t&&j.type=="bookmark"&&(!i||!S.marker.insertLeft)){var J=S.to==null||(j.inclusiveRight?S.to>=t:S.to>t);(r||(r=[])).push(new si(j,S.from,J?null:S.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],j=S.marker,X=S.to==null||(j.inclusiveRight?S.to>=t:S.to>t);if(X||S.from==t&&j.type=="bookmark"&&(!i||S.marker.insertLeft)){var J=S.from==null||(j.inclusiveLeft?S.from<=t:S.from<t);(r||(r=[])).push(new si(j,J?null:S.from-t,S.to==null?null:S.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&dt(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&dt(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,S=t.to.ch,j=St(t.from,t.to)==0,X=zi(i,n,j),J=Ki(r,S,j),q=t.text.length==1,he=te(t.text).length+(q?n:0);if(X)for(var fe=0;fe<X.length;++fe){var ke=X[fe];if(ke.to==null){var Ae=_r(J,ke.marker);Ae?q&&(ke.to=Ae.to==null?null:Ae.to+he):ke.to=n}}if(J)for(var Be=0;Be<J.length;++Be){var ze=J[Be];if(ze.to!=null&&(ze.to+=he),ze.from==null){var Ye=_r(X,ze.marker);Ye||(ze.from=he,q&&(X||(X=[])).push(ze))}else ze.from+=he,q&&(X||(X=[])).push(ze)}X&&(X=Gr(X)),J&&J!=X&&(J=Gr(J));var qe=[X];if(!q){var ot=t.text.length-2,et;if(ot>0&&X)for(var st=0;st<X.length;++st)X[st].to==null&&(et||(et=[])).push(new si(X[st].marker,null,null));for(var Et=0;Et<ot;++Et)qe.push(et);qe.push(J)}return qe}function Gr(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 bi(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(Ae){if(Ae.markedSpans)for(var Be=0;Be<Ae.markedSpans.length;++Be){var ze=Ae.markedSpans[Be].marker;ze.readOnly&&(!r||ae(r,ze)==-1)&&(r||(r=[])).push(ze)}}),!r)return null;for(var n=[{from:t,to:i}],S=0;S<r.length;++S)for(var j=r[S],X=j.find(0),J=0;J<n.length;++J){var q=n[J];if(St(q.to,X.from)<0||St(q.from,X.to)>0)continue;var he=[J,1],fe=St(q.from,X.from),ke=St(q.to,X.to);(fe<0||!j.inclusiveLeft&&!fe)&&he.push({from:q.from,to:X.from}),(ke>0||!j.inclusiveRight&&!ke)&&he.push({from:X.to,to:q.to}),n.splice.apply(n,he),J+=he.length-3}return n}function dn(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 xi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Jt(e){return e.inclusiveLeft?-1:0}function Ft(e){return e.inclusiveRight?1:0}function dr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),S=St(r.from,n.from)||Jt(e)-Jt(t);if(S)return-S;var j=St(r.to,n.to)||Ft(e)-Ft(t);return j||t.id-e.id}function Dt(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=void 0,S=0;S<i.length;++S)n=i[S],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||dr(r,n.marker)<0)&&(r=n.marker);return r}function qt(e){return Dt(e,!0)}function Wt(e){return Dt(e,!1)}function ti(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var S=i[n];S.marker.collapsed&&(S.from==null||S.from<t)&&(S.to==null||S.to>t)&&(!r||dr(r,S.marker)<0)&&(r=S.marker)}return r}function ar(e,t,i,r,n){var S=dt(e,t),j=nr&&S.markedSpans;if(j)for(var X=0;X<j.length;++X){var J=j[X];if(!J.marker.collapsed)continue;var q=J.marker.find(0),he=St(q.from,i)||Jt(J.marker)-Jt(n),fe=St(q.to,r)||Ft(J.marker)-Ft(n);if(he>=0&&fe<=0||he<=0&&fe>=0)continue;if(he<=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?St(q.to,i)>=0:St(q.to,i)>0)||he>=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?St(q.from,r)<=0:St(q.from,r)<0))return!0}}function Er(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Wt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=Wt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=dt(e,t),r=Er(i);return i==r?t:kt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=dt(e,t),r;if(!ri(e,i))return t;for(;r=Wt(i);)i=r.find(1,!0).line;return kt(i)+1}function ri(e,t){var i=nr&&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&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,_r(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,S=0;S<t.markedSpans.length;++S)if(n=t.markedSpans[S],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function $r(e){e=Er(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 S=i.parent;S;i=S,S=i.parent)for(var j=0;j<S.children.length;++j){var X=S.children[j];if(X==i)break;t+=X.height}return t}function pn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=qt(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wt(r);){var S=i.find(0,!0);t-=r.text.length-S.from.ch,r=S.to.line,t+=r.text.length-S.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=dt(i,i.first),t.maxLineLength=pn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=pn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Pi=function(e,t,i){this.text=e,xi(this,t),this.height=i?i(this):1};Pi.prototype.lineNo=function(){return kt(this)},ye(Pi);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),dn(e),xi(e,i);var n=r?r(e):1;n!=e.height&&mr(e,n)}function pt(e){e.parent=null,dn(e)}var Ct={},yt={};function Lt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?yt:Ct;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Mt(e,t){var i=b("span",null,null,P?"padding-right: .1px":null),r={pre:b("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 S=n?t.rest[n-1]:t.line,j=void 0;r.pos=0,r.addToken=Pt,wt(e.display.measure)&&(j=tt(S,e.doc.direction))&&(r.addToken=Cr(r.addToken,j)),r.map=[];var X=t!=e.display.externalMeasured&&kt(S);li(S,r,We(e,S,X)),S.styleClasses&&(S.styleClasses.bgClass&&(r.bgClass=K(S.styleClasses.bgClass,r.bgClass||"")),S.styleClasses.textClass&&(r.textClass=K(S.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(mt(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(P){var J=r.content.lastChild;(/\bcm-tab\b/.test(J.className)||J.querySelector&&J.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Fe(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=K(r.pre.className,r.textClass||"")),r}function Gt(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Pt(e,t,i,r,n,S,j){if(!t)return;var X=e.splitSpaces?rr(t,e.trailingSpace):t,J=e.cm.state.specialChars,q=!1,he;if(!J.test(t))e.col+=t.length,he=document.createTextNode(X),e.map.push(e.pos,e.pos+t.length,he),z&&W<9&&(q=!0),e.pos+=t.length;else{he=document.createDocumentFragment();for(var fe=0;;){J.lastIndex=fe;var ke=J.exec(t),Ae=ke?ke.index-fe:t.length-fe;if(Ae){var Be=document.createTextNode(X.slice(fe,fe+Ae));z&&W<9?he.appendChild(a("span",[Be])):he.appendChild(Be),e.map.push(e.pos,e.pos+Ae,Be),e.col+=Ae,e.pos+=Ae}if(!ke)break;fe+=Ae+1;var ze=void 0;if(ke[0]==" "){var Ye=e.cm.options.tabSize,qe=Ye-e.col%Ye;ze=he.appendChild(a("span",le(qe),"cm-tab")),ze.setAttribute("role","presentation"),ze.setAttribute("cm-text"," "),e.col+=qe}else ke[0]=="\r"||ke[0]==`
`?(ze=he.appendChild(a("span",ke[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),ze.setAttribute("cm-text",ke[0]),e.col+=1):(ze=e.cm.options.specialCharPlaceholder(ke[0]),ze.setAttribute("cm-text",ke[0]),z&&W<9?he.appendChild(a("span",[ze])):he.appendChild(ze),e.col+=1);e.map.push(e.pos,e.pos+1,ze),e.pos++}}if(e.trailingSpace=X.charCodeAt(t.length-1)==32,i||r||n||q||S||j){var ot=i||"";r&&(ot+=r),n&&(ot+=n);var et=a("span",[he],ot,S);if(j)for(var st in j)j.hasOwnProperty(st)&&st!="style"&&st!="class"&&et.setAttribute(st,j[st]);return e.content.appendChild(et)}e.content.appendChild(he)}function rr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var S=e.charAt(n);S==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(S="\xA0"),r+=S,i=S==" "}return r}function Cr(e,t){return function(i,r,n,S,j,X,J){n=n?n+" cm-force-border":"cm-force-border";for(var q=i.pos,he=q+r.length;;){for(var fe=void 0,ke=0;ke<t.length&&!(fe=t[ke],fe.to>q&&fe.from<=q);ke++);if(fe.to>=he)return e(i,r,n,S,j,X,J);e(i,r.slice(0,fe.to-q),n,S,null,X,J),S=null,r=r.slice(fe.to-q),q=fe.to}}}function Rt(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 li(e,t,i){var r=e.markedSpans,n=e.text,S=0;if(!r){for(var j=1;j<i.length;j+=2)t.addToken(t,n.slice(S,S=i[j]),Lt(i[j+1],t.cm.options));return}for(var X=n.length,J=0,q=1,he="",fe,ke,Ae=0,Be,ze,Ye,qe,ot;;){if(Ae==J){Be=ze=Ye=ke="",ot=null,qe=null,Ae=Infinity;for(var et=[],st=void 0,Et=0;Et<r.length;++Et){var gt=r[Et],At=gt.marker;if(At.type=="bookmark"&&gt.from==J&&At.widgetNode)et.push(At);else if(gt.from<=J&&(gt.to==null||gt.to>J||At.collapsed&&gt.to==J&&gt.from==J)){if(gt.to!=null&&gt.to!=J&&Ae>gt.to&&(Ae=gt.to,ze=""),At.className&&(Be+=" "+At.className),At.css&&(ke=(ke?ke+";":"")+At.css),At.startStyle&&gt.from==J&&(Ye+=" "+At.startStyle),At.endStyle&&gt.to==Ae&&(st||(st=[])).push(At.endStyle,gt.to),At.title&&((ot||(ot={})).title=At.title),At.attributes)for(var zt in At.attributes)(ot||(ot={}))[zt]=At.attributes[zt];At.collapsed&&(!qe||dr(qe.marker,At)<0)&&(qe=gt)}else gt.from>J&&Ae>gt.from&&(Ae=gt.from)}if(st)for(var lr=0;lr<st.length;lr+=2)st[lr+1]==Ae&&(ze+=" "+st[lr]);if(!qe||qe.from==J)for(var Yt=0;Yt<et.length;++Yt)Rt(t,0,et[Yt]);if(qe&&(qe.from||0)==J){if(Rt(t,(qe.to==null?X+1:qe.to)-J,qe.marker,qe.from==null),qe.to==null)return;qe.to==J&&(qe=!1)}}if(J>=X)break;for(var Mr=Math.min(X,Ae);;){if(he){var kr=J+he.length;if(!qe){var er=kr>Mr?he.slice(0,Mr-J):he;t.addToken(t,er,fe?fe+Be:Be,Ye,J+er.length==Ae?ze:"",ke,ot)}if(kr>=Mr){he=he.slice(Mr-J),J=Mr;break}J=kr,Ye=""}he=n.slice(S,S=i[q++]),fe=Lt(i[q++],t.cm.options)}}}function Ut(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?kt(te(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function wr(e,t,i){for(var r=[],n,S=t;S<i;S=n){var j=new Ut(e.doc,dt(e.doc,S),S);n=S+j.size,r.push(j)}return r}var yr=null;function zr(e){yr?yr.ops.push(e):e.ownsGroup=yr={ops:[e],delayedCallbacks:[]}}function Rs(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 Os(e,t){var i=e.ownsGroup;if(!i)return;try{Rs(i)}finally{yr=null,t(i)}}var mn=null;function cr(e,t){var i=ht(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;yr?n=yr.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(_s,0));for(var S=function(X){n.push(function(){return i[X].apply(null,r)})},j=0;j<i.length;++j)S(j)}function _s(){var e=mn;mn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var S=t.changes[n];S=="text"?Ms(e,t):S=="gutter"?Za(e,t,i,r):S=="class"?ha(e,t):S=="widget"&&Is(e,t,r)}t.changes=null}function gn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),z&&W<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Mt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(e,t),t.line.wrapClass?gn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=gn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var S=t.line.gutterMarkers;if(e.options.lineNumbers||S){var j=gn(t),X=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(X),j.insertBefore(X,t.text),t.line.gutterClass&&(X.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=X.appendChild(a("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),S)for(var J=0;J<e.display.gutterSpecs.length;++J){var q=e.display.gutterSpecs[J].className,he=S.hasOwnProperty(q)&&S[q];he&&X.appendChild(a("div",[he],"CodeMirror-gutter-elt","left: "+r.gutterLeft[q]+"px; width: "+r.gutterWidth[q]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=E("CodeMirror-linewidget"),n=t.node.firstChild,S=void 0;n;n=S)S=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Ja(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ha(e,t),Za(e,t,i,r),Ja(e,t,r),t.node}function Ja(e,t,i){if(Qa(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Qa(e,t.rest[r],t,i,!1)}function Qa(e,t,i,r,n){if(!t.widgets)return;for(var S=gn(i),j=0,X=t.widgets;j<X.length;++j){var J=X[j],q=a("div",[J.node],"CodeMirror-linewidget"+(J.className?" "+J.className:""));J.handleMouseEvents||q.setAttribute("cm-ignore-events","true"),Fs(J,q,i,r),e.display.input.setUneditable(q),n&&J.above?S.insertBefore(q,i.gutter||i.text):S.appendChild(q),cr(J,"redraw")}}function Fs(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 vn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!x(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,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=be(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 da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=u(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return de-e.display.nativeBarWidth}function Mi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Bs(e,t,i){var r=e.options.lineWrapping,n=r&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var S=t.measure.heights=[];if(r){t.measure.width=n;for(var j=t.text.firstChild.getClientRects(),X=0;X<j.length-1;X++){var J=j[X],q=j[X+1];Math.abs(J.bottom-q.bottom)>2&&S.push((J.bottom+q.top)/2-i.top)}}S.push(i.bottom-i.top)}}function eo(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(kt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=Er(t);var i=kt(t),r=e.display.externalMeasured=new Ut(e.doc,t,i);r.lineN=i;var n=r.built=Mt(e,r);return r.text=n.pre,u(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return ni(e,Xi(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Fi(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=kt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ni(e,t,i,r,n){t.before&&(i=-1);var S=i+(r||""),j;return t.cache.hasOwnProperty(S)?j=t.cache[S]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Bs(e,t.view,t.rect),t.hasHeights=!0),j=Ws(e,t,i,r),j.bogus||(t.cache[S]=j)),{left:j.left,right:j.right,top:n?j.rtop:j.top,bottom:n?j.rbottom:j.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,S,j,X,J,q=0;q<e.length;q+=3)if(X=e[q],J=e[q+1],t<X?(n=0,S=1,j="left"):t<J?(n=t-X,S=n+1):(q==e.length-3||t==J&&e[q+3]>t)&&(S=J-X,n=S-1,t>=J&&(j="right")),n!=null){if(r=e[q+2],X==J&&i==(r.insertLeft?"left":"right")&&(j=i),i=="left"&&n==0)for(;q&&e[q-2]==e[q-3]&&e[q-1].insertLeft;)r=e[(q-=3)+2],j="left";if(i=="right"&&n==J-X)for(;q<e.length-3&&e[q+3]==e[q+4]&&!e[q+5].insertLeft;)r=e[(q+=3)+2],j="right";break}return{node:r,start:n,end:S,collapse:j,coverStart:X,coverEnd:J}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),S=n.node,j=n.start,X=n.end,J=n.collapse,q;if(S.nodeType==3){for(var he=0;he<4;he++){for(;j&&Ie(t.line.text.charAt(n.coverStart+j));)--j;for(;n.coverStart+X<n.coverEnd&&Ie(t.line.text.charAt(n.coverStart+X));)++X;if(z&&W<9&&j==0&&X==n.coverEnd-n.coverStart?q=S.parentNode.getBoundingClientRect():q=js(m(S,j,X).getClientRects(),r),q.left||q.right||j==0)break;X=j,j=j-1,J="right"}z&&W<11&&(q=Hs(e.display.measure,q))}else{j>0&&(J=r="right");var fe;e.options.lineWrapping&&(fe=S.getClientRects()).length>1?q=fe[r=="right"?fe.length-1:0]:q=S.getBoundingClientRect()}if(z&&W<9&&!j&&(!q||!q.left&&!q.right)){var ke=S.parentNode.getClientRects()[0];ke?q={left:ke.left,right:ke.left+$i(e.display),top:ke.top,bottom:ke.bottom}:q=ro}for(var Ae=q.top-t.rect.top,Be=q.bottom-t.rect.top,ze=(Ae+Be)/2,Ye=t.view.measure.heights,qe=0;qe<Ye.length-1&&!(ze<Ye[qe]);qe++);var ot=qe?Ye[qe-1]:0,et=Ye[qe],st={left:(J=="right"?q.right:q.left)-t.rect.left,right:(J=="left"?q.left:q.right)-t.rect.left,top:ot,bottom:et};return!q.left&&!q.right&&(st.bogus=!0),e.options.singleCursorHeightPerLine||(st.rtop=Ae,st.rbottom=Be),st}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Zt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function yn(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return y&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return y&&h?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=vn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var S=pa(t);i.top+=S,i.bottom+=S}if(r=="line")return i;r||(r="local");var j=$r(t);if(r=="local"?j+=Wn(e.display):j-=e.display.viewOffset,r=="page"||r=="window"){var X=e.display.lineSpace.getBoundingClientRect();j+=X.top+(r=="window"?0:so());var J=X.left+(r=="window"?0:oo());i.left+=J,i.right+=J}return i.top+=j,i.bottom+=j,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var S=e.display.sizer.getBoundingClientRect();r+=S.left,n+=S.top}var j=e.display.lineSpace.getBoundingClientRect();return{left:r-j.left,top:n-j.top}}function ma(e,t,i,r,n){return r||(r=dt(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,S){r=r||dt(e.doc,t.line),n||(n=Xi(e,r));function j(Be,ze){var Ye=ni(e,n,Be,ze?"right":"left",S);return ze?Ye.left=Ye.right:Ye.right=Ye.left,Hn(e,r,Ye,i)}var X=tt(r,e.doc.direction),J=t.ch,q=t.sticky;if(J>=r.text.length?(J=r.text.length,q="before"):J<=0&&(J=0,q="after"),!X)return j(q=="before"?J-1:J,q=="before");function he(Be,ze,Ye){var qe=X[ze],ot=qe.level==1;return j(Ye?Be-1:Be,ot!=Ye)}var fe=Qe(X,J,q),ke=$e,Ae=he(J,fe,q=="before");return ke!=null&&(Ae.other=he(J,ke,q!="before")),Ae}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=dt(e.doc,t.line),n=$r(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var S=Xe(e,t,i);return S.xRel=n,r&&(S.outside=r),S}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=Br(r,i),S=r.first+r.size-1;if(n>S)return ga(r.first+r.size-1,dt(r,S).text.length,null,1,1);t<0&&(t=0);for(var j=dt(r,n);;){var X=Gs(e,j,n,t,i),J=ti(j,X.ch+(X.xRel>0||X.outside>0?1:0));if(!J)return X;var q=J.find(1);if(q.line==n)return q;j=dt(r,n=q.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,S=Ke(function(j){return ni(e,i,j-1).bottom<=r},n,0);return n=Ke(function(j){return ni(e,i,j).top>r},S,n),{begin:S,end:n}}function co(e,t,i,r){i||(i=Xi(e,t));var n=Hn(e,t,ni(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=$r(t);var S=Xi(e,t),j=pa(t),X=0,J=t.text.length,q=!0,he=tt(t,e.doc.direction);if(he){var fe=(e.options.lineWrapping?Ks:zs)(e,t,i,S,he,r,n);q=fe.level!=1,X=q?fe.from:fe.to-1,J=q?fe.to:fe.from-1}var ke=null,Ae=null,Be=Ke(function(Et){var gt=ni(e,S,Et);return gt.top+=j,gt.bottom+=j,ya(gt,r,n,!1)?(gt.top<=n&&gt.left<=r&&(ke=Et,Ae=gt),!0):!1},X,J),ze,Ye,qe=!1;if(Ae){var ot=r-Ae.left<Ae.right-r,et=ot==q;Be=ke+(et?0:1),Ye=et?"after":"before",ze=ot?Ae.left:Ae.right}else{!q&&(Be==J||Be==X)&&Be++,Ye=Be==0?"after":Be==t.text.length?"before":ni(e,S,Be-(q?1:0)).bottom+j<=n==q?"after":"before";var st=Zr(e,Xe(i,Be,Ye),"line",t,S);ze=st.left,qe=n<st.top?-1:n>=st.bottom?1:0}return Be=Me(t.text,Be,1),ga(i,Be,Ye,qe,r-ze)}function zs(e,t,i,r,n,S,j){var X=Ke(function(fe){var ke=n[fe],Ae=ke.level!=1;return ya(Zr(e,Xe(i,Ae?ke.to:ke.from,Ae?"before":"after"),"line",t,r),S,j,!0)},0,n.length-1),J=n[X];if(X>0){var q=J.level!=1,he=Zr(e,Xe(i,q?J.from:J.to,q?"after":"before"),"line",t,r);ya(he,S,j,!0)&&he.top>j&&(J=n[X-1])}return J}function Ks(e,t,i,r,n,S,j){var X=ho(e,t,r,j),J=X.begin,q=X.end;/\s/.test(t.text.charAt(q-1))&&q--;for(var he=null,fe=null,ke=0;ke<n.length;ke++){var Ae=n[ke];if(Ae.from>=q||Ae.to<=J)continue;var Be=Ae.level!=1,ze=ni(e,r,Be?Math.min(q,Ae.to)-1:Math.max(J,Ae.from)).right,Ye=ze<S?S-ze+1e9:ze-S;(!he||fe>Ye)&&(he=Ae,fe=Ye)}return he||(he=n[n.length-1]),he.from<J&&(he={from:J,to:he.to,level:he.level}),he.to>q&&(he={from:he.from,to:q,level:he.level}),he}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(a("br"));Ii.appendChild(document.createTextNode("x"))}u(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("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 ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,S=t.gutters.firstChild,j=0;S;S=S.nextSibling,++j){var X=e.display.gutterSpecs[j].className;i[X]=S.offsetLeft+S.clientLeft+n,r[X]=S.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(ri(e.doc,n))return 0;var S=0;if(n.widgets)for(var j=0;j<n.widgets.length;j++)n.widgets[j].height&&(S+=n.widgets[j].height);return i?S+(Math.ceil(n.text.length/r)||1)*t:S+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&mr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&be(t).getAttribute("cm-not-content")=="true")return null;var S,j,X=n.lineSpace.getBoundingClientRect();try{S=t.clientX-X.left,j=t.clientY-X.top}catch(fe){return null}var J=va(e,S,j),q;if(r&&J.xRel>0&&(q=dt(e.doc,J.line).text).length==J.ch){var he=Y(q,q.length,e.options.tabSize)-q.length;J=Xe(J.line,Math.max(0,Math.round((S-qa(e.display).left)/$i(e.display))-he))}return J}function Fi(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 Ar(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)nr&&cn(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)nr&&Si(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 S=Gn(e,i,i+r,1);S?(n.view=n.view.slice(S.index),n.viewFrom=S.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var j=Gn(e,t,t,-1);j?(n.view=n.view.slice(0,j.index),n.viewTo=j.lineN):Ci(e)}else{var X=Gn(e,t,t,-1),J=Gn(e,i,i+r,1);X&&J?(n.view=n.view.slice(0,X.index).concat(wr(e,X.lineN,J.lineN)).concat(n.view.slice(J.index)),n.viewTo+=r):Ci(e)}var q=n.externalMeasured;q&&(i<q.lineN?q.lineN+=r:t<q.lineN+q.size&&(n.externalMeasured=null))}function Ti(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 S=r.view[Fi(e,t)];if(S.node==null)return;var j=S.changes||(S.changes=[]);ae(j,i)==-1&&j.push(i)}function Ci(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gn(e,t,i,r){var n=Fi(e,t),S,j=e.display.view;if(!nr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var X=e.display.viewFrom,J=0;J<n;J++)X+=j[J].size;if(X!=t){if(r>0){if(n==j.length-1)return null;S=X+j[n].size-t,n++}else S=X-t;t+=S,i+=S}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:j.length-1))return null;i+=r*j[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=wr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=wr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Fi(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(wr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Fi(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function bn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),S=r.selection=document.createDocumentFragment(),j=0;j<i.sel.ranges.length;j++){if(!t&&j==i.sel.primIndex)continue;var X=i.sel.ranges[j];if(X.from().line>=e.display.viewTo||X.to().line<e.display.viewFrom)continue;var J=X.empty();(J||e.options.showCursorWhenSelecting)&&go(e,X.head,n),J||Xs(e,X,S)}return r}function go(e,t,i){var r=Zr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var S=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));S.style.display="",S.style.left=r.other.left+"px",S.style.top=r.other.top+"px",S.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,S=document.createDocumentFragment(),j=qa(e.display),X=j.left,J=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-j.right,q=n.direction=="ltr";function he(et,st,Et,gt){st<0&&(st=0),st=Math.round(st),gt=Math.round(gt),S.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+et+`px;
top: `+st+"px; width: "+(Et==null?J-et:Et)+`px;
height: `+(gt-st)+"px"))}function fe(et,st,Et){var gt=dt(n,et),At=gt.text.length,zt,lr;function Yt(er,Dr){return ma(e,Xe(et,er),"div",gt,Dr)}function Mr(er,Dr,fr){var ir=co(e,gt,null,er),tr=Dr=="ltr"==(fr=="after")?"left":"right",$t=fr=="after"?ir.begin:ir.end-(/\s/.test(gt.text.charAt(ir.end-1))?2:1);return Yt($t,tr)[tr]}var kr=tt(gt,n.direction);return Ze(kr,st||0,Et==null?At:Et,function(er,Dr,fr,ir){var tr=fr=="ltr",$t=Yt(er,tr?"left":"right"),Rr=Yt(Dr-1,tr?"right":"left"),un=st==null&&er==0,Ri=Et==null&&Dr==At,xr=ir==0,ai=!kr||ir==kr.length-1;if(Rr.top-$t.top<=3){var ur=(q?un:Ri)&&xr,Va=(q?Ri:un)&&ai,di=ur?X:(tr?$t:Rr).left,Hi=Va?J:(tr?Rr:$t).right;he(di,$t.top,Hi-di,$t.bottom)}else{var Gi,Tr,hn,Xa;tr?(Gi=q&&un&&xr?X:$t.left,Tr=q?J:Mr(er,fr,"before"),hn=q?X:Mr(Dr,fr,"after"),Xa=q&&Ri&&ai?J:Rr.right):(Gi=q?Mr(er,fr,"before"):X,Tr=!q&&un&&xr?J:$t.right,hn=!q&&Ri&&ai?X:Rr.left,Xa=q?Mr(Dr,fr,"after"):J),he(Gi,$t.top,Tr-Gi,$t.bottom),$t.bottom<Rr.top&&he(X,$t.bottom,null,Rr.top),he(hn,Rr.top,Xa-hn,Rr.bottom)}(!zt||zn($t,zt)<0)&&(zt=$t),zn(Rr,zt)<0&&(zt=Rr),(!lr||zn($t,lr)<0)&&(lr=$t),zn(Rr,lr)<0&&(lr=Rr)}),{start:zt,end:lr}}var ke=t.from(),Ae=t.to();if(ke.line==Ae.line)fe(ke.line,ke.ch,Ae.ch);else{var Be=dt(n,ke.line),ze=dt(n,Ae.line),Ye=Er(Be)==Er(ze),qe=fe(ke.line,ke.ch,Ye?Be.text.length+1:null).end,ot=fe(Ae.line,Ye?0:null,Ae.ch).start;Ye&&(qe.top<ot.top-2?(he(qe.right,qe.top,null,qe.bottom),he(X,ot.top,ot.left,ot.bottom)):he(qe.right,qe.top,ot.left-qe.right,qe.bottom)),qe.bottom<ot.top&&he(X,qe.bottom,null,ot.top)}i.appendChild(S)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Fe(e,"focus",e,t),e.state.focused=!0,U(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),P&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Fe(e,"blur",e,t),e.state.focused=!1,p(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],S=e.options.lineWrapping,j=void 0,X=0;if(n.hidden)continue;if(z&&W<8){var J=n.node.offsetTop+n.node.offsetHeight;j=J-i,i=J}else{var q=n.node.getBoundingClientRect();j=q.bottom-q.top,!S&&n.text.firstChild&&(X=n.text.firstChild.getBoundingClientRect().right-q.left-1)}var he=n.line.height-j;if((he>.005||he<-.005)&&(mr(n.line,j),bo(n.line),n.rest))for(var fe=0;fe<n.rest.length;fe++)bo(n.rest[fe]);if(X>e.display.sizerWidth){var ke=Math.ceil(X/$i(e.display));ke>e.display.maxLineLength&&(e.display.maxLineLength=ke,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function 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,S=Br(t,r),j=Br(t,n);if(i&&i.ensure){var X=i.ensure.from.line,J=i.ensure.to.line;X<S?(S=X,j=Br(t,$r(dt(t,X))+e.wrapper.clientHeight)):Math.min(J,t.lastLine())>=j&&(S=Br(t,$r(dt(t,J))-e.wrapper.clientHeight),j=J)}return{from:S,to:Math.max(j,S+1)}}function Ys(e,t){if(Ve(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!C){var S=a("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(S),S.scrollIntoView(n),e.display.lineSpace.removeChild(S)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Xe(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Xe(t.line,t.ch+1,"before"):t);for(var S=0;S<5;S++){var j=!1,X=Zr(e,t),J=!i||i==t?X:Zr(e,i);n={left:Math.min(X.left,J.left),top:Math.min(X.top,J.top)-r,right:Math.max(X.left,J.left),bottom:Math.max(X.bottom,J.bottom)+r};var q=Ca(e,n),he=e.doc.scrollTop,fe=e.doc.scrollLeft;if(q.scrollTop!=null&&(En(e,q.scrollTop),Math.abs(e.doc.scrollTop-he)>1&&(j=!0)),q.scrollLeft!=null&&(Bi(e,q.scrollLeft),Math.abs(e.doc.scrollLeft-fe)>1&&(j=!0)),!j)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&En(e,i.scrollTop),i.scrollLeft!=null&&Bi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,S=ca(e),j={};t.bottom-t.top>S&&(t.bottom=t.top+S);var X=e.doc.height+da(i),J=t.top<r,q=t.bottom>X-r;if(t.top<n)j.scrollTop=J?0:t.top;else if(t.bottom>n+S){var he=Math.min(t.top,(q?X:t.bottom)-S);he!=n&&(j.scrollTop=he)}var fe=e.options.fixedGutter?0:i.gutters.offsetWidth,ke=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-fe,Ae=Mi(e)-i.gutters.offsetWidth,Be=t.right-t.left>Ae;return Be&&(t.right=t.left+Ae),t.left<10?j.scrollLeft=0:t.left<ke?j.scrollLeft=Math.max(0,t.left+fe-(Be?0:10)):t.right>Ae+ke-3&&(j.scrollLeft=t.right+(Be?0:10)-Ae),j}function wa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function xn(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=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});xn(e,n.scrollLeft,n.scrollTop)}function En(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||La(e,{top:t}),Eo(e,t,!0),D&&La(e),Cn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Bi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Pe(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Pe(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&W<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.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 S=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+S)+"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}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.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 ee,this.disableVert=new ee},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),S=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);S!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Tn=function(){};Tn.prototype.update=function(){return{bottom:0,right:0}},Tn.prototype.setScrollLeft=function(){},Tn.prototype.setScrollTop=function(){},Tn.prototype.clear=function(){};function Qi(e,t){t||(t=Sn(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),So(e,Sn(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var To={native:Ui,null:Tn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&p(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Pe(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"?Bi(e,t):En(e,t)},e),e.display.scrollbars.addClass&&U(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function ji(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},zr(e.curOp)}function Wi(e){var t=e.curOp;t&&Os(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 S=0;S<t.length;S++)il(t[S]);for(var j=0;j<t.length;j++)nl(t[j])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(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&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Mi(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&&Bi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==F();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(t,e.barMeasure),e.updatedDisplay&&Da(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Bi(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 S=e.maybeHiddenMarkers,j=e.maybeUnhiddenMarkers;if(S)for(var X=0;X<S.length;++X)S[X].lines.length||Fe(S[X],"hide");if(j)for(var J=0;J<j.length;++J)j[J].lines.length&&Fe(j[J],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Fe(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Pr(e,t){if(e.curOp)return t();ji(e);try{return t()}finally{Wi(e)}}function or(e,t){return function(){if(e.curOp)return t.apply(e,arguments);ji(e);try{return t.apply(e,arguments)}finally{Wi(e)}}}function Sr(e){return function(){if(this.curOp)return e.apply(this,arguments);ji(this);try{return e.apply(this,arguments)}finally{Wi(this)}}}function sr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);ji(t);try{return e.apply(this,arguments)}finally{Wi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,_(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Je(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(S){if(r.line>=e.display.viewFrom){var j=S.styles,X=S.text.length>e.options.maxHighlightLength?Fr(t.mode,r.state):null,J=me(e,S,r,!0);X&&(r.state=X),S.styles=J.styles;var q=S.styleClasses,he=J.classes;he?S.styleClasses=he:q&&(S.styleClasses=null);for(var fe=!j||j.length!=S.styles.length||q!=he&&(!q||!he||q.bgClass!=he.bgClass||q.textClass!=he.textClass),ke=0;!fe&&ke<j.length;++ke)fe=j[ke]!=S.styles[ke];fe&&n.push(r.line),S.stateAfter=r.save(),r.nextLine()}else S.text.length<=e.options.maxHighlightLength&&ct(e,S.text,r),S.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&&Pr(e,function(){for(var S=0;S<n.length;S++)Ti(e,n[S],"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=Mi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){ve(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Fe.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=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=F();if(!t||!x(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&x(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==F())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&x(document.body,e.anchorNode)&&x(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return 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&&po(e)==0)return!1;Lo(e)&&(Ci(e),t.dims=ba(e));var n=r.first+r.size,S=Math.max(t.visible.from-e.options.viewportMargin,r.first),j=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<S&&S-i.viewFrom<20&&(S=Math.max(r.first,i.viewFrom)),i.viewTo>j&&i.viewTo-j<20&&(j=Math.min(n,i.viewTo)),nr&&(S=cn(e.doc,S),j=Si(e.doc,j));var X=S!=i.viewFrom||j!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,S,j),i.viewOffset=$r(dt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var J=po(e);if(!X&&J==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var q=sl(e);return J>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),J>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(q),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 wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Mi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(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(!Aa(e,t))break;Kn(e);var n=Sn(e);bn(e),Qi(e,n),Da(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function La(e,t){var i=new Yn(e,t);if(Aa(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Qi(e,r),Da(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,S=r.lineDiv,j=S.firstChild;function X(Be){var ze=Be.nextSibling;return P&&l&&e.display.currentWheelTarget==Be?Be.style.display="none":Be.parentNode.removeChild(Be),ze}for(var J=r.view,q=r.viewFrom,he=0;he<J.length;he++){var fe=J[he];if(!fe.hidden)if(!fe.node||fe.node.parentNode!=S){var ke=Ns(e,fe,q,i);S.insertBefore(ke,j)}else{for(;j!=fe.node;)j=X(j);var Ae=n&&t!=null&&t<=q&&fe.lineNumber;fe.changes&&(ae(fe.changes,"gutter")>-1&&(Ae=!1),Ya(e,fe,q,i)),Ae&&(c(fe.lineNumber),fe.lineNumber.appendChild(document.createTextNode(fi(e.options,q)))),j=fe.node.nextSibling}q+=fe.size}for(;j;)j=X(j)}function ka(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Da(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+ii(e)+"px"}function Ao(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,S=r+"px",j=0;j<i.length;j++)if(!i[j].hidden){e.options.fixedGutter&&(i[j].gutter&&(i[j].gutter.style.left=S),i[j].gutterBackground&&(i[j].gutterBackground.style.left=S));var X=i[j].alignable;if(X)for(var J=0;J<X.length;J++)X[J].style.left=S}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),S=n.firstChild.offsetWidth,j=n.offsetWidth-S;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(S,r.lineGutter.offsetWidth-j)+1,r.lineNumWidth=r.lineNumInnerWidth+j,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",ka(e.display),!0}return!1}function Ra(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var S=e[n],j=null;if(typeof S!="string"&&(j=S.style,S=S.className),S=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:S,style:j})}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],S=n.className,j=n.style,X=t.appendChild(a("div",null,"CodeMirror-gutter "+S));j&&(X.style.cssText=j),S=="CodeMirror-linenumbers"&&(e.lineGutter=X,X.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function wn(e){ko(e.display),Ar(e),Ao(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=b("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=b("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=b("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[S],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+de+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),z&&W<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(D&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Ra(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,jr=null;z?jr=-.53:D?jr=15:y?jr=-.7:O&&(jr=-1/3);function Do(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function dl(e){var t=Do(e);return t.x*=jr,t.y*=jr,t}function Ro(e,t){var i=Do(t),r=i.x,n=i.y,S=e.display,j=S.scroller,X=j.scrollWidth>j.clientWidth,J=j.scrollHeight>j.clientHeight;if(!(r&&X||n&&J))return;if(n&&l&&P){e:for(var q=t.target,he=S.view;q!=j;q=q.parentNode)for(var fe=0;fe<he.length;fe++)if(he[fe].node==q){e.display.currentWheelTarget=q;break e}}if(r&&!D&&!A&&jr!=null){n&&J&&En(e,Math.max(0,j.scrollTop+n*jr)),Bi(e,Math.max(0,j.scrollLeft+r*jr)),(!n||n&&J)&&re(t),S.wheelStartX=null;return}if(n&&jr!=null){var ke=n*jr,Ae=e.doc.scrollTop,Be=Ae+S.wrapper.clientHeight;ke<0?Ae=Math.max(0,Ae+ke-50):Be=Math.min(e.doc.height,Be+ke+50),La(e,{top:Ae,bottom:Be})}$n<20&&(S.wheelStartX==null?(S.wheelStartX=j.scrollLeft,S.wheelStartY=j.scrollTop,S.wheelDX=r,S.wheelDY=n,setTimeout(function(){if(S.wheelStartX==null)return;var ze=j.scrollLeft-S.wheelStartX,Ye=j.scrollTop-S.wheelStartY,qe=Ye&&S.wheelDY&&Ye/S.wheelDY||ze&&S.wheelDX&&ze/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!qe)return;jr=(jr*$n+qe)/($n+1),++$n},200)):(S.wheelDX+=r,S.wheelDY+=n))}var Wr=function(e,t){this.ranges=e,this.primIndex=t};Wr.prototype.primary=function(){return this.ranges[this.primIndex]},Wr.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(!pi(i.anchor,r.anchor)||!pi(i.head,r.head))return!1}return!0},Wr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new jt(mi(this.ranges[t].anchor),mi(this.ranges[t].head));return new Wr(e,this.primIndex)},Wr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Wr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(St(t,r.from())>=0&&St(e,r.to())<=0)return i}return-1};var jt=function(e,t){this.anchor=e,this.head=t};jt.prototype.from=function(){return vi(this.anchor,this.head)},jt.prototype.to=function(){return gi(this.anchor,this.head)},jt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Jr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(ke,Ae){return St(ke.from(),Ae.from())}),i=ae(t,n);for(var S=1;S<t.length;S++){var j=t[S],X=t[S-1],J=St(X.to(),j.from());if(r&&!j.empty()?J>0:J>=0){var q=vi(X.from(),j.from()),he=gi(X.to(),j.to()),fe=X.empty()?j.from()==j.head:X.from()==X.head;S<=i&&--i,t.splice(--S,2,new jt(fe?he:q,fe?q:he))}}return new Wr(t,i)}function wi(e,t){return new Wr([new jt(e,t||e)],0)}function Ai(e){return e.text?Xe(e.from.line+e.text.length-1,te(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Oo(e,t){if(St(e,t.from)<0)return e;if(St(e,t.to)<=0)return Ai(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+=Ai(t).ch-t.to.ch),Xe(i,r)}function Oa(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new jt(Oo(n.anchor,t),Oo(n.head,t)))}return Jr(e.cm,i,e.sel.primIndex)}function _o(e,t,i){return e.line==t.line?Xe(i.line,e.ch-t.ch+i.ch):Xe(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Xe(e.first,0),S=n,j=0;j<t.length;j++){var X=t[j],J=_o(X.from,n,S),q=_o(Ai(X),n,S);if(n=X.to,S=q,i=="around"){var he=e.sel.ranges[j],fe=St(he.head,he.anchor)<0;r[j]=new jt(fe?q:J,fe?J:q)}else r[j]=new jt(J,J)}return new Wr(r,e.sel.primIndex)}function _a(e){e.doc.mode=Nr(e.options,e.doc.modeOption),An(e)}function An(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&&Ar(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&te(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(ot){return i?i[ot]:null}function S(ot,et,st){ua(ot,et,st,r),cr(ot,"change",ot,t)}function j(ot,et){for(var st=[],Et=ot;Et<et;++Et)st.push(new Pi(q[Et],n(Et),r));return st}var X=t.from,J=t.to,q=t.text,he=dt(e,X.line),fe=dt(e,J.line),ke=te(q),Ae=n(q.length-1),Be=J.line-X.line;if(t.full)e.insert(0,j(0,q.length)),e.remove(q.length,e.size-q.length);else if(Po(e,t)){var ze=j(0,q.length-1);S(fe,fe.text,Ae),Be&&e.remove(X.line,Be),ze.length&&e.insert(X.line,ze)}else if(he==fe)if(q.length==1)S(he,he.text.slice(0,X.ch)+ke+he.text.slice(J.ch),Ae);else{var Ye=j(1,q.length-1);Ye.push(new Pi(ke+he.text.slice(J.ch),Ae,r)),S(he,he.text.slice(0,X.ch)+q[0],n(0)),e.insert(X.line+1,Ye)}else if(q.length==1)S(he,he.text.slice(0,X.ch)+q[0]+fe.text.slice(J.ch),n(0)),e.remove(X.line+1,Be);else{S(he,he.text.slice(0,X.ch)+q[0],n(0)),S(fe,ke+fe.text.slice(J.ch),Ae);var qe=j(1,q.length-1);Be>1&&e.remove(X.line+1,Be-1),e.insert(X.line+1,qe)}cr(e,"change",e,t)}function Li(e,t,i){function r(n,S,j){if(n.linked)for(var X=0;X<n.linked.length;++X){var J=n.linked[X];if(J.doc==S)continue;var q=j&&J.sharedHist;if(i&&!q)continue;t(J.doc,q),r(J.doc,n,q)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),_a(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Ar(e)}function Io(e){(e.doc.direction=="rtl"?U:p)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Pr(e,function(){Io(e),Ar(e)})}function Zn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var i={from:mi(t.from),to:Ai(t),text:Hr(e,t.from,t.to)};return Bo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Bo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=te(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),te(e.done);if(e.done.length&&!te(e.done).ranges)return te(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),te(e.done)}function Fo(e,t,i,r){var n=e.history;n.undone.length=0;var S=+new Date,j,X;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>S-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(j=pl(n,n.lastOp==r)))X=te(j.changes),St(t.from,t.to)==0&&St(t.from,X.to)==0?X.to=Ai(t):j.changes.push(Ma(e,t));else{var J=te(n.done);for((!J||!J.ranges)&&Jn(e.sel,n.done),j={changes:[Ma(e,t)],generation:n.generation},n.done.push(j);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=S,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,X||Fe(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,S=r&&r.origin;i==n.lastSelOp||S&&n.lastSelOrigin==S&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==S||ml(e,S,te(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=S,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Jn(e,t){var i=te(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Bo(e,t,i,r){var n=t["spans_"+e.id],S=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(j){j.markedSpans&&((n||(n=t["spans_"+e.id]={}))[S]=j.markedSpans),++S})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var S=i[n],j=r[n];if(S&&j){e:for(var X=0;X<j.length;++X){for(var J=j[X],q=0;q<S.length;++q)if(S[q].marker==J.marker)continue e;S.push(J)}}else j&&(i[n]=j)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var S=e[n];if(S.ranges){r.push(i?Wr.prototype.deepCopy.call(S):S);continue}var j=S.changes,X=[];r.push({changes:X});for(var J=0;J<j.length;++J){var q=j[J],he=void 0;if(X.push({from:q.from,to:q.to,text:q.text}),t)for(var fe in q)(he=fe.match(/^spans_(\d+)$/))&&(ae(t,Number(he[1]))>-1&&(te(X)[fe]=q[fe],delete q[fe]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var S=St(t,n)<0;S!=St(i,n)<0?(n=t,t=i):S!=St(t,i)<0&&(t=i)}return new jt(n,t)}else return new jt(i||t,t)}function Qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),br(e,new Wr([Ia(e.sel.primary(),t,i,n)],0),r)}function jo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),S=0;S<e.sel.ranges.length;S++)r[S]=Ia(e.sel.ranges[S],t[S],null,n);var j=Jr(e.cm,r,e.sel.primIndex);br(e,j,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,br(e,Jr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){br(e,wi(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var S=0;S<n.length;S++)this.ranges[S]=new jt(s(e,n[S].anchor),s(e,n[S].head))},origin:i&&i.origin};return Fe(e,"beforeSelectionChange",e,r),e.cm&&Fe(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Jr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=te(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):br(e,t,i)}function br(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(ve(e,"beforeSelectionChange")||e.cm&&ve(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(St(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(e.cm)}function Go(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,xe(e.cm)),cr(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,S=0;S<t.ranges.length;S++){var j=t.ranges[S],X=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[S],J=ea(e,j.anchor,X&&X.anchor,i,r),q=ea(e,j.head,X&&X.head,i,r);(n||J!=j.anchor||q!=j.head)&&(n||(n=t.ranges.slice(0,S)),n[S]=new jt(J,q))}return n?Jr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var S=dt(e,t.line);if(S.markedSpans)for(var j=0;j<S.markedSpans.length;++j){var X=S.markedSpans[j],J=X.marker,q="selectLeft"in J?!J.selectLeft:J.inclusiveLeft,he="selectRight"in J?!J.selectRight:J.inclusiveRight;if((X.from==null||(q?X.from<=t.ch:X.from<t.ch))&&(X.to==null||(he?X.to>=t.ch:X.to>t.ch))){if(n&&(Fe(J,"beforeCursorEnter"),J.explicitlyCleared))if(S.markedSpans){--j;continue}else break;if(!J.atomic)continue;if(i){var fe=J.find(r<0?1:-1),ke=void 0;if((r<0?he:q)&&(fe=Vo(e,fe,-r,fe&&fe.line==t.line?S:null)),fe&&fe.line==t.line&&(ke=St(fe,i))&&(r<0?ke<0:ke>0))return en(e,fe,t,r,n)}var Ae=J.find(r<0?-1:1);return(r<0?q:he)&&(Ae=Vo(e,Ae,r,Ae.line==t.line?S:null)),Ae?en(e,Ae,t,r,n):null}}return t}function ea(e,t,i,r,n){var S=r||1,j=en(e,t,i,S,n)||!n&&en(e,t,i,S,!0)||en(e,t,i,-S,n)||!n&&en(e,t,i,-S,!0);return j||(e.cantEdit=!0,Xe(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Xe(t.line-1)):null:i>0&&t.ch==(r||dt(e,t.line)).text.length?t.line<e.first+e.size-1?Xe(t.line+1,0):null:new Xe(t.line,t.ch+i)}function Xo(e){e.setSelection(Xe(e.firstLine(),0),Xe(e.lastLine()),Se)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,S,j,X){n&&(r.from=s(e,n)),S&&(r.to=s(e,S)),j&&(r.text=j),X!==void 0&&(r.origin=X)}),Fe(e,"beforeChange",e,r),e.cm&&Fe(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 tn(e,t,i){if(e.cm){if(!e.cm.curOp)return or(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((ve(e,"beforeChange")||e.cm&&ve(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Oi&&!i&&bi(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&St(t.from,t.to)==0)return;var i=Oa(e,t);Fo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Yr(e,t));var r=[];Li(e,function(n,S){!S&&ae(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),Ln(n,t,null,Yr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,S,j=e.sel,X=t=="undo"?n.done:n.undone,J=t=="undo"?n.undone:n.done,q=0;q<X.length&&!(S=X[q],i?S.ranges&&!S.equals(e.sel):!S.ranges);q++);if(q==X.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(S=X.pop(),S.ranges){if(Jn(S,J),i&&!S.equals(e.sel)){br(e,S,{clearRedo:!1});return}j=S}else if(r){X.push(S);return}else break;var he=[];Jn(j,J),J.push({changes:he,generation:n.generation}),n.generation=S.generation||++n.maxGeneration;for(var fe=ve(e,"beforeChange")||e.cm&&ve(e.cm,"beforeChange"),ke=function(ze){var Ye=S.changes[ze];if(Ye.origin=t,fe&&!Yo(e,Ye,!1))return X.length=0,{};he.push(Ma(e,Ye));var qe=ze?Oa(e,Ye):te(X);Ln(e,Ye,qe,Uo(e,Ye)),!ze&&e.cm&&e.cm.scrollIntoView({from:Ye.from,to:Ai(Ye)});var ot=[];Li(e,function(et,st){!st&&ae(ot,et.history)==-1&&(qo(et.history,Ye),ot.push(et.history)),Ln(et,Ye,null,Uo(et,Ye))})},Ae=S.changes.length-1;Ae>=0;--Ae){var Be=ke(Ae);if(Be)return Be.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(ce(e.sel.ranges,function(n){return new jt(Xe(n.anchor.line+t,n.anchor.ch),Xe(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Ar(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ti(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return or(e.cm,Ln)(e,t,i,r);if(t.to.line<e.first){Zo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:Xe(e.first,0),to:Xe(t.to.line+n,t.to.ch),text:[te(t.text)],origin:t.origin}}var S=e.lastLine();t.to.line>S&&(t={from:t.from,to:Xe(S,dt(e,S).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Hr(e,t.from,t.to),i||(i=Oa(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),qn(e,i,Se),e.cantEdit&&ea(e,Xe(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,S=t.from,j=t.to,X=!1,J=S.line;e.options.lineWrapping||(J=kt(Er(dt(r,S.line))),r.iter(J,j.line+1,function(Ae){if(Ae==n.maxLine)return X=!0,!0})),r.sel.contains(t.from,t.to)>-1&&xe(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(J,S.line+t.text.length,function(Ae){var Be=pn(Ae);Be>n.maxLineLength&&(n.maxLine=Ae,n.maxLineLength=Be,n.maxLineChanged=!0,X=!1)}),X&&(e.curOp.updateMaxLine=!0)),Xr(r,S.line),Cn(e,400);var q=t.text.length-(j.line-S.line)-1;t.full?Ar(e):S.line==j.line&&t.text.length==1&&!Po(e.doc,t)?Ti(e,S.line,"text"):Ar(e,S.line,j.line+1,q);var he=ve(e,"changes"),fe=ve(e,"change");if(fe||he){var ke={from:S,to:j,text:t.text,removed:t.removed,origin:t.origin};fe&&cr(e,"change",e,ke),he&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(ke)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var S;r||(r=i),St(r,i)<0&&(S=[r,i],i=S[0],r=S[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function Jo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Qo(e,t,i,r){for(var n=0;n<e.length;++n){var S=e[n],j=!0;if(S.ranges){S.copied||(S=e[n]=S.deepCopy(),S.copied=!0);for(var X=0;X<S.ranges.length;X++)Jo(S.ranges[X].anchor,t,i,r),Jo(S.ranges[X].head,t,i,r);continue}for(var J=0;J<S.changes.length;++J){var q=S.changes[J];if(i<q.from.line)q.from=Xe(q.from.line+r,q.from.ch),q.to=Xe(q.to.line+r,q.to.ch);else if(t<=q.to.line){j=!1;break}}j||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function kn(e,t,i,r){var n=t,S=t;return typeof t=="number"?S=dt(e,G(e,t)):n=kt(t),n==null?null:(r(S,n)&&e.cm&&Ti(e.cm,n,i),S)}function Dn(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}Dn.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,pt(n),cr(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 Rn(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}Rn.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 S=Math.min(t,n-e),j=r.height;if(r.removeInner(e,S),this.height-=j-r.height,n==S&&(this.children.splice(i--,1),r.parent=null),(t-=S)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var X=[];this.collapse(X),this.children=[new Dn(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],S=n.chunkSize();if(e<=S){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var j=n.lines.length%25+25,X=j;X<n.lines.length;){var J=new Dn(n.lines.slice(X,X+=25));n.height-=J.height,this.children.splice(++r,0,J),J.parent=this}n.lines=n.lines.slice(0,j),this.maybeSpill()}break}e-=S}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Rn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ae(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Rn(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],S=n.chunkSize();if(e<S){var j=Math.min(t,S-e);if(n.iterN(e,j,i))return!0;if((t-=j)==0)break;e=0}else e-=S}}};var On=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};On.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=kt(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 S=vn(this);mr(i,Math.max(0,i.height-S)),e&&(Pr(e,function(){es(e,i,-S),Ti(e,r,"widget")}),cr(e,"lineWidgetCleared",e,this,r))},On.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=vn(this)-t;if(!n)return;ri(this.doc,r)||mr(r,r.height+n),i&&Pr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,kt(r))})},ye(On);function es(e,t,i){$r(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new On(e,i,r),S=e.cm;return S&&n.noHScroll&&(S.display.alignWidgets=!0),kn(e,t,"widget",function(j){var X=j.widgets||(j.widgets=[]);if(n.insertAt==null?X.push(n):X.splice(Math.min(X.length-1,Math.max(0,n.insertAt)),0,n),n.line=j,S&&!ri(e,j)){var J=$r(j)<e.scrollTop;mr(j,j.height+vn(n)),J&&wa(S,n.height),S.curOp.forceUpdate=!0}return!0}),S&&cr(S,"lineWidgetAdded",S,n,typeof t=="number"?t:kt(t)),n}var ts=0,ki=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};ki.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&ji(e),ve(this,"clear")){var i=this.find();i&&cr(this,"clear",i.from,i.to)}for(var r=null,n=null,S=0;S<this.lines.length;++S){var j=this.lines[S],X=_r(j.markedSpans,this);e&&!this.collapsed?Ti(e,kt(j),"text"):e&&(X.to!=null&&(n=kt(j)),X.from!=null&&(r=kt(j))),j.markedSpans=_i(j.markedSpans,X),X.from==null&&this.collapsed&&!ri(this.doc,j)&&e&&mr(j,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var J=0;J<this.lines.length;++J){var q=Er(this.lines[J]),he=pn(q);he>e.display.maxLineLength&&(e.display.maxLine=q,e.display.maxLineLength=he,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Ar(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&zo(e.doc)),e&&cr(e,"markerCleared",e,this,r,n),t&&Wi(e),this.parent&&this.parent.clear()},ki.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var S=this.lines[n],j=_r(S.markedSpans,this);if(j.from!=null&&(i=Xe(t?S:kt(S),j.from),e==-1))return i;if(j.to!=null&&(r=Xe(t?S:kt(S),j.to),e==1))return r}return i&&{from:i,to:r}},ki.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Pr(r,function(){var n=t.line,S=kt(t.line),j=fa(r,S);if(j&&(no(j),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var X=i.height;i.height=null;var J=vn(i)-X;J&&mr(n,n.height+J)}cr(r,"markerChanged",r,e)})},ki.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ae(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ki.prototype.detachLine=function(e){if(this.lines.splice(ae(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},ye(ki);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return or(e.cm,nn)(e,t,i,r,n);var S=new ki(e,n),j=St(t,i);if(r&&I(r,S,!1),j>0||j==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=b("span",[S.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||S.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(S.widgetNode.insertLeft=!0)),S.collapsed){if(ar(e,t.line,t,i,S)||t.line!=i.line&&ar(e,i.line,t,i,S))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}S.addToHistory&&Fo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var X=t.line,J=e.cm,q;if(e.iter(X,i.line+1,function(fe){J&&S.collapsed&&!J.options.lineWrapping&&Er(fe)==J.display.maxLine&&(q=!0),S.collapsed&&X!=t.line&&mr(fe,0),yi(fe,new si(S,X==t.line?t.ch:null,X==i.line?i.ch:null)),++X}),S.collapsed&&e.iter(t.line,i.line+1,function(fe){ri(e,fe)&&mr(fe,0)}),S.clearOnEnter&&Pe(S,"beforeCursorEnter",function(){return S.clear()}),S.readOnly&&(Ur(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),S.collapsed&&(S.id=++ts,S.atomic=!0),J){if(q&&(J.curOp.updateMaxLine=!0),S.collapsed)Ar(J,t.line,i.line+1);else if(S.className||S.startStyle||S.endStyle||S.css||S.attributes||S.title)for(var he=t.line;he<=i.line;he++)Ti(J,he,"text");S.atomic&&zo(J.doc),cr(J,"markerAdded",J,S)}return S}var _n=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};_n.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();cr(this,"clear")},_n.prototype.find=function(e,t){return this.primary.find(e,t)},ye(_n);function Sl(e,t,i,r,n){r=I(r),r.shared=!1;var S=[nn(e,t,i,r,n)],j=S[0],X=r.widgetNode;return Li(e,function(J){X&&(r.widgetNode=X.cloneNode(!0)),S.push(nn(J,s(J,t),s(J,i),r,n));for(var q=0;q<J.linked.length;++q)if(J.linked[q].isParent)return;j=te(S)}),new _n(S,j)}function rs(e){return e.findMarks(Xe(e.first,0),e.clipPos(Xe(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),S=e.clipPos(n.from),j=e.clipPos(n.to);if(St(S,j)){var X=nn(e,S,j,r.primary,r.primary.type);r.markers.push(X),X.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],S=[n.primary.doc];Li(n.primary.doc,function(J){return S.push(J)});for(var j=0;j<n.markers.length;j++){var X=n.markers[j];ae(S,X.doc)==-1&&(X.parent=null,n.markers.splice(j--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Lr=function(e,t,i,r,n){if(!(this instanceof Lr))return new Lr(e,t,i,r,n);i==null&&(i=0),Rn.call(this,[new Dn([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var S=Xe(i,0);this.sel=wi(S),this.history=new Zn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:S,to:S,text:e}),br(this,wi(S),Se)};Lr.prototype=Oe(Rn.prototype,{constructor:Lr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:sr(function(e){var t=Xe(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Xe(i,dt(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&xn(this.cm,0,0),br(this,wi(t),Se)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=Hr(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(Vr(this,e))return dt(this,e)},getLineNumber:function(e){return kt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=dt(this,e)),Er(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:sr(function(e,t,i){Wo(this,s(this,typeof e=="number"?Xe(e,t||0):e),null,i)}),setSelection:sr(function(e,t,i){Wo(this,s(this,e),s(this,t||e),i)}),extendSelection:sr(function(e,t,i){Qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:sr(function(e,t){jo(this,N(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=ce(this.sel.ranges,e);jo(this,N(this,i),t)}),setSelections:sr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new jt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),br(this,Jr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new jt(s(this,e),s(this,t||e))),br(this,Jr(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=Hr(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=Hr(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:sr(function(e,t,i){for(var r=[],n=this.sel,S=0;S<n.ranges.length;S++){var j=n.ranges[S];r[S]={from:j.from(),to:j.to(),text:this.splitLines(e[S]),origin:i}}for(var X=t&&t!="end"&&cl(this,r,t),J=r.length-1;J>=0;J--)tn(this,r[J]);X?Ho(this,X):this.cm&&Ji(this.cm)}),undo:sr(function(){ta(this,"undo")}),redo:sr(function(){ta(this,"redo")}),undoSelection:sr(function(){ta(this,"undo",!0)}),redoSelection:sr(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 Zn(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:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Zn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:sr(function(e,t,i){return kn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&je(n)&&(r.gutterMarkers=null),!0})}),clearGutter:sr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&kn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,je(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Vr(this,e))return null;if(t=e,e=dt(this,e),!e)return null}else if(t=kt(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:sr(function(e,t,i){return kn(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(E(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:sr(function(e,t,i){return kn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",S=r[n];if(S)if(i==null)r[n]=null;else{var j=S.match(E(i));if(!j)return!1;var X=j.index+j[0].length;r[n]=S.slice(0,j.index)+(!j.index||X==S.length?"":" ")+S.slice(X)||null}else return!1;return!0})}),addLineWidget:sr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(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),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=dt(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(S){var j=S.markedSpans;if(j)for(var X=0;X<j.length;X++){var J=j[X];!(J.to!=null&&n==e.line&&e.ch>=J.to||J.from==null&&n!=e.line||J.from!=null&&n==t.line&&J.from>=t.ch)&&(!i||i(J.marker))&&r.push(J.marker.parent||J.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 S=n.text.length+r;if(S>e)return t=e,!0;e-=S,++i}),s(this,Xe(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 Lr(ei(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new Lr(ei(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Vt&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Li(e,function(n){return r.push(n.id)},!0),e.history=new Zn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(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):Tt(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:sr(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&fl(this.cm)})}),Lr.prototype.eachLine=Lr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),Ve(t,e)||ui(t.display,e))return;re(e),z&&(is=+new Date);var i=Ni(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,S=Array(n),j=0,X=function(){++j==n&&or(t,function(){i=s(t.doc,i);var Ae={from:i,to:i,text:t.doc.splitLines(S.filter(function(Be){return Be!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,Ae),Ho(t.doc,wi(s(t.doc,i),s(t.doc,Ai(Ae))))})()},J=function(Ae,Be){if(t.options.allowDropFileTypes&&ae(t.options.allowDropFileTypes,Ae.type)==-1){X();return}var ze=new FileReader;ze.onerror=function(){return X()},ze.onload=function(){var Ye=ze.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ye)){X();return}S[Be]=Ye,X()},ze.readAsText(Ae)},q=0;q<r.length;q++)J(r[q],q);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 he=e.dataTransfer.getData("Text");if(he){var fe;if(t.state.draggingText&&!t.state.draggingText.copy&&(fe=t.listSelections()),qn(t.doc,wi(i,i)),fe)for(var ke=0;ke<fe.length;++ke)rn(t.doc,"",fe[ke].anchor,fe[ke].head,"drag");t.replaceSelection(he,"around","paste"),t.display.input.focus()}}catch(Ae){}}}function Ll(e,t){if(z&&(!e.state.draggingText||+new Date-is<100)){pe(t);return}if(Ve(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!O){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",A&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),A&&i.parentNode.removeChild(i)}}function kl(e,t){var i=Ni(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),u(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var S=0;S<i.length;S++)e(i[S])})}var os=!1;function Dl(){if(os)return;Rl(),os=!0}function Rl(){var e;Pe(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Ol)},100))}),Pe(window,"blur",function(){return as(Zi)})}function Ol(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={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"},Pn=0;Pn<10;Pn++)Di[Pn+48]=Di[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[Mn+63235]="F"+Mn;var hi={};hi.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"},hi.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"},hi.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"},hi.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"]},hi.default=l?hi.macDefault:hi.pcDefault;function _l(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,S,j=0;j<t.length-1;j++){var X=t[j];if(/^(cmd|meta|m)$/i.test(X))S=!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),S&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=ce(i.split(" "),_l),S=0;S<n.length;S++){var j=void 0,X=void 0;S==n.length-1?(X=n.join(" "),j=r):(X=n.slice(0,S+1).join(" "),j="...");var J=t[X];if(!J)t[X]=j;else if(J!=j)throw new Error("Inconsistent bindings for "+X)}delete e[i]}for(var q in t)e[q]=t[q];return e}function an(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 an(e,t.fallthrough,i,r);for(var S=0;S<t.fallthrough.length;S++){var j=an(e,t.fallthrough[S],i,r);if(j)return j}}}function ss(e){var t=typeof e=="string"?e:Di[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(g?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(g?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(A&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?hi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var S=t(i[n]);r.length&&St(S.from,te(r).to)<=0;){var j=r.pop();if(St(j.from,S.from)<0){S.from=j.from;break}}r.push(S)}Pr(e,function(){for(var X=r.length-1;X>=0;X--)rn(e.doc,"",r[X].from,r[X].to,"+delete");Ji(e)})}function Fa(e,t,i){var r=Me(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ba(e,t,i){var r=Fa(e,t.ch,i);return r==null?null:new Xe(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=tt(i,t.doc.direction);if(S){var j=n<0?te(S):S[0],X=n<0==(j.level==1),J=X?"after":"before",q;if(j.level>0||t.doc.direction=="rtl"){var he=Xi(t,i);q=n<0?i.text.length-1:0;var fe=ni(t,he,q).top;q=Ke(function(ke){return ni(t,he,ke).top==fe},n<0==(j.level==1)?j.from:j.to-1,q),J=="before"&&(q=Fa(i,q,1))}else q=n<0?j.to:j.from;return new Xe(r,q,J)}}return new Xe(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=tt(t,e.doc.direction);if(!n)return Ba(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 S=Qe(n,i.ch,i.sticky),j=n[S];if(e.doc.direction=="ltr"&&j.level%2==0&&(r>0?j.to>i.ch:j.from<i.ch))return Ba(t,i,r);var X=function(qe,ot){return Fa(t,qe instanceof Xe?qe.ch:qe,ot)},J,q=function(qe){return e.options.lineWrapping?(J=J||Xi(e,t),co(e,t,J,qe)):{begin:0,end:t.text.length}},he=q(i.sticky=="before"?X(i,-1):i.ch);if(e.doc.direction=="rtl"||j.level==1){var fe=j.level==1==r<0,ke=X(i,fe?1:-1);if(ke!=null&&(fe?ke<=j.to&&ke<=he.end:ke>=j.from&&ke>=he.begin)){var Ae=fe?"before":"after";return new Xe(i.line,ke,Ae)}}var Be=function(qe,ot,et){for(var st=function(zt,lr){return lr?new Xe(i.line,X(zt,1),"before"):new Xe(i.line,zt,"after")};qe>=0&&qe<n.length;qe+=ot){var Et=n[qe],gt=ot>0==(Et.level!=1),At=gt?et.begin:X(et.end,-1);if(Et.from<=At&&At<Et.to)return st(At,gt);if(At=gt?Et.from:X(Et.to,-1),et.begin<=At&&At<et.end)return st(At,gt)}},ze=Be(S+r,r,he);if(ze)return ze;var Ye=r>0?he.end:X(he.begin,-1);return Ye!=null&&!(r>0&&Ye==t.text.length)&&(ze=Be(r>0?0:n.length-1,r,q(Ye)),ze)?ze:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Se)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=dt(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Xe(t.head.line+1,0)}:{from:t.head,to:Xe(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Xe(t.from().line,0),to:s(e.doc,Xe(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Xe(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return on(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 on(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(Xe(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Xe(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Ce)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Ce)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?ds(e,t.head):r},Ce)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var S=i[n].from(),j=Y(e.getLine(S.line),S.ch,r);t.push(le(r-j%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Pr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,S=dt(e.doc,n.line).text;if(S){if(n.ch==S.length&&(n=new Xe(n.line,n.ch-1)),n.ch>0)n=new Xe(n.line,n.ch+1),e.replaceRange(S.charAt(n.ch-1)+S.charAt(n.ch-2),Xe(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var j=dt(e.doc,n.line-1).text;j&&(n=new Xe(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+j.charAt(j.length-1),Xe(n.line-1,j.length-1),n,"+transpose"))}}i.push(new jt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Pr(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);Ji(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=dt(e.doc,t),r=Er(i);return r!=i&&(t=kt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=dt(e.doc,t),r=Vi(i);return r!=i&&(t=kt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=dt(e.doc,i.line),n=tt(r,e.doc.direction);if(!n||n[0].level==0){var S=Math.max(i.ch,r.text.search(/\S/)),j=t.line==i.line&&t.ch<=S&&t.ch;return Xe(i.line,j?0:S,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[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)!=De}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=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Fl=new ee;function Nn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Fl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&cr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(re(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Bl(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=F(),Ve(t,e))return;z&&W<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);A&&(ja=r?i:null,!r&&i==88&&!Bt&&(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)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;U(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(p(t,"CodeMirror-crosshair"),at(document,"keyup",i),at(document,"mouseover",i))}Pe(document,"keyup",i),Pe(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ve(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Ve(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(A&&i==ja){ja=null,re(e);return}if(A&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Bl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&St(t,this.pos)==0&&i==this.button};var Fn,Bn;function Wl(e,t){var i=+new Date;return Bn&&Bn.compare(i,e,t)?(Fn=Bn=null,"triple"):Fn&&Fn.compare(i,e,t)?(Bn=new Wa(i,e,t),Fn=null,"double"):(Fn=new Wa(i,e,t),Bn=null,"single")}function vs(e){var t=this,i=t.display;if(Ve(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){P||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=_e(e),S=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,S,e))return;n==1?r?zl(t,r,S,e):be(e)==i.scroller&&re(e):n==2?(r&&Qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(k?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var S="Click";return r=="double"?S="Double"+S:r=="triple"&&(S="Triple"+S),S=(t==1?"Left":t==2?"Middle":"Right")+S,Nn(e,ls(S,n),n,function(j){if(typeof j=="string"&&(j=In[j]),!j)return!1;var X=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),X=j(e,i)!=De}finally{e.state.suppressEdits=!1}return X})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var S=d?i.shiftKey&&i.metaKey:i.altKey;n.unit=S?"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 zl(e,t,i,r){z?setTimeout(_(vo,e),0):e.curOp.focus=F();var n=Gl(e,i,r),S=e.doc.sel,j;e.options.dragDrop&&He&&!e.isReadOnly()&&i=="single"&&(j=S.contains(t))>-1&&(St((j=S.ranges[j]).from(),t)<0||t.xRel>0)&&(St(j.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,S=!1,j=or(e,function(q){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,at(n.wrapper.ownerDocument,"mouseup",j),at(n.wrapper.ownerDocument,"mousemove",X),at(n.scroller,"dragstart",J),at(n.scroller,"drop",j),S||(re(q),r.addNew||Qn(e.doc,i,null,null,r.extend),P&&!O||z&&W==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),X=function(q){S=S||Math.abs(t.clientX-q.clientX)+Math.abs(t.clientY-q.clientY)>=10},J=function(){return S=!0};P&&(n.scroller.draggable=!0),e.state.draggingText=j,j.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Pe(n.wrapper.ownerDocument,"mouseup",j),Pe(n.wrapper.ownerDocument,"mousemove",X),Pe(n.scroller,"dragstart",J),Pe(n.scroller,"drop",j),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new jt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new jt(Xe(t.line,0),s(e.doc,Xe(t.line+1,0)));var r=i(e,t);return new jt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,S=e.doc;re(t);var j,X,J=S.sel,q=J.ranges;if(r.addNew&&!r.extend?(X=S.sel.contains(i),X>-1?j=q[X]:j=new jt(i,i)):(j=S.sel.primary(),X=S.sel.primIndex),r.unit=="rectangle")r.addNew||(j=new jt(i,i)),i=Ni(e,t,!0,!0),X=-1;else{var he=ys(e,i,r.unit);r.extend?j=Ia(j,he.anchor,he.head,r.extend):j=he}r.addNew?X==-1?(X=q.length,br(S,Jr(e,q.concat([j]),X),{scroll:!1,origin:"*mouse"})):q.length>1&&q[X].empty()&&r.unit=="char"&&!r.extend?(br(S,Jr(e,q.slice(0,X).concat(q.slice(X+1)),0),{scroll:!1,origin:"*mouse"}),J=S.sel):Na(S,X,j,we):(X=0,br(S,new Wr([j],0),we),J=S.sel);var fe=i;function ke(et){if(St(fe,et)==0)return;if(fe=et,r.unit=="rectangle"){for(var st=[],Et=e.options.tabSize,gt=Y(dt(S,i.line).text,i.ch,Et),At=Y(dt(S,et.line).text,et.ch,Et),zt=Math.min(gt,At),lr=Math.max(gt,At),Yt=Math.min(i.line,et.line),Mr=Math.min(e.lastLine(),Math.max(i.line,et.line));Yt<=Mr;Yt++){var kr=dt(S,Yt).text,er=Te(kr,zt,Et);zt==lr?st.push(new jt(Xe(Yt,er),Xe(Yt,er))):kr.length>er&&st.push(new jt(Xe(Yt,er),Xe(Yt,Te(kr,lr,Et))))}st.length||st.push(new jt(i,i)),br(S,Jr(e,J.ranges.slice(0,X).concat(st),X),{origin:"*mouse",scroll:!1}),e.scrollIntoView(et)}else{var Dr=j,fr=ys(e,et,r.unit),ir=Dr.anchor,tr;St(fr.anchor,ir)>0?(tr=fr.head,ir=vi(Dr.from(),fr.anchor)):(tr=fr.anchor,ir=gi(Dr.to(),fr.head));var $t=J.ranges.slice(0);$t[X]=Xl(e,new jt(s(S,ir),tr)),br(S,Jr(e,$t,X),we)}}var Ae=n.wrapper.getBoundingClientRect(),Be=0;function ze(et){var st=++Be,Et=Ni(e,et,!0,r.unit=="rectangle");if(!Et)return;if(St(Et,fe)!=0){e.curOp.focus=F(),ke(Et);var gt=Vn(n,S);(Et.line>=gt.to||Et.line<gt.from)&&setTimeout(or(e,function(){Be==st&&ze(et)}),150)}else{var At=et.clientY<Ae.top?-20:et.clientY>Ae.bottom?20:0;At&&setTimeout(or(e,function(){if(Be!=st)return;n.scroller.scrollTop+=At,ze(et)}),50)}}function Ye(et){e.state.selectingText=!1,Be=Infinity,et&&(re(et),n.input.focus()),at(n.wrapper.ownerDocument,"mousemove",qe),at(n.wrapper.ownerDocument,"mouseup",ot),S.history.lastSelOrigin=null}var qe=or(e,function(et){et.buttons===0||!_e(et)?Ye(et):ze(et)}),ot=or(e,Ye);e.state.selectingText=ot,Pe(n.wrapper.ownerDocument,"mousemove",qe),Pe(n.wrapper.ownerDocument,"mouseup",ot)}function Xl(e,t){var i=t.anchor,r=t.head,n=dt(e.doc,i.line);if(St(i,r)==0&&i.sticky==r.sticky)return t;var S=tt(n);if(!S)return t;var j=Qe(S,i.ch,i.sticky),X=S[j];if(X.from!=i.ch&&X.to!=i.ch)return t;var J=j+(X.from==i.ch==(X.level!=1)?0:1);if(J==0||J==S.length)return t;var q;if(r.line!=i.line)q=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var he=Qe(S,r.ch,r.sticky),fe=he-j||(r.ch-i.ch)*(X.level==1?-1:1);he==J-1||he==J?q=fe<0:q=fe>0}var ke=S[J+(q?-1:0)],Ae=q==(ke.level==1),Be=Ae?ke.from:ke.to,ze=Ae?"after":"before";return i.ch==Be&&i.sticky==ze?t:new jt(new Xe(i.line,Be,ze),r)}function bs(e,t,i,r){var n,S;if(t.touches)n=t.touches[0].clientX,S=t.touches[0].clientY;else try{n=t.clientX,S=t.clientY}catch(ke){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&re(t);var j=e.display,X=j.lineDiv.getBoundingClientRect();if(S>X.bottom||!ve(e,i))return ue(t);S-=X.top-j.viewOffset;for(var J=0;J<e.display.gutterSpecs.length;++J){var q=j.gutters.childNodes[J];if(q&&q.getBoundingClientRect().right>=n){var he=Br(e.doc,S),fe=e.display.gutterSpecs[J];return Fe(e,i,e,he,fe.className,t),ue(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Ve(e,t,"contextmenu"))return;k||e.display.input.onContextMenu(t)}function Yl(e,t){return ve(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,S,j){e.defaults[r]=n,S&&(t[r]=j?function(X,J,q){q!=sn&&S(X,J,q)}:S)}e.defineOption=i,e.Init=sn,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,_a(r)},!0),i("indentUnit",2,_a,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){An(r),yn(r),Ar(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var S=[],j=r.doc.first;r.doc.iter(function(J){for(var q=0;;){var he=J.text.indexOf(n,q);if(he==-1)break;q=he+n.length,S.push(Xe(j,he))}j++});for(var X=S.length-1;X>=0;X--)rn(r.doc,n,S[X],Xe(S[X].line,S[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,S){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),S!=sn&&r.refresh()}),i("specialCharPlaceholder",Gt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!w),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,S){var j=ia(n),X=S!=sn&&ia(S);X&&X.detach&&X.detach(r,j),j.attach&&j.attach(r,X||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Ra(n,r.options.lineNumbers),wn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Qi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Qi(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=Ra(r.options.gutters,n),wn(r)},!0),i("firstLineNumber",1,wn,!0),i("lineNumberFormatter",function(r){return r},wn,!0),i("showCursorWhenSelecting",!1,bn,!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,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,bn,!0),i("singleCursorHeightPerLine",!0,bn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,An,!0),i("addModeClass",!1,An,!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,An,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,S=t?Pe:at;S(e.display.scroller,"dragstart",n.start),S(e.display.scroller,"dragenter",n.enter),S(e.display.scroller,"dragover",n.over),S(e.display.scroller,"dragleave",n.leave),S(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(U(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(p(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Ea(e),Ar(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Vt(e,t){var i=this;if(!(this instanceof Vt))return new Vt(e,t);this.options=t=t?I(t):{},I(Ss,t,!1);var r=t.value;typeof r=="string"?r=new Lr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Vt.inputStyles[t.inputStyle](this),S=this.display=new hl(e,r,n,t);S.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Co(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new ee,keySeq:null,specialChars:null},t.autofocus&&!o&&S.input.focus(),z&&W<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var j in aa)aa.hasOwnProperty(j)&&aa[j](this,t[j],sn);Lo(this),t.finishInit&&t.finishInit(this);for(var X=0;X<Ga.length;++X)Ga[X](this);Wi(this),P&&t.lineWrapping&&getComputedStyle(S.lineDiv).textRendering=="optimizelegibility"&&(S.lineDiv.style.textRendering="auto")}Vt.defaults=Ss,Vt.optionHandlers=aa;function Ql(e){var t=e.display;Pe(t.scroller,"mousedown",or(e,vs)),z&&W<11?Pe(t.scroller,"dblclick",or(e,function(J){if(Ve(e,J))return;var q=Ni(e,J);if(!q||Ha(e,J)||ui(e.display,J))return;re(J);var he=e.findWordAt(q);Qn(e.doc,he.anchor,he.head)})):Pe(t.scroller,"dblclick",function(J){return Ve(e,J)||re(J)}),Pe(t.scroller,"contextmenu",function(J){return xs(e,J)}),Pe(t.input.getField(),"contextmenu",function(J){t.scroller.contains(J.target)||xs(e,J)});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 S(J){if(J.touches.length!=1)return!1;var q=J.touches[0];return q.radiusX<=1&&q.radiusY<=1}function j(J,q){if(q.left==null)return!0;var he=q.left-J.left,fe=q.top-J.top;return he*he+fe*fe>20*20}Pe(t.scroller,"touchstart",function(J){if(!Ve(e,J)&&!S(J)&&!Ha(e,J)){t.input.ensurePolled(),clearTimeout(i);var q=+new Date;t.activeTouch={start:q,moved:!1,prev:q-r.end<=300?r:null},J.touches.length==1&&(t.activeTouch.left=J.touches[0].pageX,t.activeTouch.top=J.touches[0].pageY)}}),Pe(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Pe(t.scroller,"touchend",function(J){var q=t.activeTouch;if(q&&!ui(t,J)&&q.left!=null&&!q.moved&&new Date-q.start<300){var he=e.coordsChar(t.activeTouch,"page"),fe;!q.prev||j(q,q.prev)?fe=new jt(he,he):!q.prev.prev||j(q,q.prev.prev)?fe=e.findWordAt(he):fe=new jt(Xe(he.line,0),s(e.doc,Xe(he.line+1,0))),e.setSelection(fe.anchor,fe.head),e.focus(),re(J)}n()}),Pe(t.scroller,"touchcancel",n),Pe(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Bi(e,t.scroller.scrollLeft,!0),Fe(e,"scroll",e))}),Pe(t.scroller,"mousewheel",function(J){return Ro(e,J)}),Pe(t.scroller,"DOMMouseScroll",function(J){return Ro(e,J)}),Pe(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(J){Ve(e,J)||pe(J)},over:function(J){Ve(e,J)||(kl(e,J),pe(J))},start:function(J){return Ll(e,J)},drop:or(e,Al),leave:function(J){Ve(e,J)||ns(e)}};var X=t.input.getField();Pe(X,"keyup",function(J){return ms.call(e,J)}),Pe(X,"keydown",or(e,ps)),Pe(X,"keypress",or(e,gs)),Pe(X,"focus",function(J){return Ta(e,J)}),Pe(X,"blur",function(J){return Zi(e,J)})}var Ga=[];Vt.defineInitHook=function(e){return Ga.push(e)};function Un(e,t,i,r){var n=e.doc,S;i==null&&(i="add"),i=="smart"&&(n.mode.indent?S=Je(e,t).state:i="prev");var j=e.options.tabSize,X=dt(n,t),J=Y(X.text,null,j);X.stateAfter&&(X.stateAfter=null);var q=X.text.match(/^\s*/)[0],he;if(!r&&!/\S/.test(X.text))he=0,i="not";else if(i=="smart"&&(he=n.mode.indent(S,X.text.slice(q.length),X.text),he==De||he>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?he=Y(dt(n,t-1).text,null,j):he=0:i=="add"?he=J+e.options.indentUnit:i=="subtract"?he=J-e.options.indentUnit:typeof i=="number"&&(he=J+i),he=Math.max(0,he);var fe="",ke=0;if(e.options.indentWithTabs)for(var Ae=Math.floor(he/j);Ae;--Ae)ke+=j,fe+=" ";if(ke<he&&(fe+=le(he-ke)),fe!=q)return rn(n,fe,Xe(t,0),Xe(t,q.length),"+input"),X.stateAfter=null,!0;for(var Be=0;Be<n.sel.ranges.length;Be++){var ze=n.sel.ranges[Be];if(ze.head.line==t&&ze.head.ch<q.length){var Ye=Xe(t,q.length);Na(n,Be,new jt(Ye,Ye));break}}}var Qr=null;function oa(e){Qr=e}function za(e,t,i,r,n){var S=e.doc;e.display.shift=!1,r||(r=S.sel);var j=+new Date-200,X=n=="paste"||e.state.pasteIncoming>j,J=Tt(t),q=null;if(X&&r.ranges.length>1)if(Qr&&Qr.text.join(`
`)==t){if(r.ranges.length%Qr.text.length==0){q=[];for(var he=0;he<Qr.text.length;he++)q.push(S.splitLines(Qr.text[he]))}}else J.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(q=ce(J,function(qe){return[qe]}));for(var fe=e.curOp.updateInput,ke=r.ranges.length-1;ke>=0;ke--){var Ae=r.ranges[ke],Be=Ae.from(),ze=Ae.to();Ae.empty()&&(i&&i>0?Be=Xe(Be.line,Be.ch-i):e.state.overwrite&&!X?ze=Xe(ze.line,Math.min(dt(S,ze.line).text.length,ze.ch+te(J).length)):X&&Qr&&Qr.lineWise&&Qr.text.join(`
`)==J.join(`
`)&&(Be=ze=Xe(Be.line,0)));var Ye={from:Be,to:ze,text:q?q[ke%q.length]:J,origin:n||(X?"paste":e.state.cutIncoming>j?"cut":"+input")};tn(e.doc,Ye),cr(e,"inputRead",e,Ye)}t&&!X&&Cs(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=fe),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ts(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Pr(t,function(){return za(t,i,0,null,"paste")}),!0}function Cs(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var S=e.getModeAt(n.head),j=!1;if(S.electricChars){for(var X=0;X<S.electricChars.length;X++)if(t.indexOf(S.electricChars.charAt(X))>-1){j=Un(e,n.head.line,"smart");break}}else S.electricInput&&(S.electricInput.test(dt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(j=Un(e,n.head.line,"smart")));j&&cr(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,S={anchor:Xe(n,0),head:Xe(n+1,0)};i.push(S),t.push(e.getRange(S.anchor,S.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return P?e.style.width="1000px":e.setAttribute("wrap","off"),T&&(e.style.border="1px solid black"),As(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var S=this.options,j=S[r];if(S[r]==n&&r!="mode")return;S[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,j),Fe(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,S=0;S<n.length;++S)if(n[S]==r||n[S].name==r)return n.splice(S,1),!0},addOverlay:Sr(function(r,n){var S=r.token?r:e.getMode(this.options,r);if(S.startState)throw new Error("Overlays may not be stateful.");ne(this.state.overlays,{mode:S,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(j){return j.priority}),this.state.modeGen++,Ar(this)}),removeOverlay:Sr(function(r){for(var n=this.state.overlays,S=0;S<n.length;++S){var j=n[S].modeSpec;if(j==r||typeof r=="string"&&j.name==r){n.splice(S,1),this.state.modeGen++,Ar(this);return}}}),indentLine:Sr(function(r,n,S){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Un(this,r,n,S)}),indentSelection:Sr(function(r){for(var n=this.doc.sel.ranges,S=-1,j=0;j<n.length;j++){var X=n[j];if(X.empty())X.head.line>S&&(Un(this,X.head.line,r,!0),S=X.head.line,j==this.doc.sel.primIndex&&Ji(this));else{var J=X.from(),q=X.to(),he=Math.max(S,J.line);S=Math.min(this.lastLine(),q.line-(q.ch?0:1))+1;for(var fe=he;fe<S;++fe)Un(this,fe,r);var ke=this.doc.sel.ranges;J.ch==0&&n.length==ke.length&&ke[j].from().ch>0&&Na(this.doc,j,new jt(J,ke[j].to()),Se)}}}),getTokenAt:function(r,n){return Kt(this,r,n)},getLineTokens:function(r,n){return Kt(this,Xe(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=We(this,dt(this.doc,r.line)),S=0,j=(n.length-1)/2,X=r.ch,J;if(X==0)J=n[2];else for(;;){var q=S+j>>1;if((q?n[q*2-1]:0)>=X)j=q;else if(n[q*2+1]<X)S=q+1;else{J=n[q*2+2];break}}var he=J?J.indexOf("overlay "):-1;return he<0?J:he==0?null:J.slice(0,he-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 S=[];if(!i.hasOwnProperty(n))return S;var j=i[n],X=this.getModeAt(r);if(typeof X[n]=="string")j[X[n]]&&S.push(j[X[n]]);else if(X[n])for(var J=0;J<X[n].length;J++){var q=j[X[n][J]];q&&S.push(q)}else X.helperType&&j[X.helperType]?S.push(j[X.helperType]):j[X.name]&&S.push(j[X.name]);for(var he=0;he<j._global.length;he++){var fe=j._global[he];fe.pred(X,this)&&ae(S,fe.val)==-1&&S.push(fe.val)}return S},getStateAfter:function(r,n){var S=this.doc;return r=G(S,r==null?S.first+S.size-1:r),Je(this,r+1,n).state},cursorCoords:function(r,n){var S,j=this.doc.sel.primary();return r==null?S=j.head:typeof r=="object"?S=s(this.doc,r):S=r?j.from():j.to(),Zr(this,S,n||"page")},charCoords:function(r,n){return ma(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,Br(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,S){var j=!1,X;if(typeof r=="number"){var J=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>J&&(r=J,j=!0),X=dt(this.doc,r)}else X=r;return Hn(this,X,{top:0,left:0},n||"page",S||j).top+(j?this.doc.height-$r(X):0)},defaultTextHeight:function(){return Yi(this.display)},defaultCharWidth:function(){return $i(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,S,j,X){var J=this.display;r=Zr(this,s(this.doc,r));var q=r.bottom,he=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),J.sizer.appendChild(n),j=="over")q=r.top;else if(j=="above"||j=="near"){var fe=Math.max(J.wrapper.clientHeight,this.doc.height),ke=Math.max(J.sizer.clientWidth,J.lineSpace.clientWidth);(j=="above"||r.bottom+n.offsetHeight>fe)&&r.top>n.offsetHeight?q=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=fe&&(q=r.bottom),he+n.offsetWidth>ke&&(he=ke-n.offsetWidth)}n.style.top=q+"px",n.style.left=n.style.right="",X=="right"?(he=J.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(X=="left"?he=0:X=="middle"&&(he=(J.sizer.clientWidth-n.offsetWidth)/2),n.style.left=he+"px"),S&&Zs(this,{left:he,top:q,right:he+n.offsetWidth,bottom:q+n.offsetHeight})},triggerOnKeyDown:Sr(ps),triggerOnKeyPress:Sr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Sr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Sr(function(r){Cs(this,r)}),findPosH:function(r,n,S,j){var X=1;n<0&&(X=-1,n=-n);for(var J=s(this.doc,r),q=0;q<n&&!(J=Ka(this.doc,J,X,S,j),J.hitSide);++q);return J},moveH:Sr(function(r,n){var S=this;this.extendSelectionsBy(function(j){return S.display.shift||S.doc.extend||j.empty()?Ka(S.doc,j.head,r,n,S.options.rtlMoveVisually):r<0?j.from():j.to()},Ce)}),deleteH:Sr(function(r,n){var S=this.doc.sel,j=this.doc;S.somethingSelected()?j.replaceSelection("",null,"+delete"):on(this,function(X){var J=Ka(j,X.head,r,n,!1);return r<0?{from:J,to:X.head}:{from:X.head,to:J}})}),findPosV:function(r,n,S,j){var X=1,J=j;n<0&&(X=-1,n=-n);for(var q=s(this.doc,r),he=0;he<n;++he){var fe=Zr(this,q,"div");if(J==null?J=fe.left:fe.left=J,q=ks(this,fe,X,S),q.hitSide)break}return q},moveV:Sr(function(r,n){var S=this,j=this.doc,X=[],J=!this.display.shift&&!j.extend&&j.sel.somethingSelected();if(j.extendSelectionsBy(function(he){if(J)return r<0?he.from():he.to();var fe=Zr(S,he.head,"div");he.goalColumn!=null&&(fe.left=he.goalColumn),X.push(fe.left);var ke=ks(S,fe,r,n);return n=="page"&&he==j.sel.primary()&&wa(S,ma(S,ke,"div").top-fe.top),ke},Ce),X.length)for(var q=0;q<j.sel.ranges.length;q++)j.sel.ranges[q].goalColumn=X[q]}),findWordAt:function(r){var n=this.doc,S=dt(n,r.line).text,j=r.ch,X=r.ch;if(S){var J=this.getHelper(r,"wordChars");(r.sticky=="before"||X==S.length)&&j?--j:++X;for(var q=S.charAt(j),he=Ne(q,J)?function(fe){return Ne(fe,J)}:/\s/.test(q)?function(fe){return/\s/.test(fe)}:function(fe){return!/\s/.test(fe)&&!Ne(fe)};j>0&&he(S.charAt(j-1));)--j;for(;X<S.length&&he(S.charAt(X));)++X}return new jt(Xe(r.line,j),Xe(r.line,X))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?U(this.display.cursorDiv,"CodeMirror-overwrite"):p(this.display.cursorDiv,"CodeMirror-overwrite"),Fe(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==F()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Sr(function(r,n){xn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ii(this)-this.display.barHeight,width:r.scrollWidth-ii(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Mi(this)}},scrollIntoView:Sr(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:Xe(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Js(this,r):xo(this,r.from,r.to,r.margin)}),setSize:Sr(function(r,n){var S=this,j=function(J){return typeof J=="number"||/^\d+$/.test(String(J))?J+"px":J};r!=null&&(this.display.wrapper.style.width=j(r)),n!=null&&(this.display.wrapper.style.height=j(n)),this.options.lineWrapping&&ao(this);var X=this.display.viewFrom;this.doc.iter(X,this.display.viewTo,function(J){if(J.widgets){for(var q=0;q<J.widgets.length;q++)if(J.widgets[q].noHScroll){Ti(S,X,"widget");break}}++X}),this.curOp.forceUpdate=!0,Fe(this,"refresh",this)}),operation:function(r){return Pr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Sr(function(){var r=this.display.cachedTextHeight;Ar(this),this.curOp.forceUpdate=!0,yn(this),xn(this,this.doc.scrollLeft,this.doc.scrollTop),ka(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Ea(this),Fe(this,"refresh",this)}),swapDoc:Sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yn(this),this.display.input.reset(),xn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,cr(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}},ye(e),e.registerHelper=function(r,n,S){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=S},e.registerGlobalHelper=function(r,n,S,j){e.registerHelper(r,n,j),i[r]._global.push({pred:S,val:j})}}function Ka(e,t,i,r,n){var S=t,j=i,X=dt(e,t.line),J=n&&e.direction=="rtl"?-i:i;function q(){var ot=t.line+J;return ot<e.first||ot>=e.first+e.size?!1:(t=new Xe(ot,t.ch,t.sticky),X=dt(e,ot))}function he(ot){var et;if(r=="codepoint"){var st=X.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(st)?et=null:et=new Xe(t.line,Math.max(0,Math.min(X.text.length,t.ch+i*(st>=55296&&st<56320?2:1))),-i)}else n?et=Ml(e.cm,X,t,i):et=Ba(X,t,i);if(et==null)if(!ot&&q())t=Ua(n,e.cm,X,t.line,J);else return!1;else t=et;return!0}if(r=="char"||r=="codepoint")he();else if(r=="column")he(!0);else if(r=="word"||r=="group")for(var fe=null,ke=r=="group",Ae=e.cm&&e.cm.getHelper(t,"wordChars"),Be=!0;!(i<0&&!he(!Be));Be=!1){var ze=X.text.charAt(t.ch)||`
`,Ye=Ne(ze,Ae)?"w":ke&&ze==`
`?"n":!ke||/\s/.test(ze)?null:"p";if(ke&&!Be&&!Ye&&(Ye="s"),fe&&fe!=Ye){i<0&&(i=1,he(),t.sticky="after");break}if(Ye&&(fe=Ye),i>0&&!he(!Be))break}var qe=ea(e,t,S,j,!0);return pi(S,qe)&&(qe.hitSide=!0),qe}function ks(e,t,i,r){var n=e.doc,S=t.left,j;if(r=="page"){var X=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),J=Math.max(X-.5*Yi(e.display),3);j=(i>0?t.bottom:t.top)+i*J}else r=="line"&&(j=i>0?t.bottom+3:t.top-3);for(var q;!(q=va(e,S,j),!q.outside);){if(i<0?j<=0:j>=n.height){q.hitSide=!0;break}j+=i*5}return q}var Ht=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ee,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ht.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function S(X){for(var J=X.target;J;J=J.parentNode){if(J==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(J.className))break}return!1}Pe(n,"paste",function(X){if(!S(X)||Ve(r,X)||Ts(X,r))return;W<=11&&setTimeout(or(r,function(){return t.updateFromDOM()}),20)}),Pe(n,"compositionstart",function(X){t.composing={data:X.data,done:!1}}),Pe(n,"compositionupdate",function(X){t.composing||(t.composing={data:X.data,done:!1})}),Pe(n,"compositionend",function(X){t.composing&&(X.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Pe(n,"touchstart",function(){return i.forceCompositionEnd()}),Pe(n,"input",function(){t.composing||t.readFromDOMSoon()});function j(X){if(!S(X)||Ve(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 J=ws(r);oa({lineWise:!0,text:J.text}),X.type=="cut"&&r.operation(function(){r.setSelections(J.ranges,0,Se),r.replaceSelection("",null,"cut")})}else return;if(X.clipboardData){X.clipboardData.clearData();var q=Qr.text.join(`
`);if(X.clipboardData.setData("Text",q),X.clipboardData.getData("Text")==q){X.preventDefault();return}}var he=Ls(),fe=he.firstChild;r.display.lineSpace.insertBefore(he,r.display.lineSpace.firstChild),fe.value=Qr.text.join(`
`);var ke=document.activeElement;V(fe),setTimeout(function(){r.display.lineSpace.removeChild(he),ke.focus(),ke==n&&i.showPrimarySelection()},50)}Pe(n,"copy",j),Pe(n,"cut",j)},Ht.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ht.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Ht.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Ht.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ht.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 S=sa(t,e.anchorNode,e.anchorOffset),j=sa(t,e.focusNode,e.focusOffset);if(S&&!S.bad&&j&&!j.bad&&St(vi(S,j),r)==0&&St(gi(S,j),n)==0)return;var X=t.display.view,J=r.line>=t.display.viewFrom&&Ds(t,r)||{node:X[0].measure.map[2],offset:0},q=n.line<t.display.viewTo&&Ds(t,n);if(!q){var he=X[X.length-1].measure,fe=he.maps?he.maps[he.maps.length-1]:he.map;q={node:fe[fe.length-1],offset:fe[fe.length-2]-fe[fe.length-3]}}if(!J||!q){e.removeAllRanges();return}var ke=e.rangeCount&&e.getRangeAt(0),Ae;try{Ae=m(J.node,J.offset,q.offset,q.node)}catch(Be){}Ae&&(!D&&t.state.focused?(e.collapse(J.node,J.offset),Ae.collapsed||(e.removeAllRanges(),e.addRange(Ae))):(e.removeAllRanges(),e.addRange(Ae)),ke&&e.anchorNode==null?e.addRange(ke):D&&this.startGracePeriod()),this.rememberSelection()},Ht.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)},Ht.prototype.showMultipleSelections=function(e){u(this.cm.display.cursorDiv,e.cursors),u(this.cm.display.selectionDiv,e.selection)},Ht.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ht.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return x(this.div,t)},Ht.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ht.prototype.blur=function(){this.div.blur()},Ht.prototype.getField=function(){return this.div},Ht.prototype.supportsTouch=function(){return!0},Ht.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Pr(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)},Ht.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ht.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(h&&y&&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&&Pr(t,function(){br(t.doc,wi(i,r),Se),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Ht.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=Xe(r.line-1,dt(e.doc,r.line-1).length)),n.ch==dt(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Xe(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var S,j,X;r.line==t.viewFrom||(S=Fi(e,r.line))==0?(j=kt(t.view[0].line),X=t.view[0].node):(j=kt(t.view[S].line),X=t.view[S-1].node.nextSibling);var J=Fi(e,n.line),q,he;if(J==t.view.length-1?(q=t.viewTo-1,he=t.lineDiv.lastChild):(q=kt(t.view[J+1].line)-1,he=t.view[J+1].node.previousSibling),!X)return!1;for(var fe=e.doc.splitLines(tu(e,X,he,j,q)),ke=Hr(e.doc,Xe(j,0),Xe(q,dt(e.doc,q).text.length));fe.length>1&&ke.length>1;)if(te(fe)==te(ke))fe.pop(),ke.pop(),q--;else if(fe[0]==ke[0])fe.shift(),ke.shift(),j++;else break;for(var Ae=0,Be=0,ze=fe[0],Ye=ke[0],qe=Math.min(ze.length,Ye.length);Ae<qe&&ze.charCodeAt(Ae)==Ye.charCodeAt(Ae);)++Ae;for(var ot=te(fe),et=te(ke),st=Math.min(ot.length-(fe.length==1?Ae:0),et.length-(ke.length==1?Ae:0));Be<st&&ot.charCodeAt(ot.length-Be-1)==et.charCodeAt(et.length-Be-1);)++Be;if(fe.length==1&&ke.length==1&&j==r.line)for(;Ae&&Ae>r.ch&&ot.charCodeAt(ot.length-Be-1)==et.charCodeAt(et.length-Be-1);)Ae--,Be++;fe[fe.length-1]=ot.slice(0,ot.length-Be).replace(/^\u200b+/,""),fe[0]=fe[0].slice(Ae).replace(/\u200b+$/,"");var Et=Xe(j,Ae),gt=Xe(q,ke.length?te(ke).length-Be:0);if(fe.length>1||fe[0]||St(Et,gt))return rn(e.doc,fe,Et,gt,"+input"),!0},Ht.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ht.prototype.reset=function(){this.forceCompositionEnd()},Ht.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Ht.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)},Ht.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Pr(this.cm,function(){return Ar(e.cm)})},Ht.prototype.setUneditable=function(e){e.contentEditable="false"},Ht.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||or(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Ht.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Ht.prototype.onContextMenu=function(){},Ht.prototype.resetPosition=function(){},Ht.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=dt(e.doc,t.line),n=eo(i,r,t.line),S=tt(r,e.doc.direction),j="left";if(S){var X=Qe(S,t.ch);j=X%2?"right":"left"}var J=io(n.map,t.ch,j);return J.offset=J.collapse=="right"?J.end:J.start,J}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var S="",j=!1,X=e.doc.lineSeparator(),J=!1;function q(Ae){return function(Be){return Be.id==Ae}}function he(){j&&(S+=X,J&&(S+=X),j=J=!1)}function fe(Ae){Ae&&(he(),S+=Ae)}function ke(Ae){if(Ae.nodeType==1){var Be=Ae.getAttribute("cm-text");if(Be){fe(Be);return}var ze=Ae.getAttribute("cm-marker"),Ye;if(ze){var qe=e.findMarks(Xe(r,0),Xe(n+1,0),q(+ze));qe.length&&(Ye=qe[0].find(0))&&fe(Hr(e.doc,Ye.from,Ye.to).join(X));return}if(Ae.getAttribute("contenteditable")=="false")return;var ot=/^(pre|div|p|li|table|br)$/i.test(Ae.nodeName);if(!/^br$/i.test(Ae.nodeName)&&Ae.textContent.length==0)return;ot&&he();for(var et=0;et<Ae.childNodes.length;et++)ke(Ae.childNodes[et]);/^(pre|p)$/i.test(Ae.nodeName)&&(J=!0),ot&&(j=!0)}else Ae.nodeType==3&&fe(Ae.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(ke(t),t==i);)t=t.nextSibling,J=!1;return S}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(Xe(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 S=e.display.view[n];if(S.node==r)return ru(S,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!x(r,t))return ln(Xe(kt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var S=e.rest?te(e.rest):e.line;return ln(Xe(kt(S),S.text.length),n)}var j=t.nodeType==3?t:null,X=t;for(!j&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(j=t.firstChild,i&&(i=j.nodeValue.length));X.parentNode!=r;)X=X.parentNode;var J=e.measure,q=J.maps;function he(Ye,qe,ot){for(var et=-1;et<(q?q.length:0);et++)for(var st=et<0?J.map:q[et],Et=0;Et<st.length;Et+=3){var gt=st[Et+2];if(gt==Ye||gt==qe){var At=kt(et<0?e.line:e.rest[et]),zt=st[Et]+ot;return(ot<0||gt!=Ye)&&(zt=st[Et+(ot?1:0)]),Xe(At,zt)}}}var fe=he(j,X,i);if(fe)return ln(fe,n);for(var ke=X.nextSibling,Ae=j?j.nodeValue.length-i:0;ke;ke=ke.nextSibling){if(fe=he(ke,ke.firstChild,0),fe)return ln(Xe(fe.line,fe.ch-Ae),n);Ae+=ke.textContent.length}for(var Be=X.previousSibling,ze=i;Be;Be=Be.previousSibling){if(fe=he(Be,Be.firstChild,-1),fe)return ln(Xe(fe.line,fe.ch+ze),n);ze+=Be.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ee,this.hasSelection=!1,this.composing=null};Qt.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),T&&(n.style.width="0px"),Pe(n,"input",function(){z&&W>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Pe(n,"paste",function(j){if(Ve(r,j)||Ts(j,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(j){if(Ve(r,j))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var X=ws(r);oa({lineWise:!0,text:X.text}),j.type=="cut"?r.setSelections(X.ranges,null,Se):(i.prevInput="",n.value=X.text.join(`
`),V(n))}else return;j.type=="cut"&&(r.state.cutIncoming=+new Date)}Pe(n,"cut",S),Pe(n,"copy",S),Pe(e.scroller,"paste",function(j){if(ui(e,j)||Ve(r,j))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var X=new Event("paste");X.clipboardData=j.clipboardData,n.dispatchEvent(X)}),Pe(e.lineSpace,"selectstart",function(j){ui(e,j)||re(j)}),Pe(n,"compositionstart",function(){var j=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:j,range:r.markText(j,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Pe(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Qt.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},Qt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Qt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Zr(e,i.sel.primary().head,"div"),S=t.wrapper.getBoundingClientRect(),j=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+j.top-S.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+j.left-S.left))}return r},Qt.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")},Qt.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&&V(this.textarea),z&&W>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",z&&W>=9&&(this.hasSelection=null))},Qt.prototype.getField=function(){return this.textarea},Qt.prototype.supportsTouch=function(){return!1},Qt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||F()!=this.textarea))try{this.textarea.focus()}catch(e){}},Qt.prototype.blur=function(){this.textarea.blur()},Qt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Qt.prototype.receivedFocus=function(){this.slowPoll()},Qt.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()})},Qt.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)},Qt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ut(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(z&&W>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var S=n.charCodeAt(0);if(S==8203&&!r&&(r="\u200B"),S==8666)return this.reset(),this.cm.execCommand("undo")}for(var j=0,X=Math.min(r.length,n.length);j<X&&r.charCodeAt(j)==n.charCodeAt(j);)++j;return Pr(t,function(){za(t,n.slice(j),r.length-j,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},Qt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Qt.prototype.onKeyPress=function(){z&&W>=9&&(this.hasSelection=null),this.fastPoll()},Qt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var S=Ni(i,e),j=r.scroller.scrollTop;if(!S||A)return;var X=i.options.resetSelectionOnContextMenu;X&&i.doc.sel.contains(S)==-1&&or(i,br)(i.doc,wi(S),Se);var J=n.style.cssText,q=t.wrapper.style.cssText,he=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-he.top-5)+"px; left: "+(e.clientX-he.left-5)+`px;
z-index: 1000; background: `+(z?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var fe;P&&(fe=window.scrollY),r.input.focus(),P&&window.scrollTo(null,fe),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=Ae,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function ke(){if(n.selectionStart!=null){var ze=i.somethingSelected(),Ye="\u200B"+(ze?n.value:"");n.value="\u21DA",n.value=Ye,t.prevInput=ze?"":"\u200B",n.selectionStart=1,n.selectionEnd=Ye.length,r.selForContextMenu=i.doc.sel}}function Ae(){if(t.contextMenuPending!=Ae)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=q,n.style.cssText=J,z&&W<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=j),n.selectionStart!=null){(!z||z&&W<9)&&ke();var ze=0,Ye=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):ze++<10?r.detectingSelectAll=setTimeout(Ye,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ye,200)}}if(z&&W>=9&&ke(),k){pe(e);var Be=function(){at(window,"mouseup",Be),setTimeout(Ae,20)};Pe(window,"mouseup",Be)}else setTimeout(Ae,50)},Qt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Qt.prototype.setUneditable=function(){},Qt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?I(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=F();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=X.getValue()}var n;if(e.form&&(Pe(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var S=e.form;n=S.submit;try{var j=S.submit=function(){r(),S.submit=n,S.submit(),S.submit=j}}catch(J){}}t.finishInit=function(J){J.save=r,J.getTextArea=function(){return e},J.toTextArea=function(){J.toTextArea=isNaN,r(),e.parentNode.removeChild(J.getWrapperElement()),e.style.display="",e.form&&(at(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var X=Vt(function(J){return e.parentNode.insertBefore(J,e.nextSibling)},t);return X}function nu(e){e.off=at,e.on=Pe,e.wheelEventPixels=dl,e.Doc=Lr,e.splitLines=Tt,e.countColumn=Y,e.findColumn=Te,e.isWordChar=Re,e.Pass=De,e.signal=Fe,e.Line=Pi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Xe,e.cmpPos=St,e.modes=Xt,e.mimeModes=Ot,e.resolveMode=bt,e.getMode=Nr,e.modeExtensions=hr,e.extendMode=pr,e.copyState=Fr,e.startState=qr,e.innerMode=ci,e.commands=In,e.keyMap=hi,e.keyName=us,e.isModifierKey=ss,e.lookupKey=an,e.normalizeKeyMap=Pl,e.StringStream=It,e.SharedTextMarker=_n,e.TextMarker=ki,e.LineWidget=On,e.e_preventDefault=re,e.e_stopPropagation=ie,e.e_stop=pe,e.addClass=U,e.contains=x,e.rmClass=p,e.keyNames=Di}$l(Vt),ql(Vt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Lr.prototype)Lr.prototype.hasOwnProperty(la)&&ae(au,la)<0&&(Vt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Lr.prototype[la]));return ye(Lr),Vt.inputStyles={textarea:Qt,contenteditable:Ht},Vt.defineMode=function(e){!Vt.defaults.mode&&e!="null"&&(Vt.defaults.mode=e),Ir.apply(this,arguments)},Vt.defineMIME=Kr,Vt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Vt.defineMIME("text/plain","null"),Vt.defineExtension=function(e,t){Vt.prototype[e]=t},Vt.defineDocExtension=function(e,t){Lr.prototype[e]=t},Vt.fromTextArea=iu,nu(Vt),Vt.version="5.58.2",Vt})},X0ci:function(xt,it,se){},Y1PL:function(xt,it,se){"use strict";se.r(it),se.d(it,"ResizableTextArea",function(){return ae});var oe=se("wx14"),Z=se("1OyB"),D=se("vuIU"),$=se("Ji7U"),B=se("LK+K"),M=se("q1tI"),z=se("VTBJ"),W=se("rePB"),P=se("Zm9Q"),R=se("Kwbf"),y=se("c+Xe"),A=se("m+aA"),O=se("bdgK"),L=new Map;function C(Se){Se.forEach(function(we){var Ce,Te=we.target;(Ce=L.get(Te))===null||Ce===void 0||Ce.forEach(function(ge){return ge(Te)})})}var T=new O.default(C),h=null,o=null;function l(Se,we){L.has(Se)||(L.set(Se,new Set),T.observe(Se)),L.get(Se).add(we)}function d(Se,we){L.has(Se)&&(L.get(Se).delete(we),L.get(Se).size||(T.unobserve(Se),L.delete(Se)))}var w=function(Se){Object($.a)(Ce,Se);var we=Object(B.a)(Ce);function Ce(){return Object(Z.a)(this,Ce),we.apply(this,arguments)}return Object(D.a)(Ce,[{key:"render",value:function(){return this.props.children}}]),Ce}(M.Component),v=M.createContext(null);function g(Se){var we=Se.children,Ce=Se.onBatchResize,Te=M.useRef(0),ge=M.useRef([]),le=M.useContext(v),te=M.useCallback(function(ce,ne,Le){Te.current+=1;var Oe=Te.current;ge.current.push({size:ce,element:ne,data:Le}),Promise.resolve().then(function(){Oe===Te.current&&(Ce==null||Ce(ge.current),ge.current=[])}),le==null||le(ce,ne,Le)},[Ce,le]);return M.createElement(v.Provider,{value:te},we)}function k(Se){var we=Se.children,Ce=Se.disabled,Te=M.useRef(null),ge=M.useRef(null),le=M.useContext(v),te=M.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),ce=M.isValidElement(we)&&Object(y.c)(we),ne=ce?we.ref:null,Le=M.useMemo(function(){return Object(y.a)(ne,Te)},[ne,Te]),Oe=M.useRef(Se);Oe.current=Se;var Ee=M.useCallback(function(Re){var Ne=Oe.current,je=Ne.onResize,Ue=Ne.data,Ie=Re.getBoundingClientRect(),Me=Ie.width,Ke=Ie.height,Ze=Re.offsetWidth,$e=Re.offsetHeight,Qe=Math.floor(Me),lt=Math.floor(Ke);if(te.current.width!==Qe||te.current.height!==lt||te.current.offsetWidth!==Ze||te.current.offsetHeight!==$e){var tt={width:Qe,height:lt,offsetWidth:Ze,offsetHeight:$e};te.current=tt;var rt=Ze===Math.round(Me)?Me:Ze,Pe=$e===Math.round(Ke)?Ke:$e,ht=Object(z.a)(Object(z.a)({},tt),{},{offsetWidth:rt,offsetHeight:Pe});le==null||le(ht,Re,Ue),je&&Promise.resolve().then(function(){je(ht,Re)})}},[]);return M.useEffect(function(){var Re=Object(A.a)(Te.current)||Object(A.a)(ge.current);return Re&&!Ce&&l(Re,Ee),function(){return d(Re,Ee)}},[Te.current,Ce]),M.createElement(w,{ref:ge},ce?M.cloneElement(we,{ref:Le}):we)}var E="rc-observer-key";function p(Se){var we=Se.children,Ce=Object(P.a)(we);return Ce.map(function(Te,ge){var le=(Te==null?void 0:Te.key)||"".concat(E,"-").concat(ge);return M.createElement(k,Object(oe.a)({},Se,{key:le}),Te)})}p.Collection=g;var c=p,u=se("bT9E"),a=se("TSYQ"),b=se.n(a),m=`
min-height:0 !important;
max-height:none !important;
height:0 !important;
visibility:hidden !important;
overflow:hidden !important;
position:absolute !important;
z-index:-1000 !important;
top:0 !important;
right:0 !important
`,x=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],F={},U;function K(Se){var we=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=Se.getAttribute("id")||Se.getAttribute("data-reactid")||Se.getAttribute("name");if(we&&F[Ce])return F[Ce];var Te=window.getComputedStyle(Se),ge=Te.getPropertyValue("box-sizing")||Te.getPropertyValue("-moz-box-sizing")||Te.getPropertyValue("-webkit-box-sizing"),le=parseFloat(Te.getPropertyValue("padding-bottom"))+parseFloat(Te.getPropertyValue("padding-top")),te=parseFloat(Te.getPropertyValue("border-bottom-width"))+parseFloat(Te.getPropertyValue("border-top-width")),ce=x.map(function(Le){return"".concat(Le,":").concat(Te.getPropertyValue(Le))}).join(";"),ne={sizingStyle:ce,paddingSize:le,borderSize:te,boxSizing:ge};return we&&Ce&&(F[Ce]=ne),ne}function V(Se){var we=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Te=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;U||(U=document.createElement("textarea"),U.setAttribute("tab-index","-1"),U.setAttribute("aria-hidden","true"),document.body.appendChild(U)),Se.getAttribute("wrap")?U.setAttribute("wrap",Se.getAttribute("wrap")):U.removeAttribute("wrap");var ge=K(Se,we),le=ge.paddingSize,te=ge.borderSize,ce=ge.boxSizing,ne=ge.sizingStyle;U.setAttribute("style","".concat(ne,";").concat(m)),U.value=Se.value||Se.placeholder||"";var Le=Number.MIN_SAFE_INTEGER,Oe=Number.MAX_SAFE_INTEGER,Ee=U.scrollHeight,Re;if(ce==="border-box"?Ee+=te:ce==="content-box"&&(Ee-=le),Ce!==null||Te!==null){U.value=" ";var Ne=U.scrollHeight-le;Ce!==null&&(Le=Ne*Ce,ce==="border-box"&&(Le=Le+le+te),Ee=Math.max(Le,Ee)),Te!==null&&(Oe=Ne*Te,ce==="border-box"&&(Oe=Oe+le+te),Re=Ee>Oe?"":"hidden",Ee=Math.min(Oe,Ee))}return{height:Ee,minHeight:Le,maxHeight:Oe,overflowY:Re,resize:"none"}}var _=se("Gytx"),I=se.n(_),Y;(function(Se){Se[Se.NONE=0]="NONE",Se[Se.RESIZING=1]="RESIZING",Se[Se.RESIZED=2]="RESIZED"})(Y||(Y={}));var ee=function(Se){Object($.a)(Ce,Se);var we=Object(B.a)(Ce);function Ce(Te){var ge;return Object(Z.a)(this,Ce),ge=we.call(this,Te),ge.nextFrameActionId=void 0,ge.resizeFrameId=void 0,ge.textArea=void 0,ge.saveTextArea=function(le){ge.textArea=le},ge.handleResize=function(le){var te=ge.state.resizeStatus,ce=ge.props,ne=ce.autoSize,Le=ce.onResize;if(te!==Y.NONE)return;typeof Le=="function"&&Le(le),ne&&ge.resizeOnNextFrame()},ge.resizeOnNextFrame=function(){cancelAnimationFrame(ge.nextFrameActionId),ge.nextFrameActionId=requestAnimationFrame(ge.resizeTextarea)},ge.resizeTextarea=function(){var le=ge.props.autoSize;if(!le||!ge.textArea)return;var te=le.minRows,ce=le.maxRows,ne=V(ge.textArea,!1,te,ce);ge.setState({textareaStyles:ne,resizeStatus:Y.RESIZING},function(){cancelAnimationFrame(ge.resizeFrameId),ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:Y.RESIZED},function(){ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:Y.NONE}),ge.fixFirefoxAutoScroll()})})})})},ge.renderTextArea=function(){var le=ge.props,te=le.prefixCls,ce=te===void 0?"rc-textarea":te,ne=le.autoSize,Le=le.onResize,Oe=le.className,Ee=le.disabled,Re=ge.state,Ne=Re.textareaStyles,je=Re.resizeStatus,Ue=Object(u.a)(ge.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ie=b()(ce,Oe,Object(W.a)({},"".concat(ce,"-disabled"),Ee));"value"in Ue&&(Ue.value=Ue.value||"");var Me=Object(z.a)(Object(z.a)(Object(z.a)({},ge.props.style),Ne),je===Y.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return M.createElement(c,{onResize:ge.handleResize,disabled:!(ne||Le)},M.createElement("textarea",Object(oe.a)({},Ue,{className:Ie,style:Me,ref:ge.saveTextArea})))},ge.state={textareaStyles:{},resizeStatus:Y.NONE},ge}return Object(D.a)(Ce,[{key:"componentDidUpdate",value:function(ge){(ge.value!==this.props.value||!I()(ge.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 ge=this.textArea.selectionStart,le=this.textArea.selectionEnd;this.textArea.setSelectionRange(ge,le)}}catch(te){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ce}(M.Component),ae=ee,de=function(Se){Object($.a)(Ce,Se);var we=Object(B.a)(Ce);function Ce(Te){var ge;Object(Z.a)(this,Ce),ge=we.call(this,Te),ge.resizableTextArea=void 0,ge.focus=function(){ge.resizableTextArea.textArea.focus()},ge.saveTextArea=function(te){ge.resizableTextArea=te},ge.handleChange=function(te){var ce=ge.props.onChange;ge.setValue(te.target.value,function(){ge.resizableTextArea.resizeTextarea()}),ce&&ce(te)},ge.handleKeyDown=function(te){var ce=ge.props,ne=ce.onPressEnter,Le=ce.onKeyDown;te.keyCode===13&&ne&&ne(te),Le&&Le(te)};var le=typeof Te.value=="undefined"||Te.value===null?Te.defaultValue:Te.value;return ge.state={value:le},ge}return Object(D.a)(Ce,[{key:"setValue",value:function(ge,le){"value"in this.props||this.setState({value:ge},le)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return M.createElement(ae,Object(oe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ge){return"value"in ge?{value:ge.value}:null}}]),Ce}(M.Component),De=it.default=de},ZpRC:function(xt,it,se){"use strict";function oe(y){return typeof y=="object"&&y!=null&&y.nodeType===1}function Z(y,A){return(!A||y!=="hidden")&&y!=="visible"&&y!=="clip"}function D(y,A){if(y.clientHeight<y.scrollHeight||y.clientWidth<y.scrollWidth){var O=getComputedStyle(y,null);return Z(O.overflowY,A)||Z(O.overflowX,A)||function(L){var C=function(T){if(!T.ownerDocument||!T.ownerDocument.defaultView)return null;try{return T.ownerDocument.defaultView.frameElement}catch(h){return null}}(L);return!!C&&(C.clientHeight<L.scrollHeight||C.clientWidth<L.scrollWidth)}(y)}return!1}function $(y,A,O,L,C,T,h,o){return T<y&&h>A||T>y&&h<A?0:T<=y&&o<=O||h>=A&&o>=O?T-y-L:h>A&&o<O||T<y&&o>O?h-A+C:0}var B=function(y,A){var O=window,L=A.scrollMode,C=A.block,T=A.inline,h=A.boundary,o=A.skipOverflowHiddenElements,l=typeof h=="function"?h:function(Ne){return Ne!==h};if(!oe(y))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,w=[],v=y;oe(v)&&l(v);){if((v=v.parentElement)===d){w.push(v);break}v!=null&&v===document.body&&D(v)&&!D(document.documentElement)||v!=null&&D(v,o)&&w.push(v)}for(var g=O.visualViewport?O.visualViewport.width:innerWidth,k=O.visualViewport?O.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,p=window.scrollY||pageYOffset,c=y.getBoundingClientRect(),u=c.height,a=c.width,b=c.top,m=c.right,x=c.bottom,F=c.left,U=C==="start"||C==="nearest"?b:C==="end"?x:b+u/2,K=T==="center"?F+a/2:T==="end"?m:F,V=[],_=0;_<w.length;_++){var I=w[_],Y=I.getBoundingClientRect(),ee=Y.height,ae=Y.width,de=Y.top,De=Y.right,Se=Y.bottom,we=Y.left;if(L==="if-needed"&&b>=0&&F>=0&&x<=k&&m<=g&&b>=de&&x<=Se&&F>=we&&m<=De)return V;var Ce=getComputedStyle(I),Te=parseInt(Ce.borderLeftWidth,10),ge=parseInt(Ce.borderTopWidth,10),le=parseInt(Ce.borderRightWidth,10),te=parseInt(Ce.borderBottomWidth,10),ce=0,ne=0,Le="offsetWidth"in I?I.offsetWidth-I.clientWidth-Te-le:0,Oe="offsetHeight"in I?I.offsetHeight-I.clientHeight-ge-te:0;if(d===I)ce=C==="start"?U:C==="end"?U-k:C==="nearest"?$(p,p+k,k,ge,te,p+U,p+U+u,u):U-k/2,ne=T==="start"?K:T==="center"?K-g/2:T==="end"?K-g:$(E,E+g,g,Te,le,E+K,E+K+a,a),ce=Math.max(0,ce+p),ne=Math.max(0,ne+E);else{ce=C==="start"?U-de-ge:C==="end"?U-Se+te+Oe:C==="nearest"?$(de,Se,ee,ge,te+Oe,U,U+u,u):U-(de+ee/2)+Oe/2,ne=T==="start"?K-we-Te:T==="center"?K-(we+ae/2)+Le/2:T==="end"?K-De+le+Le:$(we,De,ae,Te,le+Le,K,K+a,a);var Ee=I.scrollLeft,Re=I.scrollTop;U+=Re-(ce=Math.max(0,Math.min(Re+ce,I.scrollHeight-ee+Oe))),K+=Ee-(ne=Math.max(0,Math.min(Ee+ne,I.scrollWidth-ae+Le)))}V.push({el:I,top:ce,left:ne})}return V};function M(y){return y===Object(y)&&Object.keys(y).length!==0}function z(y,A){A===void 0&&(A="auto");var O="scrollBehavior"in document.body.style;y.forEach(function(L){var C=L.el,T=L.top,h=L.left;C.scroll&&O?C.scroll({top:T,left:h,behavior:A}):(C.scrollTop=T,C.scrollLeft=h)})}function W(y){return y===!1?{block:"end",inline:"nearest"}:M(y)?y:{block:"start",inline:"nearest"}}function P(y,A){var O=!y.ownerDocument.documentElement.contains(y);if(M(A)&&typeof A.behavior=="function")return A.behavior(O?[]:B(y,A));if(O)return;var L=W(A);return z(B(y,L),L.behavior)}var R=it.a=P},Zss7:function(xt,it,se){var oe;(function(Z){var D=/^\s+/,$=/\s+$/,B=0,M=Z.round,z=Z.min,W=Z.max,P=Z.random;function R(te,ce){if(te=te||"",ce=ce||{},te instanceof R)return te;if(!(this instanceof R))return new R(te,ce);var ne=y(te);this._originalInput=te,this._r=ne.r,this._g=ne.g,this._b=ne.b,this._a=ne.a,this._roundA=M(100*this._a)/100,this._format=ce.format||ne.format,this._gradientType=ce.gradientType,this._r<1&&(this._r=M(this._r)),this._g<1&&(this._g=M(this._g)),this._b<1&&(this._b=M(this._b)),this._ok=ne.ok,this._tc_id=B++}R.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var te=this.toRgb();return(te.r*299+te.g*587+te.b*114)/1e3},getLuminance:function(){var te=this.toRgb(),ce,ne,Le,Oe,Ee,Re;return ce=te.r/255,ne=te.g/255,Le=te.b/255,ce<=.03928?Oe=ce/12.92:Oe=Z.pow((ce+.055)/1.055,2.4),ne<=.03928?Ee=ne/12.92:Ee=Z.pow((ne+.055)/1.055,2.4),Le<=.03928?Re=Le/12.92:Re=Z.pow((Le+.055)/1.055,2.4),.2126*Oe+.7152*Ee+.0722*Re},setAlpha:function(te){return this._a=V(te),this._roundA=M(100*this._a)/100,this},toHsv:function(){var te=C(this._r,this._g,this._b);return{h:te.h*360,s:te.s,v:te.v,a:this._a}},toHsvString:function(){var te=C(this._r,this._g,this._b),ce=M(te.h*360),ne=M(te.s*100),Le=M(te.v*100);return this._a==1?"hsv("+ce+", "+ne+"%, "+Le+"%)":"hsva("+ce+", "+ne+"%, "+Le+"%, "+this._roundA+")"},toHsl:function(){var te=O(this._r,this._g,this._b);return{h:te.h*360,s:te.s,l:te.l,a:this._a}},toHslString:function(){var te=O(this._r,this._g,this._b),ce=M(te.h*360),ne=M(te.s*100),Le=M(te.l*100);return this._a==1?"hsl("+ce+", "+ne+"%, "+Le+"%)":"hsla("+ce+", "+ne+"%, "+Le+"%, "+this._roundA+")"},toHex:function(te){return h(this._r,this._g,this._b,te)},toHexString:function(te){return"#"+this.toHex(te)},toHex8:function(te){return o(this._r,this._g,this._b,this._a,te)},toHex8String:function(te){return"#"+this.toHex8(te)},toRgb:function(){return{r:M(this._r),g:M(this._g),b:M(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+M(this._r)+", "+M(this._g)+", "+M(this._b)+")":"rgba("+M(this._r)+", "+M(this._g)+", "+M(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:M(_(this._r,255)*100)+"%",g:M(_(this._g,255)*100)+"%",b:M(_(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+M(_(this._r,255)*100)+"%, "+M(_(this._g,255)*100)+"%, "+M(_(this._b,255)*100)+"%)":"rgba("+M(_(this._r,255)*100)+"%, "+M(_(this._g,255)*100)+"%, "+M(_(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:U[h(this._r,this._g,this._b,!0)]||!1},toFilter:function(te){var ce="#"+l(this._r,this._g,this._b,this._a),ne=ce,Le=this._gradientType?"GradientType = 1, ":"";if(te){var Oe=R(te);ne="#"+l(Oe._r,Oe._g,Oe._b,Oe._a)}return"progid:DXImageTransform.Microsoft.gradient("+Le+"startColorstr="+ce+",endColorstr="+ne+")"},toString:function(te){var ce=!!te;te=te||this._format;var ne=!1,Le=this._a<1&&this._a>=0,Oe=!ce&&Le&&(te==="hex"||te==="hex6"||te==="hex3"||te==="hex4"||te==="hex8"||te==="name");return Oe?te==="name"&&this._a===0?this.toName():this.toRgbString():(te==="rgb"&&(ne=this.toRgbString()),te==="prgb"&&(ne=this.toPercentageRgbString()),(te==="hex"||te==="hex6")&&(ne=this.toHexString()),te==="hex3"&&(ne=this.toHexString(!0)),te==="hex4"&&(ne=this.toHex8String(!0)),te==="hex8"&&(ne=this.toHex8String()),te==="name"&&(ne=this.toName()),te==="hsl"&&(ne=this.toHslString()),te==="hsv"&&(ne=this.toHsvString()),ne||this.toHexString())},clone:function(){return R(this.toString())},_applyModification:function(te,ce){var ne=te.apply(null,[this].concat([].slice.call(ce)));return this._r=ne._r,this._g=ne._g,this._b=ne._b,this.setAlpha(ne._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(k,arguments)},darken:function(){return this._applyModification(E,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(w,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(p,arguments)},_applyCombination:function(te,ce){return te.apply(null,[this].concat([].slice.call(ce)))},analogous:function(){return this._applyCombination(m,arguments)},complement:function(){return this._applyCombination(c,arguments)},monochromatic:function(){return this._applyCombination(x,arguments)},splitcomplement:function(){return this._applyCombination(b,arguments)},triad:function(){return this._applyCombination(u,arguments)},tetrad:function(){return this._applyCombination(a,arguments)}},R.fromRatio=function(te,ce){if(typeof te=="object"){var ne={};for(var Le in te)te.hasOwnProperty(Le)&&(Le==="a"?ne[Le]=te[Le]:ne[Le]=De(te[Le]));te=ne}return R(te,ce)};function y(te){var ce={r:0,g:0,b:0},ne=1,Le=null,Oe=null,Ee=null,Re=!1,Ne=!1;return typeof te=="string"&&(te=ge(te)),typeof te=="object"&&(Te(te.r)&&Te(te.g)&&Te(te.b)?(ce=A(te.r,te.g,te.b),Re=!0,Ne=String(te.r).substr(-1)==="%"?"prgb":"rgb"):Te(te.h)&&Te(te.s)&&Te(te.v)?(Le=De(te.s),Oe=De(te.v),ce=T(te.h,Le,Oe),Re=!0,Ne="hsv"):Te(te.h)&&Te(te.s)&&Te(te.l)&&(Le=De(te.s),Ee=De(te.l),ce=L(te.h,Le,Ee),Re=!0,Ne="hsl"),te.hasOwnProperty("a")&&(ne=te.a)),ne=V(ne),{ok:Re,format:te.format||Ne,r:z(255,W(ce.r,0)),g:z(255,W(ce.g,0)),b:z(255,W(ce.b,0)),a:ne}}function A(te,ce,ne){return{r:_(te,255)*255,g:_(ce,255)*255,b:_(ne,255)*255}}function O(te,ce,ne){te=_(te,255),ce=_(ce,255),ne=_(ne,255);var Le=W(te,ce,ne),Oe=z(te,ce,ne),Ee,Re,Ne=(Le+Oe)/2;if(Le==Oe)Ee=Re=0;else{var je=Le-Oe;Re=Ne>.5?je/(2-Le-Oe):je/(Le+Oe);switch(Le){case te:Ee=(ce-ne)/je+(ce<ne?6:0);break;case ce:Ee=(ne-te)/je+2;break;case ne:Ee=(te-ce)/je+4;break}Ee/=6}return{h:Ee,s:Re,l:Ne}}function L(te,ce,ne){var Le,Oe,Ee;te=_(te,360),ce=_(ce,100),ne=_(ne,100);function Re(Ue,Ie,Me){return Me<0&&(Me+=1),Me>1&&(Me-=1),Me<1/6?Ue+(Ie-Ue)*6*Me:Me<1/2?Ie:Me<2/3?Ue+(Ie-Ue)*(2/3-Me)*6:Ue}if(ce===0)Le=Oe=Ee=ne;else{var Ne=ne<.5?ne*(1+ce):ne+ce-ne*ce,je=2*ne-Ne;Le=Re(je,Ne,te+1/3),Oe=Re(je,Ne,te),Ee=Re(je,Ne,te-1/3)}return{r:Le*255,g:Oe*255,b:Ee*255}}function C(te,ce,ne){te=_(te,255),ce=_(ce,255),ne=_(ne,255);var Le=W(te,ce,ne),Oe=z(te,ce,ne),Ee,Re,Ne=Le,je=Le-Oe;if(Re=Le===0?0:je/Le,Le==Oe)Ee=0;else{switch(Le){case te:Ee=(ce-ne)/je+(ce<ne?6:0);break;case ce:Ee=(ne-te)/je+2;break;case ne:Ee=(te-ce)/je+4;break}Ee/=6}return{h:Ee,s:Re,v:Ne}}function T(te,ce,ne){te=_(te,360)*6,ce=_(ce,100),ne=_(ne,100);var Le=Z.floor(te),Oe=te-Le,Ee=ne*(1-ce),Re=ne*(1-Oe*ce),Ne=ne*(1-(1-Oe)*ce),je=Le%6,Ue=[ne,Re,Ee,Ee,Ne,ne][je],Ie=[Ne,ne,ne,Re,Ee,Ee][je],Me=[Ee,Ee,Ne,ne,ne,Re][je];return{r:Ue*255,g:Ie*255,b:Me*255}}function h(te,ce,ne,Le){var Oe=[de(M(te).toString(16)),de(M(ce).toString(16)),de(M(ne).toString(16))];return Le&&Oe[0].charAt(0)==Oe[0].charAt(1)&&Oe[1].charAt(0)==Oe[1].charAt(1)&&Oe[2].charAt(0)==Oe[2].charAt(1)?Oe[0].charAt(0)+Oe[1].charAt(0)+Oe[2].charAt(0):Oe.join("")}function o(te,ce,ne,Le,Oe){var Ee=[de(M(te).toString(16)),de(M(ce).toString(16)),de(M(ne).toString(16)),de(Se(Le))];return Oe&&Ee[0].charAt(0)==Ee[0].charAt(1)&&Ee[1].charAt(0)==Ee[1].charAt(1)&&Ee[2].charAt(0)==Ee[2].charAt(1)&&Ee[3].charAt(0)==Ee[3].charAt(1)?Ee[0].charAt(0)+Ee[1].charAt(0)+Ee[2].charAt(0)+Ee[3].charAt(0):Ee.join("")}function l(te,ce,ne,Le){var Oe=[de(Se(Le)),de(M(te).toString(16)),de(M(ce).toString(16)),de(M(ne).toString(16))];return Oe.join("")}R.equals=function(te,ce){return!te||!ce?!1:R(te).toRgbString()==R(ce).toRgbString()},R.random=function(){return R.fromRatio({r:P(),g:P(),b:P()})};function d(te,ce){ce=ce===0?0:ce||10;var ne=R(te).toHsl();return ne.s-=ce/100,ne.s=I(ne.s),R(ne)}function w(te,ce){ce=ce===0?0:ce||10;var ne=R(te).toHsl();return ne.s+=ce/100,ne.s=I(ne.s),R(ne)}function v(te){return R(te).desaturate(100)}function g(te,ce){ce=ce===0?0:ce||10;var ne=R(te).toHsl();return ne.l+=ce/100,ne.l=I(ne.l),R(ne)}function k(te,ce){ce=ce===0?0:ce||10;var ne=R(te).toRgb();return ne.r=W(0,z(255,ne.r-M(255*-(ce/100)))),ne.g=W(0,z(255,ne.g-M(255*-(ce/100)))),ne.b=W(0,z(255,ne.b-M(255*-(ce/100)))),R(ne)}function E(te,ce){ce=ce===0?0:ce||10;var ne=R(te).toHsl();return ne.l-=ce/100,ne.l=I(ne.l),R(ne)}function p(te,ce){var ne=R(te).toHsl(),Le=(ne.h+ce)%360;return ne.h=Le<0?360+Le:Le,R(ne)}function c(te){var ce=R(te).toHsl();return ce.h=(ce.h+180)%360,R(ce)}function u(te){var ce=R(te).toHsl(),ne=ce.h;return[R(te),R({h:(ne+120)%360,s:ce.s,l:ce.l}),R({h:(ne+240)%360,s:ce.s,l:ce.l})]}function a(te){var ce=R(te).toHsl(),ne=ce.h;return[R(te),R({h:(ne+90)%360,s:ce.s,l:ce.l}),R({h:(ne+180)%360,s:ce.s,l:ce.l}),R({h:(ne+270)%360,s:ce.s,l:ce.l})]}function b(te){var ce=R(te).toHsl(),ne=ce.h;return[R(te),R({h:(ne+72)%360,s:ce.s,l:ce.l}),R({h:(ne+216)%360,s:ce.s,l:ce.l})]}function m(te,ce,ne){ce=ce||6,ne=ne||30;var Le=R(te).toHsl(),Oe=360/ne,Ee=[R(te)];for(Le.h=(Le.h-(Oe*ce>>1)+720)%360;--ce;)Le.h=(Le.h+Oe)%360,Ee.push(R(Le));return Ee}function x(te,ce){ce=ce||6;for(var ne=R(te).toHsv(),Le=ne.h,Oe=ne.s,Ee=ne.v,Re=[],Ne=1/ce;ce--;)Re.push(R({h:Le,s:Oe,v:Ee})),Ee=(Ee+Ne)%1;return Re}R.mix=function(te,ce,ne){ne=ne===0?0:ne||50;var Le=R(te).toRgb(),Oe=R(ce).toRgb(),Ee=ne/100,Re={r:(Oe.r-Le.r)*Ee+Le.r,g:(Oe.g-Le.g)*Ee+Le.g,b:(Oe.b-Le.b)*Ee+Le.b,a:(Oe.a-Le.a)*Ee+Le.a};return R(Re)},R.readability=function(te,ce){var ne=R(te),Le=R(ce);return(Z.max(ne.getLuminance(),Le.getLuminance())+.05)/(Z.min(ne.getLuminance(),Le.getLuminance())+.05)},R.isReadable=function(te,ce,ne){var Le=R.readability(te,ce),Oe,Ee;Ee=!1,Oe=le(ne);switch(Oe.level+Oe.size){case"AAsmall":case"AAAlarge":Ee=Le>=4.5;break;case"AAlarge":Ee=Le>=3;break;case"AAAsmall":Ee=Le>=7;break}return Ee},R.mostReadable=function(te,ce,ne){var Le=null,Oe=0,Ee,Re,Ne,je;ne=ne||{},Re=ne.includeFallbackColors,Ne=ne.level,je=ne.size;for(var Ue=0;Ue<ce.length;Ue++)Ee=R.readability(te,ce[Ue]),Ee>Oe&&(Oe=Ee,Le=R(ce[Ue]));return R.isReadable(te,Le,{level:Ne,size:je})||!Re?Le:(ne.includeFallbackColors=!1,R.mostReadable(te,["#fff","#000"],ne))};var F=R.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},U=R.hexNames=K(F);function K(te){var ce={};for(var ne in te)te.hasOwnProperty(ne)&&(ce[te[ne]]=ne);return ce}function V(te){return te=parseFloat(te),(isNaN(te)||te<0||te>1)&&(te=1),te}function _(te,ce){ee(te)&&(te="100%");var ne=ae(te);return te=z(ce,W(0,parseFloat(te))),ne&&(te=parseInt(te*ce,10)/100),Z.abs(te-ce)<1e-6?1:te%ce/parseFloat(ce)}function I(te){return z(1,W(0,te))}function Y(te){return parseInt(te,16)}function ee(te){return typeof te=="string"&&te.indexOf(".")!=-1&&parseFloat(te)===1}function ae(te){return typeof te=="string"&&te.indexOf("%")!=-1}function de(te){return te.length==1?"0"+te:""+te}function De(te){return te<=1&&(te=te*100+"%"),te}function Se(te){return Z.round(parseFloat(te)*255).toString(16)}function we(te){return Y(te)/255}var Ce=function(){var te="[-\\+]?\\d+%?",ce="[-\\+]?\\d*\\.\\d+%?",ne="(?:"+ce+")|(?:"+te+")",Le="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?",Oe="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?";return{CSS_UNIT:new RegExp(ne),rgb:new RegExp("rgb"+Le),rgba:new RegExp("rgba"+Oe),hsl:new RegExp("hsl"+Le),hsla:new RegExp("hsla"+Oe),hsv:new RegExp("hsv"+Le),hsva:new RegExp("hsva"+Oe),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Te(te){return!!Ce.CSS_UNIT.exec(te)}function ge(te){te=te.replace(D,"").replace($,"").toLowerCase();var ce=!1;if(F[te])te=F[te],ce=!0;else if(te=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var ne;return(ne=Ce.rgb.exec(te))?{r:ne[1],g:ne[2],b:ne[3]}:(ne=Ce.rgba.exec(te))?{r:ne[1],g:ne[2],b:ne[3],a:ne[4]}:(ne=Ce.hsl.exec(te))?{h:ne[1],s:ne[2],l:ne[3]}:(ne=Ce.hsla.exec(te))?{h:ne[1],s:ne[2],l:ne[3],a:ne[4]}:(ne=Ce.hsv.exec(te))?{h:ne[1],s:ne[2],v:ne[3]}:(ne=Ce.hsva.exec(te))?{h:ne[1],s:ne[2],v:ne[3],a:ne[4]}:(ne=Ce.hex8.exec(te))?{r:Y(ne[1]),g:Y(ne[2]),b:Y(ne[3]),a:we(ne[4]),format:ce?"name":"hex8"}:(ne=Ce.hex6.exec(te))?{r:Y(ne[1]),g:Y(ne[2]),b:Y(ne[3]),format:ce?"name":"hex"}:(ne=Ce.hex4.exec(te))?{r:Y(ne[1]+""+ne[1]),g:Y(ne[2]+""+ne[2]),b:Y(ne[3]+""+ne[3]),a:we(ne[4]+""+ne[4]),format:ce?"name":"hex8"}:(ne=Ce.hex3.exec(te))?{r:Y(ne[1]+""+ne[1]),g:Y(ne[2]+""+ne[2]),b:Y(ne[3]+""+ne[3]),format:ce?"name":"hex"}:!1}function le(te){var ce,ne;return te=te||{level:"AA",size:"small"},ce=(te.level||"AA").toUpperCase(),ne=(te.size||"small").toLowerCase(),ce!=="AA"&&ce!=="AAA"&&(ce="AA"),ne!=="small"&&ne!=="large"&&(ne="small"),{level:ce,size:ne}}xt.exports?xt.exports=R:!(oe=function(){return R}.call(it,se,it,xt),oe!==void 0&&(xt.exports=oe))})(Math)},bT9E:function(xt,it,se){"use strict";se.d(it,"a",function(){return Z});var oe=se("VTBJ");function Z(D,$){var B=Object(oe.a)({},D);return Array.isArray($)&&$.forEach(function(M){delete B[M]}),B}},c5Ni:function(xt,it,se){},dejd:function(xt,it,se){},dmUQ:function(xt,it,se){"use strict";var oe=se("Ff2n"),Z=se("rePB"),D=se("1OyB"),$=se("vuIU"),B=se("Ji7U"),M=se("md7G"),z=se("foSv"),W=se("q1tI"),P=se.n(W),R=se("TSYQ"),y=se.n(R),A=se("4IlW");function O(u,a){var b=Object.keys(u);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(u);a&&(m=m.filter(function(x){return Object.getOwnPropertyDescriptor(u,x).enumerable})),b.push.apply(b,m)}return b}function L(u){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?O(Object(b),!0).forEach(function(m){Object(Z.a)(u,m,b[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(b)):O(Object(b)).forEach(function(m){Object.defineProperty(u,m,Object.getOwnPropertyDescriptor(b,m))})}return u}function C(u){var a=T();return function(){var m=Object(z.a)(u),x;if(a){var F=Object(z.a)(this).constructor;x=Reflect.construct(m,arguments,F)}else x=m.apply(this,arguments);return Object(M.a)(this,x)}}function T(){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 h(){}function o(u){u.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},d=200,w=600,v=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,g=function(a){return a!=null},k=function(a,b){return b===a||typeof b=="number"&&typeof a=="number"&&isNaN(b)&&isNaN(a)},E=function(u){Object(B.a)(b,u);var a=C(b);function b(m){var x;Object(D.a)(this,b),x=a.call(this,m),x.onKeyDown=function(K){var V=x.props,_=V.onKeyDown,I=V.onPressEnter;if(K.keyCode===A.a.UP){var Y=x.getRatio(K);x.up(K,Y,null),x.stop()}else if(K.keyCode===A.a.DOWN){var ee=x.getRatio(K);x.down(K,ee,null),x.stop()}else K.keyCode===A.a.ENTER&&I&&I(K);if(x.recordCursorPosition(),x.lastKeyCode=K.keyCode,_){for(var ae=arguments.length,de=new Array(ae>1?ae-1:0),De=1;De<ae;De++)de[De-1]=arguments[De];_.apply(void 0,[K].concat(de))}},x.onKeyUp=function(K){var V=x.props.onKeyUp;if(x.stop(),x.recordCursorPosition(),V){for(var _=arguments.length,I=new Array(_>1?_-1:0),Y=1;Y<_;Y++)I[Y-1]=arguments[Y];V.apply(void 0,[K].concat(I))}},x.onChange=function(K){var V=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent(K)),x.setState({inputValue:x.rawInput}),V(x.toNumber(x.rawInput))},x.onMouseUp=function(){var K=x.props.onMouseUp;x.recordCursorPosition(),K&&K.apply(void 0,arguments)},x.onFocus=function(){var K;x.setState({focused:!0}),(K=x.props).onFocus.apply(K,arguments)},x.onBlur=function(){var K=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var V=x.getCurrentValidValue(x.state.inputValue),_=x.setValue(V,h);if(K){var I=x.input.value,Y=x.getInputDisplayValue({focus:!1,value:_});x.input.value=Y&&Number(Y),K.apply(void 0,arguments),x.input.value=I}},x.getRatio=function(K){var V=1;return K.metaKey||K.ctrlKey?V=.1:K.shiftKey&&(V=10),V},x.getFullNum=function(K){return isNaN(K)?K:/e/i.test(String(K))?Number(K).toFixed(18).replace(/\.?0+$/,""):K},x.getPrecision=function(K){if(g(x.props.precision))return x.props.precision;var V=String(K);if(V.indexOf("e-")>=0)return parseInt(V.slice(V.indexOf("e-")+2),10);var _=0;return V.indexOf(".")>=0&&(_=V.length-V.indexOf(".")-1),_},x.getInputDisplayValue=function(K){var V=K||x.state,_=V.focused,I=V.inputValue,Y=V.value,ee;_?ee=I:ee=x.toPrecisionAsStep(Y),ee==null&&(ee="");var ae=x.formatWrapper(ee);return g(x.props.decimalSeparator)&&(ae=ae.toString().replace(".",x.props.decimalSeparator)),ae},x.recordCursorPosition=function(){try{x.cursorStart=x.input.selectionStart,x.cursorEnd=x.input.selectionEnd,x.currentValue=x.input.value,x.cursorBefore=x.input.value.substring(0,x.cursorStart),x.cursorAfter=x.input.value.substring(x.cursorEnd)}catch(K){}},x.restoreByAfter=function(K){if(K===void 0)return!1;var V=x.input.value,_=V.lastIndexOf(K);if(_===-1)return!1;var I=x.cursorBefore.length;return x.lastKeyCode===A.a.DELETE&&x.cursorBefore.charAt(I-1)===K[0]?(x.fixCaret(I,I),!0):_+K.length===V.length?(x.fixCaret(_,_),!0):!1},x.partRestoreByAfter=function(K){return K===void 0?!1:Array.prototype.some.call(K,function(V,_){var I=K.substring(_);return x.restoreByAfter(I)})},x.isNotCompleteNumber=function(K){return isNaN(K)||K===""||K===null||K&&K.toString().indexOf(".")===K.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function(K,V,_){x.pressingUpOrDown=!0,x.step("down",K,V,_)},x.up=function(K,V,_){x.pressingUpOrDown=!0,x.step("up",K,V,_)},x.saveInput=function(K){x.input=K};var F=m.value;F===void 0&&(F=m.defaultValue),x.state={focused:m.autoFocus};var U=x.getValidValue(x.toNumber(F));return x.state=L(L({},x.state),{},{inputValue:x.toPrecisionAsStep(U),value:U}),x}return Object($.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var F=this.props,U=F.value,K=F.onChange,V=F.max,_=F.min,I=this.state.focused;if(x){if(!k(x.value,U)||!k(x.max,V)||!k(x.min,_)){var Y=I?U:this.getValidValue(U),ee;this.pressingUpOrDown?ee=Y:this.inputting?ee=this.rawInput:ee=this.toPrecisionAsStep(Y),this.setState({value:Y,inputValue:ee})}var ae="value"in this.props?U:this.state.value;"max"in this.props&&x.max!==V&&typeof ae=="number"&&ae>V&&K&&K(V),"min"in this.props&&x.min!==_&&typeof ae=="number"&&ae<_&&K&&K(_)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var de=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===A.a.BACKSPACE?de=this.cursorStart-1:this.lastKeyCode===A.a.DELETE&&(de=this.cursorStart):de=this.input.value.length,this.fixCaret(de,de)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case A.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case A.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(De){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(x){var F=x;return F===""?F="":this.isNotCompleteNumber(parseFloat(F))?F=this.state.value:F=this.getValidValue(F),this.toNumber(F)}},{key:"getValueFromEvent",value:function(x){var F=x.target.value.trim().replace(/。/g,".");return g(this.props.decimalSeparator)&&(F=F.replace(this.props.decimalSeparator,".")),F}},{key:"getValidValue",value:function(x){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,K=parseFloat(x);return isNaN(K)?x:(K<F&&(K=F),K>U&&(K=U),K)}},{key:"setValue",value:function(x,F){var U=this.props.precision,K=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),V=this.state.value,_=V===void 0?null:V,I=this.state.inputValue,Y=I===void 0?null:I,ee=typeof K=="number"?K.toFixed(U):"".concat(K),ae=K!==_||ee!=="".concat(Y);return"value"in this.props?(Y=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:Y},F)):this.setState({value:K,inputValue:this.toPrecisionAsStep(x)},F),ae&&this.props.onChange(K),K}},{key:"getMaxPrecision",value:function(x){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.props,K=U.precision,V=U.step;if(g(K))return K;var _=this.getPrecision(F),I=this.getPrecision(V),Y=this.getPrecision(x);return x?Math.max(Y,_+I):_+I}},{key:"getPrecisionFactor",value:function(x){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.getMaxPrecision(x,F);return Math.pow(10,U)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var F=Math.abs(this.getMaxPrecision(x));return isNaN(F)?x.toString():Number(x).toFixed(F)}},{key:"toNumber",value:function(x){var F=this.props.precision,U=this.state.focused,K=x&&x.length>16&&U;return this.isNotCompleteNumber(x)||K?x:g(F)?Math.round(x*Math.pow(10,F))/Math.pow(10,F):Number(x)}},{key:"upStep",value:function(x,F){var U=this.props.step,K=this.getPrecisionFactor(x,F),V=Math.abs(this.getMaxPrecision(x,F)),_=((K*x+K*U*F)/K).toFixed(V);return this.toNumber(_)}},{key:"downStep",value:function(x,F){var U=this.props.step,K=this.getPrecisionFactor(x,F),V=Math.abs(this.getMaxPrecision(x,F)),_=((K*x-K*U*F)/K).toFixed(V);return this.toNumber(_)}},{key:"step",value:function(x,F){var U=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,V=arguments.length>3?arguments[3]:void 0;this.stop(),F&&(F.persist(),F.preventDefault());var _=this.props;if(_.disabled)return;var I=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(I))return;var Y=this["".concat(x,"Step")](I,K),ee=Y>_.max||Y<_.min;if(Y>_.max?Y=_.max:Y<_.min&&(Y=_.min),this.setValue(Y,null),this.setState({focused:!0},function(){U.pressingUpOrDown=!1}),ee)return;this.autoStepTimer=setTimeout(function(){U[x](F,K,!0)},V?d:w)}},{key:"fixCaret",value:function(x,F){if(x===void 0||F===void 0||!this.input||!this.input.value)return;try{var U=this.input.selectionStart,K=this.input.selectionEnd;(x!==U||F!==K)&&this.input.setSelectionRange(x,F)}catch(V){}}},{key:"render",value:function(){var x,F=this.props,U=F.prefixCls,K=F.disabled,V=F.readOnly,_=F.useTouch,I=F.autoComplete,Y=F.upHandler,ee=F.downHandler,ae=F.className,de=F.max,De=F.min,Se=F.style,we=F.title,Ce=F.onMouseEnter,Te=F.onMouseLeave,ge=F.onMouseOver,le=F.onMouseOut,te=F.required,ce=F.onClick,ne=F.tabIndex,Le=F.type,Oe=F.placeholder,Ee=F.id,Re=F.inputMode,Ne=F.pattern,je=F.step,Ue=F.maxLength,Ie=F.autoFocus,Me=F.name,Ke=F.onPaste,Ze=F.onInput,$e=Object(oe.a)(F,["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"]),Qe=this.state,lt=Qe.value,tt=Qe.focused,rt=y()(U,(x={},Object(Z.a)(x,ae,!!ae),Object(Z.a)(x,"".concat(U,"-disabled"),K),Object(Z.a)(x,"".concat(U,"-focused"),tt),x)),Pe={};Object.keys($e).forEach(function(pe){(pe.substr(0,5)==="data-"||pe.substr(0,5)==="aria-"||pe==="role")&&(Pe[pe]=$e[pe])});var ht=!V&&!K,at=this.getInputDisplayValue(null),Fe=(lt||lt===0)&&(isNaN(lt)||Number(lt)>=de),Ve=(lt||lt===0)&&(isNaN(lt)||Number(lt)<=De),xe=Fe||K||V,ve=Ve||K||V,ye=y()("".concat(U,"-handler"),"".concat(U,"-handler-up"),Object(Z.a)({},"".concat(U,"-handler-up-disabled"),xe)),re=y()("".concat(U,"-handler"),"".concat(U,"-handler-down"),Object(Z.a)({},"".concat(U,"-handler-down-disabled"),ve)),ie=_?{onTouchStart:xe?h:this.up,onTouchEnd:this.stop}:{onMouseDown:xe?h:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ue=_?{onTouchStart:ve?h:this.down,onTouchEnd:this.stop}:{onMouseDown:ve?h:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:rt,style:Se,title:we,onMouseEnter:Ce,onMouseLeave:Te,onMouseOver:ge,onMouseOut:le,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(U,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Increase Value","aria-disabled":xe,className:ye}),Y||P.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-up-inner"),onClick:o})),P.a.createElement("span",Object.assign({unselectable:"on"},ue,{role:"button","aria-label":"Decrease Value","aria-disabled":ve,className:re}),ee||P.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-down-inner"),onClick:o}))),P.a.createElement("div",{className:"".concat(U,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":de,"aria-valuenow":lt,required:te,type:Le,placeholder:Oe,onPaste:Ke,onClick:ce,onMouseUp:this.onMouseUp,className:"".concat(U,"-input"),tabIndex:ne,autoComplete:I,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:ht?this.onKeyDown:h,onKeyUp:ht?this.onKeyUp:h,autoFocus:Ie,maxLength:Ue,readOnly:V,disabled:K,max:de,min:De,step:je,name:Me,title:we,id:Ee,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(at),pattern:Ne,inputMode:Re,onInput:Ze},Pe))))}}]),b}(P.a.Component);E.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:v,min:-v,step:1,style:{},onChange:h,onKeyDown:h,onPressEnter:h,onFocus:h,onBlur:h,parser:l,required:!1,autoComplete:"off"};var p=E,c=it.a=p},h78n:function(xt,it,se){"use strict";se.d(it,"a",function(){return x});var oe=se("q1tI"),Z=se.n(oe),D=se("TSYQ"),$=se.n(D),B={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1},M=function(K){var V=K.map(function(){return Object(oe.useRef)()}),_=Object(oe.useRef)();return Object(oe.useEffect)(function(){var I=Date.now(),Y=!1;Object.keys(V).forEach(function(ee){var ae=V[ee].current;if(!ae)return;Y=!0;var de=ae.style;de.transitionDuration=".3s, .3s, .3s, .06s",_.current&&I-_.current<100&&(de.transitionDuration="0s, 0s")}),Y&&(_.current=Date.now())}),[V]};function z(){return z=Object.assign||function(U){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var _ in V)Object.prototype.hasOwnProperty.call(V,_)&&(U[_]=V[_])}return U},z.apply(this,arguments)}function W(U,K){return O(U)||A(U,K)||R(U,K)||P()}function P(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R(U,K){if(!U)return;if(typeof U=="string")return y(U,K);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return y(U,K)}function y(U,K){(K==null||K>U.length)&&(K=U.length);for(var V=0,_=new Array(K);V<K;V++)_[V]=U[V];return _}function A(U,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],_=!0,I=!1,Y=void 0;try{for(var ee=U[Symbol.iterator](),ae;!(_=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);_=!0);}catch(de){I=!0,Y=de}finally{try{!_&&ee.return!=null&&ee.return()}finally{if(I)throw Y}}return V}function O(U){if(Array.isArray(U))return U}function L(U,K){if(U==null)return{};var V=C(U,K),_,I;if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(U);for(I=0;I<Y.length;I++){if(_=Y[I],K.indexOf(_)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,_))continue;V[_]=U[_]}}return V}function C(U,K){if(U==null)return{};var V={},_=Object.keys(U),I,Y;for(Y=0;Y<_.length;Y++){if(I=_[Y],K.indexOf(I)>=0)continue;V[I]=U[I]}return V}var T=function(K){var V=K.className,_=K.percent,I=K.prefixCls,Y=K.strokeColor,ee=K.strokeLinecap,ae=K.strokeWidth,de=K.style,De=K.trailColor,Se=K.trailWidth,we=K.transition,Ce=L(K,["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"]);delete Ce.gapPosition;var Te=Array.isArray(_)?_:[_],ge=Array.isArray(Y)?Y:[Y],le=M(Te),te=W(le,1),ce=te[0],ne=ae/2,Le=100-ae/2,Oe="M ".concat(ee==="round"?ne:0,",").concat(ne,`
L `).concat(ee==="round"?Le:100,",").concat(ne),Ee="0 0 100 ".concat(ae),Re=0;return Z.a.createElement("svg",z({className:$()("".concat(I,"-line"),V),viewBox:Ee,preserveAspectRatio:"none",style:de},Ce),Z.a.createElement("path",{className:"".concat(I,"-line-trail"),d:Oe,strokeLinecap:ee,stroke:De,strokeWidth:Se||ae,fillOpacity:"0"}),Te.map(function(Ne,je){var Ue={strokeDasharray:"".concat(Ne,"px, 100px"),strokeDashoffset:"-".concat(Re,"px"),transition:we||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},Ie=ge[je]||ge[ge.length-1];return Re+=Ne,Z.a.createElement("path",{key:je,className:"".concat(I,"-line-path"),d:Oe,strokeLinecap:ee,stroke:Ie,strokeWidth:ae,fillOpacity:"0",ref:ce[je],style:Ue})}))};T.defaultProps=B;var h=T;function o(){return o=Object.assign||function(U){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var _ in V)Object.prototype.hasOwnProperty.call(V,_)&&(U[_]=V[_])}return U},o.apply(this,arguments)}function l(U,K){return k(U)||g(U,K)||w(U,K)||d()}function d(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w(U,K){if(!U)return;if(typeof U=="string")return v(U,K);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return v(U,K)}function v(U,K){(K==null||K>U.length)&&(K=U.length);for(var V=0,_=new Array(K);V<K;V++)_[V]=U[V];return _}function g(U,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],_=!0,I=!1,Y=void 0;try{for(var ee=U[Symbol.iterator](),ae;!(_=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);_=!0);}catch(de){I=!0,Y=de}finally{try{!_&&ee.return!=null&&ee.return()}finally{if(I)throw Y}}return V}function k(U){if(Array.isArray(U))return U}function E(U,K){if(U==null)return{};var V=p(U,K),_,I;if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(U);for(I=0;I<Y.length;I++){if(_=Y[I],K.indexOf(_)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,_))continue;V[_]=U[_]}}return V}function p(U,K){if(U==null)return{};var V={},_=Object.keys(U),I,Y;for(Y=0;Y<_.length;Y++){if(I=_[Y],K.indexOf(I)>=0)continue;V[I]=U[I]}return V}var c=0;function u(U){return+U.replace("%","")}function a(U){return Array.isArray(U)?U:[U]}function b(U,K,V,_){var I=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,Y=arguments.length>5?arguments[5]:void 0,ee=50-_/2,ae=0,de=-ee,De=0,Se=-2*ee;switch(Y){case"left":ae=-ee,de=0,De=2*ee,Se=0;break;case"right":ae=ee,de=0,De=-2*ee,Se=0;break;case"bottom":de=ee,Se=2*ee;break;default:}var we="M 50,50 m ".concat(ae,",").concat(de,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(De,",").concat(-Se,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(-De,",").concat(Se),Ce=Math.PI*2*ee,Te={stroke:V,strokeDasharray:"".concat(K/100*(Ce-I),"px ").concat(Ce,"px"),strokeDashoffset:"-".concat(I/2+U/100*(Ce-I),"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s"};return{pathString:we,pathStyle:Te}}var m=function(K){var V=K.prefixCls,_=K.strokeWidth,I=K.trailWidth,Y=K.gapDegree,ee=K.gapPosition,ae=K.trailColor,de=K.strokeLinecap,De=K.style,Se=K.className,we=K.strokeColor,Ce=K.percent,Te=E(K,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"]),ge=Object(oe.useMemo)(function(){return c+=1,c},[]),le=b(0,100,ae,_,Y,ee),te=le.pathString,ce=le.pathStyle,ne=a(Ce),Le=a(we),Oe=Le.find(function(Ue){return Object.prototype.toString.call(Ue)==="[object Object]"}),Ee=M(ne),Re=l(Ee,1),Ne=Re[0],je=function(){var Ie=0;return ne.map(function(Me,Ke){var Ze=Le[Ke]||Le[Le.length-1],$e=Object.prototype.toString.call(Ze)==="[object Object]"?"url(#".concat(V,"-gradient-").concat(ge,")"):"",Qe=b(Ie,Me,Ze,_,Y,ee);return Ie+=Me,Z.a.createElement("path",{key:Ke,className:"".concat(V,"-circle-path"),d:Qe.pathString,stroke:$e,strokeLinecap:de,strokeWidth:_,opacity:Me===0?0:1,fillOpacity:"0",style:Qe.pathStyle,ref:Ne[Ke]})})};return Z.a.createElement("svg",o({className:$()("".concat(V,"-circle"),Se),viewBox:"0 0 100 100",style:De},Te),Oe&&Z.a.createElement("defs",null,Z.a.createElement("linearGradient",{id:"".concat(V,"-gradient-").concat(ge),x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(Oe).sort(function(Ue,Ie){return u(Ue)-u(Ie)}).map(function(Ue,Ie){return Z.a.createElement("stop",{key:Ie,offset:Ue,stopColor:Oe[Ue]})}))),Z.a.createElement("path",{className:"".concat(V,"-circle-trail"),d:te,stroke:ae,strokeLinecap:de,strokeWidth:I||_,fillOpacity:"0",style:ce}),je().reverse())};m.defaultProps=B;var x=m,F={Line:h,Circle:x}},iIVh:function(xt,it,se){},kSUc:function(xt,it,se){},lZu9:function(xt,it,se){(function(oe){oe(se("VrN/"),se("1eCo"),se("8EBN"))})(function(oe){"use strict";oe.defineMode("markdown",function(Z,D){var $=oe.getMode(Z,"text/html"),B=$.name=="null";function M(_){if(oe.findModeByName){var I=oe.findModeByName(_);I&&(_=I.mime||I.mimes[0])}var Y=oe.getMode(Z,_);return Y.name=="null"?null:Y}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 z={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 W in z)z.hasOwnProperty(W)&&D.tokenTypeOverrides[W]&&(z[W]=D.tokenTypeOverrides[W]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,R=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,y=/^\[(x| )\](?=\s)/i,A=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,O=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,C=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,T=/^\s*\[[^\]]+?\]:.*$/,h=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(_,I,Y){return I.f=I.inline=Y,Y(_,I)}function d(_,I,Y){return I.f=I.block=Y,Y(_,I)}function w(_){return!_||!/\S/.test(_.string)}function v(_){if(_.linkTitle=!1,_.linkHref=!1,_.linkText=!1,_.em=!1,_.strong=!1,_.strikethrough=!1,_.quote=0,_.indentedCode=!1,_.f==k){var I=B;if(!I){var Y=oe.innerMode($,_.htmlState);I=Y.mode.name=="xml"&&Y.state.tagStart===null&&!Y.state.context&&Y.state.tokenize.isInText}I&&(_.f=u,_.block=g,_.htmlState=null)}return _.trailingSpace=0,_.trailingSpaceNewLine=!1,_.prevLine=_.thisLine,_.thisLine={stream:null},null}function g(_,I){var Y=_.column()===I.indentation,ee=w(I.prevLine.stream),ae=I.indentedCode,de=I.prevLine.hr,De=I.list!==!1,Se=(I.listStack[I.listStack.length-1]||0)+3;I.indentedCode=!1;var we=I.indentation;if(I.indentationDiff===null&&(I.indentationDiff=I.indentation,De)){for(I.list=null;we<I.listStack[I.listStack.length-1];)I.listStack.pop(),I.listStack.length?I.indentation=I.listStack[I.listStack.length-1]:I.list=!1;I.list!==!1&&(I.indentationDiff=we-I.listStack[I.listStack.length-1])}var Ce=!ee&&!de&&!I.prevLine.header&&(!De||!ae)&&!I.prevLine.fencedCodeEnd,Te=(I.list===!1||de||ee)&&I.indentation<=Se&&_.match(P),ge=null;if(I.indentationDiff>=4&&(ae||I.prevLine.fencedCodeEnd||I.prevLine.header||ee))return _.skipToEnd(),I.indentedCode=!0,z.code;if(_.eatSpace())return null;if(Y&&I.indentation<=Se&&(ge=_.match(A))&&ge[1].length<=6)return I.quote=0,I.header=ge[1].length,I.thisLine.header=!0,D.highlightFormatting&&(I.formatting="header"),I.f=I.inline,p(I);if(I.indentation<=Se&&_.eat(">"))return I.quote=Y?1:I.quote+1,D.highlightFormatting&&(I.formatting="quote"),_.eatSpace(),p(I);if(!Te&&!I.setext&&Y&&I.indentation<=Se&&(ge=_.match(R))){var le=ge[1]?"ol":"ul";return I.indentation=we+_.current().length,I.list=!0,I.quote=0,I.listStack.push(I.indentation),I.em=!1,I.strong=!1,I.code=!1,I.strikethrough=!1,D.taskLists&&_.match(y,!1)&&(I.taskList=!0),I.f=I.inline,D.highlightFormatting&&(I.formatting=["list","list-"+le]),p(I)}else{if(Y&&I.indentation<=Se&&(ge=_.match(C,!0)))return I.quote=0,I.fencedEndRE=new RegExp(ge[1]+"+ *$"),I.localMode=D.fencedCodeBlockHighlighting&&M(ge[2]||D.fencedCodeBlockDefaultMode),I.localMode&&(I.localState=oe.startState(I.localMode)),I.f=I.block=E,D.highlightFormatting&&(I.formatting="code-block"),I.code=-1,p(I);if(I.setext||(!Ce||!De)&&!I.quote&&I.list===!1&&!I.code&&!Te&&!T.test(_.string)&&(ge=_.lookAhead(1))&&(ge=ge.match(O)))return I.setext?(I.header=I.setext,I.setext=0,_.skipToEnd(),D.highlightFormatting&&(I.formatting="header")):(I.header=ge[0].charAt(0)=="="?1:2,I.setext=I.header),I.thisLine.header=!0,I.f=I.inline,p(I);if(Te)return _.skipToEnd(),I.hr=!0,I.thisLine.hr=!0,z.hr;if(_.peek()==="[")return l(_,I,F)}return l(_,I,I.inline)}function k(_,I){var Y=$.token(_,I.htmlState);if(!B){var ee=oe.innerMode($,I.htmlState);(ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText||I.md_inside&&_.current().indexOf(">")>-1)&&(I.f=u,I.block=g,I.htmlState=null)}return Y}function E(_,I){var Y=I.listStack[I.listStack.length-1]||0,ee=I.indentation<Y,ae=Y+3;if(I.fencedEndRE&&I.indentation<=ae&&(ee||_.match(I.fencedEndRE))){D.highlightFormatting&&(I.formatting="code-block");var de;return ee||(de=p(I)),I.localMode=I.localState=null,I.block=g,I.f=u,I.fencedEndRE=null,I.code=0,I.thisLine.fencedCodeEnd=!0,ee?d(_,I,I.block):de}else return I.localMode?I.localMode.token(_,I.localState):(_.skipToEnd(),z.code)}function p(_){var I=[];if(_.formatting){I.push(z.formatting),typeof _.formatting=="string"&&(_.formatting=[_.formatting]);for(var Y=0;Y<_.formatting.length;Y++)I.push(z.formatting+"-"+_.formatting[Y]),_.formatting[Y]==="header"&&I.push(z.formatting+"-"+_.formatting[Y]+"-"+_.header),_.formatting[Y]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=_.quote?I.push(z.formatting+"-"+_.formatting[Y]+"-"+_.quote):I.push("error"))}if(_.taskOpen)return I.push("meta"),I.length?I.join(" "):null;if(_.taskClosed)return I.push("property"),I.length?I.join(" "):null;if(_.linkHref?I.push(z.linkHref,"url"):(_.strong&&I.push(z.strong),_.em&&I.push(z.em),_.strikethrough&&I.push(z.strikethrough),_.emoji&&I.push(z.emoji),_.linkText&&I.push(z.linkText),_.code&&I.push(z.code),_.image&&I.push(z.image),_.imageAltText&&I.push(z.imageAltText,"link"),_.imageMarker&&I.push(z.imageMarker)),_.header&&I.push(z.header,z.header+"-"+_.header),_.quote&&(I.push(z.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=_.quote?I.push(z.quote+"-"+_.quote):I.push(z.quote+"-"+D.maxBlockquoteDepth)),_.list!==!1){var ee=(_.listStack.length-1)%3;ee?ee===1?I.push(z.list2):I.push(z.list3):I.push(z.list1)}return _.trailingSpaceNewLine?I.push("trailing-space-new-line"):_.trailingSpace&&I.push("trailing-space-"+(_.trailingSpace%2?"a":"b")),I.length?I.join(" "):null}function c(_,I){return _.match(L,!0)?p(I):void 0}function u(_,I){var Y=I.text(_,I);if(typeof Y!="undefined")return Y;if(I.list)return I.list=null,p(I);if(I.taskList){var ee=_.match(y,!0)[1]===" ";return ee?I.taskOpen=!0:I.taskClosed=!0,D.highlightFormatting&&(I.formatting="task"),I.taskList=!1,p(I)}if(I.taskOpen=!1,I.taskClosed=!1,I.header&&_.match(/^#+$/,!0))return D.highlightFormatting&&(I.formatting="header"),p(I);var ae=_.next();if(I.linkTitle){I.linkTitle=!1;var de=ae;ae==="("&&(de=")"),de=(de+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+de+"\\\\]+|\\\\\\\\|\\\\.)"+de;if(_.match(new RegExp(De),!0))return z.linkHref}if(ae==="`"){var Se=I.formatting;D.highlightFormatting&&(I.formatting="code"),_.eatWhile("`");var we=_.current().length;if(I.code==0&&(!I.quote||we==1))return I.code=we,p(I);if(we==I.code){var Ce=p(I);return I.code=0,Ce}else return I.formatting=Se,p(I)}else if(I.code)return p(I);if(ae==="\\"&&(_.next(),D.highlightFormatting)){var Te=p(I),ge=z.formatting+"-escape";return Te?Te+" "+ge:ge}if(ae==="!"&&_.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return I.imageMarker=!0,I.image=!0,D.highlightFormatting&&(I.formatting="image"),p(I);if(ae==="["&&I.imageMarker&&_.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return I.imageMarker=!1,I.imageAltText=!0,D.highlightFormatting&&(I.formatting="image"),p(I);if(ae==="]"&&I.imageAltText){D.highlightFormatting&&(I.formatting="image");var Te=p(I);return I.imageAltText=!1,I.image=!1,I.inline=I.f=b,Te}if(ae==="["&&!I.image)return I.linkText&&_.match(/^.*?\]/)||(I.linkText=!0,D.highlightFormatting&&(I.formatting="link")),p(I);if(ae==="]"&&I.linkText){D.highlightFormatting&&(I.formatting="link");var Te=p(I);return I.linkText=!1,I.inline=I.f=_.match(/\(.*?\)| ?\[.*?\]/,!1)?b:u,Te}if(ae==="<"&&_.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=a,D.highlightFormatting&&(I.formatting="link");var Te=p(I);return Te?Te+=" ":Te="",Te+z.linkInline}if(ae==="<"&&_.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=a,D.highlightFormatting&&(I.formatting="link");var Te=p(I);return Te?Te+=" ":Te="",Te+z.linkEmail}if(D.xml&&ae==="<"&&_.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var le=_.string.indexOf(">",_.pos);if(le!=-1){var te=_.string.substring(_.start,le);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(te)&&(I.md_inside=!0)}return _.backUp(1),I.htmlState=oe.startState($),d(_,I,k)}if(D.xml&&ae==="<"&&_.match(/^\/\w*?>/))return I.md_inside=!1,"tag";if(ae==="*"||ae==="_"){for(var ce=1,ne=_.pos==1?" ":_.string.charAt(_.pos-2);ce<3&&_.eat(ae);)ce++;var Le=_.peek()||" ",Oe=!/\s/.test(Le)&&(!h.test(Le)||/\s/.test(ne)||h.test(ne)),Ee=!/\s/.test(ne)&&(!h.test(ne)||/\s/.test(Le)||h.test(Le)),Re=null,Ne=null;if(ce%2&&(!I.em&&Oe&&(ae==="*"||!Ee||h.test(ne))?Re=!0:I.em==ae&&Ee&&(ae==="*"||!Oe||h.test(Le))&&(Re=!1)),ce>1&&(!I.strong&&Oe&&(ae==="*"||!Ee||h.test(ne))?Ne=!0:I.strong==ae&&Ee&&(ae==="*"||!Oe||h.test(Le))&&(Ne=!1)),Ne!=null||Re!=null){D.highlightFormatting&&(I.formatting=Re==null?"strong":Ne==null?"em":"strong em"),Re===!0&&(I.em=ae),Ne===!0&&(I.strong=ae);var Ce=p(I);return Re===!1&&(I.em=!1),Ne===!1&&(I.strong=!1),Ce}}else if(ae===" "&&(_.eat("*")||_.eat("_"))){if(_.peek()===" ")return p(I);_.backUp(1)}if(D.strikethrough){if(ae==="~"&&_.eatWhile(ae)){if(I.strikethrough){D.highlightFormatting&&(I.formatting="strikethrough");var Ce=p(I);return I.strikethrough=!1,Ce}else if(_.match(/^[^\s]/,!1))return I.strikethrough=!0,D.highlightFormatting&&(I.formatting="strikethrough"),p(I)}else if(ae===" "&&_.match(/^~~/,!0)){if(_.peek()===" ")return p(I);_.backUp(2)}}if(D.emoji&&ae===":"&&_.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){I.emoji=!0,D.highlightFormatting&&(I.formatting="emoji");var je=p(I);return I.emoji=!1,je}return ae===" "&&(_.match(/^ +$/,!1)?I.trailingSpace++:I.trailingSpace&&(I.trailingSpaceNewLine=!0)),p(I)}function a(_,I){var Y=_.next();if(Y===">"){I.f=I.inline=u,D.highlightFormatting&&(I.formatting="link");var ee=p(I);return ee?ee+=" ":ee="",ee+z.linkInline}return _.match(/^[^>]+/,!0),z.linkInline}function b(_,I){if(_.eatSpace())return null;var Y=_.next();return Y==="("||Y==="["?(I.f=I.inline=x(Y==="("?")":"]"),D.highlightFormatting&&(I.formatting="link-string"),I.linkHref=!0,p(I)):"error"}var m={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(_){return function(I,Y){var ee=I.next();if(ee===_){Y.f=Y.inline=u,D.highlightFormatting&&(Y.formatting="link-string");var ae=p(Y);return Y.linkHref=!1,ae}return I.match(m[_]),Y.linkHref=!0,p(Y)}}function F(_,I){return _.match(/^([^\]\\]|\\.)*\]:/,!1)?(I.f=U,_.next(),D.highlightFormatting&&(I.formatting="link"),I.linkText=!0,p(I)):l(_,I,u)}function U(_,I){if(_.match(/^\]:/,!0)){I.f=I.inline=K,D.highlightFormatting&&(I.formatting="link");var Y=p(I);return I.linkText=!1,Y}return _.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function K(_,I){return _.eatSpace()?null:(_.match(/^[^\s]+/,!0),_.peek()===void 0?I.linkTitle=!0:_.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),I.f=I.inline=u,z.linkHref+" url")}var V={startState:function(){return{f:g,prevLine:{stream:null},thisLine:{stream:null},block:g,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(_){return{f:_.f,prevLine:_.prevLine,thisLine:_.thisLine,block:_.block,htmlState:_.htmlState&&oe.copyState($,_.htmlState),indentation:_.indentation,localMode:_.localMode,localState:_.localMode?oe.copyState(_.localMode,_.localState):null,inline:_.inline,text:_.text,formatting:!1,linkText:_.linkText,linkTitle:_.linkTitle,linkHref:_.linkHref,code:_.code,em:_.em,strong:_.strong,strikethrough:_.strikethrough,emoji:_.emoji,header:_.header,setext:_.setext,hr:_.hr,taskList:_.taskList,list:_.list,listStack:_.listStack.slice(0),quote:_.quote,indentedCode:_.indentedCode,trailingSpace:_.trailingSpace,trailingSpaceNewLine:_.trailingSpaceNewLine,md_inside:_.md_inside,fencedEndRE:_.fencedEndRE}},token:function(_,I){if(I.formatting=!1,_!=I.thisLine.stream){if(I.header=0,I.hr=!1,_.match(/^\s*$/,!0))return v(I),null;if(I.prevLine=I.thisLine,I.thisLine={stream:_},I.taskList=!1,I.trailingSpace=0,I.trailingSpaceNewLine=!1,!I.localState&&(I.f=I.block,I.f!=k)){var Y=_.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(I.indentation=Y,I.indentationDiff=null,Y>0)return null}}return I.f(_,I)},innerMode:function(_){return _.block==k?{state:_.htmlState,mode:$}:_.localState?{state:_.localState,mode:_.localMode}:{state:_,mode:V}},indent:function(_,I,Y){return _.block==k&&$.indent?$.indent(_.htmlState,I,Y):_.localState&&_.localMode.indent?_.localMode.indent(_.localState,I,Y):oe.Pass},blankLine:v,getType:p,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return V},"xml"),oe.defineMIME("text/markdown","markdown"),oe.defineMIME("text/x-markdown","markdown")})},nojB:function(xt,it,se){"use strict";se.r(it);var oe=se("T2oS"),Z=se("W9HT"),D=se("9og8"),$=se("tJVT"),B=se("k1fw"),M=se("WmNS"),z=se.n(M),W=se("q1tI"),P=se.n(W),R=se("X0ci"),y=se("iIVh"),A=se("Ty5D"),O=se("55Ip"),L=se("+L6B"),C=se("2/Rp"),T=se("5NDa"),h=se("5rEg"),o=se("2qtc"),l=se("kLXV"),d=se("miYZ"),w=se("tsqr"),v=se("PpiC"),g=se("y8nQ"),k=se("Vl3Y"),E=se("DZo9"),p=se("8z0m"),c=se("sRBo"),u=se("kaz8"),a=se("LtfV"),b=se("m3rI"),m=se("Ot1p"),x=u.a.Group,F=p.a.Dragger;function U(ae,de){var De=new FileReader;De.addEventListener("load",function(){return de(De.result)}),De.readAsDataURL(ae)}var K=function(ae){var de=ae.callback,De=ae.tags,Se=De===void 0?[]:De,we=ae.initialValues,Ce=we===void 0?{}:we,Te=ae.removeAttachment,ge=Object(W.useState)(""),le=Object($.a)(ge,2),te=le[0],ce=le[1],ne=k.a.useForm(),Le=Object($.a)(ne,1),Oe=Le[0];function Ee(Ie){var Me=Ie.cover_id,Ke=Ie.attachment_ids,Ze=Object(v.a)(Ie,["cover_id","attachment_ids"]);de(Object(B.a)(Object(B.a)({},Ze),{},{cover_id:Me==null?void 0:Me.map(function($e){return $e.response?$e.response.id:$e.uid})[(Me==null?void 0:Me.length)-1],attachment_ids:Ke?Ke==null?void 0:Ke.map(function($e){return $e.response?$e.response.id:$e.uid}):[]}))}function Re(Ie){return Array.isArray(Ie)?Ie:Ie&&Ie.fileList}var Ne={multiple:!0,beforeUpload:function(Me){var Ke=Me.size/1024/1024<100;if(!Ke)return w.b.error("\u8BE5\u6587\u4EF6\u65E0\u6CD5\u4E0A\u4F20\u3002\u8D85\u8FC7\u6587\u4EF6\u5927\u5C0F\u9650\u5236(100MB),\u5EFA\u8BAE\u4E0A\u4F20\u5230\u767E\u5EA6\u4E91\u7B49\u5176\u5B83\u5171\u4EAB\u5DE5\u5177\u91CC\uFF0C\u7136\u540E\u518Dtxt\u6587\u6863\u91CC\u7ED9\u51FA\u94FE\u63A5\u4EE5\u53CA\u5171\u4EAB\u5BC6\u7801\u5E76\u4E0A\u4F20"),Ke},action:"".concat(b.a.API_SERVER,"/api/attachments.json"),onRemove:function(Me){l.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",content:"\u662F\u5426\u786E\u8BA4\u5220\u9664?",onOk:function(){return Te(Me.response?Me.response.id:Me.uid)},onCancel:function(){return!1}})}};function je(Ie){Ie.file.status==="done"&&U(Ie.file.originFileObj,function(Me){return ce(Me)})}var Ue={showUploadList:!1,withCredentials:!0,action:"".concat(b.a.API_SERVER,"/api/attachments.json"),onChange:je};return Object(W.useEffect)(function(){Ce.title&&(Oe.setFieldsValue(Ce),Ce.cover_id.length>0&&ce(b.a.IMG_SERVER+Ce.cover_id[0].url))},[Ce]),P.a.createElement(k.a,{form:Oe,initialValues:Ce,className:"moop-panel",onFinish:Ee},P.a.createElement(k.a.Item,{label:"\u6807\u9898",name:"title",extra:P.a.createElement("p",{className:"tip"},"\u7B80\u660E\u627C\u8981\u4ECB\u7ECD\u6587\u6863/\u89C6\u9891\u6240\u5305\u542B\u7684\u4E3B\u8981\u7684\u5185\u5BB9"),rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6807\u9898"}]},P.a.createElement(h.a,{placeholder:"\u4F8B\u5982\uFF1A\u8F6F\u4EF6\u5DE5\u7A0B\u6559\u5B66\u6848\u4F8B"})),P.a.createElement("div",{className:"flex-container"},P.a.createElement(k.a.Item,{label:"\u4F5C\u8005",name:"author_name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F5C\u8005\u540D\u79F0"}]},P.a.createElement(h.a,{placeholder:"\u8BF7\u8F93\u5165\u59D3\u540D",style:{marginRight:20,width:200}})),P.a.createElement(k.a.Item,{name:"author_school_name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F5C\u8005\u5355\u4F4D\u540D\u79F0"}]},P.a.createElement(h.a,{placeholder:"\u8BF7\u8F93\u5165\u4F5C\u8005\u5355\u4F4D\u540D\u79F0",style:{width:200}}))),P.a.createElement(k.a.Item,{name:"tag_ids",label:"\u6807\u7B7E",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u4E00\u4E2A\u6807\u7B7E"}]},P.a.createElement(x,null,Se.map(function(Ie){return P.a.createElement(u.a,{key:Ie.id,value:Ie.id}," ",Ie.name," ")}))),P.a.createElement(k.a.Item,{name:"publish",valuePropName:"checked"},P.a.createElement(u.a,null,"\u662F\u5426\u7533\u8BF7\u53D1\u5E03")),P.a.createElement(k.a.Item,{name:"content",label:"\u63CF\u8FF0",valuePropName:"defaultValue",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u63CF\u8FF0\u5185\u5BB9"}]},P.a.createElement(m.a,{id:"moop_cases_content",height:400})),P.a.createElement(k.a.Item,{name:"attachment_ids",valuePropName:"fileList",getValueFromEvent:Re},P.a.createElement(F,Ne,P.a.createElement("p",{className:"c-blue",style:{marginBottom:10,fontSize:18}},"\u4E0A\u4F20\u9644\u4EF6"),P.a.createElement("p",{className:"c-grey-c"},"\u4ECE\u6211\u7684\u7535\u8111\u9009\u62E9\u8981\u4E0A\u4F20\u7684\u6587\u6863\uFF1A\u6309\u4F4FCTRL\u53EF\u4EE5\u4E0A\u4F20\u591A\u4EFD\u6587\u6863\u3002\u5355\u4E2A\u6587\u4EF6\u6700\u5927\u9650\u5236\uFF1A100MB"))),P.a.createElement(k.a.Item,{name:"cover_id",label:"\u5C01\u9762\u56FE",extra:"\u4E0A\u4F20\u5C3A\u5BF8\uFF1A120*90 px",getValueFromEvent:Re,valuePropName:"fileList",rules:[{required:!0,message:"\u8BF7\u4E0A\u4F20\u5C01\u9762\u56FE"}]},P.a.createElement(p.a,Ue,te?P.a.createElement("img",{src:te,width:120}):P.a.createElement("a",{title:"\u4E0A\u4F20\u5C01\u9762\u56FE",className:"upload-cover"}," ",P.a.createElement(a.a,null)," "))),P.a.createElement("div",{className:"desc"},P.a.createElement("h3",null,"\u5BA1\u6838\u8BF4\u660E"),P.a.createElement("p",null," ","\u5E73\u53F0\u7BA1\u7406\u5458\u5C06\u5BF9\u6BCF\u5929\u65B0\u4E0A\u4F20\u7684\u6587\u6863\u8FDB\u884C\u5BA1\u6838\uFF0C\u5BA1\u6838\u901A\u8FC7\u7684\u6587\u6863\u5C06\u516C\u5F00\u663E\u793A\uFF0C\u5426\u5219\u5C06\u79C1\u6709\u5316\u6216\u79FB\u9664"," ")),P.a.createElement("div",{className:"desc"},P.a.createElement("h3",null,"\u6E29\u99A8\u63D0\u793A"),P.a.createElement("ul",{style:{padding:0}},P.a.createElement("li",null,"1.\u8BF7\u52FF\u4E0A\u4F20\u5DF2\u8BBE\u7F6E\u52A0\u5BC6\u53E3\u4EE4\u7684\u6587\u6863\u8D44\u6E90\uFF1B"),P.a.createElement("li",null,"2.\u53EF\u4EE5\u4E0A\u4F20\u7B26\u5408\u6559\u5B66\u6848\u4F8B\u6807\u51C6\u7684\u6587\u6863\u8D44\u6599\uFF0C\u5982",P.a.createElement("a",{href:"https://www.educoder.net/courses/1309/boards/5909/messages/34799",target:"_blank"}," ","\u6848\u4F8B\u5165\u5E93\u6807\u51C6"," ")," ","\u3001",P.a.createElement("a",{href:"https://www.educoder.net/courses/1309/boards/5909/messages/34798",target:"_blank"},"\u6848\u4F8B\u4F7F\u7528\u8BF4\u660E\u4E66"),"\u4EE5\u53CA\u5176\u4ED6\u8D44\u6599\u7B49\uFF0C\u4E0A\u4F20\u652F\u6301\u7684\u6587\u4EF6\u6700\u5927\u5BB9\u91CF\uFF1A100MB\uFF1B"),P.a.createElement("li",null,"3.\u8BF7\u786E\u4FDD\u4E0A\u4F20\u5185\u5BB9\u65E0\u4FB5\u6743\u6216\u8FDD\u53CD\u56FD\u5BB6\u5173\u4E8E\u4E92\u8054\u7F51\u653F\u7B56\u7684\u4E0D\u826F\u884C\u4E3A\uFF1B"),P.a.createElement("li",null,"4.\u8BF7\u4F7F\u7528Chrome\uFF0CFirefox\uFF0CSafari\uFF0CIE11\uFF08\u53CA\u4EE5\u4E0A\u7248\u672C\uFF09\u6D4F\u89C8\u5668\uFF1B"))),P.a.createElement(k.a.Item,{style:{marginTop:10}},P.a.createElement(C.a,{type:"primary",htmlType:"submit"},"\u63D0\u4EA4")))},V=se("wzkS"),_={loading:!1,data:{},tags:[]},I;(function(ae){ae[ae.GET_DATA=0]="GET_DATA",ae[ae.SET_LOADING=1]="SET_LOADING",ae[ae.GET_TAGS=2]="GET_TAGS"})(I||(I={}));function Y(ae,de){switch(de.type){case I.GET_DATA:return Object(B.a)(Object(B.a)({},ae),de.payload);case I.GET_TAGS:return Object(B.a)(Object(B.a)({},ae),{},{tags:de.payload});case I.SET_LOADING:return Object(B.a)(Object(B.a)({},ae),{},{loading:de.payload});default:throw new Error}}var ee=it.default=function(){var ae=Object(A.i)(),de=ae.caseId,De=Object(A.g)(),Se=Object(W.useReducer)(Y,_),we=Object($.a)(Se,2),Ce=we[0],Te=we[1],ge=Ce.loading,le=Ce.tags,te=Ce.data;Object(W.useEffect)(function(){function Oe(){return Ee.apply(this,arguments)}function Ee(){return Ee=Object(D.a)(z.a.mark(function Re(){var Ne;return z.a.wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:return Ue.next=2,Object(V.b)();case 2:Ne=Ue.sent,Te({type:I.GET_TAGS,payload:Ne.library_tags});case 4:case"end":return Ue.stop()}},Re)})),Ee.apply(this,arguments)}Oe()},[]),Object(W.useEffect)(function(){var Oe=!1;function Ee(){return Re.apply(this,arguments)}function Re(){return Re=Object(D.a)(z.a.mark(function Ne(){var je,Ue,Ie,Me,Ke,Ze,$e,Qe,lt;return z.a.wrap(function(rt){for(;;)switch(rt.prev=rt.next){case 0:return Te({type:I.SET_LOADING,payload:!1}),rt.next=3,Object(V.c)(de);case 3:je=rt.sent,Ue=je.author_name,Ie=je.author_school_name,Me=je.content,Ke=je.cover,Ze=je.attachments,$e=je.status,Qe=je.title,lt=je.tags,Oe||(je.status===404?De.push("/moop_cases"):Te({type:I.GET_DATA,payload:{data:{title:Qe,author_name:Ue,author_school_name:Ie,content:Me,tag_ids:lt.map(function(Pe){return Pe.id}),publish:$e==="published",attachment_ids:Ze.map(function(Pe){return{uid:Pe.id,id:Pe.id,name:Pe.title,url:Pe.url,filesize:Pe.filesize,status:"done"}}),cover_id:Ke!=null&&Ke.id?[{uid:Ke==null?void 0:Ke.id,id:Ke==null?void 0:Ke.id,name:Ke==null?void 0:Ke.title,url:Ke==null?void 0:Ke.url,filesize:Ke==null?void 0:Ke.filesize,status:"done"}]:[]},loading:!1}}));case 6:case"end":return rt.stop()}},Ne)})),Re.apply(this,arguments)}return!Oe&&de&&Ee(),function(){Oe=!0}},[de]);function ce(Oe){return ne.apply(this,arguments)}function ne(){return ne=Object(D.a)(z.a.mark(function Oe(Ee){var Re,Ne;return z.a.wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:if(!de){Ue.next=6;break}return Ue.next=3,Object(V.e)(de,Ee);case 3:De.push("/moop_cases/".concat(de,"/publish-success")),Ue.next=11;break;case 6:return Ue.next=8,Object(V.a)(Ee);case 8:Re=Ue.sent,Ne=Re.id,Ne&&De.push("/moop_cases/".concat(Ne,"/publish-success"));case 11:case"end":return Ue.stop()}},Oe)})),ne.apply(this,arguments)}var Le={initialValues:te,tags:le,removeAttachment:V.d,callback:ce};return P.a.createElement(Z.a,{spinning:ge,delay:500},P.a.createElement("div",{className:"moop-info"},P.a.createElement("div",{className:"crumb"},P.a.createElement(O.a,{to:"/moop_cases"},"\u6559\u5B66\u6848\u4F8B > "),P.a.createElement("span",null,"\u65B0\u5EFA")),P.a.createElement("div",{className:"title"},P.a.createElement("h2",null,"\u4E0A\u4F20\u6559\u5B66\u6848\u4F8B"),P.a.createElement(O.a,{to:"/moop_cases"},"\u8FD4\u56DE")),P.a.createElement(K,Le)))}},osHv:function(xt,it,se){(function(oe){oe(se("VrN/"))})(function(oe){"use strict";var Z=oe.Pos;function D(h,o){return h.line-o.line||h.ch-o.ch}var $="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",B=$+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",M=new RegExp("<(/?)(["+$+"]["+B+"]*)","g");function z(h,o,l,d){this.line=o,this.ch=l,this.cm=h,this.text=h.getLine(o),this.min=d?Math.max(d.from,h.firstLine()):h.firstLine(),this.max=d?Math.min(d.to-1,h.lastLine()):h.lastLine()}function W(h,o){var l=h.cm.getTokenTypeAt(Z(h.line,o));return l&&/\btag\b/.test(l)}function P(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function R(h){return h.line<=h.min?void 0:(h.text=h.cm.getLine(--h.line),h.ch=h.text.length,!0)}function y(h){for(;;){var o=h.text.indexOf(">",h.ch);if(o==-1){if(P(h))continue;return}if(!W(h,o+1)){h.ch=o+1;continue}var l=h.text.lastIndexOf("/",o),d=l>-1&&!/\S/.test(h.text.slice(l+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function A(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(R(h))continue;return}if(!W(h,o+1)){h.ch=o;continue}M.lastIndex=o,h.ch=o;var l=M.exec(h.text);if(l&&l.index==o)return l}}function O(h){for(;;){M.lastIndex=h.ch;var o=M.exec(h.text);if(!o){if(P(h))continue;return}if(!W(h,o.index+1)){h.ch=o.index+1;continue}return h.ch=o.index+o[0].length,o}}function L(h){for(;;){var o=h.ch?h.text.lastIndexOf(">",h.ch-1):-1;if(o==-1){if(R(h))continue;return}if(!W(h,o+1)){h.ch=o;continue}var l=h.text.lastIndexOf("/",o),d=l>-1&&!/\S/.test(h.text.slice(l+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function C(h,o){for(var l=[];;){var d=O(h),w,v=h.line,g=h.ch-(d?d[0].length:0);if(!d||!(w=y(h)))return;if(w=="selfClose")continue;if(d[1]){for(var k=l.length-1;k>=0;--k)if(l[k]==d[2]){l.length=k;break}if(k<0&&(!o||o==d[2]))return{tag:d[2],from:Z(v,g),to:Z(h.line,h.ch)}}else l.push(d[2])}}function T(h,o){for(var l=[];;){var d=L(h);if(!d)return;if(d=="selfClose"){A(h);continue}var w=h.line,v=h.ch,g=A(h);if(!g)return;if(g[1])l.push(g[2]);else{for(var k=l.length-1;k>=0;--k)if(l[k]==g[2]){l.length=k;break}if(k<0&&(!o||o==g[2]))return{tag:g[2],from:Z(h.line,h.ch),to:Z(w,v)}}}}oe.registerHelper("fold","xml",function(h,o){for(var l=new z(h,o.line,0);;){var d=O(l);if(!d||l.line!=o.line)return;var w=y(l);if(!w)return;if(!d[1]&&w!="selfClose"){var v=Z(l.line,l.ch),g=C(l,d[2]);return g&&D(g.from,v)>0?{from:v,to:g.from}:null}}}),oe.findMatchingTag=function(h,o,l){var d=new z(h,o.line,o.ch,l);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var w=y(d),v=w&&Z(d.line,d.ch),g=w&&A(d);if(!w||!g||D(d,o)>0)return;var k={from:Z(d.line,d.ch),to:v,tag:g[2]};return w=="selfClose"?{open:k,close:null,at:"open"}:g[1]?{open:T(d,g[2]),close:k,at:"close"}:(d=new z(h,v.line,v.ch,l),{open:k,close:C(d,g[2]),at:"open"})},oe.findEnclosingTag=function(h,o,l,d){for(var w=new z(h,o.line,o.ch,l);;){var v=T(w,d);if(!v)break;var g=new z(h,o.line,o.ch,l),k=C(g,v.tag);if(k)return{open:v,close:k}}},oe.scanForClosingTag=function(h,o,l,d){var w=new z(h,o.line,o.ch,d?{from:0,to:d}:null);return C(w,l)}})},p5ED:function(xt,it,se){"use strict";var oe=se("+L6B"),Z=se("2/Rp"),D=se("5Dmo"),$=se("3S7+"),B=se("k1fw"),M=se("9og8"),z=se("tJVT"),W=se("WmNS"),P=se.n(W),R=se("q1tI"),y=se.n(R),A=se("vHTk"),O=se.n(A),L=se("yEEn"),C=se("ZW9T"),T=se("1vsH"),h=se("V0Rq"),o=se("m3rI");it.a=function(l){var d,w,v,g,k,E,p,c=l.editOffice,u=c===void 0?"view":c,a=l.data,b=l.theme,m=l.type,x=l.filename,F=l.monacoEditor,U=l.className,K=l.style,V=l.close,_=l.onClose,I=l.hasMask,Y=l.disabledDownload,ee=Object(R.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ae=Object(z.a)(ee,2),de=ae[0],De=ae[1],Se=Object(R.useState)(""),we=Object(z.a)(Se,2),Ce=we[0],Te=we[1],ge=Object(R.useState)(),le=Object(z.a)(ge,2),te=le[0],ce=le[1],ne=window.ENV==="build"?"/react/build":"",Le=o.a.PROXY_SERVER||location.origin,Oe,Ee=1024*1024,Re=10*Ee,Ne=Object(R.useRef)();(d=a)!==null&&d!==void 0&&d.startsWith("/api")&&m!=="txt"&&(a=o.a.API_SERVER+a),m==="office"&&(Oe=Object(T.T)(a).filesize,Oe>Re&&(m="other")),x&&F&&(F.filename=x),Object(R.useEffect)(function(){var Me,Ke,Ze=(Me=document.cookie)===null||Me===void 0||((Ke=Me.replace(/\s/g,""))===null||Ke===void 0)?void 0:Ke.split(";");Ze==null||Ze.map(function($e){var Qe=$e.split("=");Qe[0]==="_educoder_session"&&Te(Qe[1])})},[]),Object(R.useEffect)(function(){m==="office"&&je()},[m,a]);var je=function(){var Me=Object(M.a)(P.a.mark(function Ke(){var Ze,$e,Qe;return P.a.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return console.log("data:",a),Ze=a,a.startsWith("http")||(Ze=location.origin+Ze),$e=new URL(Ze).pathname.split("/").pop(),tt.next=6,Object(h.V)({attachment_id:$e});case 6:Qe=tt.sent,ce(Qe);case 8:case"end":return tt.stop()}},Ke)}));return function(){return Me.apply(this,arguments)}}(),Ue=function(){if(a.startsWith("http")||a.startsWith("blob:")){Ie();return}Object(T.z)(x||"educoder",a,x)},Ie=function(){Object(T.x)(x||"educoder",decodeURIComponent(a))};return y.a.createElement("div",{style:Object(B.a)({},K||{}),className:"".concat(I&&O.a.bgBlack," ").concat(m?O.a.wrp:"hide")},V&&y.a.createElement("div",{className:O.a.close,ref:Ne},!Y&&y.a.createElement($.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Ne.current}},y.a.createElement("span",{onClick:Ie},y.a.createElement("i",{className:"icon-quxiaozhiding"}))),y.a.createElement($.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Ne.current}},y.a.createElement("span",{className:"",onClick:_},y.a.createElement("i",{className:"icon-guanbi1"})))),y.a.createElement("div",{className:"".concat(O.a[U]," ").concat(U," ").concat(O.a.monaco," ").concat(m==="txt"?"show":"hide")},m==="txt"&&y.a.createElement(C.b,F)),m==="audio"&&y.a.createElement("audio",{src:"".concat(((w=a)===null||w===void 0?void 0:w.indexOf("http://"))>-1||((v=a)===null||v===void 0?void 0:v.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),m==="video"&&y.a.createElement(y.a.Fragment,null,((g=a)===null||g===void 0?void 0:g.indexOf("http"))>-1?y.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):y.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),m==="office"&&te&&y.a.createElement("iframe",{src:"".concat(ne,"/office.html?key=").concat(te.key,"&url=").concat(Le+te.url,"&callbackUrl=").concat(Le+te.callbackUrl,"&fileType=").concat(te.fileType,"&title=").concat(te.title,"&model=").concat(u,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!Y)}),m==="html"&&y.a.createElement("iframe",{src:a+"&disposition=inline"}),m==="pdf"&&y.a.createElement("iframe",{src:"".concat(ne,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!Y)}),m==="image"&&y.a.createElement("img",{src:"".concat(((k=a)===null||k===void 0?void 0:k.indexOf("http://"))>-1||((E=a)===null||E===void 0?void 0:E.indexOf("https://"))>-1||(p=a)!==null&&p!==void 0&&p.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),m==="other"&&y.a.createElement("div",null,y.a.createElement(Z.a,{type:"primary",size:"large",onClick:Ue},y.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),m==="download"&&y.a.createElement(Z.a,{type:"primary",size:"large",onClick:Ue},y.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(xt,it,se){},rUJ1:function(xt,it){const se=/[&<>"']/,oe=/[&<>"']/g,Z=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,$={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},B=E=>$[E];function M(E,p){if(p){if(se.test(E))return E.replace(oe,B)}else if(Z.test(E))return E.replace(D,B);return E}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function W(E){return E.replace(z,(p,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const P=/(^|[^\[])\^/g;function R(E,p){E=E.source||E,p=p||"";const c={replace:(u,a)=>(a=a.source||a,a=a.replace(P,"$1"),E=E.replace(u,a),c),getRegex:()=>new RegExp(E,p)};return c}const y=/[^\w:]/g,A=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function O(E,p,c){if(E){let u;try{u=decodeURIComponent(W(c)).replace(y,"").toLowerCase()}catch(a){return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}p&&!A.test(c)&&(c=o(p,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(u){return null}return c}const L={},C=/^[^:]+:\/*[^/]*$/,T=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(E,p){L[" "+E]||(C.test(E)?L[" "+E]=E+"/":L[" "+E]=v(E,"/",!0)),E=L[" "+E];const c=E.indexOf(":")===-1;return p.substring(0,2)==="//"?c?p:E.replace(T,"$1")+p:p.charAt(0)==="/"?c?p:E.replace(h,"$1")+p:E+p}const l={exec:function(){}};function d(E){let p=1,c,u;for(;p<arguments.length;p++){c=arguments[p];for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(E[u]=c[u])}return E}function w(E,p){const c=E.replace(/\|/g,(b,m,x)=>{let F=!1,U=m;for(;--U>=0&&x[U]==="\\";)F=!F;return F?"|":" |"}),u=c.split(/ \|/);let a=0;if(u.length>p)u.splice(p);else for(;u.length<p;)u.push("");for(;a<u.length;a++)u[a]=u[a].trim().replace(/\\\|/g,"|");return u}function v(E,p,c){const u=E.length;if(u===0)return"";let a=0;for(;a<u;){const b=E.charAt(u-a-1);if(b===p&&!c)a++;else if(b!==p&&c)a++;else break}return E.substr(0,u-a)}function g(E,p){if(E.indexOf(p[1])===-1)return-1;const c=E.length;let u=0,a=0;for(;a<c;a++)if(E[a]==="\\")a++;else if(E[a]===p[0])u++;else if(E[a]===p[1]&&(u--,u<0))return a;return-1}function k(E){E&&E.sanitize&&!E.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")}xt.exports={escape:M,unescape:W,edit:R,cleanUrl:O,resolveUrl:o,noopTest:l,merge:d,splitCells:w,rtrim:v,findClosingBracket:g,checkSanitizeDeprecation:k}},ulZh:function(xt,it,se){typeof window!="undefined"&&function(Z,D){xt.exports=D()}(this,function(){return function(oe){var Z={};function D($){if(Z[$])return Z[$].exports;var B=Z[$]={i:$,l:!1,exports:{}};return oe[$].call(B.exports,B,B.exports,D),B.l=!0,B.exports}return D.m=oe,D.c=Z,D.d=function($,B,M){D.o($,B)||Object.defineProperty($,B,{enumerable:!0,get:M})},D.r=function($){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),Object.defineProperty($,"__esModule",{value:!0})},D.t=function($,B){if(B&1&&($=D($)),B&8)return $;if(B&4&&typeof $=="object"&&$&&$.__esModule)return $;var M=Object.create(null);if(D.r(M),Object.defineProperty(M,"default",{enumerable:!0,value:$}),B&2&&typeof $!="string")for(var z in $)D.d(M,z,function(W){return $[W]}.bind(null,z));return M},D.n=function($){var B=$&&$.__esModule?function(){return $.default}:function(){return $};return D.d(B,"a",B),B},D.o=function($,B){return Object.prototype.hasOwnProperty.call($,B)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(oe,Z,D){"use strict";var $=Object.prototype.hasOwnProperty,B="~";function M(){}Object.create&&(M.prototype=Object.create(null),new M().__proto__||(B=!1));function z(y,A,O){this.fn=y,this.context=A,this.once=O||!1}function W(y,A,O,L,C){if(typeof O!="function")throw new TypeError("The listener must be a function");var T=new z(O,L||y,C),h=B?B+A:A;return y._events[h]?y._events[h].fn?y._events[h]=[y._events[h],T]:y._events[h].push(T):(y._events[h]=T,y._eventsCount++),y}function P(y,A){--y._eventsCount===0?y._events=new M:delete y._events[A]}function R(){this._events=new M,this._eventsCount=0}R.prototype.eventNames=function(){var A=[],O,L;if(this._eventsCount===0)return A;for(L in O=this._events)$.call(O,L)&&A.push(B?L.slice(1):L);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(O)):A},R.prototype.listeners=function(A){var O=B?B+A:A,L=this._events[O];if(!L)return[];if(L.fn)return[L.fn];for(var C=0,T=L.length,h=new Array(T);C<T;C++)h[C]=L[C].fn;return h},R.prototype.listenerCount=function(A){var O=B?B+A:A,L=this._events[O];return L?L.fn?1:L.length:0},R.prototype.emit=function(A,O,L,C,T,h){var o=B?B+A:A;if(!this._events[o])return!1;var l=this._events[o],d=arguments.length,w,v;if(l.fn){l.once&&this.removeListener(A,l.fn,void 0,!0);switch(d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,O),!0;case 3:return l.fn.call(l.context,O,L),!0;case 4:return l.fn.call(l.context,O,L,C),!0;case 5:return l.fn.call(l.context,O,L,C,T),!0;case 6:return l.fn.call(l.context,O,L,C,T,h),!0}for(v=1,w=new Array(d-1);v<d;v++)w[v-1]=arguments[v];l.fn.apply(l.context,w)}else{var g=l.length,k;for(v=0;v<g;v++){l[v].once&&this.removeListener(A,l[v].fn,void 0,!0);switch(d){case 1:l[v].fn.call(l[v].context);break;case 2:l[v].fn.call(l[v].context,O);break;case 3:l[v].fn.call(l[v].context,O,L);break;case 4:l[v].fn.call(l[v].context,O,L,C);break;default:if(!w)for(k=1,w=new Array(d-1);k<d;k++)w[k-1]=arguments[k];l[v].fn.apply(l[v].context,w)}}}return!0},R.prototype.on=function(A,O,L){return W(this,A,O,L,!1)},R.prototype.once=function(A,O,L){return W(this,A,O,L,!0)},R.prototype.removeListener=function(A,O,L,C){var T=B?B+A:A;if(!this._events[T])return this;if(!O)return P(this,T),this;var h=this._events[T];if(h.fn)h.fn===O&&(!C||h.once)&&(!L||h.context===L)&&P(this,T);else{for(var o=0,l=[],d=h.length;o<d;o++)(h[o].fn!==O||C&&!h[o].once||L&&h[o].context!==L)&&l.push(h[o]);l.length?this._events[T]=l.length===1?l[0]:l:P(this,T)}return this},R.prototype.removeAllListeners=function(A){var O;return A?(O=B?B+A:A,this._events[O]&&P(this,O)):(this._events=new M,this._eventsCount=0),this},R.prototype.off=R.prototype.removeListener,R.prototype.addListener=R.prototype.on,R.prefixed=B,R.EventEmitter=R,oe.exports=R},"./node_modules/url-toolkit/src/url-toolkit.js":function(oe,Z,D){(function($){var B=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,M=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,W=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(R,y,A){if(A=A||{},R=R.trim(),y=y.trim(),!y){if(!A.alwaysNormalize)return R;var O=P.parseURL(R);if(!O)throw new Error("Error trying to parse base URL.");return O.path=P.normalizePath(O.path),P.buildURLFromParts(O)}var L=P.parseURL(y);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return A.alwaysNormalize?(L.path=P.normalizePath(L.path),P.buildURLFromParts(L)):y;var C=P.parseURL(R);if(!C)throw new Error("Error trying to parse base URL.");if(!C.netLoc&&C.path&&C.path[0]!=="/"){var T=M.exec(C.path);C.netLoc=T[1],C.path=T[2]}C.netLoc&&!C.path&&(C.path="/");var h={scheme:C.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(h.netLoc=C.netLoc,L.path[0]!=="/"))if(!L.path)h.path=C.path,L.params||(h.params=C.params,L.query||(h.query=C.query));else{var o=C.path,l=o.substring(0,o.lastIndexOf("/")+1)+L.path;h.path=P.normalizePath(l)}return h.path===null&&(h.path=A.alwaysNormalize?P.normalizePath(L.path):L.path),P.buildURLFromParts(h)},parseURL:function(R){var y=B.exec(R);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(R){for(R=R.split("").reverse().join("").replace(z,"");R.length!==(R=R.replace(W,"")).length;);return R.split("").reverse().join("")},buildURLFromParts:function(R){return R.scheme+R.netLoc+R.path+R.params+R.query+R.fragment}};oe.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(oe,Z,D){function $(A){var O={};function L(T){if(O[T])return O[T].exports;var h=O[T]={i:T,l:!1,exports:{}};return A[T].call(h.exports,h,h.exports,L),h.l=!0,h.exports}L.m=A,L.c=O,L.i=function(T){return T},L.d=function(T,h,o){L.o(T,h)||Object.defineProperty(T,h,{configurable:!1,enumerable:!0,get:o})},L.r=function(T){Object.defineProperty(T,"__esModule",{value:!0})},L.n=function(T){var h=T&&T.__esModule?function(){return T.default}:function(){return T};return L.d(h,"a",h),h},L.o=function(T,h){return Object.prototype.hasOwnProperty.call(T,h)},L.p="/",L.oe=function(T){throw console.error(T),T};var C=L(L.s=ENTRY_MODULE);return C.default||C}var B="[\\.|\\-|\\+|\\w|/|@]+",M="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+B+").*?\\)";function z(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function W(A){return!isNaN(1*A)}function P(A,O,L){var C={};C[L]=[];var T=O.toString(),h=T.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return C;for(var o=h[1],l=new RegExp("(\\\\n|\\W)"+z(o)+M,"g"),d;d=l.exec(T);){if(d[3]==="dll-reference")continue;C[L].push(d[3])}for(l=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+B+'))"\\)\\)'+M,"g");d=l.exec(T);)A[d[2]]||(C[L].push(d[1]),A[d[2]]=D(d[1]).m),C[d[2]]=C[d[2]]||[],C[d[2]].push(d[4]);for(var w=Object.keys(C),v=0;v<w.length;v++)for(var g=0;g<C[w[v]].length;g++)W(C[w[v]][g])&&(C[w[v]][g]=1*C[w[v]][g]);return C}function R(A){var O=Object.keys(A);return O.reduce(function(L,C){return L||A[C].length>0},!1)}function y(A,O){for(var L={main:[O]},C={main:[]},T={main:{}};R(L);)for(var h=Object.keys(L),o=0;o<h.length;o++){var l=h[o],d=L[l],w=d.pop();if(T[l]=T[l]||{},T[l][w]||!A[l][w])continue;T[l][w]=!0,C[l]=C[l]||[],C[l].push(w);for(var v=P(A,A[l][w],l),g=Object.keys(v),k=0;k<g.length;k++)L[g[k]]=L[g[k]]||[],L[g[k]]=L[g[k]].concat(v[g[k]])}return C}oe.exports=function(A,O){O=O||{};var L={main:D.m},C=O.all?{main:Object.keys(L.main)}:y(L,A),T="";Object.keys(C).filter(function(w){return w!=="main"}).forEach(function(w){for(var v=0;C[w][v];)v++;C[w].push(v),L[w][v]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",T=T+"var "+w+" = ("+$.toString().replace("ENTRY_MODULE",JSON.stringify(v))+")({"+C[w].map(function(g){return""+JSON.stringify(g)+": "+L[w][g].toString()}).join(",")+`});
`}),T=T+"new (("+$.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+C.main.map(function(w){return""+JSON.stringify(w)+": "+L.main[w].toString()}).join(",")+"}))(self);";var h=new window.Blob([T],{type:"text/javascript"});if(O.bare)return h;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.createObjectURL(h),d=new window.Worker(l);return d.objectURL=l,d}},"./src/config.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"hlsDefaultConfig",function(){return k}),D.d(Z,"mergeConfig",function(){return p}),D.d(Z,"enableStreamingMode",function(){return c});var $=D("./src/controller/abr-controller.ts"),B=D("./src/controller/audio-stream-controller.ts"),M=D("./src/controller/audio-track-controller.ts"),z=D("./src/controller/subtitle-stream-controller.ts"),W=D("./src/controller/subtitle-track-controller.ts"),P=D("./src/controller/buffer-controller.ts"),R=D("./src/controller/timeline-controller.ts"),y=D("./src/controller/cap-level-controller.ts"),A=D("./src/controller/fps-controller.ts"),O=D("./src/controller/eme-controller.ts"),L=D("./src/controller/cmcd-controller.ts"),C=D("./src/utils/xhr-loader.ts"),T=D("./src/utils/fetch-loader.ts"),h=D("./src/utils/cues.ts"),o=D("./src/utils/mediakeys-helper.ts"),l=D("./src/utils/logger.ts");function d(){return d=Object.assign||function(u){for(var a=1;a<arguments.length;a++){var b=arguments[a];for(var m in b)Object.prototype.hasOwnProperty.call(b,m)&&(u[m]=b[m])}return u},d.apply(this,arguments)}function w(u,a){var b=Object.keys(u);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(u);a&&(m=m.filter(function(x){return Object.getOwnPropertyDescriptor(u,x).enumerable})),b.push.apply(b,m)}return b}function v(u){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?w(Object(b),!0).forEach(function(m){g(u,m,b[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(b)):w(Object(b)).forEach(function(m){Object.defineProperty(u,m,Object.getOwnPropertyDescriptor(b,m))})}return u}function g(u,a,b){return a in u?Object.defineProperty(u,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):u[a]=b,u}var k=v(v({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:C.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$.default,bufferController:P.default,capLevelController:y.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},E()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:W.default,timelineController:R.TimelineController,audioStreamController:B.default,audioTrackController:M.default,emeController:O.default,cmcdController:L.default});function E(){return{cueHandler:h.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 p(u,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return d({},u,a)}function c(u){var a=u.loader;if(a!==T.default&&a!==C.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var b=Object(T.fetchSupported)();b&&(u.loader=T.default,u.progressive=!0,u.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/polyfills/number.ts"),B=D("./src/utils/ewma-bandwidth-estimator.ts"),M=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),W=D("./src/errors.ts"),P=D("./src/types/loader.ts"),R=D("./src/utils/logger.ts");function y(L,C){for(var T=0;T<C.length;T++){var h=C[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function A(L,C,T){return C&&y(L.prototype,C),T&&y(L,T),L}var O=function(){function L(T){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=T;var h=T.config;this.bwEstimator=new B.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var C=L.prototype;return C.registerListeners=function(){var h=this.hls;h.on(M.Events.FRAG_LOADING,this.onFragLoading,this),h.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(M.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var h=this.hls;h.off(M.Events.FRAG_LOADING,this.onFragLoading,this),h.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(M.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},C.onFragLoading=function(h,o){var l=o.frag;if(l.type===P.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=l,this.partCurrent=(d=o.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},C.onLevelLoaded=function(h,o){var l=this.hls.config;o.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},C._abandonRulesCheck=function(){var h=this.fragCurrent,o=this.partCurrent,l=this.hls,d=l.autoLevelEnabled,w=l.config,v=l.media;if(!h||!v)return;var g=o?o.stats:h.stats,k=o?o.duration:h.duration;if(g.aborted){R.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||v.paused||!v.playbackRate||!v.readyState)return;var E=performance.now()-g.loading.start,p=Math.abs(v.playbackRate);if(E<=500*k/p)return;var c=l.levels,u=l.minAutoLevel,a=c[h.level],b=g.total||Math.max(g.loaded,Math.round(k*a.maxBitrate/8)),m=Math.max(1,g.bwEstimate?g.bwEstimate/8:g.loaded*1e3/E),x=(b-g.loaded)/m,F=v.currentTime,U=(z.BufferHelper.bufferInfo(v,F,w.maxBufferHole).end-F)/p;if(U>=2*k/p||x<=U)return;var K=Number.POSITIVE_INFINITY,V;for(V=h.level-1;V>u;V--){var _=c[V].maxBitrate;if(K=k*_/(8*.8*m),K<U)break}if(K>=x)return;var I=this.bwEstimator.getEstimate();R.logger.warn("Fragment "+h.sn+(o?" part "+o.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+V+`
Current BW estimate: `+(Object($.isFiniteNumber)(I)?(I/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+x.toFixed(3)+` s
Estimated load time for the next fragment: `+K.toFixed(3)+` s
Time to underbuffer: `+U.toFixed(3)+" s"),l.nextLoadLevel=V,this.bwEstimator.sample(E,g.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),l.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:g})},C.onFragLoaded=function(h,o){var l=o.frag,d=o.part;if(l.type===P.PlaylistLevelType.MAIN&&Object($.isFiniteNumber)(l.sn)){var w=d?d.stats:l.stats,v=d?d.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[l.level],k=(g.loaded?g.loaded.bytes:0)+w.loaded,E=(g.loaded?g.loaded.duration:0)+v;g.loaded={bytes:k,duration:E},g.realBitrate=Math.round(8*k/E)}if(l.bitrateTest){var p={stats:w,frag:l,part:d,id:l.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,p),l.bitrateTest=!1}}},C.onFragBuffered=function(h,o){var l=o.frag,d=o.part,w=d?d.stats:l.stats;if(w.aborted)return;if(l.type!==P.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var v=w.parsing.end-w.loading.start;this.bwEstimator.sample(v,w.loaded),w.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=v/1e3:this.bitrateTestDelay=0},C.onError=function(h,o){switch(o.details){case W.ErrorDetails.FRAG_LOAD_ERROR:case W.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},C.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},C.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,l=this.hls,d=l.maxAutoLevel,w=l.config,v=l.minAutoLevel,g=l.media,k=o?o.duration:h?h.duration:0,E=g?g.currentTime:0,p=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():w.abrEwmaDefaultEstimate,u=(z.BufferHelper.bufferInfo(g,E,w.maxBufferHole).end-E)/p,a=this.findBestLevel(c,v,d,u,w.abrBandWidthFactor,w.abrBandWidthUpFactor);if(a>=0)return a;R.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=k?Math.min(k,w.maxStarvationDelay):w.maxStarvationDelay,m=w.abrBandWidthFactor,x=w.abrBandWidthUpFactor;if(!u){var F=this.bitrateTestDelay;if(F){var U=k?Math.min(k,w.maxLoadingDelay):w.maxLoadingDelay;b=U-F,R.logger.trace("bitrate test took "+Math.round(1e3*F)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),m=x=1}}return a=this.findBestLevel(c,v,d,u+b,m,x),Math.max(a,0)},C.findBestLevel=function(h,o,l,d,w,v){for(var g,k=this.fragCurrent,E=this.partCurrent,p=this.lastLoadedFragLevel,c=this.hls.levels,u=c[p],a=!!(u!=null&&(g=u.details)!==null&&g!==void 0&&g.live),b=u==null?void 0:u.codecSet,m=E?E.duration:k?k.duration:0,x=l;x>=o;x--){var F=c[x];if(!F||b&&F.codecSet!==b)continue;var U=F.details,K=(E?U==null?void 0:U.partTarget:U==null?void 0:U.averagetargetduration)||m,V=void 0;x<=p?V=w*h:V=v*h;var _=c[x].maxBitrate,I=_*K/V;if(R.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(V)+"/"+_+"/"+K+"/"+d+"/"+I),V>_&&(!I||a&&!this.bitrateTestDelay||I<d))return x}return-1},A(L,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&(!o||!o.canEstimate()))return h;var l=this.getNextABRAutoLevel();return h!==-1&&(l=Math.min(h,l)),l},set:function(h){this._nextAutoLevel=h}}]),L}();Z.default=O},"./src/controller/audio-stream-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/polyfills/number.ts"),B=D("./src/controller/base-stream-controller.ts"),M=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),W=D("./src/controller/fragment-tracker.ts"),P=D("./src/types/level.ts"),R=D("./src/types/loader.ts"),y=D("./src/loader/fragment.ts"),A=D("./src/demux/chunk-cache.ts"),O=D("./src/demux/transmuxer-interface.ts"),L=D("./src/types/transmuxer.ts"),C=D("./src/controller/fragment-finders.ts"),T=D("./src/utils/discontinuities.ts"),h=D("./src/errors.ts"),o=D("./src/utils/logger.ts");function l(){return l=Object.assign||function(k){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var c in p)Object.prototype.hasOwnProperty.call(p,c)&&(k[c]=p[c])}return k},l.apply(this,arguments)}function d(k,E){k.prototype=Object.create(E.prototype),k.prototype.constructor=k,w(k,E)}function w(k,E){return w=Object.setPrototypeOf||function(c,u){return c.__proto__=u,c},w(k,E)}var v=100,g=function(k){d(E,k);function E(c,u){var a;return a=k.call(this,c,u,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var p=E.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var u=this.hls;u.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(M.Events.ERROR,this.onError,this),u.on(M.Events.BUFFER_RESET,this.onBufferReset,this),u.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),u.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var u=this.hls;u.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(M.Events.ERROR,this.onError,this),u.off(M.Events.BUFFER_RESET,this.onBufferReset,this),u.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),u.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onInitPtsFound=function(u,a){var b=a.frag,m=a.id,x=a.initPTS;if(m==="main"){var F=b.cc;this.initPTS[b.cc]=x,this.log("InitPTS for cc: "+F+" found from main: "+x),this.videoTrackCC=F,this.state===B.State.WAITING_INIT_PTS&&this.tick()}},p.startLoad=function(u){if(!this.levels){this.startPosition=u,this.state=B.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,a>0&&u===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=B.State.IDLE):(this.loadedmetadata=!1,this.state=B.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()},p.doTick=function(){switch(this.state){case B.State.IDLE:this.doTickIdle();break;case B.State.WAITING_TRACK:{var u,a=this.levels,b=this.trackId,m=a==null||((u=a[b])===null||u===void 0)?void 0:u.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=B.State.WAITING_INIT_PTS}break}case B.State.FRAG_LOADING_WAITING_RETRY:{var x,F=performance.now(),U=this.retryDate;(!U||F>=U||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=B.State.IDLE);break}case B.State.WAITING_INIT_PTS:{var K=this.waitingData;if(K){var V=K.frag,_=K.part,I=K.cache,Y=K.complete;if(this.initPTS[V.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=B.State.FRAG_LOADING;var ee=I.flush(),ae={frag:V,part:_,payload:ee,networkDetails:null};this._handleFragmentLoadProgress(ae),Y&&k.prototype._handleFragmentLoadComplete.call(this,ae)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+V.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var de=this.getLoadPosition(),De=z.BufferHelper.bufferInfo(this.mediaBuffer,de,this.config.maxBufferHole),Se=Object(C.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,V);Se<0&&(o.logger.log("Waiting fragment cc ("+V.cc+") @ "+V.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=B.State.IDLE}}this.onTickEnd()},p.clearWaitingFragment=function(){var u=this.waitingData;u&&(this.fragmentTracker.removeFragment(u.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=B.State.IDLE)},p.onTickEnd=function(){var u=this.media;if(!u||!u.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:u,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=u.currentTime},p.doTickIdle=function(){var u,a,b=this.hls,m=this.levels,x=this.media,F=this.trackId,U=b.config;if(!m||!m[F])return;if(!x&&(this.startFragRequested||!U.startFragPrefetch))return;var K=m[F],V=K.details;if(!V||V.live&&this.levelLastLoaded!==F||this.waitForCdnTuneIn(V)){this.state=B.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,R.PlaylistLevelType.AUDIO));var _=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,R.PlaylistLevelType.AUDIO);if(_===null)return;var I=_.len,Y=this.getMaxBufferLength(),ee=this.audioSwitch;if(I>=Y&&!ee)return;if(!ee&&this._streamEnded(_,V)){b.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=B.State.ENDED;return}var ae=V.fragments,de=ae[0].start,De=_.end;if(ee){var Se=this.getLoadPosition();De=Se,V.PTSKnown&&Se<de&&((_.end>de||_.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=de+.05))}var we=this.getNextFragment(De,V);if(!we){this.bufferFlushed=!0;return}((u=we.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((a=we.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(we,V):this.loadFragment(we,V,De)},p.getMaxBufferLength=function(){var u=k.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,R.PlaylistLevelType.MAIN);return a===null?u:Math.max(u,a.len)},p.onMediaDetaching=function(){this.videoBuffer=null,k.prototype.onMediaDetaching.call(this)},p.onAudioTracksUpdated=function(u,a){var b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(m){return new P.Level(m)})},p.onAudioTrackSwitching=function(u,a){var b=!!a.url;this.trackId=a.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(v):this.resetTransmuxer(),b?(this.audioSwitch=!0,this.state=B.State.IDLE):this.state=B.State.STOPPED,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},p.onLevelLoaded=function(u,a){this.mainDetails=a.details},p.onAudioTrackLoaded=function(u,a){var b,m=this.levels,x=a.details,F=a.id;if(!m){this.warn("Audio tracks were reset while loading level "+F);return}this.log("Track "+F+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var U=m[F],K=0;if(x.live||(b=U.details)!==null&&b!==void 0&&b.live){var V=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!V)return;!U.details&&x.hasProgramDateTime&&V.hasProgramDateTime?(Object(T.alignMediaPlaylistByPDT)(x,V),K=x.fragments[0].start):K=this.alignPlaylists(x,U.details)}U.details=x,this.levelLastLoaded=F,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(U.details,K),this.state===B.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=B.State.IDLE),this.tick()},p._handleFragmentLoadProgress=function(u){var a,b=u.frag,m=u.part,x=u.payload,F=this.config,U=this.trackId,K=this.levels;if(!K){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+b.sn+" of level "+b.level+" will not be buffered");return}var V=K[U];console.assert(V,"Audio track is defined on fragment load progress");var _=V.details;console.assert(_,"Audio track details are defined on fragment load progress");var I=F.defaultAudioCodec||V.audioCodec||"mp4a.40.2",Y=this.transmuxer;Y||(Y=this.transmuxer=new O.default(this.hls,R.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ee=this.initPTS[b.cc],ae=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(ee!==void 0){var de=!1,De=m?m.index:-1,Se=De!==-1,we=new L.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,x.byteLength,De,Se);Y.push(x,ae,I,"",b,m,_.totalduration,de,we,ee)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+_.startSN+" ,"+_.endSN+"],track "+U);var Ce=this.waitingData=this.waitingData||{frag:b,part:m,cache:new A.default,complete:!1},Te=Ce.cache;Te.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=B.State.WAITING_INIT_PTS}},p._handleFragmentLoadComplete=function(u){if(this.waitingData){this.waitingData.complete=!0;return}k.prototype._handleFragmentLoadComplete.call(this,u)},p.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},p.onBufferCreated=function(u,a){var b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},p.onFragBuffered=function(u,a){var b=a.frag,m=a.part;if(b.type!==R.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(m?" p: "+m.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,m)},p.onError=function(u,a){switch(a.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.AUDIO,a);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==B.State.ERROR&&this.state!==B.State.STOPPED&&(this.state=a.fatal?B.State.ERROR:B.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===B.State.PARSING||this.state===B.State.PARSED)){var b=!0,m=this.getFwdBufferInfo(this.mediaBuffer,R.PlaylistLevelType.AUDIO);m&&m.len>.5&&(b=!this.reduceMaxBufferLength(m.len)),b&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},p.onBufferFlushed=function(u,a){var b=a.type;b===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},p._handleTransmuxComplete=function(u){var a,b="audio",m=this.hls,x=u.remuxResult,F=u.chunkMeta,U=this.getCurrentContext(F);if(!U){this.warn("The loading context changed while buffering fragment "+F.sn+" of level "+F.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(F.level);return}var K=U.frag,V=U.part,_=x.audio,I=x.text,Y=x.id3,ee=x.initSegment;if(this.fragContextChanged(K))return;if(this.state=B.State.PARSING,this.audioSwitch&&_&&this.completeAudioSwitch(),ee!=null&&ee.tracks&&(this._bufferInitSegment(ee.tracks,K,F),m.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:K,id:b,tracks:ee.tracks})),_){var ae=_.startPTS,de=_.endPTS,De=_.startDTS,Se=_.endDTS;V&&(V.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:ae,endPTS:de,startDTS:De,endDTS:Se}),K.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,ae,de,De,Se),this.bufferFragmentData(_,K,V,F)}if(Y!=null&&(a=Y.samples)!==null&&a!==void 0&&a.length){var we=l({frag:K,id:b},Y);m.trigger(M.Events.FRAG_PARSING_METADATA,we)}if(I){var Ce=l({frag:K,id:b},I);m.trigger(M.Events.FRAG_PARSING_USERDATA,Ce)}},p._bufferInitSegment=function(u,a,b){if(this.state!==B.State.PARSING)return;u.video&&delete u.video;var m=u.audio;if(!m)return;m.levelCodec=m.codec,m.id="audio",this.log("Init audio buffer, container:"+m.container+", codecs[parsed]=["+m.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,u);var x=m.initSegment;if(x!=null&&x.byteLength){var F={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:x};this.hls.trigger(M.Events.BUFFER_APPENDING,F)}this.tick()},p.loadFragment=function(u,a,b){var m=this.fragmentTracker.getState(u);this.fragCurrent=u,(this.audioSwitch||m===W.FragmentState.NOT_LOADED||m===W.FragmentState.PARTIAL)&&(u.sn==="initSegment"?this._loadInitSegment(u):a.live&&!Object($.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=B.State.WAITING_INIT_PTS):(this.startFragRequested=!0,k.prototype.loadFragment.call(this,u,a,b)))},p.completeAudioSwitch=function(){var u=this.hls,a=this.media,b=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,u.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:b})},E}(B.default);Z.default=g},"./src/controller/audio-track-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts"),B=D("./src/errors.ts"),M=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function W(O,L){for(var C=0;C<L.length;C++){var T=L[C];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function P(O,L,C){return L&&W(O.prototype,L),C&&W(O,C),O}function R(O,L){O.prototype=Object.create(L.prototype),O.prototype.constructor=O,y(O,L)}function y(O,L){return y=Object.setPrototypeOf||function(T,h){return T.__proto__=h,T},y(O,L)}var A=function(O){R(L,O);function L(T){var h;return h=O.call(this,T,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var C=L.prototype;return C.registerListeners=function(){var h=this.hls;h.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on($.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on($.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on($.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var h=this.hls;h.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off($.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off($.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off($.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,O.prototype.destroy.call(this)},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},C.onManifestParsed=function(h,o){this.tracks=o.audioTracks||[]},C.onAudioTrackLoaded=function(h,o){var l=o.id,d=o.details,w=this.tracksInGroup[l];if(!w){this.warn("Invalid audio track id "+l);return}var v=w.details;w.details=o.details,this.log("audioTrack "+l+" loaded ["+d.startSN+"-"+d.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,v))},C.onLevelLoading=function(h,o){this.switchLevel(o.level)},C.onLevelSwitching=function(h,o){this.switchLevel(o.level)},C.switchLevel=function(h){var o=this.hls.levels[h];if(!(o!=null&&o.audioGroupIds))return;var l=o.audioGroupIds[o.urlId];if(this.groupId!==l){this.groupId=l;var d=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!d.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var w={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger($.Events.AUDIO_TRACKS_UPDATED,w),this.selectInitialTrack()}},C.onError=function(h,o){if(O.prototype.onError.call(this,h,o),o.fatal||!o.context)return;o.context.type===z.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},C.setAudioTrack=function(h){var o=this.tracksInGroup;if(h<0||h>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=o[this.trackId];this.log("Now switching to audio-track index "+h);var d=o[h],w=d.id,v=d.groupId,g=v===void 0?"":v,k=d.name,E=d.type,p=d.url;if(this.trackId=h,this.trackName=k,this.selectDefaultTrack=!1,this.hls.trigger($.Events.AUDIO_TRACK_SWITCHING,{id:w,groupId:g,name:k,type:E,url:p}),d.details&&!d.details.live)return;var c=this.switchParams(d.url,l==null?void 0:l.details);this.loadPlaylist(c)},C.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,l=this.findTrackId(o)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},C.findTrackId=function(h){for(var o=this.tracksInGroup,l=0;l<o.length;l++){var d=o[l];if((!this.selectDefaultTrack||d.default)&&(!h||h===d.name))return d.id}return-1},C.loadPlaylist=function(h){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,d=o.groupId,w=o.url;if(h)try{w=h.addDirectives(w)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger($.Events.AUDIO_TRACK_LOADING,{url:w,id:l,groupId:d,deliveryDirectives:h||null})}},P(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),L}(M.default);Z.default=A},"./src/controller/base-playlist-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var $=D("./src/polyfills/number.ts"),B=D("./src/types/level.ts"),M=D("./src/controller/level-helper.ts"),z=D("./src/utils/logger.ts"),W=D("./src/errors.ts"),P=function(){function R(A,O){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=z.logger.log.bind(z.logger,O+":"),this.warn=z.logger.warn.bind(z.logger,O+":"),this.hls=A}var y=R.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(O,L){L.fatal&&L.type===W.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(O,L){var C=L==null?void 0:L.renditionReports;if(C)for(var T=0;T<C.length;T++){var h=C[T],o=""+h.URI;if(o===O.substr(-o.length)){var l=parseInt(h["LAST-MSN"]),d=parseInt(h["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var w=Math.min(L.age-L.partTarget,L.targetduration);d!==void 0&&w>L.partTarget&&(d+=1)}if(Object($.isFiniteNumber)(l))return new B.HlsUrlParameters(l,Object($.isFiniteNumber)(d)?d:void 0,B.HlsSkip.No)}}},y.loadPlaylist=function(O){},y.shouldLoadTrack=function(O){return this.canLoad&&O&&!!O.url&&(!O.details||O.details.live)},y.playlistLoaded=function(O,L,C){var T=this,h=L.details,o=L.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-l,h.live||C!=null&&C.live){if(h.reloaded(C),C&&this.log("live playlist "+O+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),C&&h.fragments.length>0&&Object(M.mergeDetails)(C,h),!this.canLoad||!h.live)return;var d,w=void 0,v=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var g=this.hls.config.lowLatencyMode,k=h.lastPartSn,E=h.endSN,p=h.lastPartIndex,c=p!==-1,u=k===E,a=g?0:p;c?(w=u?E+1:k,v=u?a:p+1):w=E+1;var b=h.age,m=b+h.ageHeader,x=Math.min(m-h.partTarget,h.targetduration*1.5);if(x>0){if(C&&x>C.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+C.tuneInGoal+" to: "+x+" with playlist age: "+h.age),x=0;else{var F=Math.floor(x/h.targetduration);if(w+=F,v!==void 0){var U=Math.round(x%h.targetduration/h.partTarget);v+=U}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+x+" skip sn "+F+" to part "+v)}h.tuneInGoal=x}if(d=this.getDeliveryDirectives(h,L.deliveryDirectives,w,v),g||!u){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(h,L.deliveryDirectives,w,v);var K=Object(M.computeReloadInterval)(h,o);w!==void 0&&h.canBlockReload&&(K-=h.partTarget||1),this.log("reload live playlist "+O+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return T.loadPlaylist(d)},K)}else this.clearTimer()},y.getDeliveryDirectives=function(O,L,C,T){var h=Object(B.getSkipValue)(O,C);return L!=null&&L.skip&&O.deltaUpdateFailed&&(C=L.msn,T=L.part,h=B.HlsSkip.No),new B.HlsUrlParameters(C,T,h)},y.retryLoadingOrFail=function(O){var L=this,C=this.hls.config,T=this.retryCount<C.levelLoadingMaxRetry;if(T){var h;if(this.retryCount++,O.details.indexOf("LoadTimeOut")>-1&&(h=O.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+O.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*C.levelLoadingRetryDelay,C.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+O.details+'"')}}else this.warn('cannot recover from error "'+O.details+'"'),this.clearTimer(),O.fatal=!0;return T},R}()},"./src/controller/base-stream-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"State",function(){return E}),D.d(Z,"default",function(){return p});var $=D("./src/polyfills/number.ts"),B=D("./src/task-loop.ts"),M=D("./src/controller/fragment-tracker.ts"),z=D("./src/utils/buffer-helper.ts"),W=D("./src/utils/logger.ts"),P=D("./src/events.ts"),R=D("./src/errors.ts"),y=D("./src/types/transmuxer.ts"),A=D("./src/utils/mp4-tools.ts"),O=D("./src/utils/discontinuities.ts"),L=D("./src/controller/fragment-finders.ts"),C=D("./src/controller/level-helper.ts"),T=D("./src/loader/fragment-loader.ts"),h=D("./src/crypt/decrypter.ts"),o=D("./src/utils/time-ranges.ts"),l=D("./src/types/loader.ts");function d(c,u){for(var a=0;a<u.length;a++){var b=u[a];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(c,b.key,b)}}function w(c,u,a){return u&&d(c.prototype,u),a&&d(c,a),c}function v(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function g(c,u){c.prototype=Object.create(u.prototype),c.prototype.constructor=c,k(c,u)}function k(c,u){return k=Object.setPrototypeOf||function(b,m){return b.__proto__=m,b},k(c,u)}var E={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"},p=function(c){g(u,c);function u(b,m,x){var F;return F=c.call(this)||this,F.hls=void 0,F.fragPrevious=null,F.fragCurrent=null,F.fragmentTracker=void 0,F.transmuxer=null,F._state=E.STOPPED,F.media=void 0,F.mediaBuffer=void 0,F.config=void 0,F.bitrateTest=!1,F.lastCurrentTime=0,F.nextLoadPosition=0,F.startPosition=0,F.loadedmetadata=!1,F.fragLoadError=0,F.retryDate=0,F.levels=null,F.fragmentLoader=void 0,F.levelLastLoaded=null,F.startFragRequested=!1,F.decrypter=void 0,F.initPTS=[],F.onvseeking=null,F.onvended=null,F.logPrefix="",F.log=void 0,F.warn=void 0,F.logPrefix=x,F.log=W.logger.log.bind(W.logger,x+":"),F.warn=W.logger.warn.bind(W.logger,x+":"),F.hls=b,F.fragmentLoader=new T.default(b.config),F.fragmentTracker=m,F.config=b.config,F.decrypter=new h.default(b,b.config),b.on(P.Events.KEY_LOADED,F.onKeyLoaded,v(F)),F}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(m){},a.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},a._streamEnded=function(m,x){var F=this.fragCurrent,U=this.fragmentTracker;if(!x.live&&F&&F.sn===x.endSN&&!m.nextStart){var K=U.getState(F);return K===M.FragmentState.PARTIAL||K===M.FragmentState.OK}return!1},a.onMediaAttached=function(m,x){var F=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),F.addEventListener("seeking",this.onvseeking),F.addEventListener("ended",this.onvended);var U=this.config;this.levels&&U.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(U.startPosition)},a.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var m=this.config,x=this.fragCurrent,F=this.media,U=this.mediaBuffer,K=this.state,V=F?F.currentTime:0,_=z.BufferHelper.bufferInfo(U||F,V,m.maxBufferHole);if(this.log("media seeking to "+(Object($.isFiniteNumber)(V)?V.toFixed(3):V)+", state: "+K),K===E.ENDED)this.resetLoadingState();else if(x&&!_.len){var I=m.maxFragLookUpTolerance,Y=x.start-I,ee=x.start+x.duration+I,ae=V>ee;(V<Y||ae)&&(ae&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}F&&(this.lastCurrentTime=V),!this.loadedmetadata&&!_.len&&(this.nextLoadPosition=this.startPosition=V),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(m,x){if(this.state!==E.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=E.IDLE;var F=this.levels[x.frag.level].details;F&&this.loadFragment(x.frag,F,x.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=E.STOPPED,this.hls.off(P.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(m,x){this.log("Loading key for "+m.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=E.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(P.Events.KEY_LOADING,{frag:m})},a.loadFragment=function(m,x,F){this._loadFragForPlayback(m,x,F)},a._loadFragForPlayback=function(m,x,F){var U=this,K=function(_){if(U.fragContextChanged(m)){U.warn("Fragment "+m.sn+(_.part?" p: "+_.part.index:"")+" of level "+m.level+" was dropped during download."),U.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,U._handleFragmentLoadProgress(_)};this._doFragLoad(m,x,F,K).then(function(V){if(!V)return;U.fragLoadError=0;var _=U.state;if(U.fragContextChanged(m)){(_===E.FRAG_LOADING||_===E.BACKTRACKING||!U.fragCurrent&&_===E.PARSING)&&(U.fragmentTracker.removeFragment(m),U.state=E.IDLE);return}if("payload"in V&&(U.log("Loaded fragment "+m.sn+" of level "+m.level),U.hls.trigger(P.Events.FRAG_LOADED,V),U.state===E.BACKTRACKING)){U.fragmentTracker.backtrack(m,V),U.resetFragmentLoading(m);return}U._handleFragmentLoadComplete(V)}).catch(function(V){U.warn(V),U.resetFragmentLoading(m)})},a.flushMainBuffer=function(m,x,F){if(F===void 0&&(F=null),!(m-x))return;var U={startOffset:m,endOffset:x,type:F};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,U)},a._loadInitSegment=function(m){var x=this;this._doFragLoad(m).then(function(F){if(!F||x.fragContextChanged(m)||!x.levels)throw new Error("init load aborted");return F}).then(function(F){var U=x.hls,K=F.payload,V=m.decryptdata;if(K&&K.byteLength>0&&V&&V.key&&V.iv&&V.method==="AES-128"){var _=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(K),V.key.buffer,V.iv.buffer).then(function(I){var Y=self.performance.now();return U.trigger(P.Events.FRAG_DECRYPTED,{frag:m,payload:I,stats:{tstart:_,tdecrypt:Y}}),F.payload=I,F})}return F}).then(function(F){var U=x.fragCurrent,K=x.hls,V=x.levels;if(!V)throw new Error("init load aborted, missing levels");var _=V[m.level].details;console.assert(_,"Level details are defined when init segment is loaded");var I=m.stats;x.state=E.IDLE,x.fragLoadError=0,m.data=new Uint8Array(F.payload),I.parsing.start=I.buffering.start=self.performance.now(),I.parsing.end=I.buffering.end=self.performance.now(),F.frag===U&&K.trigger(P.Events.FRAG_BUFFERED,{stats:I,frag:U,part:null,id:m.type}),x.tick()}).catch(function(F){x.warn(F),x.resetFragmentLoading(m)})},a.fragContextChanged=function(m){var x=this.fragCurrent;return!m||!x||m.level!==x.level||m.sn!==x.sn||m.urlId!==x.urlId},a.fragBufferedComplete=function(m,x){var F=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+o.default.toString(z.BufferHelper.getBuffered(F))),this.state=E.IDLE,this.tick()},a._handleFragmentLoadComplete=function(m){var x=this.transmuxer;if(!x)return;var F=m.frag,U=m.part,K=m.partsLoaded,V=!K||K.length===0||K.some(function(I){return!I}),_=new y.ChunkMetadata(F.level,F.sn,F.stats.chunkCount+1,0,U?U.index:-1,!V);x.flush(_)},a._handleFragmentLoadProgress=function(m){},a._doFragLoad=function(m,x,F,U){var K=this;if(F===void 0&&(F=null),!this.levels)throw new Error("frag load aborted, missing levels");if(F=Math.max(m.start,F||0),this.config.lowLatencyMode&&x){var V=x.partList;if(V&&U){F>m.end&&x.fragmentHint&&(m=x.fragmentHint);var _=this.getNextPart(V,m,F);if(_>-1){var I=V[_];return this.log("Loading part sn: "+m.sn+" p: "+I.index+" cc: "+m.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+_+"-"+(V.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(F.toFixed(3))),this.nextLoadPosition=I.start+I.duration,this.state=E.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:m,part:V[_],targetBufferTime:F}),this.doFragPartsLoad(m,V,_,U).catch(function(Y){return K.handleFragLoadError(Y)})}else if(!m.url||this.loadedEndOfParts(V,F))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(F.toFixed(3))),Object($.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=E.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:m,targetBufferTime:F}),this.fragmentLoader.load(m,U).catch(function(Y){return K.handleFragLoadError(Y)})},a.doFragPartsLoad=function(m,x,F,U){var K=this;return new Promise(function(V,_){var I=[],Y=function ee(ae){var de=x[ae];K.fragmentLoader.loadPart(m,de,U).then(function(De){I[de.index]=De;var Se=De.part;K.hls.trigger(P.Events.FRAG_LOADED,De);var we=x[ae+1];if(we&&we.fragment===m)ee(ae+1);else return V({frag:m,part:Se,partsLoaded:I})}).catch(_)};Y(F)})},a.handleFragLoadError=function(m){var x=m.data;return x&&x.details===R.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(P.Events.ERROR,x),null},a._handleTransmuxerFlush=function(m){var x=this.getCurrentContext(m);if(!x||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var F=x.frag,U=x.part,K=x.level,V=self.performance.now();F.stats.parsing.end=V,U&&(U.stats.parsing.end=V),this.updateLevelTiming(F,U,K,m.partial)},a.getCurrentContext=function(m){var x=this.levels,F=m.level,U=m.sn,K=m.part;if(!x||!x[F])return this.warn("Levels object was unset while buffering fragment "+U+" of level "+F+". The current chunk will not be buffered."),null;var V=x[F],_=K>-1?Object(C.getPartWith)(V,U,K):null,I=_?_.fragment:Object(C.getFragmentWithSN)(V,U,this.fragCurrent);return I?{frag:I,part:_,level:V}:null},a.bufferFragmentData=function(m,x,F,U){if(!m||this.state!==E.PARSING)return;var K=m.data1,V=m.data2,_=K;if(K&&V&&(_=Object(A.appendUint8Array)(K,V)),!_||!_.length)return;var I={type:m.type,frag:x,part:F,chunkMeta:U,parent:x.type,data:_};this.hls.trigger(P.Events.BUFFER_APPENDING,I),m.dropped&&m.independent&&!F&&this.flushBufferGap(x)},a.flushBufferGap=function(m){var x=this.media;if(!x)return;if(!z.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,m.start);return}var F=x.currentTime,U=z.BufferHelper.bufferInfo(x,F,0),K=m.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,K*.25),_=Math.max(Math.min(m.start-V,U.end-V),F+V);m.start-_>V&&this.flushMainBuffer(_,m.start)},a.getFwdBufferInfo=function(m,x){var F=this.config,U=this.getLoadPosition();if(!Object($.isFiniteNumber)(U))return null;var K=z.BufferHelper.bufferInfo(m,U,F.maxBufferHole);if(K.len===0&&K.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(U,x);if(V&&K.nextStart<V.end)return z.BufferHelper.bufferInfo(m,U,Math.max(K.nextStart,F.maxBufferHole))}return K},a.getMaxBufferLength=function(m){var x=this.config,F;return m?F=Math.max(8*x.maxBufferSize/m,x.maxBufferLength):F=x.maxBufferLength,Math.min(F,x.maxMaxBufferLength)},a.reduceMaxBufferLength=function(m){var x=this.config,F=m||x.maxBufferLength;return x.maxMaxBufferLength>=F?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(m,x){var F,U,K=x.fragments,V=K.length;if(!V)return null;var _=this.config,I=K[0].start,Y;if(x.live){var ee=_.initialLiveManifestSize;if(V<ee)return this.warn("Not enough fragments to start playback (have: "+V+", need: "+ee+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Y=this.getInitialLiveFragment(x,K),this.startPosition=Y?this.hls.liveSyncPosition||Y.start:m)}else m<=I&&(Y=K[0]);if(!Y){var ae=_.lowLatencyMode?x.partEnd:x.fragmentEnd;Y=this.getFragmentAtPosition(m,ae,x)}return(F=Y)!==null&&F!==void 0&&F.initSegment&&!((U=Y)!==null&&U!==void 0&&U.initSegment.data)&&!this.bitrateTest&&(Y=Y.initSegment),Y},a.getNextPart=function(m,x,F){for(var U=-1,K=!1,V=!0,_=0,I=m.length;_<I;_++){var Y=m[_];if(V=V&&!Y.independent,U>-1&&F<Y.start)break;var ee=Y.loaded;!ee&&(K||Y.independent||V)&&Y.fragment===x&&(U=_),K=ee}return U},a.loadedEndOfParts=function(m,x){var F=m[m.length-1];return F&&x>F.start&&F.loaded},a.getInitialLiveFragment=function(m,x){var F=this.fragPrevious,U=null;if(F){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+F.programDateTime),U=Object(L.findFragmentByPDT)(x,F.endProgramDateTime,this.config.maxFragLookUpTolerance)),!U){var K=F.sn+1;if(K>=m.startSN&&K<=m.endSN){var V=x[K-m.startSN];F.cc===V.cc&&(U=V,this.log("Live playlist, switching playlist, load frag with next SN: "+U.sn))}U||(U=Object(L.findFragWithCC)(x,F.cc),U&&this.log("Live playlist, switching playlist, load frag with same CC: "+U.sn))}}else{var _=this.hls.liveSyncPosition;_!==null&&(U=this.getFragmentAtPosition(_,this.bitrateTest?m.fragmentEnd:m.edge,m))}return U},a.getFragmentAtPosition=function(m,x,F){var U=this.config,K=this.fragPrevious,V=F.fragments,_=F.endSN,I=F.fragmentHint,Y=U.maxFragLookUpTolerance,ee=!!(U.lowLatencyMode&&F.partList&&I);ee&&I&&!this.bitrateTest&&(V=V.concat(I),_=I.sn);var ae;if(m<x){var de=m>x-Y?0:Y;ae=Object(L.findFragmentByPTS)(K,V,m,de)}else ae=V[V.length-1];if(ae){var De=ae.sn-F.startSN,Se=K&&ae.level===K.level,we=V[De+1],Ce=this.fragmentTracker.getState(ae);if(Ce===M.FragmentState.BACKTRACKED){ae=null;for(var Te=De;V[Te]&&this.fragmentTracker.getState(V[Te])===M.FragmentState.BACKTRACKED;)K?ae=V[Te--]:ae=V[--Te];ae||(ae=we)}else K&&ae.sn===K.sn&&!ee&&(Se&&(ae.sn<_&&this.fragmentTracker.getState(we)!==M.FragmentState.OK?(this.log("SN "+ae.sn+" just loaded, load next one: "+we.sn),ae=we):ae=null))}return ae},a.synchronizeToLiveEdge=function(m){var x=this.config,F=this.media;if(!F)return;var U=this.hls.liveSyncPosition,K=F.currentTime,V=m.fragments[0].start,_=m.edge,I=K>=V-x.maxFragLookUpTolerance&&K<=_;if(U!==null&&F.duration>U&&(K<U||!I)){var Y=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*m.targetduration;(!I&&F.readyState<4||K<_-Y)&&(this.loadedmetadata||(this.nextLoadPosition=U),F.readyState&&(this.warn("Playback: "+K.toFixed(3)+" is located too far from the end of live sliding playlist: "+_+", reset currentTime to : "+U.toFixed(3)),F.currentTime=U))}},a.alignPlaylists=function(m,x){var F=this.levels,U=this.levelLastLoaded,K=this.fragPrevious,V=U!==null?F[U]:null,_=m.fragments.length;if(!_)return this.warn("No fragments in live playlist"),0;var I=m.fragments[0].start,Y=!x,ee=m.alignedSliding&&Object($.isFiniteNumber)(I);if(Y||!ee&&!I){Object(O.alignStream)(K,V,m);var ae=m.fragments[0].start;return this.log("Live playlist sliding: "+ae.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+m.startSN+" prev-sn: "+(K?K.sn:"na")+" fragments: "+_),ae}return I},a.waitForCdnTuneIn=function(m){var x=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*x)},a.setStartPosition=function(m,x){var F=this.startPosition;if(F<x&&(F=-1),F===-1||this.lastCurrentTime===-1){var U=m.startTimeOffset;Object($.isFiniteNumber)(U)?(F=x+U,U<0&&(F+=m.totalduration),F=Math.min(Math.max(x,F),x+m.totalduration),this.log("Start time offset "+U+" found in playlist, adjust startPosition to "+F),this.startPosition=F):m.live?F=this.hls.liveSyncPosition||x:this.startPosition=F=0,this.lastCurrentTime=F}this.nextLoadPosition=F},a.getLoadPosition=function(){var m=this.media,x=0;return this.loadedmetadata&&m?x=m.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},a.handleFragLoadAborted=function(m,x){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(x?" part"+x.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},a.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=E.IDLE)},a.onFragmentOrKeyLoadError=function(m,x){if(x.fatal)return;var F=x.frag;if(!F||F.type!==m)return;var U=this.fragCurrent;console.assert(U&&F.sn===U.sn&&F.level===U.level&&F.urlId===U.urlId,"Frag load error must match current frag to retry");var K=this.config;if(this.fragLoadError+1<=K.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(F.level))return;var V=Math.min(Math.pow(2,this.fragLoadError)*K.fragLoadingRetryDelay,K.fragLoadingMaxRetryTimeout);this.warn("Fragment "+F.sn+" of "+m+" "+F.level+" failed to load, retrying in "+V+"ms"),this.retryDate=self.performance.now()+V,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(m===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(W.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)},a.afterBufferFlushed=function(m,x,F){if(!m)return;var U=z.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(x,U,F),this.state===E.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},a.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[m].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(m,x,F,U){var K=this,V=F.details;console.assert(!!V,"level.details must be defined");var _=Object.keys(m.elementaryStreams).reduce(function(I,Y){var ee=m.elementaryStreams[Y];if(ee){var ae=ee.endPTS-ee.startPTS;if(ae<=0)return K.warn("Could not parse fragment "+m.sn+" "+Y+" duration reliably ("+ae+") resetting transmuxer to fallback to playlist timing"),K.resetTransmuxer(),I||!1;var de=U?0:Object(C.updateFragPTSDTS)(V,m,ee.startPTS,ee.endPTS,ee.startDTS,ee.endDTS);return K.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:V,level:F,drift:de,type:Y,frag:m,start:ee.startPTS,end:ee.endPTS}),!0}return I},!1);_?(this.state=E.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:m,part:x})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},w(u,[{key:"state",get:function(){return this._state},set:function(m){var x=this._state;x!==m&&(this._state=m,this.log(x+"->"+m))}}]),u}(B.default)},"./src/controller/buffer-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var $=D("./src/polyfills/number.ts"),B=D("./src/events.ts"),M=D("./src/utils/logger.ts"),z=D("./src/errors.ts"),W=D("./src/utils/buffer-helper.ts"),P=D("./src/utils/mediasource-helper.ts"),R=D("./src/loader/fragment.ts"),y=D("./src/controller/buffer-operation-queue.ts"),A=Object(P.getMediaSource)(),O=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function C(h){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=o.hls,d=o.media,w=o.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),d&&(o.updateMediaElementDuration(),l.trigger(B.Events.MEDIA_ATTACHED,{media:d})),w&&w.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var T=C.prototype;return T.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},T.destroy=function(){this.unregisterListeners(),this.details=null},T.registerListeners=function(){var o=this.hls;o.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(B.Events.BUFFER_RESET,this.onBufferReset,this),o.on(B.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(B.Events.BUFFER_EOS,this.onBufferEos,this),o.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(B.Events.FRAG_PARSED,this.onFragParsed,this),o.on(B.Events.FRAG_CHANGED,this.onFragChanged,this)},T.unregisterListeners=function(){var o=this.hls;o.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(B.Events.BUFFER_RESET,this.onBufferReset,this),o.off(B.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(B.Events.BUFFER_EOS,this.onBufferEos,this),o.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(B.Events.FRAG_PARSED,this.onFragParsed,this),o.off(B.Events.FRAG_CHANGED,this.onFragChanged,this)},T._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},T.onManifestParsed=function(o,l){var d=2;(l.audio&&!l.video||!l.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},T.onMediaAttaching=function(o,l){var d=this.media=l.media;if(d&&A){var w=this.mediaSource=new A;w.addEventListener("sourceopen",this._onMediaSourceOpen),w.addEventListener("sourceended",this._onMediaSourceEnded),w.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(w),this._objectUrl=d.src}},T.onMediaDetaching=function(){var o=this.media,l=this.mediaSource,d=this._objectUrl;if(l){if(M.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(w){M.logger.warn("[buffer-controller]: onMediaDetaching: "+w.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(d&&self.URL.revokeObjectURL(d),o.src===d?(o.removeAttribute("src"),o.load()):M.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(B.Events.MEDIA_DETACHED,void 0)},T.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var d=o.sourceBuffer[l];try{d&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(d),o.sourceBuffer[l]=void 0)}catch(w){M.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",w)}}),this._initSourceBuffer()},T.onBufferCodecs=function(o,l){var d=this,w=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(v){if(w){var g=d.tracks[v];if(g&&typeof g.buffer.changeType=="function"){var k=l[v],E=k.codec,p=k.levelCodec,c=k.container,u=(g.levelCodec||g.codec).replace(O,"$1"),a=(p||E).replace(O,"$1");if(u!==a){var b=c+";codecs="+(p||E);d.appendChangeType(v,b)}}}else d.pendingTracks[v]=l[v]}),w)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},T.appendChangeType=function(o,l){var d=this,w=this.operationQueue,v={execute:function(){var k=d.sourceBuffer[o];k&&(M.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),k.changeType(l)),w.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(k){M.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",k)}};w.append(v,o)},T.onBufferAppending=function(o,l){var d=this,w=this.hls,v=this.operationQueue,g=this.tracks,k=l.data,E=l.type,p=l.frag,c=l.part,u=l.chunkMeta,a=u.buffering[E],b=self.performance.now();a.start=b;var m=p.stats.buffering,x=c?c.stats.buffering:null;m.start===0&&(m.start=b),x&&x.start===0&&(x.start=b);var F=g.audio,U=E==="audio"&&u.id===1&&(F==null?void 0:F.container)==="audio/mpeg",K={execute:function(){if(a.executeStart=self.performance.now(),U){var _=d.sourceBuffer[E];if(_){var I=p.start-_.timestampOffset;Math.abs(I)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p.start+" (delta: "+I+") sn: "+p.sn+")"),_.timestampOffset=p.start)}}d.appendExecutor(k,E)},onStart:function(){},onComplete:function(){var _=self.performance.now();a.executeEnd=a.end=_,m.first===0&&(m.first=_),x&&x.first===0&&(x.first=_);var I=d.sourceBuffer,Y={};for(var ee in I)Y[ee]=W.BufferHelper.getBuffered(I[ee]);d.appendError=0,d.hls.trigger(B.Events.BUFFER_APPENDED,{type:E,frag:p,part:c,chunkMeta:u,parent:p.type,timeRanges:Y})},onError:function(_){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",_);var I={type:z.ErrorTypes.MEDIA_ERROR,parent:p.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:_,fatal:!1};_.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=z.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,I.details=z.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>w.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+w.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),I.fatal=!0)),w.trigger(B.Events.ERROR,I)}};v.append(K,E)},T.onBufferFlushing=function(o,l){var d=this,w=this.operationQueue,v=function(k){return{execute:d.removeExecutor.bind(d,k,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(B.Events.BUFFER_FLUSHED,{type:k})},onError:function(p){M.logger.warn("[buffer-controller]: Failed to remove from "+k+" SourceBuffer",p)}}};l.type?w.append(v(l.type),l.type):this.getSourceBufferTypes().forEach(function(g){w.append(v(g),g)})},T.onFragParsed=function(o,l){var d=this,w=l.frag,v=l.part,g=[],k=v?v.elementaryStreams:w.elementaryStreams;k[R.ElementaryStreamTypes.AUDIOVIDEO]?g.push("audiovideo"):(k[R.ElementaryStreamTypes.AUDIO]&&g.push("audio"),k[R.ElementaryStreamTypes.VIDEO]&&g.push("video"));var E=function(){var c=self.performance.now();w.stats.buffering.end=c,v&&(v.stats.buffering.end=c);var u=v?v.stats:w.stats;d.hls.trigger(B.Events.FRAG_BUFFERED,{frag:w,part:v,stats:u,id:w.type})};g.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+w.type+" level: "+w.level+" sn: "+w.sn),this.blockBuffers(E,g)},T.onFragChanged=function(o,l){this.flushBackBuffer()},T.onBufferEos=function(o,l){var d=this,w=this.getSourceBufferTypes().reduce(function(v,g){var k=d.sourceBuffer[g];return(!l.type||l.type===g)&&(k&&!k.ended&&(k.ended=!0,M.logger.log("[buffer-controller]: "+g+" sourceBuffer now EOS"))),v&&!!(!k||k.ended)},!0);w&&this.blockBuffers(function(){var v=d.mediaSource;if(!v||v.readyState!=="open")return;v.endOfStream()})},T.onLevelUpdated=function(o,l){var d=l.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},T.flushBackBuffer=function(){var o=this.hls,l=this.details,d=this.media,w=this.sourceBuffer;if(!d||l===null)return;var v=this.getSourceBufferTypes();if(!v.length)return;var g=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object($.isFiniteNumber)(g)||g<0)return;var k=d.currentTime,E=l.levelTargetDuration,p=Math.max(g,E),c=Math.floor(k/E)*E-p;v.forEach(function(u){var a=w[u];if(a){var b=W.BufferHelper.getBuffered(a);b.length>0&&c>b.start(0)&&(o.trigger(B.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),l.live&&o.trigger(B.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u}))}})},T.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,d=this.media,w=this.mediaSource,v=o.fragments[0].start+o.totalduration,g=d.duration,k=Object($.isFiniteNumber)(w.duration)?w.duration:0;o.live&&l.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),w.duration=Infinity,this.updateSeekableRange(o)):(v>k&&v>g||!Object($.isFiniteNumber)(g))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+v.toFixed(3)),w.duration=v)},T.updateSeekableRange=function(o){var l=this.mediaSource,d=o.fragments,w=d.length;if(w&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var v=Math.max(0,d[0].start),g=Math.max(v,v+o.totalduration);l.setLiveSeekableRange(v,g)}},T.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,d=this.pendingTracks,w=Object.keys(d).length;if(w&&!o||w===2){this.createSourceBuffers(d),this.pendingTracks={};var v=this.getSourceBufferTypes();if(v.length===0){this.hls.trigger(B.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}v.forEach(function(g){l.executeNext(g)})}},T.createSourceBuffers=function(o){var l=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var w=0;for(var v in o)if(!l[v]){var g=o[v];if(!g)throw Error("source buffer exists for track "+v+", however track does not");var k=g.levelCodec||g.codec,E=g.container+";codecs="+k;M.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var p=l[v]=d.addSourceBuffer(E),c=v;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[v]={buffer:p,codec:k,container:g.container,levelCodec:g.levelCodec,id:g.id},w++}catch(u){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(B.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:E})}}w&&this.hls.trigger(B.Events.BUFFER_CREATED,{tracks:this.tracks})},T._onSBUpdateStart=function(o){var l=this.operationQueue,d=l.current(o);d.onStart()},T._onSBUpdateEnd=function(o){var l=this.operationQueue,d=l.current(o);d.onComplete(),l.shiftAndExecuteNext(o)},T._onSBUpdateError=function(o,l){M.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(B.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(o);d&&d.onError(l)},T.removeExecutor=function(o,l,d){var w=this.media,v=this.mediaSource,g=this.operationQueue,k=this.sourceBuffer,E=k[o];if(!w||!v||!E){M.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),g.shiftAndExecuteNext(o);return}var p=Object($.isFiniteNumber)(w.duration)?w.duration:Infinity,c=Object($.isFiniteNumber)(v.duration)?v.duration:Infinity,u=Math.max(0,l),a=Math.min(d,p,c);a>u?(M.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+o+" SourceBuffer"),console.assert(!E.updating,o+" sourceBuffer must not be updating"),E.remove(u,a)):g.shiftAndExecuteNext(o)},T.appendExecutor=function(o,l){var d=this.operationQueue,w=this.sourceBuffer,v=w[l];if(!v){M.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(l);return}v.ended=!1,console.assert(!v.updating,l+" sourceBuffer must not be updating"),v.appendBuffer(o)},T.blockBuffers=function(o,l){var d=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var w=this.operationQueue,v=l.map(function(g){return w.appendBlocker(g)});Promise.all(v).then(function(){o(),l.forEach(function(g){var k=d.sourceBuffer[g];(!k||!k.updating)&&w.shiftAndExecuteNext(g)})})},T.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},T.addBufferListener=function(o,l,d){var w=this.sourceBuffer[o];if(!w)return;var v=d.bind(this,o);this.listeners[o].push({event:l,listener:v}),w.addEventListener(l,v)},T.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(d){l.removeEventListener(d.event,d.listener)})},C}()},"./src/controller/buffer-operation-queue.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return B});var $=D("./src/utils/logger.ts"),B=function(){function M(W){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=W}var z=M.prototype;return z.append=function(P,R){var y=this.queues[R];y.push(P),y.length===1&&this.buffers[R]&&this.executeNext(R)},z.insertAbort=function(P,R){var y=this.queues[R];y.unshift(P),this.executeNext(R)},z.appendBlocker=function(P){var R,y=new Promise(function(O){R=O}),A={execute:R,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,P),y},z.executeNext=function(P){var R=this.buffers,y=this.queues,A=R[P],O=y[P];if(O.length){var L=O[0];try{L.execute()}catch(C){$.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(C),(!A||!A.updating)&&(O.shift(),this.executeNext(P))}}},z.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},z.current=function(P){return this.queues[P][0]},M}()},"./src/controller/cap-level-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts");function B(W,P){for(var R=0;R<P.length;R++){var y=P[R];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(W,y.key,y)}}function M(W,P,R){return P&&B(W.prototype,P),R&&B(W,R),W}var z=function(){function W(R){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=R,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=W.prototype;return P.setStreamController=function(y){this.streamController=y},P.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},P.registerListeners=function(){var y=this.hls;y.on($.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on($.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var y=this.hls;y.off($.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off($.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(y,A){W.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},P.onMediaAttaching=function(y,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},P.onManifestParsed=function(y,A){var O=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,O.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onBufferCodecs=function(y,A){var O=this.hls;O.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onMediaDetaching=function(){this.stopCapping()},P.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(y.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},P.getMaxLevel=function(y){var A=this,O=this.hls.levels;if(!O.length)return-1;var L=O.filter(function(C,T){return W.isLevelAllowed(T,A.restrictedLevels)&&T<=y});return this.clientRect=null,W.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},P.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},P.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},P.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,A={width:0,height:0};if(y){var O=y.getBoundingClientRect();A.width=O.width,A.height=O.height,!A.width&&!A.height&&(A.width=O.right-O.left||y.width||0,A.height=O.bottom-O.top||y.height||0)}return this.clientRect=A,A},W.isLevelAllowed=function(y,A){return A===void 0&&(A=[]),A.indexOf(y)===-1},W.getMaxLevelByMediaSize=function(y,A,O){if(!y||!y.length)return-1;for(var L=function(l,d){return d?l.width!==d.width||l.height!==d.height:!0},C=y.length-1,T=0;T<y.length;T+=1){var h=y[T];if((h.width>=A||h.height>=O)&&L(h,y[T+1])){C=T;break}}return C},M(W,[{key:"mediaWidth",get:function(){return this.getDimensions().width*W.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*W.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var y=1;try{y=self.devicePixelRatio}catch(A){}return y}}]),W}();Z.default=z},"./src/controller/cmcd-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var $=D("./src/events.ts"),B=D("./src/types/cmcd.ts"),M=D("./src/utils/buffer-helper.ts"),z=D("./src/utils/logger.ts");function W(C,T){for(var h=0;h<T.length;h++){var o=T[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(C,o.key,o)}}function P(C,T,h){return T&&W(C.prototype,T),h&&W(C,h),C}function R(C,T){var h=typeof Symbol!="undefined"&&C[Symbol.iterator]||C["@@iterator"];if(h)return(h=h.call(C)).next.bind(h);if(Array.isArray(C)||(h=y(C))||T&&C&&typeof C.length=="number"){h&&(C=h);var o=0;return function(){return o>=C.length?{done:!0}:{done:!1,value:C[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(C,T){if(!C)return;if(typeof C=="string")return A(C,T);var h=Object.prototype.toString.call(C).slice(8,-1);if(h==="Object"&&C.constructor&&(h=C.constructor.name),h==="Map"||h==="Set")return Array.from(C);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return A(C,T)}function A(C,T){(T==null||T>C.length)&&(T=C.length);for(var h=0,o=new Array(T);h<T;h++)o[h]=C[h];return o}function O(){return O=Object.assign||function(C){for(var T=1;T<arguments.length;T++){var h=arguments[T];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(C[o]=h[o])}return C},O.apply(this,arguments)}var L=function(){function C(h){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(w){try{o.apply(w,{ot:B.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(v){z.logger.warn("Could not generate manifest CMCD data.",v)}},this.applyFragmentData=function(w){try{var v=w.frag,g=o.hls.levels[v.level],k=o.getObjectType(v),E={d:v.duration*1e3,ot:k};(k===B.CMCDObjectType.VIDEO||k===B.CMCDObjectType.AUDIO||k==B.CMCDObjectType.MUXED)&&(E.br=g.bitrate/1e3,E.tb=o.getTopBandwidth(k),E.bl=o.getBufferLength(k)),o.apply(w,E)}catch(p){z.logger.warn("Could not generate segment CMCD data.",p)}},this.hls=h;var l=this.config=h.config,d=l.cmcd;d!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||C.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var T=C.prototype;return T.registerListeners=function(){var o=this.hls;o.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on($.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on($.Events.BUFFER_CREATED,this.onBufferCreated,this)},T.unregisterListeners=function(){var o=this.hls;o.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off($.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off($.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},T.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},T.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},T.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},T.onBufferCreated=function(o,l){var d,w;this.audioBuffer=(d=l.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(w=l.tracks.video)===null||w===void 0?void 0:w.buffer},T.createData=function(){var o;return{v:B.CMCDVersion,sf:B.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},T.apply=function(o,l){l===void 0&&(l={}),O(l,this.createData());var d=l.ot===B.CMCDObjectType.INIT||l.ot===B.CMCDObjectType.VIDEO||l.ot===B.CMCDObjectType.MUXED;if(this.starved&&d&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var w=C.toHeaders(l);if(!Object.keys(w).length)return;o.headers||(o.headers={}),O(o.headers,w)}else{var v=C.toQuery(l);if(!v)return;o.url=C.appendQueryToUri(o.url,v)}},T.getObjectType=function(o){var l=o.type;return l==="subtitle"?B.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?B.CMCDObjectType.INIT:l==="audio"?B.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?B.CMCDObjectType.VIDEO:B.CMCDObjectType.MUXED:void 0},T.getTopBandwidth=function(o){for(var l=0,d=o===B.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,w=R(d),v;!(v=w()).done;){var g=v.value;g.bitrate>l&&(l=g.bitrate)}return l>0?l:NaN},T.getBufferLength=function(o){var l=this.hls.media,d=o===B.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!l)return NaN;var w=M.BufferHelper.bufferInfo(d,l.currentTime,this.config.maxBufferHole);return w.len*1e3},T.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,d=o||this.config.loader;return function(){function w(g){this.loader=void 0,this.loader=new d(g)}var v=w.prototype;return v.destroy=function(){this.loader.destroy()},v.abort=function(){this.loader.abort()},v.load=function(k,E,p){l(k),this.loader.load(k,E,p)},P(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},T.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,d=o||this.config.loader;return function(){function w(g){this.loader=void 0,this.loader=new d(g)}var v=w.prototype;return v.destroy=function(){this.loader.destroy()},v.abort=function(){this.loader.abort()},v.load=function(k,E,p){l(k),this.loader.load(k,E,p)},P(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},C.uuid=function(){var o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},C.serialize=function(o){for(var l=[],d=function(U){return!Number.isNaN(U)&&U!=null&&U!==""&&U!==!1},w=function(U){return Math.round(U)},v=function(U){return w(U/100)*100},g=function(U){return encodeURIComponent(U)},k={br:w,d:w,bl:v,dl:v,mtp:v,nor:g,rtp:v,tb:w},E=Object.keys(o||{}).sort(),p=R(E),c;!(c=p()).done;){var u=c.value,a=o[u];if(!d(a))continue;if(u==="v"&&a===1)continue;if(u=="pr"&&a===1)continue;var b=k[u];b&&(a=b(a));var m=typeof a,x=void 0;u==="ot"||u==="sf"||u==="st"?x=u+"="+a:m==="boolean"?x=u:m==="number"?x=u+"="+a:x=u+"="+JSON.stringify(a),l.push(x)}return l.join(",")},C.toHeaders=function(o){for(var l=Object.keys(o),d={},w=["Object","Request","Session","Status"],v=[{},{},{},{}],g={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},k=0,E=l;k<E.length;k++){var p=E[k],c=g[p]!=null?g[p]:1;v[c][p]=o[p]}for(var u=0;u<v.length;u++){var a=C.serialize(v[u]);a&&(d["CMCD-"+w[u]]=a)}return d},C.toQuery=function(o){return"CMCD="+encodeURIComponent(C.serialize(o))},C.appendQueryToUri=function(o,l){if(!l)return o;var d=o.includes("?")?"&":"?";return""+o+d+l},C}()},"./src/controller/eme-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts"),B=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),z=D("./src/utils/mediakeys-helper.ts");function W(L,C){for(var T=0;T<C.length;T++){var h=C[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function P(L,C,T){return C&&W(L.prototype,C),T&&W(L,T),L}var R=3,y=function(C,T,h){var o={audioCapabilities:[],videoCapabilities:[]};return C.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:h.audioRobustness||""})}),T.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:h.videoRobustness||""})}),[o]},A=function(C,T,h,o){switch(C){case z.KeySystems.WIDEVINE:return y(T,h,o);default:throw new Error("Unknown key-system: "+C)}},O=function(){function L(T){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=T,this._config=T.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var C=L.prototype;return C.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},C._registerListeners=function(){this.hls.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this)},C._unregisterListeners=function(){this.hls.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this)},C.getLicenseServerUrl=function(h){switch(h){case z.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},C._attemptKeySystemAccess=function(h,o,l){var d=this,w=A(h,o,l,this._drmSystemOptions);M.logger.log("Requesting encrypted media key-system access");var v=this.requestMediaKeySystemAccess(h,w);this.mediaKeysPromise=v.then(function(g){return d._onMediaKeySystemAccessObtained(h,g)}),v.catch(function(g){M.logger.error('Failed to obtain key-system "'+h+'" access:',g)})},C._onMediaKeySystemAccessObtained=function(h,o){var l=this;M.logger.log('Access for key-system "'+h+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:h};this._mediaKeysList.push(d);var w=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(v){return d.mediaKeys=v,M.logger.log('Media-keys created for key-system "'+h+'"'),l._onMediaKeysCreated(),v});return w.catch(function(v){M.logger.error("Failed to create media-keys:",v)}),w},C._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),h._onNewMediaKeySession(o.mediaKeysSession))})},C._onNewMediaKeySession=function(h){var o=this;M.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(l){o._onKeySessionMessage(h,l.message)},!1)},C._onKeySessionMessage=function(h,o){M.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(l){M.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),h.update(l)})},C.onMediaEncrypted=function(h){var o=this;if(M.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(w){if(!o._media)return;o._attemptSetMediaKeys(w),o._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(l).catch(l)},C._attemptSetMediaKeys=function(h){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}M.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},C._generateRequestWithPreferredKeySession=function(h,o){var l=this,d=this._mediaKeysList[0];if(!d){M.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){M.logger.warn("Key-Session already initialized but requested again");return}var w=d.mediaKeysSession;if(!w){M.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){M.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}M.logger.log('Generating key-session request for "'+h+'" init data type'),d.mediaKeysSessionInitialized=!0,w.generateRequest(h,o).then(function(){M.logger.debug("Key-session generation succeeded")}).catch(function(v){M.logger.error("Error generating key-session request:",v),l.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},C._createLicenseXhr=function(h,o,l){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,h,o,l);var w=this._licenseXhrSetup;if(w)try{w.call(this.hls,d,h),w=void 0}catch(v){M.logger.error(v)}try{d.readyState||d.open("POST",h,!0),w&&w.call(this.hls,d,h)}catch(v){throw new Error("issue setting up KeySystem license XHR "+v)}return d},C._onLicenseRequestReadyStageChange=function(h,o,l,d){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,M.logger.log("License request succeeded");var w=h.response,v=this._licenseResponseCallback;if(v)try{w=v.call(this.hls,h,o)}catch(k){M.logger.error(k)}d(w)}else{if(M.logger.error("License Request XHR failed ("+o+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>R){this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var g=R-this._requestLicenseFailureCount+1;M.logger.warn("Retrying license request, "+g+" attempts left"),this._requestLicense(l,d)}break}},C._generateLicenseRequestChallenge=function(h,o){switch(h.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},C._requestLicense=function(h,o){M.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){M.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(l.mediaKeySystemDomain),w=this._createLicenseXhr(d,h,o);M.logger.log("Sending license request to URL: "+d);var v=this._generateLicenseRequestChallenge(l,h);w.send(v)}catch(g){M.logger.error("Failure requesting DRM license: "+g),this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},C.onMediaAttached=function(h,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},C.onMediaDetached=function(){var h=this._media,o=this._mediaKeysList;if(!h)return;h.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},C.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var l=o.levels.map(function(w){return w.audioCodec}).filter(function(w){return!!w}),d=o.levels.map(function(w){return w.videoCodec}).filter(function(w){return!!w});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,l,d)},P(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();Z.default=O},"./src/controller/fps-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts"),B=D("./src/utils/logger.ts"),M=function(){function z(P){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=P,this.registerListeners()}var W=z.prototype;return W.setStreamController=function(R){this.streamController=R},W.registerListeners=function(){this.hls.on($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},W.unregisterListeners=function(){this.hls.off($.Events.MEDIA_ATTACHING,this.onMediaAttaching)},W.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},W.onMediaAttaching=function(R,y){var A=this.hls.config;if(A.capLevelOnFPSDrop){var O=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=O,O&&typeof O.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},W.checkFPS=function(R,y,A){var O=performance.now();if(y){if(this.lastTime){var L=O-this.lastTime,C=A-this.lastDroppedFrames,T=y-this.lastDecodedFrames,h=1e3*C/L,o=this.hls;if(o.trigger($.Events.FPS_DROP,{currentDropped:C,currentDecoded:T,totalDroppedFrames:A}),h>0&&C>o.config.fpsDroppedMonitoringThreshold*T){var l=o.currentLevel;B.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=l)&&(l=l-1,o.trigger($.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=O,this.lastDroppedFrames=A,this.lastDecodedFrames=y}},W.checkFPSInterval=function(){var R=this.media;if(R)if(this.isVideoPlaybackQualityAvailable){var y=R.getVideoPlaybackQuality();this.checkFPS(R,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(R,R.webkitDecodedFrameCount,R.webkitDroppedFrameCount)},z}();Z.default=M},"./src/controller/fragment-finders.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"findFragmentByPDT",function(){return M}),D.d(Z,"findFragmentByPTS",function(){return z}),D.d(Z,"fragmentWithinToleranceTest",function(){return W}),D.d(Z,"pdtWithinToleranceTest",function(){return P}),D.d(Z,"findFragWithCC",function(){return R});var $=D("./src/polyfills/number.ts"),B=D("./src/utils/binary-search.ts");function M(y,A,O){if(A===null||!Array.isArray(y)||!y.length||!Object($.isFiniteNumber)(A))return null;var L=y[0].programDateTime;if(A<(L||0))return null;var C=y[y.length-1].endProgramDateTime;if(A>=(C||0))return null;O=O||0;for(var T=0;T<y.length;++T){var h=y[T];if(P(A,O,h))return h}return null}function z(y,A,O,L){O===void 0&&(O=0),L===void 0&&(L=0);var C=null;if(y?C=A[y.sn-A[0].sn+1]||null:O===0&&A[0].start===0&&(C=A[0]),C&&W(O,L,C)===0)return C;var T=B.default.search(A,W.bind(null,O,L));return T||C}function W(y,A,O){y===void 0&&(y=0),A===void 0&&(A=0);var L=Math.min(A,O.duration+(O.deltaPTS?O.deltaPTS:0));return O.start+O.duration-L<=y?1:O.start-L>y&&O.start?-1:0}function P(y,A,O){var L=Math.min(A,O.duration+(O.deltaPTS?O.deltaPTS:0))*1e3,C=O.endProgramDateTime||0;return C-L>y}function R(y,A){return B.default.search(y,function(O){return O.cc<A?1:O.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"FragmentState",function(){return M}),D.d(Z,"FragmentTracker",function(){return z});var $=D("./src/events.ts"),B=D("./src/types/loader.ts"),M;(function(R){R.NOT_LOADED="NOT_LOADED",R.BACKTRACKED="BACKTRACKED",R.APPENDING="APPENDING",R.PARTIAL="PARTIAL",R.OK="OK"})(M||(M={}));var z=function(){function R(A){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=A,this._registerListeners()}var y=R.prototype;return y._registerListeners=function(){var O=this.hls;O.on($.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.on($.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.on($.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var O=this.hls;O.off($.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.off($.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.off($.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(O,L){if(L===B.PlaylistLevelType.MAIN){var C=this.activeFragment,T=this.activeParts;if(!C)return null;if(T)for(var h=T.length;h--;){var o=T[h],l=o?o.end:C.appendedPTS;if(o.start<=O&&l!==void 0&&O<=l)return h>9&&(this.activeParts=T.slice(h-9)),o}else if(C.start<=O&&C.appendedPTS!==void 0&&O<=C.appendedPTS)return C}return this.getBufferedFrag(O,L)},y.getBufferedFrag=function(O,L){for(var C=this.fragments,T=Object.keys(C),h=T.length;h--;){var o=C[T[h]];if((o==null?void 0:o.body.type)===L&&o.buffered){var l=o.body;if(l.start<=O&&O<=l.end)return l}}return null},y.detectEvictedFragments=function(O,L,C){var T=this;Object.keys(this.fragments).forEach(function(h){var o=T.fragments[h];if(!o)return;if(!o.buffered){o.body.type===C&&T.removeFragment(o.body);return}var l=o.range[O];if(!l)return;l.time.some(function(d){var w=!T.isTimeBuffered(d.startPTS,d.endPTS,L);return w&&T.removeFragment(o.body),w})})},y.detectPartialFragments=function(O){var L=this,C=this.timeRanges,T=O.frag,h=O.part;if(!C||T.sn==="initSegment")return;var o=P(T),l=this.fragments[o];if(!l)return;Object.keys(C).forEach(function(d){var w=T.elementaryStreams[d];if(!w)return;var v=C[d],g=h!==null||w.partial===!0;l.range[d]=L.getBufferedTimes(T,h,g,v)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},y.fragBuffered=function(O){var L=P(O),C=this.fragments[L];C&&(C.backtrack=C.loaded=null,C.buffered=!0)},y.getBufferedTimes=function(O,L,C,T){for(var h={time:[],partial:C},o=L?L.start:O.start,l=L?L.end:O.end,d=O.minEndPTS||l,w=O.maxStartPTS||o,v=0;v<T.length;v++){var g=T.start(v)-this.bufferPadding,k=T.end(v)+this.bufferPadding;if(w>=g&&d<=k){h.time.push({startPTS:Math.max(o,T.start(v)),endPTS:Math.min(l,T.end(v))});break}else if(o<k&&l>g)h.partial=!0,h.time.push({startPTS:Math.max(o,T.start(v)),endPTS:Math.min(l,T.end(v))});else if(l<=g)break}return h},y.getPartialFragment=function(O){var L=null,C,T,h,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(w){var v=d[w];if(!v)return;W(v)&&(T=v.body.start-l,h=v.body.end+l,O>=T&&O<=h&&(C=Math.min(O-T,h-O),o<=C&&(L=v.body,o=C)))}),L},y.getState=function(O){var L=P(O),C=this.fragments[L];return C?C.buffered?W(C)?M.PARTIAL:M.OK:C.backtrack?M.BACKTRACKED:M.APPENDING:M.NOT_LOADED},y.backtrack=function(O,L){var C=P(O),T=this.fragments[C];if(!T||T.backtrack)return null;var h=T.backtrack=L||T.loaded;return T.loaded=null,h},y.getBacktrackData=function(O){var L=P(O),C=this.fragments[L];if(C){var T,h=C.backtrack;if(h!=null&&(T=h.payload)!==null&&T!==void 0&&T.byteLength)return h;this.removeFragment(O)}return null},y.isTimeBuffered=function(O,L,C){for(var T,h,o=0;o<C.length;o++){if(T=C.start(o)-this.bufferPadding,h=C.end(o)+this.bufferPadding,O>=T&&L<=h)return!0;if(L<=T)return!1}return!1},y.onFragLoaded=function(O,L){var C=L.frag,T=L.part;if(C.sn==="initSegment"||C.bitrateTest||T)return;var h=P(C);this.fragments[h]={body:C,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},y.onBufferAppended=function(O,L){var C=this,T=L.frag,h=L.part,o=L.timeRanges;if(T.type===B.PlaylistLevelType.MAIN)if(this.activeFragment=T,h){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(d){var w=o[d];if(C.detectEvictedFragments(d,w),!h)for(var v=0;v<w.length;v++)T.appendedPTS=Math.max(w.end(v),T.appendedPTS||0)})},y.onFragBuffered=function(O,L){this.detectPartialFragments(L)},y.hasFragment=function(O){var L=P(O);return!!this.fragments[L]},y.removeFragmentsInRange=function(O,L,C){var T=this;Object.keys(this.fragments).forEach(function(h){var o=T.fragments[h];if(!o)return;if(o.buffered){var l=o.body;l.type===C&&l.start<L&&l.end>O&&T.removeFragment(l)}})},y.removeFragment=function(O){var L=P(O);O.stats.loaded=0,O.clearElementaryStreamInfo(),delete this.fragments[L]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},R}();function W(R){var y,A;return R.buffered&&(((y=R.range.video)===null||y===void 0?void 0:y.partial)||((A=R.range.audio)===null||A===void 0?void 0:A.partial))}function P(R){return R.type+"_"+R.level+"_"+R.urlId+"_"+R.sn}},"./src/controller/gap-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"STALL_MINIMUM_DURATION_MS",function(){return W}),D.d(Z,"MAX_START_GAP_JUMP",function(){return P}),D.d(Z,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return R}),D.d(Z,"SKIP_BUFFER_RANGE_START",function(){return y}),D.d(Z,"default",function(){return A});var $=D("./src/utils/buffer-helper.ts"),B=D("./src/errors.ts"),M=D("./src/events.ts"),z=D("./src/utils/logger.ts"),W=250,P=2,R=.1,y=.05,A=function(){function O(C,T,h,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=C,this.media=T,this.fragmentTracker=h,this.hls=o}var L=O.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(T){var h=this.config,o=this.media,l=this.stalled,d=o.currentTime,w=o.seeking,v=this.seeking&&!w,g=!this.seeking&&w;if(this.seeking=w,d!==T){if(this.moved=!0,l!==null){if(this.stallReported){var k=self.performance.now()-l;z.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((g||v)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!$.BufferHelper.getBuffered(o).length)return;var E=$.BufferHelper.bufferInfo(o,d,0),p=E.len>0,c=E.nextStart||0;if(!p&&!c)return;if(w){var u=E.len>P,a=!c||c-d>P&&!this.fragmentTracker.getPartialFragment(d);if(u||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,m=Math.max(c,E.start||0)-d,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,F=x==null||((b=x.details)===null||b===void 0)?void 0:b.live,U=F?x.details.targetduration*2:P;if(m>0&&m<=U){this._trySkipBufferHole(null);return}}var K=self.performance.now();if(l===null){this.stalled=K;return}var V=K-l;!w&&V>=W&&this._reportStall(E.len);var _=$.BufferHelper.bufferInfo(o,d,h.maxBufferHole);this._tryFixBufferStall(_,V)},L._tryFixBufferStall=function(T,h){var o=this.config,l=this.fragmentTracker,d=this.media,w=d.currentTime,v=l.getPartialFragment(w);if(v){var g=this._trySkipBufferHole(v);if(g)return}T.len>o.maxBufferHole&&h>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(T){var h=this.hls,o=this.media,l=this.stallReported;l||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+T+")"),h.trigger(M.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:T}))},L._trySkipBufferHole=function(T){for(var h=this.config,o=this.hls,l=this.media,d=l.currentTime,w=0,v=$.BufferHelper.getBuffered(l),g=0;g<v.length;g++){var k=v.start(g);if(d+h.maxBufferHole>=w&&d<k){var E=Math.max(k+y,l.currentTime+R);return z.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+E),this.moved=!0,this.stalled=null,l.currentTime=E,T&&o.trigger(M.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+E,frag:T}),E}w=v.end(g)}return 0},L._tryNudgeBuffer=function(){var T=this.config,h=this.hls,o=this.media,l=o.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<T.nudgeMaxRetry){var w=l+d*T.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+l+" to "+w),o.currentTime=w,h.trigger(M.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else z.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+T.nudgeMaxRetry+" nudges"),h.trigger(M.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},O}()},"./src/controller/id3-track-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts"),B=D("./src/utils/texttrack-utils.ts"),M=D("./src/demux/id3.ts"),z=.25,W=function(){function P(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var R=P.prototype;return R.destroy=function(){this._unregisterListeners()},R._registerListeners=function(){var A=this.hls;A.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on($.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R._unregisterListeners=function(){var A=this.hls;A.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off($.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R.onMediaAttached=function(A,O){this.media=O.media},R.onMediaDetaching=function(){if(!this.id3Track)return;Object(B.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},R.getID3Track=function(A){if(!this.media)return;for(var O=0;O<A.length;O++){var L=A[O];if(L.kind==="metadata"&&L.label==="id3")return Object(B.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},R.onFragParsingMetadata=function(A,O){if(!this.media)return;var L=O.frag,C=O.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var T=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<C.length;h++){var o=M.getID3Frames(C[h].data);if(o){var l=C[h].pts,d=h<C.length-1?C[h+1].pts:L.end,w=d-l;w<=0&&(d=l+z);for(var v=0;v<o.length;v++){var g=o[v];if(!M.isTimeStampFrame(g)){var k=new T(l,d,"");k.value=g,this.id3Track.addCue(k)}}}}},R.onBufferFlushing=function(A,O){var L=O.startOffset,C=O.endOffset,T=O.type;if(!T||T==="audio"){var h=this.id3Track;h&&Object(B.removeCuesInRange)(h,L,C)}},P}();Z.default=W},"./src/controller/latency-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var $=D("./src/errors.ts"),B=D("./src/events.ts"),M=D("./src/utils/logger.ts");function z(R,y){for(var A=0;A<y.length;A++){var O=y[A];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function W(R,y,A){return y&&z(R.prototype,y),A&&z(R,A),R}var P=function(){function R(A){var O=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 O.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var y=R.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(B.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(B.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(B.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(B.Events.ERROR,this.onError)},y.onMediaAttached=function(O,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(O,L){var C=L.details;this.levelDetails=C,C.advanced&&this.timeupdate(),!C.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(O,L){if(L.details!==$.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},y.timeupdate=function(){var O=this.media,L=this.levelDetails;if(!O||!L)return;this.currentTime=O.currentTime;var C=this.computeLatency();if(C===null)return;this._latency=C;var T=this.config,h=T.lowLatencyMode,o=T.maxLiveSyncPlaybackRate;if(!h||o===1)return;var l=this.targetLatency;if(l===null)return;var d=C-l,w=Math.min(this.maxLatency,l+L.targetduration),v=d<w;if(L.live&&v&&d>.05&&this.forwardBufferLength>1){var g=Math.min(2,Math.max(1,o)),k=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;O.playbackRate=Math.min(g,Math.max(1,k))}else O.playbackRate!==1&&O.playbackRate!==0&&(O.playbackRate=1)},y.estimateLiveEdge=function(){var O=this.levelDetails;return O===null?null:O.edge+O.age},y.computeLatency=function(){var O=this.estimateLiveEdge();return O===null?null:O-this.currentTime},W(R,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var O=this.config,L=this.levelDetails;return O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:L?O.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var O=this.levelDetails;if(O===null)return null;var L=O.holdBack,C=O.partHoldBack,T=O.targetduration,h=this.config,o=h.liveSyncDuration,l=h.liveSyncDurationCount,d=h.lowLatencyMode,w=this.hls.userConfig,v=d&&C||L;(w.liveSyncDuration||w.liveSyncDurationCount||v===0)&&(v=o!==void 0?o:l*T);var g=T,k=1;return v+Math.min(this.stallCount*k,g)}},{key:"liveSyncPosition",get:function(){var O=this.estimateLiveEdge(),L=this.targetLatency,C=this.levelDetails;if(O===null||L===null||C===null)return null;var T=C.edge,h=O-L-this.edgeStalled,o=T-C.totalduration,l=T-(this.config.lowLatencyMode&&C.partTarget||C.targetduration);return Math.min(Math.max(o,h),l)}},{key:"drift",get:function(){var O=this.levelDetails;return O===null?1:O.drift}},{key:"edgeStalled",get:function(){var O=this.levelDetails;if(O===null)return 0;var L=(this.config.lowLatencyMode&&O.partTarget||O.targetduration)*3;return Math.max(O.age-L,0)}},{key:"forwardBufferLength",get:function(){var O=this.media,L=this.levelDetails;if(!O||!L)return 0;var C=O.buffered.length;return C?O.buffered.end(C-1):L.edge-this.currentTime}}]),R}()},"./src/controller/level-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return h});var $=D("./src/types/level.ts"),B=D("./src/events.ts"),M=D("./src/errors.ts"),z=D("./src/utils/codecs.ts"),W=D("./src/controller/level-helper.ts"),P=D("./src/controller/base-playlist-controller.ts"),R=D("./src/types/loader.ts");function y(){return y=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var w in d)Object.prototype.hasOwnProperty.call(d,w)&&(o[w]=d[w])}return o},y.apply(this,arguments)}function A(o,l){for(var d=0;d<l.length;d++){var w=l[d];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function O(o,l,d){return l&&A(o.prototype,l),d&&A(o,d),o}function L(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,C(o,l)}function C(o,l){return C=Object.setPrototypeOf||function(w,v){return w.__proto__=v,w},C(o,l)}var T=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){L(l,o);function l(w){var v;return v=o.call(this,w,"[level-controller]")||this,v._levels=[],v._firstLevel=-1,v._startLevel=void 0,v.currentLevelIndex=-1,v.manualLevelIndex=-1,v.onParsedComplete=void 0,v._registerListeners(),v}var d=l.prototype;return d._registerListeners=function(){var v=this.hls;v.on(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),v.on(B.Events.FRAG_LOADED,this.onFragLoaded,this),v.on(B.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var v=this.hls;v.off(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),v.off(B.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(B.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},d.startLoad=function(){var v=this._levels;v.forEach(function(g){g.loadError=0}),o.prototype.startLoad.call(this)},d.onManifestLoaded=function(v,g){var k=[],E=[],p=[],c,u={},a,b=!1,m=!1,x=!1;if(g.levels.forEach(function(V){var _=V.attrs;b=b||!!(V.width&&V.height),m=m||!!V.videoCodec,x=x||!!V.audioCodec,T&&V.audioCodec&&V.audioCodec.indexOf("mp4a.40.34")!==-1&&(V.audioCodec=void 0);var I=V.bitrate+"-"+V.attrs.RESOLUTION+"-"+V.attrs.CODECS;a=u[I],a?a.url.push(V.url):(a=new $.Level(V),u[I]=a,k.push(a)),_&&(_.AUDIO&&Object(W.addGroupId)(a,"audio",_.AUDIO),_.SUBTITLES&&Object(W.addGroupId)(a,"text",_.SUBTITLES))}),(b||m)&&x&&(k=k.filter(function(V){var _=V.videoCodec,I=V.width,Y=V.height;return!!_||!!(I&&Y)})),k=k.filter(function(V){var _=V.audioCodec,I=V.videoCodec;return(!_||Object(z.isCodecSupportedInMp4)(_,"audio"))&&(!I||Object(z.isCodecSupportedInMp4)(I,"video"))}),g.audioTracks&&(E=g.audioTracks.filter(function(V){return!V.audioCodec||Object(z.isCodecSupportedInMp4)(V.audioCodec,"audio")}),Object(W.assignTrackIdsByGroup)(E)),g.subtitles&&(p=g.subtitles,Object(W.assignTrackIdsByGroup)(p)),k.length>0){c=k[0].bitrate,k.sort(function(V,_){return V.bitrate-_.bitrate}),this._levels=k;for(var F=0;F<k.length;F++)if(k[F].bitrate===c){this._firstLevel=F,this.log("manifest loaded, "+k.length+" level(s) found, first bitrate: "+c);break}var U=x&&!m,K={levels:k,audioTracks:E,subtitleTracks:p,firstLevel:this._firstLevel,stats:g.stats,audio:x,video:m,altAudio:!U&&E.some(function(V){return!!V.url})};this.hls.trigger(B.Events.MANIFEST_PARSED,K),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(B.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:g.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(v,g){if(o.prototype.onError.call(this,v,g),g.fatal)return;var k=g.context,E=this._levels[this.currentLevelIndex];if(k&&(k.type===R.PlaylistContextType.AUDIO_TRACK&&E.audioGroupIds&&k.groupId===E.audioGroupIds[E.urlId]||k.type===R.PlaylistContextType.SUBTITLE_TRACK&&E.textGroupIds&&k.groupId===E.textGroupIds[E.urlId])){this.redundantFailover(this.currentLevelIndex);return}var p=!1,c=!0,u;switch(g.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:case M.ErrorDetails.KEY_LOAD_ERROR:case M.ErrorDetails.KEY_LOAD_TIMEOUT:if(g.frag){var a=this._levels[g.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(u=g.frag.level)):u=g.frag.level}break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:k&&(k.deliveryDirectives&&(c=!1),u=k.level),p=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:u=g.level,p=!0;break}u!==void 0&&this.recoverLevel(g,u,p,c)},d.recoverLevel=function(v,g,k,E){var p=v.details,c=this._levels[g];if(c.loadError++,k){var u=this.retryLoadingOrFail(v);if(u)v.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var a=c.url.length;if(a>1&&c.loadError<a)v.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){var b=g===0?this._levels.length-1:g-1;this.currentLevelIndex!==b&&this._levels[b].loadError===0&&(this.warn(p+": switch to "+b),v.levelRetry=!0,this.hls.nextAutoLevel=b)}}},d.redundantFailover=function(v){var g=this._levels[v],k=g.url.length;if(k>1){var E=(g.urlId+1)%k;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(p){p.urlId=E}),this.level=v}},d.onFragLoaded=function(v,g){var k=g.frag;if(k!==void 0&&k.type===R.PlaylistLevelType.MAIN){var E=this._levels[k.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},d.onLevelLoaded=function(v,g){var k,E=g.level,p=g.details,c=this._levels[E];if(!c){var u;this.warn("Invalid level index "+E),(u=g.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(p.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(E,g,c.details)):(k=g.deliveryDirectives)!==null&&k!==void 0&&k.skip&&(p.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(v,g){var k=this.hls.levels[this.currentLevelIndex];if(!k)return;if(k.audioGroupIds){for(var E=-1,p=this.hls.audioTracks[g.id].groupId,c=0;c<k.audioGroupIds.length;c++)if(k.audioGroupIds[c]===p){E=c;break}E!==k.urlId&&(k.urlId=E,this.startLoad())}},d.loadPlaylist=function(v){var g=this.currentLevelIndex,k=this._levels[g];if(this.canLoad&&k&&k.url.length>0){var E=k.urlId,p=k.url[E];if(v)try{p=v.addDirectives(p)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+g+(v?" at sn "+v.msn+" part "+v.part:"")+" with URL-id "+E+" "+p),this.clearTimer(),this.hls.trigger(B.Events.LEVEL_LOADING,{url:p,level:g,id:E,deliveryDirectives:v||null})}},d.removeLevel=function(v,g){var k=function(c,u){return u!==g},E=this._levels.filter(function(p,c){return c!==v?!0:p.url.length>1&&g!==void 0?(p.url=p.url.filter(k),p.audioGroupIds&&(p.audioGroupIds=p.audioGroupIds.filter(k)),p.textGroupIds&&(p.textGroupIds=p.textGroupIds.filter(k)),p.urlId=0,!0):!1}).map(function(p,c){var u=p.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=c}),p});this._levels=E,this.hls.trigger(B.Events.LEVELS_UPDATED,{levels:E})},O(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(v){var g,k=this._levels;if(k.length===0)return;if(this.currentLevelIndex===v&&(g=k[v])!==null&&g!==void 0&&g.details)return;if(v<0||v>=k.length){var E=v<0;if(this.hls.trigger(B.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:v,fatal:E,reason:"invalid level idx"}),E)return;v=Math.min(v,k.length-1)}this.clearTimer();var p=this.currentLevelIndex,c=k[p],u=k[v];this.log("switching to level "+v+" from "+p),this.currentLevelIndex=v;var a=y({},u,{level:v,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(B.Events.LEVEL_SWITCHING,a);var b=u.details;if(!b||b.live){var m=this.switchParams(u.uri,c==null?void 0:c.details);this.loadPlaylist(m)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(v){this.manualLevelIndex=v,this._startLevel===void 0&&(this._startLevel=v),v!==-1&&(this.level=v)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(v){this._firstLevel=v}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var v=this.hls.config.startLevel;return v!==void 0?v:this._firstLevel}else return this._startLevel},set:function(v){this._startLevel=v}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(v){this.level=v,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=v)}}]),l}(P.default)},"./src/controller/level-helper.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"addGroupId",function(){return M}),D.d(Z,"assignTrackIdsByGroup",function(){return z}),D.d(Z,"updatePTS",function(){return W}),D.d(Z,"updateFragPTSDTS",function(){return R}),D.d(Z,"mergeDetails",function(){return y}),D.d(Z,"mapPartIntersection",function(){return A}),D.d(Z,"mapFragmentIntersection",function(){return O}),D.d(Z,"adjustSliding",function(){return L}),D.d(Z,"addSliding",function(){return C}),D.d(Z,"computeReloadInterval",function(){return T}),D.d(Z,"getFragmentWithSN",function(){return h}),D.d(Z,"getPartWith",function(){return o});var $=D("./src/polyfills/number.ts"),B=D("./src/utils/logger.ts");function M(l,d,w){switch(d){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(w);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(w);break}}function z(l){var d={};l.forEach(function(w){var v=w.groupId||"";w.id=d[v]=d[v]||0,d[v]++})}function W(l,d,w){var v=l[d],g=l[w];P(v,g)}function P(l,d){var w=d.startPTS;if(Object($.isFiniteNumber)(w)){var v=0,g;d.sn>l.sn?(v=w-l.start,g=l):(v=l.start-w,g=d),g.duration!==v&&(g.duration=v)}else if(d.sn>l.sn){var k=l.cc===d.cc;k&&l.minEndPTS?d.start=l.start+(l.minEndPTS-l.start):d.start=l.start+l.duration}else d.start=Math.max(l.start-d.duration,0)}function R(l,d,w,v,g,k){var E=v-w;E<=0&&(B.logger.warn("Fragment should have a positive duration",d),v=w+d.duration,k=g+d.duration);var p=w,c=v,u=d.startPTS,a=d.endPTS;if(Object($.isFiniteNumber)(u)){var b=Math.abs(u-w);Object($.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(b,d.deltaPTS):d.deltaPTS=b,p=Math.max(w,u),w=Math.min(w,u),g=Math.min(g,d.startDTS),c=Math.min(v,a),v=Math.max(v,a),k=Math.max(k,d.endDTS)}d.duration=v-w;var m=w-d.start;d.appendedPTS=v,d.start=d.startPTS=w,d.maxStartPTS=p,d.startDTS=g,d.endPTS=v,d.minEndPTS=c,d.endDTS=k;var x=d.sn;if(!l||x<l.startSN||x>l.endSN)return 0;var F,U=x-l.startSN,K=l.fragments;for(K[U]=d,F=U;F>0;F--)P(K[F],K[F-1]);for(F=U;F<K.length-1;F++)P(K[F],K[F+1]);return l.fragmentHint&&P(K[K.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,m}function y(l,d){for(var w=null,v=l.fragments,g=v.length-1;g>=0;g--){var k=v[g].initSegment;if(k){w=k;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var E=0,p;if(O(l,d,function(F,U){F.relurl&&(E=F.cc-U.cc),Object($.isFiniteNumber)(F.startPTS)&&Object($.isFiniteNumber)(F.endPTS)&&(U.start=U.startPTS=F.startPTS,U.startDTS=F.startDTS,U.appendedPTS=F.appendedPTS,U.maxStartPTS=F.maxStartPTS,U.endPTS=F.endPTS,U.endDTS=F.endDTS,U.minEndPTS=F.minEndPTS,U.duration=F.endPTS-F.startPTS,U.duration&&(p=U),d.PTSKnown=d.alignedSliding=!0),U.elementaryStreams=F.elementaryStreams,U.loader=F.loader,U.stats=F.stats,U.urlId=F.urlId,F.initSegment&&(U.initSegment=F.initSegment,w=F.initSegment)}),w){var c=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;c.forEach(function(F){var U;(!F.initSegment||F.initSegment.relurl===((U=w)===null||U===void 0?void 0:U.relurl))&&(F.initSegment=w)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(F){return!F}),d.deltaUpdateFailed)){B.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=d.skippedSegments;u--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var a=d.fragments;if(E){B.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].cc+=E}d.skippedSegments&&(d.startCC=d.fragments[0].cc),A(l.partList,d.partList,function(F,U){U.elementaryStreams=F.elementaryStreams,U.stats=F.stats}),p?R(d,p,p.startPTS,p.endPTS,p.startDTS,p.endDTS):L(l,d),a.length&&(d.totalduration=d.edge-a[0].start),d.driftStartTime=l.driftStartTime,d.driftStart=l.driftStart;var m=d.advancedDateTime;if(d.advanced&&m){var x=d.edge;d.driftStart||(d.driftStartTime=m,d.driftStart=x),d.driftEndTime=m,d.driftEnd=x}else d.driftEndTime=l.driftEndTime,d.driftEnd=l.driftEnd,d.advancedDateTime=l.advancedDateTime}function A(l,d,w){if(l&&d)for(var v=0,g=0,k=l.length;g<=k;g++){var E=l[g],p=d[g+v];E&&p&&E.index===p.index&&E.fragment.sn===p.fragment.sn?w(E,p):v--}}function O(l,d,w){for(var v=d.skippedSegments,g=Math.max(l.startSN,d.startSN)-d.startSN,k=(l.fragmentHint?1:0)+(v?d.endSN:Math.min(l.endSN,d.endSN))-d.startSN,E=d.startSN-l.startSN,p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,u=g;u<=k;u++){var a=c[E+u],b=p[u];v&&!b&&u<v&&(b=d.fragments[u]=a),a&&b&&w(a,b)}}function L(l,d){var w=d.startSN+d.skippedSegments-l.startSN,v=l.fragments;if(w<0||w>=v.length)return;C(d,v[w].start)}function C(l,d){if(d){for(var w=l.fragments,v=l.skippedSegments;v<w.length;v++)w[v].start+=d;l.fragmentHint&&(l.fragmentHint.start+=d)}}function T(l,d){var w=1e3*l.levelTargetDuration,v=w/2,g=l.age,k=g>0&&g<w*3,E=d.loading.end-d.loading.start,p,c=l.availabilityDelay;if(l.updated===!1)if(k){var u=333*l.misses;p=Math.max(Math.min(v,E*2),u),l.availabilityDelay=(l.availabilityDelay||0)+p}else p=v;else k?(c=Math.min(c||w/2,g),l.availabilityDelay=c,p=c+w-g):p=w-E;return Math.round(p)}function h(l,d,w){if(!l||!l.details)return null;var v=l.details,g=v.fragments[d-v.startSN];return g||(g=v.fragmentHint,g&&g.sn===d?g:d<v.startSN&&w&&w.sn===d?w:null)}function o(l,d,w){if(!l||!l.details)return null;var v=l.details.partList;if(v)for(var g=v.length;g--;){var k=v[g];if(k.index===w&&k.fragment.sn===d)return k}return null}},"./src/controller/stream-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return v});var $=D("./src/polyfills/number.ts"),B=D("./src/controller/base-stream-controller.ts"),M=D("./src/is-supported.ts"),z=D("./src/events.ts"),W=D("./src/utils/buffer-helper.ts"),P=D("./src/controller/fragment-tracker.ts"),R=D("./src/types/loader.ts"),y=D("./src/loader/fragment.ts"),A=D("./src/demux/transmuxer-interface.ts"),O=D("./src/types/transmuxer.ts"),L=D("./src/controller/gap-controller.ts"),C=D("./src/errors.ts"),T=D("./src/utils/logger.ts");function h(g,k){for(var E=0;E<k.length;E++){var p=k[E];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(g,p.key,p)}}function o(g,k,E){return k&&h(g.prototype,k),E&&h(g,E),g}function l(g,k){g.prototype=Object.create(k.prototype),g.prototype.constructor=g,d(g,k)}function d(g,k){return d=Object.setPrototypeOf||function(p,c){return p.__proto__=c,p},d(g,k)}var w=100,v=function(g){l(k,g);function k(p,c){var u;return u=g.call(this,p,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 E=k.prototype;return E._registerListeners=function(){var c=this.hls;c.on(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(z.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(z.Events.ERROR,this.onError,this),c.on(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var c=this.hls;c.off(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(z.Events.ERROR,this.onError,this),c.off(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},E.startLoad=function(c){if(this.levels){var u=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=a.startLevel;b===-1&&(a.config.testBandwidth?(b=0,this.bitrateTest=!0):b=a.nextAutoLevel),this.level=a.nextLoadLevel=b,this.loadedmetadata=!1}u>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),c=u),this.state=B.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=B.State.STOPPED},E.stopLoad=function(){this._forceStartLoad=!1,g.prototype.stopLoad.call(this)},E.doTick=function(){switch(this.state){case B.State.IDLE:this.doTickIdle();break;case B.State.WAITING_LEVEL:{var c,u=this.levels,a=this.level,b=u==null||((c=u[a])===null||c===void 0)?void 0:c.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=B.State.IDLE;break}break}case B.State.FRAG_LOADING_WAITING_RETRY:{var m,x=self.performance.now(),F=this.retryDate;(!F||x>=F||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=B.State.IDLE)}break;default:break}this.onTickEnd()},E.onTickEnd=function(){g.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},E.doTickIdle=function(){var c,u,a=this.hls,b=this.levelLastLoaded,m=this.levels,x=this.media,F=a.config,U=a.nextLoadLevel;if(b===null||!x&&(this.startFragRequested||!F.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!m||!m[U])return;var K=m[U];this.level=a.nextLoadLevel=U;var V=K.details;if(!V||this.state===B.State.WAITING_LEVEL||V.live&&this.levelLastLoaded!==U){this.state=B.State.WAITING_LEVEL;return}var _=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,R.PlaylistLevelType.MAIN);if(_===null)return;var I=_.len,Y=this.getMaxBufferLength(K.maxBitrate);if(I>=Y)return;if(this._streamEnded(_,V)){var ee={};this.altAudio&&(ee.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,ee),this.state=B.State.ENDED;return}var ae=_.end,de=this.getNextFragment(ae,V);if(this.couldBacktrack&&!this.fragPrevious&&de&&de.sn!=="initSegment"){var De=de.sn-V.startSN;De>1&&(de=V.fragments[De-1],this.fragmentTracker.removeFragment(de))}if(de&&this.fragmentTracker.getState(de)===P.FragmentState.OK&&this.nextLoadPosition>ae){var Se=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,Se,R.PlaylistLevelType.MAIN),de=this.getNextFragment(this.nextLoadPosition,V)}if(!de)return;de.initSegment&&!de.initSegment.data&&!this.bitrateTest&&(de=de.initSegment),((c=de.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((u=de.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(de,V):this.loadFragment(de,V,ae)},E.loadFragment=function(c,u,a){var b,m=this.fragmentTracker.getState(c);if(this.fragCurrent=c,m===P.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(c);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else m=P.FragmentState.NOT_LOADED}m===P.FragmentState.NOT_LOADED||m===P.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,g.prototype.loadFragment.call(this,c,u,a)):m===P.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((b=this.media)===null||b===void 0?void 0:b.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},E.getAppendedFrag=function(c){var u=this.fragmentTracker.getAppendedFrag(c,R.PlaylistLevelType.MAIN);return u&&"fragment"in u?u.fragment:u},E.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,R.PlaylistLevelType.MAIN)},E.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},E.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},E.nextLevelSwitch=function(){var c=this.levels,u=this.media;if(u!=null&&u.readyState){var a,b=this.getAppendedFrag(u.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!u.paused&&c){var m=this.hls.nextLoadLevel,x=c[m],F=this.fragLastKbps;F&&this.fragCurrent?a=this.fragCurrent.duration*x.maxBitrate/(1e3*F)+1:a=0}else a=0;var U=this.getBufferedFrag(u.currentTime+a);if(U){var K=this.followingBufferedFrag(U);if(K){this.abortCurrentFrag();var V=K.maxStartPTS?K.maxStartPTS:K.start,_=K.duration,I=Math.max(U.end,V+Math.min(Math.max(_-this.config.maxFragLookUpTolerance,_*.5),_*.75));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},E.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===B.State.KEY_LOADING&&(this.state=B.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},E.flushMainBuffer=function(c,u){g.prototype.flushMainBuffer.call(this,c,u,this.altAudio?"video":null)},E.onMediaAttached=function(c,u){g.prototype.onMediaAttached.call(this,c,u);var a=u.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,a,this.fragmentTracker,this.hls)},E.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),g.prototype.onMediaDetaching.call(this)},E.onMediaPlaying=function(){this.tick()},E.onMediaSeeked=function(){var c=this.media,u=c?c.currentTime:null;Object($.isFiniteNumber)(u)&&this.log("Media seeked to "+u.toFixed(3)),this.tick()},E.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(z.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},E.onManifestParsed=function(c,u){var a=!1,b=!1,m;u.levels.forEach(function(x){m=x.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(a=!0),m.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!Object(M.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},E.onLevelLoading=function(c,u){var a=this.levels;if(!a||this.state!==B.State.IDLE)return;var b=a[u.level];(!b.details||b.details.live&&this.levelLastLoaded!==u.level||this.waitForCdnTuneIn(b.details))&&(this.state=B.State.WAITING_LEVEL)},E.onLevelLoaded=function(c,u){var a,b=this.levels,m=u.level,x=u.details,F=x.totalduration;if(!b){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+F);var U=this.fragCurrent;U&&(this.state===B.State.FRAG_LOADING||this.state===B.State.FRAG_LOADING_WAITING_RETRY)&&(U.level!==u.level&&U.loader&&(this.state=B.State.IDLE,U.loader.abort()));var K=b[m],V=0;if(x.live||(a=K.details)!==null&&a!==void 0&&a.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;V=this.alignPlaylists(x,K.details)}if(K.details=x,this.levelLastLoaded=m,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:x,level:m}),this.state===B.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=B.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,V),this.tick()},E._handleFragmentLoadProgress=function(c){var u,a=c.frag,b=c.part,m=c.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var F=x[a.level],U=F.details;if(!U){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var K=F.videoCodec,V=U.PTSKnown||!U.live,_=(u=a.initSegment)===null||u===void 0?void 0:u.data,I=this._getAudioCodec(F),Y=this.transmuxer=this.transmuxer||new A.default(this.hls,R.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ee=b?b.index:-1,ae=ee!==-1,de=new O.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,m.byteLength,ee,ae),De=this.initPTS[a.cc];Y.push(m,_,I,K,a,b,U.totalduration,V,de,De)},E.onAudioTrackSwitching=function(c,u){var a=this.altAudio,b=!!u.url,m=u.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var F=this.hls;a&&F.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),F.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:m})}},E.onAudioTrackSwitched=function(c,u){var a=u.id,b=!!this.hls.audioTracks[a].url;if(b){var m=this.videoBuffer;m&&this.mediaBuffer!==m&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=m)}this.altAudio=b,this.tick()},E.onBufferCreated=function(c,u){var a=u.tracks,b,m,x=!1;for(var F in a){var U=a[F];if(U.id==="main"){if(m=F,b=U,F==="video"){var K=a[F];K&&(this.videoBuffer=K.buffer)}}else x=!0}x&&b?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},E.onFragBuffered=function(c,u){var a=u.frag,b=u.part;if(a&&a.type!==R.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===B.State.PARSED&&(this.state=B.State.IDLE);return}var m=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},E.onError=function(c,u){switch(u.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:case C.ErrorDetails.KEY_LOAD_ERROR:case C.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,u);break;case C.ErrorDetails.LEVEL_LOAD_ERROR:case C.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==B.State.ERROR&&(u.fatal?(this.warn(""+u.details),this.state=B.State.ERROR):!u.levelRetry&&this.state===B.State.WAITING_LEVEL&&(this.state=B.State.IDLE));break;case C.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="main"&&(this.state===B.State.PARSING||this.state===B.State.PARSED)){var a=!0,b=this.getFwdBufferInfo(this.media,R.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},E.checkBuffer=function(){var c=this.media,u=this.gapController;if(!c||!u||!c.readyState)return;var a=W.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):u.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},E.onFragLoadEmergencyAborted=function(){this.state=B.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},E.onBufferFlushed=function(c,u){var a=u.type;if(a!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,R.PlaylistLevelType.MAIN)}},E.onLevelsUpdated=function(c,u){this.levels=u.levels},E.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},E.seekToStartPos=function(){var c=this.media,u=c.currentTime,a=this.startPosition;if(a>=0&&u<a){if(c.seeking){T.logger.log("could not seek to "+a+", already seeking at "+u);return}var b=W.BufferHelper.getBuffered(c),m=b.length?b.start(0):0,x=m-a;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(T.logger.log("adjusting start position by "+x+" to match buffer start"),a+=x,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+u),c.currentTime=a}},E._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},E._loadBitrateTestFrag=function(c){var u=this;this._doFragLoad(c).then(function(a){var b=u.hls;if(!a||b.nextLoadLevel||u.fragContextChanged(c))return;u.fragLoadError=0,u.state=B.State.IDLE,u.startFragRequested=!1,u.bitrateTest=!1;var m=c.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),b.trigger(z.Events.FRAG_LOADED,a)})},E._handleTransmuxComplete=function(c){var u,a="main",b=this.hls,m=c.remuxResult,x=c.chunkMeta,F=this.getCurrentContext(x);if(!F){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var U=F.frag,K=F.part,V=F.level,_=m.video,I=m.text,Y=m.id3,ee=m.initSegment,ae=this.altAudio?void 0:m.audio;if(this.fragContextChanged(U))return;if(this.state=B.State.PARSING,ee){ee.tracks&&(this._bufferInitSegment(V,ee.tracks,U,x),b.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:a,tracks:ee.tracks}));var de=ee.initPTS,De=ee.timescale;Object($.isFiniteNumber)(de)&&(this.initPTS[U.cc]=de,b.trigger(z.Events.INIT_PTS_FOUND,{frag:U,id:a,initPTS:de,timescale:De}))}if(_&&m.independent!==!1){if(V.details){var Se=_.startPTS,we=_.endPTS,Ce=_.startDTS,Te=_.endDTS;if(K)K.elementaryStreams[_.type]={startPTS:Se,endPTS:we,startDTS:Ce,endDTS:Te};else if(_.firstKeyFrame&&_.independent&&(this.couldBacktrack=!0),_.dropped&&_.independent){var ge=this.getLoadPosition()+this.config.maxBufferHole;if(ge<Se){this.backtrack(U);return}U.setElementaryStreamInfo(_.type,U.start,we,U.start,Te,!0)}U.setElementaryStreamInfo(_.type,Se,we,Ce,Te),this.bufferFragmentData(_,U,K,x)}}else if(m.independent===!1){this.backtrack(U);return}if(ae){var le=ae.startPTS,te=ae.endPTS,ce=ae.startDTS,ne=ae.endDTS;K&&(K.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:le,endPTS:te,startDTS:ce,endDTS:ne}),U.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,le,te,ce,ne),this.bufferFragmentData(ae,U,K,x)}if(Y!=null&&(u=Y.samples)!==null&&u!==void 0&&u.length){var Le={frag:U,id:a,samples:Y.samples};b.trigger(z.Events.FRAG_PARSING_METADATA,Le)}if(I){var Oe={frag:U,id:a,samples:I.samples};b.trigger(z.Events.FRAG_PARSING_USERDATA,Oe)}},E._bufferInitSegment=function(c,u,a,b){var m=this;if(this.state!==B.State.PARSING)return;this.audioOnly=!!u.audio&&!u.video,this.altAudio&&!this.audioOnly&&delete u.audio;var x=u.audio,F=u.video,U=u.audiovideo;if(x){var K=c.audioCodec,V=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(K&&(K.indexOf("mp4a.40.5")!==-1?K="mp4a.40.2":K="mp4a.40.5"),x.metadata.channelCount!==1&&V.indexOf("firefox")===-1&&(K="mp4a.40.5")),V.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(K="mp4a.40.2",this.log("Android: force audio codec to "+K)),c.audioCodec&&c.audioCodec!==K&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+K+'"'),x.levelCodec=K,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(K||"")+"/"+(c.audioCodec||"")+"/"+x.codec+"]")}F&&(F.levelCodec=c.videoCodec,F.id="main",this.log("Init video buffer, container:"+F.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+F.codec+"]")),U&&this.log("Init audiovideo buffer, container:"+U.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+U.codec+"]"),this.hls.trigger(z.Events.BUFFER_CODECS,u),Object.keys(u).forEach(function(_){var I=u[_],Y=I.initSegment;Y!=null&&Y.byteLength&&m.hls.trigger(z.Events.BUFFER_APPENDING,{type:_,data:Y,frag:a,part:null,chunkMeta:b,parent:a.type})}),this.tick()},E.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=B.State.BACKTRACKING},E.checkFragmentChanged=function(){var c=this.media,u=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(W.BufferHelper.isBuffered(c,a)?u=this.getAppendedFrag(a):W.BufferHelper.isBuffered(c,a+.1)&&(u=this.getAppendedFrag(a+.1)),u){var b=this.fragPlaying,m=u.level;(!b||u.sn!==b.sn||b.level!==m||u.urlId!==b.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:u}),(!b||b.level!==m)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=u)}}},o(k,[{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}}]),k}(B.default)},"./src/controller/subtitle-stream-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"SubtitleStreamController",function(){return l});var $=D("./src/events.ts"),B=D("./src/utils/logger.ts"),M=D("./src/utils/buffer-helper.ts"),z=D("./src/controller/fragment-finders.ts"),W=D("./src/utils/discontinuities.ts"),P=D("./src/controller/level-helper.ts"),R=D("./src/controller/fragment-tracker.ts"),y=D("./src/controller/base-stream-controller.ts"),A=D("./src/types/loader.ts"),O=D("./src/types/level.ts");function L(d,w){for(var v=0;v<w.length;v++){var g=w[v];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(d,g.key,g)}}function C(d,w,v){return w&&L(d.prototype,w),v&&L(d,v),d}function T(d,w){d.prototype=Object.create(w.prototype),d.prototype.constructor=d,h(d,w)}function h(d,w){return h=Object.setPrototypeOf||function(g,k){return g.__proto__=k,g},h(d,w)}var o=500,l=function(d){T(w,d);function w(g,k){var E;return E=d.call(this,g,k,"[subtitle-stream-controller]")||this,E.levels=[],E.currentTrackId=-1,E.tracksBuffered=[],E.mainDetails=null,E._registerListeners(),E}var v=w.prototype;return v.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},v._registerListeners=function(){var k=this.hls;k.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.on($.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.on($.Events.ERROR,this.onError,this),k.on($.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.on($.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.on($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.on($.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.on($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},v._unregisterListeners=function(){var k=this.hls;k.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.off($.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.off($.Events.ERROR,this.onError,this),k.off($.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.off($.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.off($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.off($.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.off($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},v.startLoad=function(){this.stopLoad(),this.state=y.State.IDLE,this.setInterval(o),this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},v.onLevelLoaded=function(k,E){this.mainDetails=E.details},v.onSubtitleFragProcessed=function(k,E){var p=E.frag,c=E.success;if(this.fragPrevious=p,this.state=y.State.IDLE,!c)return;var u=this.tracksBuffered[this.currentTrackId];if(!u)return;for(var a,b=p.start,m=0;m<u.length;m++)if(b>=u[m].start&&b<=u[m].end){a=u[m];break}var x=p.start+p.duration;a?a.end=x:(a={start:b,end:x},u.push(a)),this.fragmentTracker.fragBuffered(p)},v.onBufferFlushing=function(k,E){var p=E.startOffset,c=E.endOffset;if(p===0&&c!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var b=a[u].details,m=b.targetduration,x=c-m;if(x<=0)return;E.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(F){for(var U=0;U<F.length;){if(F[U].end<=x){F.shift();continue}else if(F[U].start<x)F[U].start=x;else break;U++}}),this.fragmentTracker.removeFragmentsInRange(p,x,A.PlaylistLevelType.SUBTITLE)}},v.onError=function(k,E){var p,c=E.frag;if(!c||c.type!==A.PlaylistLevelType.SUBTITLE)return;(p=this.fragCurrent)!==null&&p!==void 0&&p.loader&&this.fragCurrent.loader.abort(),this.state=y.State.IDLE},v.onSubtitleTracksUpdated=function(k,E){var p=this,c=E.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(u){return new O.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){p.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},v.onSubtitleTrackSwitch=function(k,E){if(this.currentTrackId=E.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var p=this.levels[this.currentTrackId];p!=null&&p.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,p&&this.setInterval(o)},v.onSubtitleTrackLoaded=function(k,E){var p,c=E.details,u=E.id,a=this.currentTrackId,b=this.levels;if(!b.length)return;var m=b[a];if(u>=b.length||u!==a||!m)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(p=m.details)!==null&&p!==void 0&&p.live){var x=this.mainDetails;if(c.deltaUpdateFailed||!x)return;var F=x.fragments[0];if(!m.details)c.hasProgramDateTime&&x.hasProgramDateTime?Object(W.alignMediaPlaylistByPDT)(c,x):F&&Object(P.addSliding)(c,F.start);else{var U=this.alignPlaylists(c,m.details);U===0&&F&&Object(P.addSliding)(c,F.start)}}if(m.details=c,this.levelLastLoaded=u,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===y.State.IDLE){var K=Object(z.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);K||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}},v._handleFragmentLoadComplete=function(k){var E=k.frag,p=k.payload,c=E.decryptdata,u=this.hls;if(this.fragContextChanged(E))return;if(p&&p.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(p),c.key.buffer,c.iv.buffer).then(function(b){var m=performance.now();u.trigger($.Events.FRAG_DECRYPTED,{frag:E,payload:b,stats:{tstart:a,tdecrypt:m}})})}},v.doTick=function(){if(!this.media){this.state=y.State.IDLE;return}if(this.state===y.State.IDLE){var k,E=this.currentTrackId,p=this.levels;if(!p.length||!p[E]||!p[E].details)return;var c=p[E].details,u=c.targetduration,a=this.config,b=this.media,m=M.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-u,a.maxBufferHole),x=m.end,F=m.len,U=this.getMaxBufferLength()+u;if(F>U)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var K=c.fragments,V=K.length,_=c.edge,I,Y=this.fragPrevious;if(x<_){var ee=a.maxFragLookUpTolerance;Y&&c.hasProgramDateTime&&(I=Object(z.findFragmentByPDT)(K,Y.endProgramDateTime,ee)),I||(I=Object(z.findFragmentByPTS)(Y,K,x,ee),!I&&Y&&Y.start<K[0].start&&(I=K[0]))}else I=K[V-1];(k=I)!==null&&k!==void 0&&k.encrypted?(B.logger.log("Loading key for "+I.sn),this.state=y.State.KEY_LOADING,this.hls.trigger($.Events.KEY_LOADING,{frag:I})):I&&this.fragmentTracker.getState(I)===R.FragmentState.NOT_LOADED&&this.loadFragment(I,c,x)}},v.loadFragment=function(k,E,p){this.fragCurrent=k,d.prototype.loadFragment.call(this,k,E,p)},C(w,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),w}(y.default)},"./src/controller/subtitle-track-controller.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/events.ts"),B=D("./src/utils/texttrack-utils.ts"),M=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function W(L,C){for(var T=0;T<C.length;T++){var h=C[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function P(L,C,T){return C&&W(L.prototype,C),T&&W(L,T),L}function R(L,C){L.prototype=Object.create(C.prototype),L.prototype.constructor=L,y(L,C)}function y(L,C){return y=Object.setPrototypeOf||function(h,o){return h.__proto__=o,h},y(L,C)}var A=function(L){R(C,L);function C(h){var o;return o=L.call(this,h,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var T=C.prototype;return T.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},T.registerListeners=function(){var o=this.hls;o.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on($.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on($.Events.ERROR,this.onError,this)},T.unregisterListeners=function(){var o=this.hls;o.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off($.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off($.Events.ERROR,this.onError,this)},T.onMediaAttached=function(o,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)},T.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},T.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=O(this.media.textTracks);o.forEach(function(l){Object(B.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},T.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},T.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},T.onSubtitleTrackLoaded=function(o,l){var d=l.id,w=l.details,v=this.trackId,g=this.tracksInGroup[v];if(!g){this.warn("Invalid subtitle track id "+d);return}var k=g.details;g.details=l.details,this.log("subtitle track "+d+" loaded ["+w.startSN+"-"+w.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,l,k))},T.onLevelLoading=function(o,l){this.switchLevel(l.level)},T.onLevelSwitching=function(o,l){this.switchLevel(l.level)},T.switchLevel=function(o){var l=this.hls.levels[o];if(!(l!=null&&l.textGroupIds))return;var d=l.textGroupIds[l.urlId];if(this.groupId!==d){var w=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,v=this.tracks.filter(function(E){return!d||E.groupId===d});this.tracksInGroup=v;var g=this.findTrackId(w==null?void 0:w.name)||this.findTrackId();this.groupId=d;var k={subtitleTracks:v};this.log("Updating subtitle tracks, "+v.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger($.Events.SUBTITLE_TRACKS_UPDATED,k),g!==-1&&this.setSubtitleTrack(g,w)}},T.findTrackId=function(o){for(var l=this.tracksInGroup,d=0;d<l.length;d++){var w=l[d];if((!this.selectDefaultTrack||w.default)&&(!o||o===w.name))return w.id}return-1},T.onError=function(o,l){if(L.prototype.onError.call(this,o,l),l.fatal||!l.context)return;l.context.type===z.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},T.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var d=l.id,w=l.groupId,v=l.url;if(o)try{v=o.addDirectives(v)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger($.Events.SUBTITLE_TRACK_LOADING,{url:v,id:d,groupId:w,deliveryDirectives:o||null})}},T.toggleTrackModes=function(o){var l=this,d=this.media,w=this.subtitleDisplay,v=this.trackId;if(!d)return;var g=O(d.textTracks),k=g.filter(function(c){return c.groupId===l.groupId});if(o===-1)[].slice.call(g).forEach(function(c){c.mode="disabled"});else{var E=k[v];E&&(E.mode="disabled")}var p=k[o];p&&(p.mode=w?"showing":"hidden")},T.setSubtitleTrack=function(o,l){var d,w=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(d=w[o])!==null&&d!==void 0&&d.details)||o<-1||o>=w.length)return;this.clearTimer();var v=w[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,v){var g=v.id,k=v.groupId,E=k===void 0?"":k,p=v.name,c=v.type,u=v.url;this.hls.trigger($.Events.SUBTITLE_TRACK_SWITCH,{id:g,groupId:E,name:p,type:c,url:u});var a=this.switchParams(v.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger($.Events.SUBTITLE_TRACK_SWITCH,{id:o})},T.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,l=O(this.media.textTracks),d=0;d<l.length;d++)if(l[d].mode==="hidden")o=d;else if(l[d].mode==="showing"){o=d;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},P(C,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,l)}}]),C}(M.default);function O(L){for(var C=[],T=0;T<L.length;T++){var h=L[T];h.kind==="subtitles"&&h.label&&C.push(L[T])}return C}Z.default=A},"./src/controller/timeline-controller.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"TimelineController",function(){return O});var $=D("./src/polyfills/number.ts"),B=D("./src/events.ts"),M=D("./src/utils/cea-608-parser.ts"),z=D("./src/utils/output-filter.ts"),W=D("./src/utils/webvtt-parser.ts"),P=D("./src/utils/texttrack-utils.ts"),R=D("./src/utils/imsc1-ttml-parser.ts"),y=D("./src/types/loader.ts"),A=D("./src/utils/logger.ts"),O=function(){function h(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=T(),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 d=new z.default(this,"textTrack1"),w=new z.default(this,"textTrack2"),v=new z.default(this,"textTrack3"),g=new z.default(this,"textTrack4");this.cea608Parser1=new M.default(1,d,w),this.cea608Parser2=new M.default(3,v,g)}l.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(B.Events.FRAG_LOADING,this.onFragLoading,this),l.on(B.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(B.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(B.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(B.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(B.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=h.prototype;return o.destroy=function(){var d=this.hls;d.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(B.Events.FRAG_LOADING,this.onFragLoading,this),d.off(B.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(B.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(B.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(B.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(B.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(d,w,v,g,k){for(var E=!1,p=k.length;p--;){var c=k[p],u=C(c[0],c[1],w,v);if(u>=0&&(c[0]=Math.min(c[0],w),c[1]=Math.max(c[1],v),E=!0,u/(v-w)>.5))return}if(E||k.push([w,v]),this.config.renderTextTracksNatively){var a=this.captionsTracks[d];this.Cues.newCue(a,w,v,g)}else{var b=this.Cues.newCue(null,w,v,g);this.hls.trigger(B.Events.CUES_PARSED,{type:"captions",cues:b,track:d})}},o.onInitPtsFound=function(d,w){var v=this,g=w.frag,k=w.id,E=w.initPTS,p=w.timescale,c=this.unparsedVttFrags;k==="main"&&(this.initPTS[g.cc]=E,this.timescale[g.cc]=p),c.length&&(this.unparsedVttFrags=[],c.forEach(function(u){v.onFragLoaded(B.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(d){var w=this.media;if(w)for(var v=0;v<w.textTracks.length;v++){var g=w.textTracks[v];if(g[d])return g}return null},o.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},o.createNativeTrack=function(d){if(this.captionsTracks[d])return;var w=this.captionsProperties,v=this.captionsTracks,g=this.media,k=w[d],E=k.label,p=k.languageCode,c=this.getExistingTrack(d);if(c)v[d]=c,Object(P.clearCurrentCues)(v[d]),Object(P.sendAddTrackEvent)(v[d],g);else{var u=this.createTextTrack("captions",E,p);u&&(u[d]=!0,v[d]=u)}},o.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var w=this.captionsProperties[d];if(!w)return;var v=w.label,g={_id:d,label:v,kind:"captions",default:w.media?!!w.media.default:!1,closedCaptions:w.media};this.nonNativeCaptionsTracks[d]=g,this.hls.trigger(B.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[g]})},o.createTextTrack=function(d,w,v){var g=this.media;return g?g.addTextTrack(d,w,v):void 0},o.onMediaAttaching=function(d,w){this.media=w.media,this._cleanTracks()},o.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(w){Object(P.clearCurrentCues)(d[w]),delete d[w]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=T(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var d=this.media;if(!d)return;var w=d.textTracks;if(w)for(var v=0;v<w.length;v++)Object(P.clearCurrentCues)(w[v])},o.onSubtitleTracksUpdated=function(d,w){var v=this;this.textTracks=[];var g=w.subtitleTracks||[],k=g.some(function(u){return u.textCodec===R.IMSC1_CODEC});if(this.config.enableWebVTT||k&&this.config.enableIMSC1){var E=this.tracks&&g&&this.tracks.length===g.length;if(this.tracks=g||[],this.config.renderTextTracksNatively){var p=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,a){var b;if(a<p.length){for(var m=null,x=0;x<p.length;x++)if(L(p[x],u)){m=p[x];break}m&&(b=m)}b?Object(P.clearCurrentCues)(b):(b=v.createTextTrack("subtitles",u.name,u.lang),b&&(b.mode="disabled")),b&&(b.groupId=u.groupId,v.textTracks.push(b))})}else if(!E&&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(B.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(d,w){var v=this;this.config.enableCEA708Captions&&w.captions&&w.captions.forEach(function(g){var k=/(?:CC|SERVICE)([1-4])/.exec(g.instreamId);if(!k)return;var E="textTrack"+k[1],p=v.captionsProperties[E];if(!p)return;p.label=g.name,g.lang&&(p.languageCode=g.lang),p.media=g})},o.onFragLoading=function(d,w){var v=this.cea608Parser1,g=this.cea608Parser2,k=this.lastSn,E=this.lastPartIndex;if(!this.enabled||!(v&&g))return;if(w.frag.type===y.PlaylistLevelType.MAIN){var p,c,u=w.frag.sn,a=(p=w==null||((c=w.part)===null||c===void 0)?void 0:c.index)!=null?p:-1;u===k+1||u===k&&a===E+1||(v.reset(),g.reset()),this.lastSn=u,this.lastPartIndex=a}},o.onFragLoaded=function(d,w){var v=w.frag,g=w.payload,k=this.initPTS,E=this.unparsedVttFrags;if(v.type===y.PlaylistLevelType.SUBTITLE)if(g.byteLength){if(!Object($.isFiniteNumber)(k[v.cc])){E.push(w),k.length&&this.hls.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:new Error("Missing initial subtitle PTS")});return}var p=v.decryptdata;if(p==null||p.key==null||p.method!=="AES-128"){var c=this.tracks[v.level],u=this.vttCCs;u[v.cc]||(u[v.cc]={start:v.start,prevCC:this.prevCC,new:!0},this.prevCC=v.cc),c&&c.textCodec===R.IMSC1_CODEC?this._parseIMSC1(v,g):this._parseVTTs(v,g,u)}}else this.hls.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(d,w){var v=this,g=this.hls;Object(R.parseIMSC1)(w,this.initPTS[d.cc],this.timescale[d.cc],function(k){v._appendCues(k,d.level),g.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(k){A.logger.log("Failed to parse IMSC1: "+k),g.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:k})})},o._parseVTTs=function(d,w,v){var g=this,k=this.hls;Object(W.parseWebVTT)(w,this.initPTS[d.cc],this.timescale[d.cc],v,d.cc,d.start,function(E){g._appendCues(E,d.level),k.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(E){g._fallbackToIMSC1(d,w),A.logger.log("Failed to parse VTT cue: "+E),k.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:E})})},o._fallbackToIMSC1=function(d,w){var v=this,g=this.tracks[d.level];g.textCodec||Object(R.parseIMSC1)(w,this.initPTS[d.cc],this.timescale[d.cc],function(){g.textCodec=R.IMSC1_CODEC,v._parseIMSC1(d,w)},function(){g.textCodec="wvtt"})},o._appendCues=function(d,w){var v=this.hls;if(this.config.renderTextTracksNatively){var g=this.textTracks[w];if(g.mode==="disabled")return;d.forEach(function(p){return Object(P.addCueToTrack)(g,p)})}else{var k=this.tracks[w],E=k.default?"default":"subtitles"+w;v.trigger(B.Events.CUES_PARSED,{type:"subtitles",cues:d,track:E})}},o.onFragDecrypted=function(d,w){var v=w.frag;if(v.type===y.PlaylistLevelType.SUBTITLE){if(!Object($.isFiniteNumber)(this.initPTS[v.cc])){this.unparsedVttFrags.push(w);return}this.onFragLoaded(B.Events.FRAG_LOADED,w)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(d,w){var v=this.cea608Parser1,g=this.cea608Parser2;if(!this.enabled||!(v&&g))return;for(var k=0;k<w.samples.length;k++){var E=w.samples[k].bytes;if(E){var p=this.extractCea608Data(E);v.addData(w.samples[k].pts,p[0]),g.addData(w.samples[k].pts,p[1])}}},o.onBufferFlushing=function(d,w){var v=w.startOffset,g=w.endOffset,k=w.endOffsetSubtitles,E=w.type,p=this.media;if(!p||p.currentTime<g)return;if(!E||E==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(P.removeCuesInRange)(c[a],v,g)})}if(this.config.renderTextTracksNatively&&(v===0&&k!==void 0)){var u=this.textTracks;Object.keys(u).forEach(function(a){return Object(P.removeCuesInRange)(u[a],v,k)})}},o.extractCea608Data=function(d){for(var w=d[0]&31,v=2,g=[[],[]],k=0;k<w;k++){var E=d[v++],p=127&d[v++],c=127&d[v++],u=(4&E)!==0,a=3&E;if(p===0&&c===0)continue;u&&((a===0||a===1)&&(g[a].push(p),g[a].push(c)))}return g},h}();function L(h,o){return h&&h.label===o.name&&!(h.textTrack1||h.textTrack2)}function C(h,o,l,d){return Math.min(o,d)-Math.max(h,l)}function T(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return $});var $=function(){function B(z,W){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=W}var M=B.prototype;return M.decrypt=function(W,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,W)},B}()},"./src/crypt/aes-decryptor.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"removePadding",function(){return B}),D.d(Z,"default",function(){return M});var $=D("./src/utils/typed-array.ts");function B(z){var W=z.byteLength,P=W&&new DataView(z.buffer).getUint8(W-1);return P?Object($.sliceUint8)(z,0,W-P):z}var M=function(){function z(){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 W=z.prototype;return W.uint8ArrayToUint32Array_=function(R){for(var y=new DataView(R),A=new Uint32Array(4),O=0;O<4;O++)A[O]=y.getUint32(O*4);return A},W.initTable=function(){var R=this.sBox,y=this.invSBox,A=this.subMix,O=A[0],L=A[1],C=A[2],T=A[3],h=this.invSubMix,o=h[0],l=h[1],d=h[2],w=h[3],v=new Uint32Array(256),g=0,k=0,E=0;for(E=0;E<256;E++)E<128?v[E]=E<<1:v[E]=E<<1^283;for(E=0;E<256;E++){var p=k^k<<1^k<<2^k<<3^k<<4;p=p>>>8^p&255^99,R[g]=p,y[p]=g;var c=v[g],u=v[c],a=v[u],b=v[p]*257^p*16843008;O[g]=b<<24|b>>>8,L[g]=b<<16|b>>>16,C[g]=b<<8|b>>>24,T[g]=b,b=a*16843009^u*65537^c*257^g*16843008,o[p]=b<<24|b>>>8,l[p]=b<<16|b>>>16,d[p]=b<<8|b>>>24,w[p]=b,g?(g=c^v[v[v[a^c]]],k^=v[v[k]]):g=k=1}},W.expandKey=function(R){for(var y=this.uint8ArrayToUint32Array_(R),A=!0,O=0;O<y.length&&A;)A=y[O]===this.key[O],O++;if(A)return;this.key=y;var L=this.keySize=y.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var C=this.ksRows=(L+6+1)*4,T,h,o=this.keySchedule=new Uint32Array(C),l=this.invKeySchedule=new Uint32Array(C),d=this.sBox,w=this.rcon,v=this.invSubMix,g=v[0],k=v[1],E=v[2],p=v[3],c,u;for(T=0;T<C;T++){if(T<L){c=o[T]=y[T];continue}u=c,T%L===0?(u=u<<8|u>>>24,u=d[u>>>24]<<24|d[u>>>16&255]<<16|d[u>>>8&255]<<8|d[u&255],u^=w[T/L|0]<<24):L>6&&T%L===4&&(u=d[u>>>24]<<24|d[u>>>16&255]<<16|d[u>>>8&255]<<8|d[u&255]),o[T]=c=(o[T-L]^u)>>>0}for(h=0;h<C;h++)T=C-h,h&3?u=o[T]:u=o[T-4],h<4||T<=4?l[h]=u:l[h]=g[d[u>>>24]]^k[d[u>>>16&255]]^E[d[u>>>8&255]]^p[d[u&255]],l[h]=l[h]>>>0},W.networkToHostOrderSwap=function(R){return R<<24|(R&65280)<<8|(R&16711680)>>8|R>>>24},W.decrypt=function(R,y,A){for(var O=this.keySize+6,L=this.invKeySchedule,C=this.invSBox,T=this.invSubMix,h=T[0],o=T[1],l=T[2],d=T[3],w=this.uint8ArrayToUint32Array_(A),v=w[0],g=w[1],k=w[2],E=w[3],p=new Int32Array(R),c=new Int32Array(p.length),u,a,b,m,x,F,U,K,V,_,I,Y,ee,ae,de=this.networkToHostOrderSwap;y<p.length;){for(V=de(p[y]),_=de(p[y+1]),I=de(p[y+2]),Y=de(p[y+3]),x=V^L[0],F=Y^L[1],U=I^L[2],K=_^L[3],ee=4,ae=1;ae<O;ae++)u=h[x>>>24]^o[F>>16&255]^l[U>>8&255]^d[K&255]^L[ee],a=h[F>>>24]^o[U>>16&255]^l[K>>8&255]^d[x&255]^L[ee+1],b=h[U>>>24]^o[K>>16&255]^l[x>>8&255]^d[F&255]^L[ee+2],m=h[K>>>24]^o[x>>16&255]^l[F>>8&255]^d[U&255]^L[ee+3],x=u,F=a,U=b,K=m,ee=ee+4;u=C[x>>>24]<<24^C[F>>16&255]<<16^C[U>>8&255]<<8^C[K&255]^L[ee],a=C[F>>>24]<<24^C[U>>16&255]<<16^C[K>>8&255]<<8^C[x&255]^L[ee+1],b=C[U>>>24]<<24^C[K>>16&255]<<16^C[x>>8&255]<<8^C[F&255]^L[ee+2],m=C[K>>>24]<<24^C[x>>16&255]<<16^C[F>>8&255]<<8^C[U&255]^L[ee+3],c[y]=de(u^v),c[y+1]=de(m^g),c[y+2]=de(b^k),c[y+3]=de(a^E),v=V,g=_,k=I,E=Y,y=y+4}return c.buffer},z}()},"./src/crypt/decrypter.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return y});var $=D("./src/crypt/aes-crypto.ts"),B=D("./src/crypt/fast-aes-key.ts"),M=D("./src/crypt/aes-decryptor.ts"),z=D("./src/utils/logger.ts"),W=D("./src/utils/mp4-tools.ts"),P=D("./src/utils/typed-array.ts"),R=16,y=function(){function A(L,C,T){var h=T===void 0?{}:T,o=h.removePKCS7Padding,l=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=C,this.removePKCS7Padding=l,l)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(w){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var O=A.prototype;return O.destroy=function(){this.observer=null},O.isSync=function(){return this.config.enableSoftwareAES},O.flush=function(){var C=this.currentResult;if(!C){this.reset();return}var T=new Uint8Array(C);return this.reset(),this.removePKCS7Padding?Object(M.removePadding)(T):T},O.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},O.decrypt=function(C,T,h,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(C),T,h);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(C),T,h).then(o)},O.softwareDecrypt=function(C,T,h){var o=this.currentIV,l=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(C=Object(W.appendUint8Array)(d,C),this.remainderData=null);var w=this.getValidChunk(C);if(!w.length)return null;o&&(h=o);var v=this.softwareDecrypter;v||(v=this.softwareDecrypter=new M.default),v.expandKey(T);var g=l;return this.currentResult=v.decrypt(w.buffer,0,h),this.currentIV=Object(P.sliceUint8)(w,-16).buffer,g||null},O.webCryptoDecrypt=function(C,T,h){var o=this,l=this.subtle;return(this.key!==T||!this.fastAesKey)&&(this.key=T,this.fastAesKey=new B.default(l,T)),this.fastAesKey.expandKey().then(function(d){if(!l)return Promise.reject(new Error("web crypto not initialized"));var w=new $.default(l,h);return w.decrypt(C.buffer,d)}).catch(function(d){return o.onWebCryptoError(d,C,T,h)})},O.onWebCryptoError=function(C,T,h,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",C),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(T,h,o)},O.getValidChunk=function(C){var T=C,h=C.length-C.length%R;return h!==C.length&&(T=Object(P.sliceUint8)(C,0,h),this.remainderData=Object(P.sliceUint8)(C,h)),T},O.logOnce=function(C){if(!this.logEnabled)return;z.logger.log("[decrypter.ts]: "+C),this.logEnabled=!1},A}()},"./src/crypt/fast-aes-key.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return $});var $=function(){function B(z,W){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=W}var M=B.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},B}()},"./src/demux/aacdemuxer.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/demux/base-audio-demuxer.ts"),B=D("./src/demux/adts.ts"),M=D("./src/utils/logger.ts"),z=D("./src/demux/id3.ts");function W(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,P(y,A)}function P(y,A){return P=Object.setPrototypeOf||function(L,C){return L.__proto__=C,L},P(y,A)}var R=function(y){W(A,y);function A(L,C){var T;return T=y.call(this)||this,T.observer=void 0,T.config=void 0,T.observer=L,T.config=C,T}var O=A.prototype;return O.resetInitSegment=function(C,T,h){y.prototype.resetInitSegment.call(this,C,T,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:C,duration:h,inputTimeScale:9e4,dropped:0}},A.probe=function(C){if(!C)return!1;for(var T=z.getID3Data(C,0)||[],h=T.length,o=C.length;h<o;h++)if(B.probe(C,h))return M.logger.log("ADTS sync word found !"),!0;return!1},O.canParse=function(C,T){return B.canParse(C,T)},O.appendFrame=function(C,T,h){B.initTrackConfig(C,this.observer,T,h,C.manifestCodec);var o=B.appendFrame(C,T,h,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},A}($.default);R.minProbeByteLength=9,Z.default=R},"./src/demux/adts.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"getAudioConfig",function(){return z}),D.d(Z,"isHeaderPattern",function(){return W}),D.d(Z,"getHeaderLength",function(){return P}),D.d(Z,"getFullFrameLength",function(){return R}),D.d(Z,"canGetFrameLength",function(){return y}),D.d(Z,"isHeader",function(){return A}),D.d(Z,"canParse",function(){return O}),D.d(Z,"probe",function(){return L}),D.d(Z,"initTrackConfig",function(){return C}),D.d(Z,"getFrameDuration",function(){return T}),D.d(Z,"parseFrameHeader",function(){return h}),D.d(Z,"appendFrame",function(){return o});var $=D("./src/utils/logger.ts"),B=D("./src/errors.ts"),M=D("./src/events.ts");function z(l,d,w,v){var g,k,E,p,c=navigator.userAgent.toLowerCase(),u=v,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];g=((d[w+2]&192)>>>6)+1;var b=(d[w+2]&60)>>>2;if(b>a.length-1){l.trigger(M.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b});return}return E=(d[w+2]&1)<<2,E|=(d[w+3]&192)>>>6,$.logger.log("manifest codec:"+v+", ADTS type:"+g+", samplingIndex:"+b),/firefox/i.test(c)?b>=6?(g=5,p=new Array(4),k=b-3):(g=2,p=new Array(2),k=b):c.indexOf("android")!==-1?(g=2,p=new Array(2),k=b):(g=5,p=new Array(4),v&&(v.indexOf("mp4a.40.29")!==-1||v.indexOf("mp4a.40.5")!==-1)||!v&&b>=6?k=b-3:((v&&v.indexOf("mp4a.40.2")!==-1&&(b>=6&&E===1||/vivaldi/i.test(c))||!v&&E===1)&&(g=2,p=new Array(2)),k=b)),p[0]=g<<3,p[0]|=(b&14)>>1,p[1]|=(b&1)<<7,p[1]|=E<<3,g===5&&(p[1]|=(k&14)>>1,p[2]=(k&1)<<7,p[2]|=2<<2,p[3]=0),{config:p,samplerate:a[b],channelCount:E,codec:"mp4a.40."+g,manifestCodec:u}}function W(l,d){return l[d]===255&&(l[d+1]&246)===240}function P(l,d){return l[d+1]&1?7:9}function R(l,d){return(l[d+3]&3)<<11|l[d+4]<<3|(l[d+5]&224)>>>5}function y(l,d){return d+5<l.length}function A(l,d){return d+1<l.length&&W(l,d)}function O(l,d){return y(l,d)&&W(l,d)&&R(l,d)<=l.length-d}function L(l,d){if(A(l,d)){var w=P(l,d);if(d+w>=l.length)return!1;var v=R(l,d);if(v<=w)return!1;var g=d+v;return g===l.length||A(l,g)}return!1}function C(l,d,w,v,g){if(!l.samplerate){var k=z(d,w,v,g);if(!k)return;l.config=k.config,l.samplerate=k.samplerate,l.channelCount=k.channelCount,l.codec=k.codec,l.manifestCodec=k.manifestCodec,$.logger.log("parsed codec:"+l.codec+", rate:"+k.samplerate+", channels:"+k.channelCount)}}function T(l){return 1024*9e4/l}function h(l,d,w,v,g){var k=P(l,d),E=R(l,d);if(E-=k,E>0){var p=w+v*g;return{headerLength:k,frameLength:E,stamp:p}}}function o(l,d,w,v,g){var k=T(l.samplerate),E=h(d,w,v,g,k);if(E){var p=E.frameLength,c=E.headerLength,u=E.stamp,a=c+p,b=Math.max(0,w+a-d.length),m;b?(m=new Uint8Array(a-c),m.set(d.subarray(w+c,d.length),0)):m=d.subarray(w+c,w+a);var x={unit:m,pts:u};return b||l.samples.push(x),{sample:x,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"initPTSFn",function(){return R});var $=D("./src/polyfills/number.ts"),B=D("./src/demux/id3.ts"),M=D("./src/demux/dummy-demuxed-track.ts"),z=D("./src/utils/mp4-tools.ts"),W=D("./src/utils/typed-array.ts"),P=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=y.prototype;return A.resetInitSegment=function(L,C,T){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(L,C){return!1},A.appendFrame=function(L,C,T){},A.demux=function(L,C){this.cachedData&&(L=Object(z.appendUint8Array)(this.cachedData,L),this.cachedData=null);var T=B.getID3Data(L,0),h=T?T.length:0,o,l,d=this._audioTrack,w=this._id3Track,v=T?B.getTimeStamp(T):void 0,g=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=R(v,C)),T&&T.length>0&&w.samples.push({pts:this.initPTS,dts:this.initPTS,data:T}),l=this.initPTS;h<g;){if(this.canParse(L,h)){var k=this.appendFrame(d,L,h);k?(this.frameIndex++,l=k.sample.pts,h+=k.length,o=h):h=g}else B.canParse(L,h)?(T=B.getID3Data(L,h),w.samples.push({pts:l,dts:l,data:T}),h+=T.length,o=h):h++;if(h===g&&o!==g){var E=Object(W.sliceUint8)(L,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,E):this.cachedData=E}}return{audioTrack:d,avcTrack:Object(M.dummyTrack)(),id3Track:w,textTrack:Object(M.dummyTrack)()}},A.demuxSampleAes=function(L,C,T){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(L){var C=this.cachedData;return C&&(this.cachedData=null,this.demux(C,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},A.destroy=function(){},y}(),R=function(A,O){return Object($.isFiniteNumber)(A)?A*90:O*9e4};Z.default=P},"./src/demux/chunk-cache.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return $});var $=function(){function M(){this.chunks=[],this.dataLength=0}var z=M.prototype;return z.push=function(P){this.chunks.push(P),this.dataLength+=P.length},z.flush=function(){var P=this.chunks,R=this.dataLength,y;if(P.length)P.length===1?y=P[0]:y=B(P,R);else return new Uint8Array(0);return this.reset(),y},z.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function B(M,z){for(var W=new Uint8Array(z),P=0,R=0;R<M.length;R++){var y=M[R];W.set(y,P),P+=y.length}return W}},"./src/demux/dummy-demuxed-track.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"dummyTrack",function(){return $});function $(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/utils/logger.ts"),B=function(){function M(W){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=W,this.bytesAvailable=W.byteLength,this.word=0,this.bitsAvailable=0}var z=M.prototype;return z.loadWord=function(){var P=this.data,R=this.bytesAvailable,y=P.byteLength-R,A=new Uint8Array(4),O=Math.min(4,R);if(O===0)throw new Error("no bytes available");A.set(P.subarray(y,y+O)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=O*8,this.bytesAvailable-=O},z.skipBits=function(P){var R;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,R=P>>3,P-=R>>3,this.bytesAvailable-=R,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},z.readBits=function(P){var R=Math.min(this.bitsAvailable,P),y=this.word>>>32-R;return P>32&&$.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=R,this.bitsAvailable>0?this.word<<=R:this.bytesAvailable>0&&this.loadWord(),R=P-R,R>0&&this.bitsAvailable?y<<R|this.readBits(R):y},z.skipLZ=function(){var P;for(P=0;P<this.bitsAvailable;++P)if((this.word&2147483648>>>P)!==0)return this.word<<=P,this.bitsAvailable-=P,P;return this.loadWord(),P+this.skipLZ()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},z.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},z.readBoolean=function(){return this.readBits(1)===1},z.readUByte=function(){return this.readBits(8)},z.readUShort=function(){return this.readBits(16)},z.readUInt=function(){return this.readBits(32)},z.skipScalingList=function(P){for(var R=8,y=8,A,O=0;O<P;O++)y!==0&&(A=this.readEG(),y=(R+A+256)%256),R=y===0?R:y},z.readSPS=function(){var P=0,R=0,y=0,A=0,O,L,C,T=this.readUByte.bind(this),h=this.readBits.bind(this),o=this.readUEG.bind(this),l=this.readBoolean.bind(this),d=this.skipBits.bind(this),w=this.skipEG.bind(this),v=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);T();var k=T();if(h(5),d(3),T(),v(),k===100||k===110||k===122||k===244||k===44||k===83||k===86||k===118||k===128){var E=o();if(E===3&&d(1),v(),v(),d(1),l())for(L=E!==3?8:12,C=0;C<L;C++)l()&&(C<6?g(16):g(64))}v();var p=o();if(p===0)o();else if(p===1)for(d(1),w(),w(),O=o(),C=0;C<O;C++)w();v(),d(1);var c=o(),u=o(),a=h(1);a===0&&d(1),d(1),l()&&(P=o(),R=o(),y=o(),A=o());var b=[1,1];if(l()&&l()){var m=T();switch(m){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[T()<<8|T(),T()<<8|T()];break}}}return{width:Math.ceil((c+1)*16-P*2-R*2),height:(2-a)*(u+1)*16-(a?2:4)*(y+A),pixelRatio:b}},z.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},M}();Z.default=B},"./src/demux/id3.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"isHeader",function(){return $}),D.d(Z,"isFooter",function(){return B}),D.d(Z,"getID3Data",function(){return M}),D.d(Z,"canParse",function(){return W}),D.d(Z,"getTimeStamp",function(){return P}),D.d(Z,"isTimeStampFrame",function(){return R}),D.d(Z,"getID3Frames",function(){return A}),D.d(Z,"decodeFrame",function(){return O}),D.d(Z,"utf8ArrayToStr",function(){return o}),D.d(Z,"testables",function(){return l});var $=function(g,k){return k+10<=g.length&&(g[k]===73&&g[k+1]===68&&g[k+2]===51&&(g[k+3]<255&&g[k+4]<255&&(g[k+6]<128&&g[k+7]<128&&g[k+8]<128&&g[k+9]<128)))},B=function(g,k){return k+10<=g.length&&(g[k]===51&&g[k+1]===68&&g[k+2]===73&&(g[k+3]<255&&g[k+4]<255&&(g[k+6]<128&&g[k+7]<128&&g[k+8]<128&&g[k+9]<128)))},M=function(g,k){for(var E=k,p=0;$(g,k);){p+=10;var c=z(g,k+6);p+=c,B(g,k+10)&&(p+=10),k+=p}return p>0?g.subarray(E,E+p):void 0},z=function(g,k){var E=0;return E=(g[k]&127)<<21,E|=(g[k+1]&127)<<14,E|=(g[k+2]&127)<<7,E|=g[k+3]&127,E},W=function(g,k){return $(g,k)&&z(g,k+6)+10<=g.length-k},P=function(g){for(var k=A(g),E=0;E<k.length;E++){var p=k[E];if(R(p))return h(p)}return},R=function(g){return g&&g.key==="PRIV"&&g.info==="com.apple.streaming.transportStreamTimestamp"},y=function(g){var k=String.fromCharCode(g[0],g[1],g[2],g[3]),E=z(g,4),p=10;return{type:k,size:E,data:g.subarray(p,p+E)}},A=function(g){for(var k=0,E=[];$(g,k);){var p=z(g,k+6);k+=10;for(var c=k+p;k+8<c;){var u=y(g.subarray(k)),a=O(u);a&&E.push(a),k+=u.size+10}B(g,k)&&(k+=10)}return E},O=function(g){return g.type==="PRIV"?L(g):g.type[0]==="W"?T(g):C(g)},L=function(g){if(g.size<2)return;var k=o(g.data,!0),E=new Uint8Array(g.data.subarray(k.length+1));return{key:g.type,info:k,data:E.buffer}},C=function(g){if(g.size<2)return;if(g.type==="TXXX"){var k=1,E=o(g.data.subarray(k),!0);k+=E.length+1;var p=o(g.data.subarray(k));return{key:g.type,info:E,data:p}}var c=o(g.data.subarray(1));return{key:g.type,data:c}},T=function(g){if(g.type==="WXXX"){if(g.size<2)return;var k=1,E=o(g.data.subarray(k),!0);k+=E.length+1;var p=o(g.data.subarray(k));return{key:g.type,info:E,data:p}}var c=o(g.data);return{key:g.type,data:c}},h=function(g){if(g.data.byteLength===8){var k=new Uint8Array(g.data),E=k[3]&1,p=(k[4]<<23)+(k[5]<<15)+(k[6]<<7)+k[7];return p/=45,E&&(p+=4772185884e-2),Math.round(p)}return},o=function(g,k){k===void 0&&(k=!1);var E=w();if(E){var p=E.decode(g);if(k){var c=p.indexOf("\0");return c!==-1?p.substring(0,c):p}return p.replace(/\0/g,"")}for(var u=g.length,a,b,m,x="",F=0;F<u;){if(a=g[F++],a===0&&k)return x;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(a);break;case 12:case 13:b=g[F++],x+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=g[F++],m=g[F++],x+=String.fromCharCode((a&15)<<12|(b&63)<<6|(m&63)<<0);break;default:}}return x},l={decodeTextFrame:C},d;function w(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/demux/base-audio-demuxer.ts"),B=D("./src/demux/id3.ts"),M=D("./src/utils/logger.ts"),z=D("./src/demux/mpegaudio.ts");function W(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,P(y,A)}function P(y,A){return P=Object.setPrototypeOf||function(L,C){return L.__proto__=C,L},P(y,A)}var R=function(y){W(A,y);function A(){return y.apply(this,arguments)||this}var O=A.prototype;return O.resetInitSegment=function(C,T,h){y.prototype.resetInitSegment.call(this,C,T,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:C,duration:h,inputTimeScale:9e4,dropped:0}},A.probe=function(C){if(!C)return!1;for(var T=B.getID3Data(C,0)||[],h=T.length,o=C.length;h<o;h++)if(z.probe(C,h))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},O.canParse=function(C,T){return z.canParse(C,T)},O.appendFrame=function(C,T,h){return this.initPTS===null?void 0:z.appendFrame(C,T,h,this.initPTS,this.frameIndex)},A}($.default);R.minProbeByteLength=4,Z.default=R},"./src/demux/mp4demuxer.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/utils/mp4-tools.ts"),B=D("./src/demux/dummy-demuxed-track.ts"),M=function(){function z(P,R){this.remainderData=null,this.config=void 0,this.config=R}var W=z.prototype;return W.resetTimeStamp=function(){},W.resetInitSegment=function(){},W.resetContiguity=function(){},z.probe=function(R){return Object($.findBox)({data:R,start:0,end:Math.min(R.length,16384)},["moof"]).length>0},W.demux=function(R){var y=R,A=Object(B.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object($.appendUint8Array)(this.remainderData,R));var O=Object($.segmentValidRange)(y);this.remainderData=O.remainder,A.samples=O.valid||new Uint8Array}else A.samples=y;return{audioTrack:Object(B.dummyTrack)(),avcTrack:A,id3Track:Object(B.dummyTrack)(),textTrack:Object(B.dummyTrack)()}},W.flush=function(){var R=Object(B.dummyTrack)();return R.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(B.dummyTrack)(),avcTrack:R,id3Track:Object(B.dummyTrack)(),textTrack:Object(B.dummyTrack)()}},W.demuxSampleAes=function(R,y,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},W.destroy=function(){},z}();M.minProbeByteLength=1024,Z.default=M},"./src/demux/mpegaudio.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"appendFrame",function(){return P}),D.d(Z,"parseHeader",function(){return R}),D.d(Z,"isHeaderPattern",function(){return y}),D.d(Z,"isHeader",function(){return A}),D.d(Z,"canParse",function(){return O}),D.d(Z,"probe",function(){return L});var $=null,B=[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],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],z=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],W=[0,1,1,4];function P(C,T,h,o,l){if(h+24>T.length)return;var d=R(T,h);if(d&&h+d.frameLength<=T.length){var w=d.samplesPerFrame*9e4/d.sampleRate,v=o+l*w,g={unit:T.subarray(h,h+d.frameLength),pts:v,dts:v};return C.config=[],C.channelCount=d.channelCount,C.samplerate=d.sampleRate,C.samples.push(g),{sample:g,length:d.frameLength,missing:0}}}function R(C,T){var h=C[T+1]>>3&3,o=C[T+1]>>1&3,l=C[T+2]>>4&15,d=C[T+2]>>2&3;if(h!==1&&l!==0&&l!==15&&d!==3){var w=C[T+2]>>1&1,v=C[T+3]>>6,g=h===3?3-o:o===3?3:4,k=B[g*14+l-1]*1e3,E=h===3?0:h===2?1:2,p=M[E*3+d],c=v===3?1:2,u=z[h][o],a=W[o],b=u*8*a,m=Math.floor(u*k/p+w)*a;if($===null){var x=navigator.userAgent||"",F=x.match(/Chrome\/(\d+)/i);$=F?parseInt(F[1]):0}var U=!!$&&$<=87;return U&&o===2&&k>=224e3&&v===0&&(C[T+3]=C[T+3]|128),{sampleRate:p,channelCount:c,frameLength:m,samplesPerFrame:b}}}function y(C,T){return C[T]===255&&(C[T+1]&224)===224&&(C[T+1]&6)!==0}function A(C,T){return T+1<C.length&&y(C,T)}function O(C,T){var h=4;return y(C,T)&&h<=C.length-T}function L(C,T){if(T+1<C.length&&y(C,T)){var h=4,o=R(C,T),l=h;o!=null&&o.frameLength&&(l=o.frameLength);var d=T+l;return d===C.length||A(C,d)}return!1}},"./src/demux/sample-aes.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/crypt/decrypter.ts"),B=D("./src/demux/tsdemuxer.ts"),M=function(){function z(P,R,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new $.default(P,R,{removePKCS7Padding:!1})}var W=z.prototype;return W.decryptBuffer=function(R,y){this.decrypter.decrypt(R,this.keyData.key.buffer,this.keyData.iv.buffer,y)},W.decryptAacSample=function(R,y,A,O){var L=R[y].unit,C=L.subarray(16,L.length-L.length%16),T=C.buffer.slice(C.byteOffset,C.byteOffset+C.length),h=this;this.decryptBuffer(T,function(o){var l=new Uint8Array(o);L.set(l,16),O||h.decryptAacSamples(R,y+1,A)})},W.decryptAacSamples=function(R,y,A){for(;;y++){if(y>=R.length){A();return}if(R[y].unit.length<32)continue;var O=this.decrypter.isSync();if(this.decryptAacSample(R,y,A,O),!O)return}},W.getAvcEncryptedData=function(R){for(var y=Math.floor((R.length-48)/160)*16+16,A=new Int8Array(y),O=0,L=32;L<=R.length-16;L+=160,O+=16)A.set(R.subarray(L,L+16),O);return A},W.getAvcDecryptedUnit=function(R,y){for(var A=new Uint8Array(y),O=0,L=32;L<=R.length-16;L+=160,O+=16)R.set(A.subarray(O,O+16),L);return R},W.decryptAvcSample=function(R,y,A,O,L,C){var T=Object(B.discardEPB)(L.data),h=this.getAvcEncryptedData(T),o=this;this.decryptBuffer(h.buffer,function(l){L.data=o.getAvcDecryptedUnit(T,l),C||o.decryptAvcSamples(R,y,A+1,O)})},W.decryptAvcSamples=function(R,y,A,O){if(R instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,A=0){if(y>=R.length){O();return}for(var L=R[y].units;!(A>=L.length);A++){var C=L[A];if(C.data.length<=48||C.type!==1&&C.type!==5)continue;var T=this.decrypter.isSync();if(this.decryptAvcSample(R,y,A,O,C,T),!T)return}}},z}();Z.default=M},"./src/demux/transmuxer-interface.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var $=D("./node_modules/webworkify-webpack/index.js"),B=D.n($),M=D("./src/events.ts"),z=D("./src/demux/transmuxer.ts"),W=D("./src/utils/logger.ts"),P=D("./src/errors.ts"),R=D("./src/utils/mediasource-helper.ts"),y=D("./node_modules/eventemitter3/index.js"),A=D.n(y),O=Object(R.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function C(h,o,l,d){var w=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=h,this.id=o,this.onTransmuxComplete=l,this.onFlush=d;var v=h.config,g=function(u,a){a=a||{},a.frag=w.frag,a.id=w.id,h.trigger(u,a)};this.observer=new y.EventEmitter,this.observer.on(M.Events.FRAG_DECRYPTED,g),this.observer.on(M.Events.ERROR,g);var k={mp4:O.isTypeSupported("video/mp4"),mpeg:O.isTypeSupported("audio/mpeg"),mp3:O.isTypeSupported('audio/mp4; codecs="mp3"')},E=navigator.vendor;if(v.enableWorker&&typeof Worker!="undefined"){W.logger.log("demuxing in webworker");var p;try{p=this.worker=$("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(c){h.trigger(M.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},p.postMessage({cmd:"init",typeSupported:k,vendor:E,id:o,config:JSON.stringify(v)})}catch(c){W.logger.warn("Error in worker:",c),W.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new z.default(this.observer,k,v,E,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,k,v,E,o)}var T=C.prototype;return T.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var d=this.observer;d&&d.removeAllListeners(),this.observer=null},T.push=function(o,l,d,w,v,g,k,E,p,c){var u=this;p.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,m=g?g.start:v.start,x=v.decryptdata,F=this.frag,U=!(F&&v.cc===F.cc),K=!(F&&p.level===F.level),V=F?p.sn-F.sn:-1,_=this.part?p.part-this.part.index:1,I=!K&&(V===1||V===0&&_===1),Y=self.performance.now();(K||V||v.stats.parsing.start===0)&&(v.stats.parsing.start=Y),g&&(_||!I)&&(g.stats.parsing.start=Y);var ee=new z.TransmuxState(U,I,E,K,m);if(!I||U){W.logger.log("[transmuxer-interface, "+v.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
discontinuity: `+U+`
trackSwitch: `+K+`
contiguous: `+I+`
accurateTimeOffset: `+E+`
timeOffset: `+m);var ae=new z.TransmuxConfig(d,w,l,k,c);this.configureTransmuxer(ae)}if(this.frag=v,this.part=g,b)b.postMessage({cmd:"demux",data:o,decryptdata:x,chunkMeta:p,state:ee},o instanceof ArrayBuffer?[o]:[]);else if(a){var de=a.push(o,x,p,ee);Object(z.isPromise)(de)?de.then(function(De){u.handleTransmuxComplete(De)}):this.handleTransmuxComplete(de)}},T.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var d=this.transmuxer,w=this.worker;if(w)w.postMessage({cmd:"flush",chunkMeta:o});else if(d){var v=d.flush(o);Object(z.isPromise)(v)?v.then(function(g){l.handleFlushResult(g,o)}):this.handleFlushResult(v,o)}},T.handleFlushResult=function(o,l){var d=this;o.forEach(function(w){d.handleTransmuxComplete(w)}),this.onFlush(l)},T.onWorkerMessage=function(o){var l=o.data,d=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,d.trigger(l.event,l.data);break}}},T.configureTransmuxer=function(o){var l=this.worker,d=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):d&&d.configure(o)},T.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},C}()},"./src/demux/transmuxer-worker.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var $=D("./src/demux/transmuxer.ts"),B=D("./src/events.ts"),M=D("./src/utils/logger.ts"),z=D("./node_modules/eventemitter3/index.js"),W=D.n(z);function P(L){var C=new z.EventEmitter,T=function(o,l){L.postMessage({event:o,data:l})};C.on(B.Events.FRAG_DECRYPTED,T),C.on(B.Events.ERROR,T),L.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);L.transmuxer=new $.default(C,o.typeSupported,l,o.vendor,o.id),Object(M.enableLogs)(l.debug),T("init",null);break}case"configure":{L.transmuxer.configure(o.config);break}case"demux":{var d=L.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object($.isPromise)(d)?d.then(function(g){R(L,g)}):R(L,d);break}case"flush":{var w=o.chunkMeta,v=L.transmuxer.flush(w);Object($.isPromise)(v)?v.then(function(g){A(L,g,w)}):A(L,v,w);break}default:break}})}function R(L,C){if(O(C.remuxResult))return;var T=[],h=C.remuxResult,o=h.audio,l=h.video;o&&y(T,o),l&&y(T,l),L.postMessage({event:"transmuxComplete",data:C},T)}function y(L,C){C.data1&&L.push(C.data1.buffer),C.data2&&L.push(C.data2.buffer)}function A(L,C,T){C.forEach(function(h){R(L,h)}),L.postMessage({event:"flush",data:T})}function O(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l}),D.d(Z,"isPromise",function(){return v}),D.d(Z,"TransmuxConfig",function(){return g}),D.d(Z,"TransmuxState",function(){return k});var $=D("./src/events.ts"),B=D("./src/errors.ts"),M=D("./src/crypt/decrypter.ts"),z=D("./src/demux/aacdemuxer.ts"),W=D("./src/demux/mp4demuxer.ts"),P=D("./src/demux/tsdemuxer.ts"),R=D("./src/demux/mp3demuxer.ts"),y=D("./src/remux/mp4-remuxer.ts"),A=D("./src/remux/passthrough-remuxer.ts"),O=D("./src/demux/chunk-cache.ts"),L=D("./src/utils/mp4-tools.ts"),C=D("./src/utils/logger.ts"),T;try{T=self.performance.now.bind(self.performance)}catch(E){C.logger.debug("Unable to use Performance API on this environment"),T=self.Date.now}var h=[{demux:P.default,remux:y.default},{demux:W.default,remux:A.default},{demux:z.default,remux:y.default},{demux:R.default,remux:y.default}],o=1024;h.forEach(function(E){var p=E.demux;o=Math.max(o,p.minProbeByteLength)});var l=function(){function E(c,u,a,b,m){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 O.default,this.observer=c,this.typeSupported=u,this.config=a,this.vendor=b,this.id=m}var p=E.prototype;return p.configure=function(u){this.transmuxConfig=u,this.decrypter&&this.decrypter.reset()},p.push=function(u,a,b,m){var x=this,F=b.transmuxing;F.executeStart=T();var U=new Uint8Array(u),K=this.cache,V=this.config,_=this.currentTransmuxState,I=this.transmuxConfig;m&&(this.currentTransmuxState=m);var Y=d(U,a);if(Y&&Y.method==="AES-128"){var ee=this.getDecrypter();if(V.enableSoftwareAES){var ae=ee.softwareDecrypt(U,Y.key.buffer,Y.iv.buffer);if(!ae)return F.executeEnd=T(),w(b);U=new Uint8Array(ae)}else return this.decryptionPromise=ee.webCryptoDecrypt(U,Y.key.buffer,Y.iv.buffer).then(function(Re){var Ne=x.push(Re,null,b);return x.decryptionPromise=null,Ne}),this.decryptionPromise}var de=m||_,De=de.contiguous,Se=de.discontinuity,we=de.trackSwitch,Ce=de.accurateTimeOffset,Te=de.timeOffset,ge=I.audioCodec,le=I.videoCodec,te=I.defaultInitPts,ce=I.duration,ne=I.initSegmentData;if((Se||we)&&this.resetInitSegment(ne,ge,le,ce),Se&&this.resetInitialTimestamp(te),De||this.resetContiguity(),this.needsProbing(U,Se,we)){if(K.dataLength){var Le=K.flush();U=Object(L.appendUint8Array)(Le,U)}this.configureTransmuxer(U,I)}var Oe=this.transmux(U,Y,Te,Ce,b),Ee=this.currentTransmuxState;return Ee.contiguous=!0,Ee.discontinuity=!1,Ee.trackSwitch=!1,F.executeEnd=T(),Oe},p.flush=function(u){var a=this,b=u.transmuxing;b.executeStart=T();var m=this.decrypter,x=this.cache,F=this.currentTransmuxState,U=this.decryptionPromise;if(U)return U.then(function(){return a.flush(u)});var K=[],V=F.timeOffset;if(m){var _=m.flush();_&&K.push(this.push(_,null,u))}var I=x.dataLength;x.reset();var Y=this.demuxer,ee=this.remuxer;if(!Y||!ee)return I>=o&&this.observer.emit($.Events.ERROR,$.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),b.executeEnd=T(),[w(u)];var ae=Y.flush(V);return v(ae)?ae.then(function(de){return a.flushRemux(K,de,u),K}):(this.flushRemux(K,ae,u),K)},p.flushRemux=function(u,a,b){var m=a.audioTrack,x=a.avcTrack,F=a.id3Track,U=a.textTrack,K=this.currentTransmuxState,V=K.accurateTimeOffset,_=K.timeOffset;C.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var I=this.remuxer.remux(m,x,F,U,_,V,!0,this.id);u.push({remuxResult:I,chunkMeta:b}),b.transmuxing.executeEnd=T()},p.resetInitialTimestamp=function(u){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(u),b.resetTimeStamp(u)},p.resetContiguity=function(){var u=this.demuxer,a=this.remuxer;if(!u||!a)return;u.resetContiguity(),a.resetNextTimestamp()},p.resetInitSegment=function(u,a,b,m){var x=this.demuxer,F=this.remuxer;if(!x||!F)return;x.resetInitSegment(a,b,m),F.resetInitSegment(u,a,b)},p.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},p.transmux=function(u,a,b,m,x){var F;return a&&a.method==="SAMPLE-AES"?F=this.transmuxSampleAes(u,a,b,m,x):F=this.transmuxUnencrypted(u,b,m,x),F},p.transmuxUnencrypted=function(u,a,b,m){var x=this.demuxer.demux(u,a,!1,!this.config.progressive),F=x.audioTrack,U=x.avcTrack,K=x.id3Track,V=x.textTrack,_=this.remuxer.remux(F,U,K,V,a,b,!1,this.id);return{remuxResult:_,chunkMeta:m}},p.transmuxSampleAes=function(u,a,b,m,x){var F=this;return this.demuxer.demuxSampleAes(u,a,b).then(function(U){var K=F.remuxer.remux(U.audioTrack,U.avcTrack,U.id3Track,U.textTrack,b,m,!1,F.id);return{remuxResult:K,chunkMeta:x}})},p.configureTransmuxer=function(u,a){for(var b=this.config,m=this.observer,x=this.typeSupported,F=this.vendor,U=a.audioCodec,K=a.defaultInitPts,V=a.duration,_=a.initSegmentData,I=a.videoCodec,Y,ee=0,ae=h.length;ee<ae;ee++)if(h[ee].demux.probe(u)){Y=h[ee];break}Y||(C.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Y={demux:W.default,remux:A.default});var de=this.demuxer,De=this.remuxer,Se=Y.remux,we=Y.demux;(!De||!(De instanceof Se))&&(this.remuxer=new Se(m,b,x,F)),(!de||!(de instanceof we))&&(this.demuxer=new we(m,b,x),this.probe=we.probe),this.resetInitSegment(_,U,I,V),this.resetInitialTimestamp(K)},p.needsProbing=function(u,a,b){return!this.demuxer||!this.remuxer||a||b},p.getDecrypter=function(){var u=this.decrypter;return u||(u=this.decrypter=new M.default(this.observer,this.config)),u},E}();function d(E,p){var c=null;return E.byteLength>0&&p!=null&&p.key!=null&&p.iv!==null&&p.method!=null&&(c=p),c}var w=function(p){return{remuxResult:{},chunkMeta:p}};function v(E){return"then"in E&&E.then instanceof Function}var g=function(p,c,u,a,b){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=p,this.videoCodec=c,this.initSegmentData=u,this.duration=a,this.defaultInitPts=b},k=function(p,c,u,a,b){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=p,this.contiguous=c,this.accurateTimeOffset=u,this.trackSwitch=a,this.timeOffset=b}},"./src/demux/tsdemuxer.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"discardEPB",function(){return w});var $=D("./src/demux/adts.ts"),B=D("./src/demux/mpegaudio.ts"),M=D("./src/demux/exp-golomb.ts"),z=D("./src/demux/id3.ts"),W=D("./src/demux/sample-aes.ts"),P=D("./src/events.ts"),R=D("./src/utils/mp4-tools.ts"),y=D("./src/utils/logger.ts"),A=D("./src/errors.ts"),O={video:1,audio:2,id3:3,text:4},L=function(){function v(k,E,p){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=k,this.config=E,this.typeSupported=p}v.probe=function(E){var p=v.syncOffset(E);return p<0?!1:(p&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+p+", junk ahead ?"),!0)},v.syncOffset=function(E){for(var p=Math.min(1e3,E.length-3*188),c=0;c<p;){if(E[c]===71&&E[c+188]===71&&E[c+2*188]===71)return c;c++}return-1},v.createTrack=function(E,p){return{container:E==="video"||E==="audio"?"video/mp2t":void 0,type:E,id:O[E],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:E==="audio"?p:void 0}};var g=v.prototype;return g.resetInitSegment=function(E,p,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=v.createTrack("video",c),this._audioTrack=v.createTrack("audio",c),this._id3Track=v.createTrack("id3",c),this._txtTrack=v.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=E,this.videoCodec=p,this._duration=c},g.resetTimeStamp=function(){},g.resetContiguity=function(){var E=this._audioTrack,p=this._avcTrack,c=this._id3Track;E&&(E.pesData=null),p&&(p.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},g.demux=function(E,p,c,u){c===void 0&&(c=!1),u===void 0&&(u=!1),c||(this.sampleAes=null);var a,b=this._avcTrack,m=this._audioTrack,x=this._id3Track,F=b.pid,U=b.pesData,K=m.pid,V=x.pid,_=m.pesData,I=x.pesData,Y=!1,ee=this.pmtParsed,ae=this._pmtId,de=E.length;if(this.remainderData&&(E=Object(R.appendUint8Array)(this.remainderData,E),de=E.length,this.remainderData=null),de<188&&!u)return this.remainderData=E,{audioTrack:m,avcTrack:b,id3Track:x,textTrack:this._txtTrack};var De=Math.max(0,v.syncOffset(E));de-=(de+De)%188,de<E.byteLength&&!u&&(this.remainderData=new Uint8Array(E.buffer,de,E.buffer.byteLength-de));for(var Se=De;Se<de;Se+=188)if(E[Se]===71){var we=!!(E[Se+1]&64),Ce=((E[Se+1]&31)<<8)+E[Se+2],Te=(E[Se+3]&48)>>4,ge=void 0;if(Te>1){if(ge=Se+5+E[Se+4],ge===Se+188)continue}else ge=Se+4;switch(Ce){case F:we&&(U&&(a=o(U))&&this.parseAVCPES(a,!1),U={data:[],size:0}),U&&(U.data.push(E.subarray(ge,Se+188)),U.size+=Se+188-ge);break;case K:we&&(_&&(a=o(_))&&(m.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),_={data:[],size:0}),_&&(_.data.push(E.subarray(ge,Se+188)),_.size+=Se+188-ge);break;case V:we&&(I&&(a=o(I))&&this.parseID3PES(a),I={data:[],size:0}),I&&(I.data.push(E.subarray(ge,Se+188)),I.size+=Se+188-ge);break;case 0:we&&(ge+=E[ge]+1),ae=this._pmtId=T(E,ge);break;case ae:{we&&(ge+=E[ge]+1);var le=h(E,ge,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);F=le.avc,F>0&&(b.pid=F),K=le.audio,K>0&&(m.pid=K,m.isAAC=le.isAAC),V=le.id3,V>0&&(x.pid=V),Y&&!ee&&(y.logger.log("reparse from beginning"),Y=!1,Se=De-188),ee=this.pmtParsed=!0;break}case 17:case 8191:break;default:Y=!0;break}}else this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b.pesData=U,m.pesData=_,x.pesData=I;var te={audioTrack:m,avcTrack:b,id3Track:x,textTrack:this._txtTrack};return u&&this.extractRemainingSamples(te),te},g.flush=function(){var E=this.remainderData;this.remainderData=null;var p;return E?p=this.demux(E,-1,!1,!0):p={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},g.extractRemainingSamples=function(E){var p=E.audioTrack,c=E.avcTrack,u=E.id3Track,a=c.pesData,b=p.pesData,m=u.pesData,x;a&&(x=o(a))?(this.parseAVCPES(x,!0),c.pesData=null):c.pesData=a,b&&(x=o(b))?(p.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),p.pesData=null):(b!=null&&b.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=b),m&&(x=o(m))?(this.parseID3PES(x),u.pesData=null):u.pesData=m},g.demuxSampleAes=function(E,p,c){var u=this.demux(E,c,!0,!this.config.progressive),a=this.sampleAes=new W.default(this.observer,this.config,p);return this.decrypt(u,a)},g.decrypt=function(E,p){return new Promise(function(c){var u=E.audioTrack,a=E.avcTrack;u.samples&&u.isAAC?p.decryptAacSamples(u.samples,0,function(){a.samples?p.decryptAvcSamples(a.samples,0,0,function(){c(E)}):c(E)}):a.samples&&p.decryptAvcSamples(a.samples,0,0,function(){c(E)})})},g.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},g.parseAVCPES=function(E,p){var c=this,u=this._avcTrack,a=this.parseAVCNALu(E.data),b=!1,m=this.avcSample,x,F=!1;E.data=null,m&&a.length&&!u.audFound&&(l(m,u),m=this.avcSample=C(!1,E.pts,E.dts,"")),a.forEach(function(U){switch(U.type){case 1:{x=!0,m||(m=c.avcSample=C(!0,E.pts,E.dts,"")),b&&(m.debug+="NDR "),m.frame=!0;var K=U.data;if(F&&K.length>4){var V=new M.default(K).readSliceType();(V===2||V===4||V===7||V===9)&&(m.key=!0)}break}case 5:x=!0,m||(m=c.avcSample=C(!0,E.pts,E.dts,"")),b&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{x=!0,b&&m&&(m.debug+="SEI ");var _=new M.default(w(U.data));_.readUByte();for(var I=0,Y=0,ee=!1,ae=0;!ee&&_.bytesAvailable>1;){I=0;do ae=_.readUByte(),I+=ae;while(ae===255);Y=0;do ae=_.readUByte(),Y+=ae;while(ae===255);if(I===4&&_.bytesAvailable!==0){ee=!0;var de=_.readUByte();if(de===181){var De=_.readUShort();if(De===49){var Se=_.readUInt();if(Se===1195456820){var we=_.readUByte();if(we===3){for(var Ce=_.readUByte(),Te=_.readUByte(),ge=31&Ce,le=[Ce,Te],te=0;te<ge;te++)le.push(_.readUByte()),le.push(_.readUByte()),le.push(_.readUByte());d(c._txtTrack.samples,{type:3,pts:E.pts,bytes:le})}}}}}else if(I===5&&_.bytesAvailable!==0){if(ee=!0,Y>16){for(var ce=[],ne=0;ne<16;ne++)ce.push(_.readUByte().toString(16)),(ne===3||ne===5||ne===7||ne===9)&&ce.push("-");for(var Le=Y-16,Oe=new Uint8Array(Le),Ee=0;Ee<Le;Ee++)Oe[Ee]=_.readUByte();d(c._txtTrack.samples,{pts:E.pts,payloadType:I,uuid:ce.join(""),userData:Object(z.utf8ArrayToStr)(Oe),userDataBytes:Oe})}}else if(Y<_.bytesAvailable)for(var Re=0;Re<Y;Re++)_.readUByte()}break}case 7:if(x=!0,F=!0,b&&m&&(m.debug+="SPS "),!u.sps){var Ne=new M.default(U.data),je=Ne.readSPS();u.width=je.width,u.height=je.height,u.pixelRatio=je.pixelRatio,u.sps=[U.data],u.duration=c._duration;for(var Ue=U.data.subarray(1,4),Ie="avc1.",Me=0;Me<3;Me++){var Ke=Ue[Me].toString(16);Ke.length<2&&(Ke="0"+Ke),Ie+=Ke}u.codec=Ie}break;case 8:x=!0,b&&m&&(m.debug+="PPS "),u.pps||(u.pps=[U.data]);break;case 9:x=!1,u.audFound=!0,m&&l(m,u),m=c.avcSample=C(!1,E.pts,E.dts,b?"AUD ":"");break;case 12:x=!1;break;default:x=!1,m&&(m.debug+="unknown NAL "+U.type+" ");break}if(m&&x){var Ze=m.units;Ze.push(U)}}),p&&m&&(l(m,u),this.avcSample=null)},g.getLastNalUnit=function(){var E,p=this.avcSample,c;if(!p||p.units.length===0){var u=this._avcTrack.samples;p=u[u.length-1]}if((E=p)!==null&&E!==void 0&&E.units){var a=p.units;c=a[a.length-1]}return c},g.parseAVCNALu=function(E){var p=E.byteLength,c=this._avcTrack,u=c.naluState||0,a=u,b=[],m=0,x,F,U,K=-1,V=0;for(u===-1&&(K=0,V=E[0]&31,u=0,m=1);m<p;){if(x=E[m++],!u){u=x?0:1;continue}if(u===1){u=x?0:2;continue}if(!x)u=3;else if(x===1){if(K>=0){var _={data:E.subarray(K,m-u-1),type:V};b.push(_)}else{var I=this.getLastNalUnit();if(I&&(a&&m<=4-a&&(I.state&&(I.data=I.data.subarray(0,I.data.byteLength-a))),F=m-u-1,F>0)){var Y=new Uint8Array(I.data.byteLength+F);Y.set(I.data,0),Y.set(E.subarray(0,F),I.data.byteLength),I.data=Y,I.state=0}}m<p?(U=E[m]&31,K=m,V=U,u=0):u=-1}else u=0}if(K>=0&&u>=0){var ee={data:E.subarray(K,p),type:V,state:u};b.push(ee)}if(b.length===0){var ae=this.getLastNalUnit();if(ae){var de=new Uint8Array(ae.data.byteLength+E.byteLength);de.set(ae.data,0),de.set(E,ae.data.byteLength),ae.data=de}}return c.naluState=u,b},g.parseAACPES=function(E){var p=0,c=this._audioTrack,u=this.aacOverFlow,a=E.data;if(u){this.aacOverFlow=null;var b=u.sample.unit.byteLength,m=Math.min(u.missing,b),x=b-m;u.sample.unit.set(a.subarray(0,m),x),c.samples.push(u.sample),p=u.missing}var F,U;for(F=p,U=a.length;F<U-1&&!$.isHeader(a,F);F++);if(F!==p){var K,V;if(F<U-1?(K="AAC PES did not start with ADTS header,offset:"+F,V=!1):(K="no ADTS header found in AAC PES",V=!0),y.logger.warn("parsing error:"+K),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:K}),V)return}$.initTrackConfig(c,this.observer,a,F,this.audioCodec);var _;if(E.pts!==void 0)_=E.pts;else if(u){var I=$.getFrameDuration(c.samplerate);_=u.sample.pts+I}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Y=0;F<U;)if($.isHeader(a,F)){if(F+5<U){var ee=$.appendFrame(c,a,F,_,Y);if(ee)if(ee.missing)this.aacOverFlow=ee;else{F+=ee.length,Y++;continue}}break}else F++},g.parseMPEGPES=function(E){var p=E.data,c=p.length,u=0,a=0,b=E.pts;if(b===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(B.isHeader(p,a)){var m=B.appendFrame(this._audioTrack,p,a,b,u);if(m)a+=m.length,u++;else break}else a++},g.parseID3PES=function(E){if(E.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(E)},v}();L.minProbeByteLength=188;function C(v,g,k,E){return{key:v,frame:!1,pts:g,dts:k,units:[],debug:E,length:0}}function T(v,g){return(v[g+10]&31)<<8|v[g+11]}function h(v,g,k,E){var p={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(v[g+1]&15)<<8|v[g+2],u=g+3+c-4,a=(v[g+10]&15)<<8|v[g+11];for(g+=12+a;g<u;){var b=(v[g+1]&31)<<8|v[g+2];switch(v[g]){case 207:if(!E){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:p.audio===-1&&(p.audio=b);break;case 21:p.id3===-1&&(p.id3=b);break;case 219:if(!E){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:p.avc===-1&&(p.avc=b);break;case 3:case 4:k?p.audio===-1&&(p.audio=b,p.isAAC=!1):y.logger.log("MPEG audio found, not supported in this browser");break;case 36:y.logger.warn("Unsupported HEVC stream type found");break;default:break}g+=((v[g+3]&15)<<8|v[g+4])+5}return p}function o(v){var g=0,k,E,p,c,u,a=v.data;if(!v||v.size===0)return null;for(;a[0].length<19&&a.length>1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}k=a[0];var m=(k[0]<<16)+(k[1]<<8)+k[2];if(m===1){if(E=(k[4]<<8)+k[5],E&&E>v.size-6)return null;var x=k[7];x&192&&(c=(k[9]&14)*536870912+(k[10]&255)*4194304+(k[11]&254)*16384+(k[12]&255)*128+(k[13]&254)/2,x&64?(u=(k[14]&14)*536870912+(k[15]&255)*4194304+(k[16]&254)*16384+(k[17]&255)*128+(k[18]&254)/2,c-u>60*9e4&&(y.logger.warn(Math.round((c-u)/9e4)+"s delta between PTS and DTS, align them"),c=u)):u=c),p=k[8];var F=p+9;if(v.size<=F)return null;v.size-=F;for(var U=new Uint8Array(v.size),K=0,V=a.length;K<V;K++){k=a[K];var _=k.byteLength;if(F)if(F>_){F-=_;continue}else k=k.subarray(F),_-=F,F=0;U.set(k,g),g+=_}return E&&(E-=p+3),{data:U,pts:c,dts:u,len:E}}return null}function l(v,g){if(v.units.length&&v.frame){if(v.pts===void 0){var k=g.samples,E=k.length;if(E){var p=k[E-1];v.pts=p.pts,v.dts=p.dts}else{g.dropped++;return}}g.samples.push(v)}v.debug.length&&y.logger.log(v.pts+"/"+v.dts+":"+v.debug)}function d(v,g){var k=v.length;if(k>0){if(g.pts>=v[k-1].pts)v.push(g);else for(var E=k-1;E>=0;E--)if(g.pts<v[E].pts){v.splice(E,0,g);break}}else v.push(g)}function w(v){for(var g=v.byteLength,k=[],E=1;E<g-2;)v[E]===0&&v[E+1]===0&&v[E+2]===3?(k.push(E+2),E+=2):E++;if(k.length===0)return v;var p=g-k.length,c=new Uint8Array(p),u=0;for(E=0;E<p;u++,E++)u===k[0]&&(u++,k.shift()),c[E]=v[u];return c}Z.default=L},"./src/errors.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"ErrorTypes",function(){return $}),D.d(Z,"ErrorDetails",function(){return B});var $;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})($||($={}));var B;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(B||(B={}))},"./src/events.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"Events",function(){return $});var $;(function(B){B.MEDIA_ATTACHING="hlsMediaAttaching",B.MEDIA_ATTACHED="hlsMediaAttached",B.MEDIA_DETACHING="hlsMediaDetaching",B.MEDIA_DETACHED="hlsMediaDetached",B.BUFFER_RESET="hlsBufferReset",B.BUFFER_CODECS="hlsBufferCodecs",B.BUFFER_CREATED="hlsBufferCreated",B.BUFFER_APPENDING="hlsBufferAppending",B.BUFFER_APPENDED="hlsBufferAppended",B.BUFFER_EOS="hlsBufferEos",B.BUFFER_FLUSHING="hlsBufferFlushing",B.BUFFER_FLUSHED="hlsBufferFlushed",B.MANIFEST_LOADING="hlsManifestLoading",B.MANIFEST_LOADED="hlsManifestLoaded",B.MANIFEST_PARSED="hlsManifestParsed",B.LEVEL_SWITCHING="hlsLevelSwitching",B.LEVEL_SWITCHED="hlsLevelSwitched",B.LEVEL_LOADING="hlsLevelLoading",B.LEVEL_LOADED="hlsLevelLoaded",B.LEVEL_UPDATED="hlsLevelUpdated",B.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",B.LEVELS_UPDATED="hlsLevelsUpdated",B.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",B.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",B.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",B.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",B.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",B.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",B.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",B.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",B.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",B.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",B.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",B.CUES_PARSED="hlsCuesParsed",B.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",B.INIT_PTS_FOUND="hlsInitPtsFound",B.FRAG_LOADING="hlsFragLoading",B.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",B.FRAG_LOADED="hlsFragLoaded",B.FRAG_DECRYPTED="hlsFragDecrypted",B.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",B.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",B.FRAG_PARSING_METADATA="hlsFragParsingMetadata",B.FRAG_PARSED="hlsFragParsed",B.FRAG_BUFFERED="hlsFragBuffered",B.FRAG_CHANGED="hlsFragChanged",B.FPS_DROP="hlsFpsDrop",B.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",B.ERROR="hlsError",B.DESTROYING="hlsDestroying",B.KEY_LOADING="hlsKeyLoading",B.KEY_LOADED="hlsKeyLoaded",B.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",B.BACK_BUFFER_REACHED="hlsBackBufferReached"})($||($={}))},"./src/hls.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return v});var $=D("./node_modules/url-toolkit/src/url-toolkit.js"),B=D.n($),M=D("./src/loader/playlist-loader.ts"),z=D("./src/loader/key-loader.ts"),W=D("./src/controller/id3-track-controller.ts"),P=D("./src/controller/latency-controller.ts"),R=D("./src/controller/level-controller.ts"),y=D("./src/controller/fragment-tracker.ts"),A=D("./src/controller/stream-controller.ts"),O=D("./src/is-supported.ts"),L=D("./src/utils/logger.ts"),C=D("./src/config.ts"),T=D("./node_modules/eventemitter3/index.js"),h=D.n(T),o=D("./src/events.ts"),l=D("./src/errors.ts");function d(g,k){for(var E=0;E<k.length;E++){var p=k[E];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(g,p.key,p)}}function w(g,k,E){return k&&d(g.prototype,k),E&&d(g,E),g}var v=function(){g.isSupported=function(){return Object(O.isSupported)()};function g(E){E===void 0&&(E={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new T.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 p=this.config=Object(C.mergeConfig)(g.DefaultConfig,E);this.userConfig=E,Object(L.enableLogs)(p.debug),this._autoLevelCapping=-1,p.progressive&&Object(C.enableStreamingMode)(p);var c=p.abrController,u=p.bufferController,a=p.capLevelController,b=p.fpsController,m=this.abrController=new c(this),x=this.bufferController=new u(this),F=this.capLevelController=new a(this),U=new b(this),K=new M.default(this),V=new z.default(this),_=new W.default(this),I=this.levelController=new R.default(this),Y=new y.FragmentTracker(this),ee=this.streamController=new A.default(this,Y);F.setStreamController(ee),U.setStreamController(ee);var ae=[I,ee];this.networkControllers=ae;var de=[K,V,m,x,F,U,_,Y];this.audioTrackController=this.createController(p.audioTrackController,null,ae),this.createController(p.audioStreamController,Y,ae),this.subtitleTrackController=this.createController(p.subtitleTrackController,null,ae),this.createController(p.subtitleStreamController,Y,ae),this.createController(p.timelineController,null,de),this.emeController=this.createController(p.emeController,null,de),this.cmcdController=this.createController(p.cmcdController,null,de),this.latencyController=this.createController(P.default,null,de),this.coreComponents=de}var k=g.prototype;return k.createController=function(p,c,u){if(p){var a=c?new p(this,c):new p(this);return u&&u.push(a),a}return null},k.on=function(p,c,u){u===void 0&&(u=this),this._emitter.on(p,c,u)},k.once=function(p,c,u){u===void 0&&(u=this),this._emitter.once(p,c,u)},k.removeAllListeners=function(p){this._emitter.removeAllListeners(p)},k.off=function(p,c,u,a){u===void 0&&(u=this),this._emitter.off(p,c,u,a)},k.listeners=function(p){return this._emitter.listeners(p)},k.emit=function(p,c,u){return this._emitter.emit(p,c,u)},k.trigger=function(p,c){if(this.config.debug)return this.emit(p,p,c);try{return this.emit(p,p,c)}catch(u){L.logger.error("An internal error happened while handling event "+p+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(o.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:p,error:u})}return!1},k.listenerCount=function(p){return this._emitter.listenerCount(p)},k.destroy=function(){L.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(p){return p.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(p){return p.destroy()}),this.coreComponents.length=0},k.attachMedia=function(p){L.logger.log("attachMedia"),this._media=p,this.trigger(o.Events.MEDIA_ATTACHING,{media:p})},k.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},k.loadSource=function(p){this.stopLoad();var c=this.media,u=this.url,a=this.url=$.buildAbsoluteURL(self.location.href,p,{alwaysNormalize:!0});L.logger.log("loadSource:"+a),c&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:p})},k.startLoad=function(p){p===void 0&&(p=-1),L.logger.log("startLoad("+p+")"),this.networkControllers.forEach(function(c){c.startLoad(p)})},k.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(p){p.stopLoad()})},k.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},k.recoverMediaError=function(){L.logger.log("recoverMediaError");var p=this._media;this.detachMedia(),p&&this.attachMedia(p)},k.removeLevel=function(p,c){c===void 0&&(c=0),this.levelController.removeLevel(p,c)},w(g,[{key:"levels",get:function(){var p=this.levelController.levels;return p||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(p){L.logger.log("set currentLevel:"+p),this.loadLevel=p,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(p){L.logger.log("set nextLevel:"+p),this.levelController.manualLevel=p,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(p){L.logger.log("set loadLevel:"+p),this.levelController.manualLevel=p}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(p){this.levelController.nextLoadLevel=p}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(p){L.logger.log("set firstLevel:"+p),this.levelController.firstLevel=p}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(p){L.logger.log("set startLevel:"+p),p!==-1&&(p=Math.max(p,this.minAutoLevel)),this.levelController.startLevel=p}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(p){var c=!!p;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(p){this._autoLevelCapping!==p&&(L.logger.log("set autoLevelCapping:"+p),this._autoLevelCapping=p)}},{key:"bandwidthEstimate",get:function(){var p=this.abrController.bwEstimator;return p?p.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var p=this.levels,c=this.config.minAutoBitrate;if(!p)return 0;for(var u=p.length,a=0;a<u;a++)if(p[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var p=this.levels,c=this.autoLevelCapping,u;return c===-1&&p&&p.length?u=p.length-1:u=c,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(p){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,p)}},{key:"audioTracks",get:function(){var p=this.audioTrackController;return p?p.audioTracks:[]}},{key:"audioTrack",get:function(){var p=this.audioTrackController;return p?p.audioTrack:-1},set:function(p){var c=this.audioTrackController;c&&(c.audioTrack=p)}},{key:"subtitleTracks",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTrack:-1},set:function(p){var c=this.subtitleTrackController;c&&(c.subtitleTrack=p)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var p=this.subtitleTrackController;return p?p.subtitleDisplay:!1},set:function(p){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=p)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(p){this.config.lowLatencyMode=p}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return g.defaultConfig?g.defaultConfig:C.hlsDefaultConfig},set:function(p){g.defaultConfig=p}}]),g}();v.defaultConfig=void 0},"./src/is-supported.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"isSupported",function(){return M}),D.d(Z,"changeTypeSupported",function(){return z});var $=D("./src/utils/mediasource-helper.ts");function B(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var W=Object($.getMediaSource)();if(!W)return!1;var P=B(),R=W&&typeof W.isTypeSupported=="function"&&W.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!R&&!!y}function z(){var W,P=B();return typeof(P==null||((W=P.prototype)===null||W===void 0)?void 0:W.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L}),D.d(Z,"LoadError",function(){return T});var $=D("./src/polyfills/number.ts"),B=D("./src/errors.ts");function M(h,o){h.prototype=Object.create(o.prototype),h.prototype.constructor=h,y(h,o)}function z(h){var o=typeof Map=="function"?new Map:void 0;return z=function(d){if(d===null||!R(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(d))return o.get(d);o.set(d,w)}function w(){return W(d,arguments,A(this).constructor)}return w.prototype=Object.create(d.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),y(w,d)},z(h)}function W(h,o,l){return P()?W=Reflect.construct:W=function(w,v,g){var k=[null];k.push.apply(k,v);var E=Function.bind.apply(w,k),p=new E;return g&&y(p,g.prototype),p},W.apply(null,arguments)}function P(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function R(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function y(h,o){return y=Object.setPrototypeOf||function(d,w){return d.__proto__=w,d},y(h,o)}function A(h){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},A(h)}var O=Math.pow(2,17),L=function(){function h(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var o=h.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(d,w){var v=this,g=d.url;if(!g)return Promise.reject(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(g?"part list":"url")));this.abort();var k=this.config,E=k.fLoader,p=k.loader;return new Promise(function(c,u){v.loader&&v.loader.destroy();var a=v.loader=d.loader=E?new E(k):new p(k),b=C(d),m={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:O};d.stats=a.stats,a.load(b,m,{onSuccess:function(F,U,K,V){v.resetLoader(d,a),c({frag:d,part:null,payload:F.data,networkDetails:V})},onError:function(F,U,K){v.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:F,networkDetails:K}))},onAbort:function(F,U,K){v.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:K}))},onTimeout:function(F,U,K){v.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:K}))},onProgress:function(F,U,K,V){w&&w({frag:d,part:null,payload:K,networkDetails:V})}})})},o.loadPart=function(d,w,v){var g=this;this.abort();var k=this.config,E=k.fLoader,p=k.loader;return new Promise(function(c,u){g.loader&&g.loader.destroy();var a=g.loader=d.loader=E?new E(k):new p(k),b=C(d,w),m={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:O};w.stats=a.stats,a.load(b,m,{onSuccess:function(F,U,K,V){g.resetLoader(d,a),g.updateStatsFromPart(d,w);var _={frag:d,part:w,payload:F.data,networkDetails:V};v(_),c(_)},onError:function(F,U,K){g.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:w,response:F,networkDetails:K}))},onAbort:function(F,U,K){d.stats.aborted=w.stats.aborted,g.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:w,networkDetails:K}))},onTimeout:function(F,U,K){g.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:w,networkDetails:K}))}})})},o.updateStatsFromPart=function(d,w){var v=d.stats,g=w.stats,k=g.total;if(v.loaded+=g.loaded,k){var E=Math.round(d.duration/w.duration),p=Math.min(Math.round(v.loaded/k),E),c=E-p,u=c*Math.round(v.loaded/p);v.total=v.loaded+u}else v.total=Math.max(v.loaded,v.total);var a=v.loading,b=g.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(d,w){d.loader=null,this.loader===w&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),w.destroy()},h}();function C(h,o){o===void 0&&(o=null);var l=o||h,d={frag:h,part:o,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},w=l.byteRangeStartOffset,v=l.byteRangeEndOffset;return Object($.isFiniteNumber)(w)&&Object($.isFiniteNumber)(v)&&(d.rangeStart=w,d.rangeEnd=v),d}var T=function(h){M(o,h);function o(l){for(var d,w=arguments.length,v=new Array(w>1?w-1:0),g=1;g<w;g++)v[g-1]=arguments[g];return d=h.call.apply(h,[this].concat(v))||this,d.data=void 0,d.data=l,d}return o}(z(Error))},"./src/loader/fragment.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"ElementaryStreamTypes",function(){return L}),D.d(Z,"BaseSegment",function(){return C}),D.d(Z,"Fragment",function(){return T}),D.d(Z,"Part",function(){return h});var $=D("./src/polyfills/number.ts"),B=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(B),z=D("./src/utils/logger.ts"),W=D("./src/loader/level-key.ts"),P=D("./src/loader/load-stats.ts");function R(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,y(o,l)}function y(o,l){return y=Object.setPrototypeOf||function(w,v){return w.__proto__=v,w},y(o,l)}function A(o,l){for(var d=0;d<l.length;d++){var w=l[d];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function O(o,l,d){return l&&A(o.prototype,l),d&&A(o,d),o}var L;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(L||(L={}));var C=function(){function o(d){var w;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(w={},w[L.AUDIO]=null,w[L.VIDEO]=null,w[L.AUDIOVIDEO]=null,w),this.baseurl=d}var l=o.prototype;return l.setByteRange=function(w,v){var g=w.split("@",2),k=[];g.length===1?k[0]=v?v.byteRangeEndOffset:0:k[0]=parseInt(g[1]),k[1]=parseInt(g[0])+k[0],this._byteRange=k},O(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(B.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(w){this._url=w}}]),o}(),T=function(o){R(l,o);function l(w,v){var g;return g=o.call(this,v)||this,g._decryptdata=null,g.rawProgramDateTime=null,g.programDateTime=null,g.tagList=[],g.duration=0,g.sn=0,g.levelkey=void 0,g.type=void 0,g.loader=null,g.level=-1,g.cc=0,g.startPTS=void 0,g.endPTS=void 0,g.appendedPTS=void 0,g.startDTS=void 0,g.endDTS=void 0,g.start=0,g.deltaPTS=void 0,g.maxStartPTS=void 0,g.minEndPTS=void 0,g.stats=new P.LoadStats,g.urlId=0,g.data=void 0,g.bitrateTest=!1,g.title=null,g.initSegment=null,g.type=w,g}var d=l.prototype;return d.createInitializationVector=function(v){for(var g=new Uint8Array(16),k=12;k<16;k++)g[k]=v>>8*(15-k)&255;return g},d.setDecryptDataFromLevelKey=function(v,g){var k=v;return(v==null?void 0:v.method)==="AES-128"&&v.uri&&!v.iv&&(k=W.LevelKey.fromURI(v.uri),k.method=v.method,k.iv=this.createInitializationVector(g),k.keyFormat="identity"),k},d.setElementaryStreamInfo=function(v,g,k,E,p,c){c===void 0&&(c=!1);var u=this.elementaryStreams,a=u[v];if(!a){u[v]={startPTS:g,endPTS:k,startDTS:E,endDTS:p,partial:c};return}a.startPTS=Math.min(a.startPTS,g),a.endPTS=Math.max(a.endPTS,k),a.startDTS=Math.min(a.startDTS,E),a.endDTS=Math.max(a.endDTS,p)},d.clearElementaryStreamInfo=function(){var v=this.elementaryStreams;v[L.AUDIO]=null,v[L.VIDEO]=null,v[L.AUDIOVIDEO]=null},O(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var v=this.sn;typeof v!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&z.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),v=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,v)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object($.isFiniteNumber)(this.programDateTime))return null;var v=Object($.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+v*1e3}},{key:"encrypted",get:function(){var v;return!!((v=this.decryptdata)!==null&&v!==void 0&&v.keyFormat&&this.decryptdata.uri)}}]),l}(C),h=function(o){R(l,o);function l(d,w,v,g,k){var E;E=o.call(this,v)||this,E.fragOffset=0,E.duration=0,E.gap=!1,E.independent=!1,E.relurl=void 0,E.fragment=void 0,E.index=void 0,E.stats=new P.LoadStats,E.duration=d.decimalFloatingPoint("DURATION"),E.gap=d.bool("GAP"),E.independent=d.bool("INDEPENDENT"),E.relurl=d.enumeratedString("URI"),E.fragment=w,E.index=g;var p=d.enumeratedString("BYTERANGE");return p&&E.setByteRange(p,k),k&&(E.fragOffset=k.fragOffset+k.duration),E}return O(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 w=this.elementaryStreams;return!!(w.audio||w.video||w.audiovideo)}}]),l}(C)},"./src/loader/key-loader.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return z});var $=D("./src/events.ts"),B=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),z=function(){function W(R){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=R,this._registerListeners()}var P=W.prototype;return P._registerListeners=function(){this.hls.on($.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off($.Events.KEY_LOADING,this.onKeyLoading)},P.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var A=this.loaders[y];A&&A.destroy()}this.loaders={}},P.onKeyLoading=function(y,A){var O=A.frag,L=O.type,C=this.loaders[L];if(!O.decryptdata){M.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var T=O.decryptdata.uri;if(T!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(C&&(M.logger.warn("abort previous key loader for type:"+L),C.abort()),!T){M.logger.warn("key uri is falsy");return}var o=h.loader,l=O.loader=this.loaders[L]=new o(h);this.decrypturl=T,this.decryptkey=null;var d={url:T,frag:O,responseType:"arraybuffer"},w={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(d,w,v)}else this.decryptkey&&(O.decryptdata.key=this.decryptkey,this.hls.trigger($.Events.KEY_LOADED,{frag:O}))},P.loadsuccess=function(y,A,O){var L=O.frag;if(!L.decryptdata){M.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(y.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger($.Events.KEY_LOADED,{frag:L})},P.loaderror=function(y,A){var O=A.frag,L=O.loader;L&&L.abort(),delete this.loaders[O.type],this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:O,response:y})},P.loadtimeout=function(y,A){var O=A.frag,L=O.loader;L&&L.abort(),delete this.loaders[O.type],this.hls.trigger($.Events.ERROR,{type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:O})},W}()},"./src/loader/level-details.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"LevelDetails",function(){return W});var $=D("./src/polyfills/number.ts");function B(P,R){for(var y=0;y<R.length;y++){var A=R[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function M(P,R,y){return R&&B(P.prototype,R),y&&B(P,y),P}var z=10,W=function(){function P(y){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=y}var R=P.prototype;return R.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var O=this.lastPartSn-A.lastPartSn,L=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!L||!!O,this.advanced=this.endSN>A.endSN||O>0||O===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},M(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object($.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||z}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var O=this.driftEnd-this.driftStart;return O*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.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 A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),P}()},"./src/loader/level-key.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"LevelKey",function(){return W});var $=D("./node_modules/url-toolkit/src/url-toolkit.js"),B=D.n($);function M(P,R){for(var y=0;y<R.length;y++){var A=R[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function z(P,R,y){return R&&M(P.prototype,R),y&&M(P,y),P}var W=function(){P.fromURL=function(y,A){return new P(y,A)},P.fromURI=function(y){return new P(y)};function P(R,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object($.buildAbsoluteURL)(R,y,{alwaysNormalize:!0}):this._uri=R}return z(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"LoadStats",function(){return $});var $=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l});var $=D("./src/polyfills/number.ts"),B=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(B),z=D("./src/loader/fragment.ts"),W=D("./src/loader/level-details.ts"),P=D("./src/loader/level-key.ts"),R=D("./src/utils/attr-list.ts"),y=D("./src/utils/logger.ts"),A=D("./src/utils/codecs.ts"),O=/#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,C=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),T=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("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function o(k){var E,p;return h.test((E=(p=B.parseURL(k))===null||p===void 0?void 0:p.path)!=null?E:"")}var l=function(){function k(){}return k.findGroup=function(p,c){for(var u=0;u<p.length;u++){var a=p[u];if(a.id===c)return a}},k.convertAVC1ToAVCOTI=function(p){var c=p.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 p},k.resolve=function(p,c){return B.buildAbsoluteURL(c,p,{alwaysNormalize:!0})},k.parseMasterPlaylist=function(p,c){var u=[],a={},b=!1;O.lastIndex=0;for(var m;(m=O.exec(p))!=null;)if(m[1]){var x=new R.AttrList(m[1]),F={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:k.resolve(m[2],c)},U=x.decimalResolution("RESOLUTION");U&&(F.width=U.width,F.height=U.height),d((x.CODECS||"").split(/[ ,]+/).filter(function(V){return V}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=k.convertAVC1ToAVCOTI(F.videoCodec)),u.push(F)}else if(m[3]){var K=new R.AttrList(m[3]);K["DATA-ID"]&&(b=!0,a[K["DATA-ID"]]=K)}return{levels:u,sessionData:b?a:null}},k.parseMasterPlaylistMedia=function(p,c,u,a){a===void 0&&(a=[]);var b,m=[],x=0;for(L.lastIndex=0;(b=L.exec(p))!==null;){var F=new R.AttrList(b[1]);if(F.TYPE===u){var U={attrs:F,bitrate:0,id:x++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:u,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?k.resolve(F.URI,c):""};if(a.length){var K=k.findGroup(a,U.groupId)||a[0];w(U,K,"audioCodec"),w(U,K,"textCodec")}m.push(U)}}return m},k.parseLevelPlaylist=function(p,c,u,a,b){var m=new W.LevelDetails(c),x=m.fragments,F=null,U=0,K=0,V=0,_=0,I=null,Y=new z.Fragment(a,c),ee,ae,de,De=-1,Se=!1;for(C.lastIndex=0,m.m3u8=p;(ee=C.exec(p))!==null;){Se&&(Se=!1,Y=new z.Fragment(a,c),Y.start=V,Y.sn=U,Y.cc=_,Y.level=u,F&&(Y.initSegment=F,Y.rawProgramDateTime=F.rawProgramDateTime));var we=ee[1];if(we){Y.duration=parseFloat(we);var Ce=(" "+ee[2]).slice(1);Y.title=Ce||null,Y.tagList.push(Ce?["INF",we,Ce]:["INF",we])}else if(ee[3])Object($.isFiniteNumber)(Y.duration)&&(Y.start=V,de&&(Y.levelkey=de),Y.sn=U,Y.level=u,Y.cc=_,Y.urlId=b,x.push(Y),Y.relurl=(" "+ee[3]).slice(1),g(Y,I),I=Y,V+=Y.duration,U++,K=0,Se=!0);else if(ee[4]){var Te=(" "+ee[4]).slice(1);I?Y.setByteRange(Te,I):Y.setByteRange(Te)}else if(ee[5])Y.rawProgramDateTime=(" "+ee[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),De===-1&&(De=x.length);else{if(ee=ee[0].match(T),!ee){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(ae=1;ae<ee.length&&!(typeof ee[ae]!="undefined");ae++);var ge=(" "+ee[ae]).slice(1),le=(" "+ee[ae+1]).slice(1),te=ee[ae+2]?(" "+ee[ae+2]).slice(1):"";switch(ge){case"PLAYLIST-TYPE":m.type=le.toUpperCase();break;case"MEDIA-SEQUENCE":U=m.startSN=parseInt(le);break;case"SKIP":{var ce=new R.AttrList(le),ne=ce.decimalInteger("SKIPPED-SEGMENTS");if(Object($.isFiniteNumber)(ne)){m.skippedSegments=ne;for(var Le=ne;Le--;)x.unshift(null);U+=ne}var Oe=ce.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(m.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(le);break;case"VERSION":m.version=parseInt(le);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(le||te)&&Y.tagList.push(te?[le,te]:[le]);break;case"DIS":_++;case"GAP":Y.tagList.push([ge]);break;case"BITRATE":Y.tagList.push([ge,le]);break;case"DISCONTINUITY-SEQ":_=parseInt(le);break;case"KEY":{var Ee,Re=new R.AttrList(le),Ne=Re.enumeratedString("METHOD"),je=Re.URI,Ue=Re.hexadecimalInteger("IV"),Ie=Re.enumeratedString("KEYFORMATVERSIONS"),Me=Re.enumeratedString("KEYID"),Ke=(Ee=Re.enumeratedString("KEYFORMAT"))!=null?Ee:"identity",Ze=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ze.indexOf(Ke)>-1){y.logger.warn("Keyformat "+Ke+" is not supported from the manifest");continue}else if(Ke!=="identity")continue;Ne&&(de=P.LevelKey.fromURL(c,je),je&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ne)>=0&&(de.method=Ne,de.keyFormat=Ke,Me&&(de.keyID=Me),Ie&&(de.keyFormatVersions=Ie),de.iv=Ue));break}case"START":{var $e=new R.AttrList(le),Qe=$e.decimalFloatingPoint("TIME-OFFSET");Object($.isFiniteNumber)(Qe)&&(m.startTimeOffset=Qe);break}case"MAP":{var lt=new R.AttrList(le);Y.relurl=lt.URI,lt.BYTERANGE&&Y.setByteRange(lt.BYTERANGE),Y.level=u,Y.sn="initSegment",de&&(Y.levelkey=de),Y.initSegment=null,F=Y,Se=!0;break}case"SERVER-CONTROL":{var tt=new R.AttrList(le);m.canBlockReload=tt.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=tt.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&tt.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=tt.optionalFloat("PART-HOLD-BACK",0),m.holdBack=tt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new R.AttrList(le);m.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Pe=m.partList;Pe||(Pe=m.partList=[]);var ht=K>0?Pe[Pe.length-1]:void 0,at=K++,Fe=new z.Part(new R.AttrList(le),Y,c,at,ht);Pe.push(Fe),Y.duration+=Fe.duration;break}case"PRELOAD-HINT":{var Ve=new R.AttrList(le);m.preloadHint=Ve;break}case"RENDITION-REPORT":{var xe=new R.AttrList(le);m.renditionReports=m.renditionReports||[],m.renditionReports.push(xe);break}default:y.logger.warn("line parsed but not handled: "+ee);break}}}I&&!I.relurl?(x.pop(),V-=I.duration,m.partList&&(m.fragmentHint=I)):m.partList&&(g(Y,I),Y.cc=_,m.fragmentHint=Y);var ve=x.length,ye=x[0],re=x[ve-1];if(V+=m.skippedSegments*m.targetduration,V>0&&ve&&re){m.averagetargetduration=V/ve;var ie=re.sn;m.endSN=ie!=="initSegment"?ie:0,ye&&(m.startCC=ye.cc,ye.initSegment||m.fragments.every(function(ue){return ue.relurl&&o(ue.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new z.Fragment(a,c),Y.relurl=re.relurl,Y.level=u,Y.sn="initSegment",ye.initSegment=Y,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(V+=m.fragmentHint.duration),m.totalduration=V,m.endCC=_,De>0&&v(x,De),m},k}();function d(k,E){["video","audio","text"].forEach(function(p){var c=k.filter(function(a){return Object(A.isCodecType)(a,p)});if(c.length){var u=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});E[p+"Codec"]=u.length>0?u[0]:c[0],k=k.filter(function(a){return c.indexOf(a)===-1})}}),E.unknownCodecs=k}function w(k,E,p){var c=E[p];c&&(k[p]=c)}function v(k,E){for(var p=k[E],c=E;c--;){var u=k[c];if(!u)return;u.programDateTime=p.programDateTime-u.duration*1e3,p=u}}function g(k,E){k.rawProgramDateTime?k.programDateTime=Date.parse(k.rawProgramDateTime):E!=null&&E.programDateTime&&(k.programDateTime=E.endProgramDateTime),Object($.isFiniteNumber)(k.programDateTime)||(k.programDateTime=null,k.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/polyfills/number.ts"),B=D("./src/events.ts"),M=D("./src/errors.ts"),z=D("./src/utils/logger.ts"),W=D("./src/utils/mp4-tools.ts"),P=D("./src/loader/m3u8-parser.ts"),R=D("./src/types/loader.ts"),y=D("./src/utils/attr-list.ts");function A(C){var T=C.type;switch(T){case R.PlaylistContextType.AUDIO_TRACK:return R.PlaylistLevelType.AUDIO;case R.PlaylistContextType.SUBTITLE_TRACK:return R.PlaylistLevelType.SUBTITLE;default:return R.PlaylistLevelType.MAIN}}function O(C,T){var h=C.url;return(h===void 0||h.indexOf("data:")===0)&&(h=T.url),h}var L=function(){function C(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var T=C.prototype;return T.registerListeners=function(){var o=this.hls;o.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(B.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(B.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},T.unregisterListeners=function(){var o=this.hls;o.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(B.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(B.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},T.createInternalLoader=function(o){var l=this.hls.config,d=l.pLoader,w=l.loader,v=d||w,g=new v(l);return o.loader=g,this.loaders[o.type]=g,g},T.getInternalLoader=function(o){return this.loaders[o.type]},T.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},T.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},T.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},T.onManifestLoading=function(o,l){var d=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:R.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},T.onLevelLoading=function(o,l){var d=l.id,w=l.level,v=l.url,g=l.deliveryDirectives;this.load({id:d,groupId:null,level:w,responseType:"text",type:R.PlaylistContextType.LEVEL,url:v,deliveryDirectives:g})},T.onAudioTrackLoading=function(o,l){var d=l.id,w=l.groupId,v=l.url,g=l.deliveryDirectives;this.load({id:d,groupId:w,level:null,responseType:"text",type:R.PlaylistContextType.AUDIO_TRACK,url:v,deliveryDirectives:g})},T.onSubtitleTrackLoading=function(o,l){var d=l.id,w=l.groupId,v=l.url,g=l.deliveryDirectives;this.load({id:d,groupId:w,level:null,responseType:"text",type:R.PlaylistContextType.SUBTITLE_TRACK,url:v,deliveryDirectives:g})},T.load=function(o){var l,d=this.hls.config,w=this.getInternalLoader(o);if(w){var v=w.context;if(v&&v.url===o.url){z.logger.trace("[playlist-loader]: playlist request ongoing");return}z.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),w.abort()}var g,k,E,p;switch(o.type){case R.PlaylistContextType.MANIFEST:g=d.manifestLoadingMaxRetry,k=d.manifestLoadingTimeOut,E=d.manifestLoadingRetryDelay,p=d.manifestLoadingMaxRetryTimeout;break;case R.PlaylistContextType.LEVEL:case R.PlaylistContextType.AUDIO_TRACK:case R.PlaylistContextType.SUBTITLE_TRACK:g=0,k=d.levelLoadingTimeOut;break;default:g=d.levelLoadingMaxRetry,k=d.levelLoadingTimeOut,E=d.levelLoadingRetryDelay,p=d.levelLoadingMaxRetryTimeout;break}if(w=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var c;if(o.type===R.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===R.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===R.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var u=c.partTarget,a=c.targetduration;u&&a&&(k=Math.min(Math.max(u*3,a*.8)*1e3,k))}}var b={timeout:k,maxRetry:g,retryDelay:E,maxRetryDelay:p,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};w.load(o,b,m)},T.loadsuccess=function(o,l,d,w){if(w===void 0&&(w=null),d.isSidxRequest){this.handleSidxRequest(o,d),this.handlePlaylistLoaded(o,l,d,w);return}this.resetInternalLoader(d.type);var v=o.data;if(v.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,d,"no EXTM3U delimiter",w);return}l.parsing.start=performance.now(),v.indexOf("#EXTINF:")>0||v.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,d,w):this.handleMasterPlaylist(o,l,d,w)},T.loaderror=function(o,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!1,o)},T.loadtimeout=function(o,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!0)},T.handleMasterPlaylist=function(o,l,d,w){var v=this.hls,g=o.data,k=O(o,d),E=P.default.parseMasterPlaylist(g,k),p=E.levels,c=E.sessionData;if(!p.length){this.handleManifestParsingError(o,d,"no level found in manifest",w);return}var u=p.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),a=p.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),b=P.default.parseMasterPlaylistMedia(g,k,"AUDIO",u),m=P.default.parseMasterPlaylistMedia(g,k,"SUBTITLES",a),x=P.default.parseMasterPlaylistMedia(g,k,"CLOSED-CAPTIONS");if(b.length){var F=b.some(function(U){return!U.url});!F&&p[0].audioCodec&&!p[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}v.trigger(B.Events.MANIFEST_LOADED,{levels:p,audioTracks:b,subtitles:m,captions:x,url:k,stats:l,networkDetails:w,sessionData:c})},T.handleTrackOrLevelPlaylist=function(o,l,d,w){var v=this.hls,g=d.id,k=d.level,E=d.type,p=O(o,d),c=Object($.isFiniteNumber)(g)?g:0,u=Object($.isFiniteNumber)(k)?k:c,a=A(d),b=P.default.parseLevelPlaylist(o.data,p,u,a,c);if(!b.fragments.length){v.trigger(B.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(E===R.PlaylistContextType.MANIFEST){var m={attrs:new y.AttrList({}),bitrate:0,details:b,name:"",url:p};v.trigger(B.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:p,stats:l,networkDetails:w,sessionData:null})}if(l.parsing.end=performance.now(),b.needSidxRanges){var x,F=(x=b.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:F,isSidxRequest:!0,type:E,level:k,levelDetails:b,id:g,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=b,this.handlePlaylistLoaded(o,l,d,w)},T.handleSidxRequest=function(o,l){var d=Object(W.parseSegmentIndex)(new Uint8Array(o.data));if(!d)return;var w=d.references,v=l.levelDetails;w.forEach(function(g,k){var E=g.info,p=v.fragments[k];p.byteRange.length===0&&p.setByteRange(String(1+E.end-E.start)+"@"+String(E.start)),p.initSegment&&p.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},T.handleManifestParsingError=function(o,l,d,w){this.hls.trigger(B.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===R.PlaylistContextType.MANIFEST,url:o.url,reason:d,response:o,context:l,networkDetails:w})},T.handleNetworkError=function(o,l,d,w){d===void 0&&(d=!1),z.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var v=M.ErrorDetails.UNKNOWN,g=!1,k=this.getInternalLoader(o);switch(o.type){case R.PlaylistContextType.MANIFEST:v=d?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,g=!0;break;case R.PlaylistContextType.LEVEL:v=d?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,g=!1;break;case R.PlaylistContextType.AUDIO_TRACK:v=d?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,g=!1;break;case R.PlaylistContextType.SUBTITLE_TRACK:v=d?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,g=!1;break}k&&this.resetInternalLoader(o.type);var E={type:M.ErrorTypes.NETWORK_ERROR,details:v,fatal:g,url:o.url,loader:k,context:o,networkDetails:l};w&&(E.response=w),this.hls.trigger(B.Events.ERROR,E)},T.handlePlaylistLoaded=function(o,l,d,w){var v=d.type,g=d.level,k=d.id,E=d.groupId,p=d.loader,c=d.levelDetails,u=d.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,d,"invalid target duration",w);return}if(!p)return;c.live&&(p.getCacheAge&&(c.ageHeader=p.getCacheAge()||0),(!p.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(v){case R.PlaylistContextType.MANIFEST:case R.PlaylistContextType.LEVEL:this.hls.trigger(B.Events.LEVEL_LOADED,{details:c,level:g||0,id:k||0,stats:l,networkDetails:w,deliveryDirectives:u});break;case R.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(B.Events.AUDIO_TRACK_LOADED,{details:c,id:k||0,groupId:E||"",stats:l,networkDetails:w,deliveryDirectives:u});break;case R.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(B.Events.SUBTITLE_TRACK_LOADED,{details:c,id:k||0,groupId:E||"",stats:l,networkDetails:w,deliveryDirectives:u});break}},C}();Z.default=L},"./src/polyfills/number.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"isFiniteNumber",function(){return $}),D.d(Z,"MAX_SAFE_INTEGER",function(){return B});var $=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},B=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(oe,Z,D){"use strict";D.r(Z);var $=function(){function B(){}return B.getSilentFrame=function(z,W){switch(z){case"mp4a.40.2":if(W===1)return new Uint8Array([0,200,0,128,35,128]);if(W===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(W===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(W===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(W===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(W===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(W===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(W===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(W===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},B}();Z.default=$},"./src/remux/mp4-generator.ts":function(oe,Z,D){"use strict";D.r(Z);var $=Math.pow(2,32)-1,B=function(){function M(){}return M.init=function(){M.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 W;for(W in M.types)M.types.hasOwnProperty(W)&&(M.types[W]=[W.charCodeAt(0),W.charCodeAt(1),W.charCodeAt(2),W.charCodeAt(3)]);var P=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),R=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]);M.HDLR_TYPES={video:P,audio:R};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);M.STTS=M.STSC=M.STCO=A,M.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),M.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),M.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var O=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),C=new Uint8Array([0,0,0,1]);M.FTYP=M.box(M.types.ftyp,O,C,O,L),M.DINF=M.box(M.types.dinf,M.box(M.types.dref,y))},M.box=function(W){for(var P=8,R=arguments.length,y=new Array(R>1?R-1:0),A=1;A<R;A++)y[A-1]=arguments[A];for(var O=y.length,L=O;O--;)P+=y[O].byteLength;var C=new Uint8Array(P);for(C[0]=P>>24&255,C[1]=P>>16&255,C[2]=P>>8&255,C[3]=P&255,C.set(W,4),O=0,P=8;O<L;O++)C.set(y[O],P),P+=y[O].byteLength;return C},M.hdlr=function(W){return M.box(M.types.hdlr,M.HDLR_TYPES[W])},M.mdat=function(W){return M.box(M.types.mdat,W)},M.mdhd=function(W,P){P*=W;var R=Math.floor(P/($+1)),y=Math.floor(P%($+1));return M.box(M.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,W>>24&255,W>>16&255,W>>8&255,W&255,R>>24,R>>16&255,R>>8&255,R&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},M.mdia=function(W){return M.box(M.types.mdia,M.mdhd(W.timescale,W.duration),M.hdlr(W.type),M.minf(W))},M.mfhd=function(W){return M.box(M.types.mfhd,new Uint8Array([0,0,0,0,W>>24,W>>16&255,W>>8&255,W&255]))},M.minf=function(W){return W.type==="audio"?M.box(M.types.minf,M.box(M.types.smhd,M.SMHD),M.DINF,M.stbl(W)):M.box(M.types.minf,M.box(M.types.vmhd,M.VMHD),M.DINF,M.stbl(W))},M.moof=function(W,P,R){return M.box(M.types.moof,M.mfhd(W),M.traf(R,P))},M.moov=function(W){for(var P=W.length,R=[];P--;)R[P]=M.trak(W[P]);return M.box.apply(null,[M.types.moov,M.mvhd(W[0].timescale,W[0].duration)].concat(R).concat(M.mvex(W)))},M.mvex=function(W){for(var P=W.length,R=[];P--;)R[P]=M.trex(W[P]);return M.box.apply(null,[M.types.mvex].concat(R))},M.mvhd=function(W,P){P*=W;var R=Math.floor(P/($+1)),y=Math.floor(P%($+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,W>>24&255,W>>16&255,W>>8&255,W&255,R>>24,R>>16&255,R>>8&255,R&255,y>>24,y>>16&255,y>>8&255,y&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 M.box(M.types.mvhd,A)},M.sdtp=function(W){var P=W.samples||[],R=new Uint8Array(4+P.length),y,A;for(y=0;y<P.length;y++)A=P[y].flags,R[y+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return M.box(M.types.sdtp,R)},M.stbl=function(W){return M.box(M.types.stbl,M.stsd(W),M.box(M.types.stts,M.STTS),M.box(M.types.stsc,M.STSC),M.box(M.types.stsz,M.STSZ),M.box(M.types.stco,M.STCO))},M.avc1=function(W){var P=[],R=[],y,A,O;for(y=0;y<W.sps.length;y++)A=W.sps[y],O=A.byteLength,P.push(O>>>8&255),P.push(O&255),P=P.concat(Array.prototype.slice.call(A));for(y=0;y<W.pps.length;y++)A=W.pps[y],O=A.byteLength,R.push(O>>>8&255),R.push(O&255),R=R.concat(Array.prototype.slice.call(A));var L=M.box(M.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|W.sps.length].concat(P).concat([W.pps.length]).concat(R))),C=W.width,T=W.height,h=W.pixelRatio[0],o=W.pixelRatio[1];return M.box(M.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,C>>8&255,C&255,T>>8&255,T&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,M.box(M.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),M.box(M.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,o>>24,o>>16&255,o>>8&255,o&255])))},M.esds=function(W){var P=W.config.length;return new Uint8Array([0,0,0,0,3,23+P,0,1,0,4,15+P,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([P]).concat(W.config).concat([6,1,2]))},M.mp4a=function(W){var P=W.samplerate;return M.box(M.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,W.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]),M.box(M.types.esds,M.esds(W)))},M.mp3=function(W){var P=W.samplerate;return M.box(M.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,W.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]))},M.stsd=function(W){return W.type==="audio"?!W.isAAC&&W.codec==="mp3"?M.box(M.types.stsd,M.STSD,M.mp3(W)):M.box(M.types.stsd,M.STSD,M.mp4a(W)):M.box(M.types.stsd,M.STSD,M.avc1(W))},M.tkhd=function(W){var P=W.id,R=W.duration*W.timescale,y=W.width,A=W.height,O=Math.floor(R/($+1)),L=Math.floor(R%($+1));return M.box(M.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,O>>24,O>>16&255,O>>8&255,O&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,y>>8&255,y&255,0,0,A>>8&255,A&255,0,0]))},M.traf=function(W,P){var R=M.sdtp(W),y=W.id,A=Math.floor(P/($+1)),O=Math.floor(P%($+1));return M.box(M.types.traf,M.box(M.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),M.box(M.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,O>>24,O>>16&255,O>>8&255,O&255])),M.trun(W,R.length+16+20+8+16+8+8),R)},M.trak=function(W){return W.duration=W.duration||4294967295,M.box(M.types.trak,M.tkhd(W),M.mdia(W))},M.trex=function(W){var P=W.id;return M.box(M.types.trex,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},M.trun=function(W,P){var R=W.samples||[],y=R.length,A=12+16*y,O=new Uint8Array(A),L,C,T,h,o,l;for(P+=8+A,O.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255],0),L=0;L<y;L++)C=R[L],T=C.duration,h=C.size,o=C.flags,l=C.cts,O.set([T>>>24&255,T>>>16&255,T>>>8&255,T&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*L);return M.box(M.types.trun,O)},M.initSegment=function(W){M.types||M.init();var P=M.moov(W),R=new Uint8Array(M.FTYP.byteLength+P.byteLength);return R.set(M.FTYP),R.set(P,M.FTYP.byteLength),R},M}();B.types=void 0,B.HDLR_TYPES=void 0,B.STTS=void 0,B.STSC=void 0,B.STCO=void 0,B.STSZ=void 0,B.VMHD=void 0,B.SMHD=void 0,B.STSD=void 0,B.FTYP=void 0,B.DINF=void 0,Z.default=B},"./src/remux/mp4-remuxer.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l}),D.d(Z,"normalizePts",function(){return d});var $=D("./src/polyfills/number.ts"),B=D("./src/remux/aac-helper.ts"),M=D("./src/remux/mp4-generator.ts"),z=D("./src/events.ts"),W=D("./src/errors.ts"),P=D("./src/utils/logger.ts"),R=D("./src/types/loader.ts"),y=D("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(k){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var c in p)Object.prototype.hasOwnProperty.call(p,c)&&(k[c]=p[c])}return k},A.apply(this,arguments)}var O=10*1e3,L=1024,C=1152,T=null,h=null,o=!1,l=function(){function k(p,c,u,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=p,this.config=c,this.typeSupported=u,this.ISGenerated=!1,T===null){var b=navigator.userAgent||"",m=b.match(/Chrome\/(\d+)/i);T=m?parseInt(m[1]):0}if(h===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);h=x?parseInt(x[1]):0}o=!!T&&T<75||!!h&&h<600}var E=k.prototype;return E.destroy=function(){},E.resetTimeStamp=function(c){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},E.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},E.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},E.getVideoStartPts=function(c){var u=!1,a=c.reduce(function(b,m){var x=m.pts-b;return x<-4294967296?(u=!0,d(b,m.pts)):x>0?b:m.pts},c[0].pts);return u&&P.logger.debug("PTS rollover detected"),a},E.remux=function(c,u,a,b,m,x,F,U){var K,V,_,I,Y,ee,ae=m,de=m,De=c.pid>-1,Se=u.pid>-1,we=u.samples.length,Ce=c.samples.length>0,Te=we>1,ge=(!De||Ce)&&(!Se||Te)||this.ISGenerated||F;if(ge){this.ISGenerated||(_=this.generateIS(c,u,m));var le=this.isVideoContiguous,te=-1;if(Te&&(te=w(u.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(ee=!0,te>0){P.logger.warn("[mp4-remuxer]: Dropped "+te+" out of "+we+" video samples due to a missing keyframe");var ce=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(te),u.dropped+=te,de+=(u.samples[0].pts-ce)/(u.timescale||9e4)}else te===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+we+" video samples"),ee=!1);if(this.ISGenerated){if(Ce&&Te){var ne=this.getVideoStartPts(u.samples),Le=d(c.samples[0].pts,ne)-ne,Oe=Le/u.inputTimeScale;ae+=Math.max(0,Oe),de+=Math.max(0,-Oe)}if(Ce){if(c.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),_=this.generateIS(c,u,m)),V=this.remuxAudio(c,ae,this.isAudioContiguous,x,Se||Te||U===R.PlaylistLevelType.AUDIO?de:void 0),Te){var Ee=V?V.endPTS-V.startPTS:0;u.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),_=this.generateIS(c,u,m)),K=this.remuxVideo(u,de,le,Ee)}}else Te&&(K=this.remuxVideo(u,de,le,0));K&&(K.firstKeyFrame=te,K.independent=te!==-1)}}return this.ISGenerated&&(a.samples.length&&(Y=this.remuxID3(a,m)),b.samples.length&&(I=this.remuxText(b,m))),{audio:V,video:K,initSegment:_,independent:ee,text:I,id3:Y}},E.generateIS=function(c,u,a){var b=c.samples,m=u.samples,x=this.typeSupported,F={},U=!Object($.isFiniteNumber)(this._initPTS),K="audio/mp4",V,_,I;if(U&&(V=_=Infinity),c.config&&b.length&&(c.timescale=c.samplerate,c.isAAC||(x.mpeg?(K="audio/mpeg",c.codec=""):x.mp3&&(c.codec="mp3")),F.audio={id:"audio",container:K,codec:c.codec,initSegment:!c.isAAC&&x.mpeg?new Uint8Array(0):M.default.initSegment([c]),metadata:{channelCount:c.channelCount}},U&&(I=c.inputTimeScale,V=_=b[0].pts-Math.round(I*a))),u.sps&&u.pps&&m.length&&(u.timescale=u.inputTimeScale,F.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:M.default.initSegment([u]),metadata:{width:u.width,height:u.height}},U)){I=u.inputTimeScale;var Y=this.getVideoStartPts(m),ee=Math.round(I*a);_=Math.min(_,d(m[0].dts,Y)-ee),V=Math.min(V,Y-ee)}if(Object.keys(F).length)return this.ISGenerated=!0,U&&(this._initPTS=V,this._initDTS=_),{tracks:F,initPTS:V,timescale:I}},E.remuxVideo=function(c,u,a,b){var m=c.inputTimeScale,x=c.samples,F=[],U=x.length,K=this._initPTS,V=this.nextAvcDts,_=8,I,Y,ee,ae=Number.POSITIVE_INFINITY,de=Number.NEGATIVE_INFINITY,De=0,Se=!1;if(!a||V===null){var we=u*m,Ce=x[0].pts-d(x[0].dts,x[0].pts);V=we-Ce}for(var Te=0;Te<U;Te++){var ge=x[Te];if(ge.pts=d(ge.pts-K,V),ge.dts=d(ge.dts-K,V),ge.dts>ge.pts){var le=9e4*.2;De=Math.max(Math.min(De,ge.pts-ge.dts),-1*le)}ge.dts<x[Te>0?Te-1:Te].dts&&(Se=!0)}Se&&x.sort(function(wt,Tt){var ut=wt.dts-Tt.dts,Bt=wt.pts-Tt.pts;return ut||Bt}),Y=x[0].dts,ee=x[x.length-1].dts;var te=Math.round((ee-Y)/(U-1));if(De<0){if(De<te*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-te,!0)+" ms");for(var ce=De,ne=0;ne<U;ne++)x[ne].dts=ce=Math.max(ce,x[ne].pts-te),x[ne].pts=Math.max(ce,x[ne].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var Le=0;Le<U;Le++)x[Le].dts=x[Le].dts+De}Y=x[0].dts}if(a){var Oe=Y-V,Ee=Oe>te,Re=Oe<-1;if(Ee||Re){Ee?P.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(Oe,!0)+" ms ("+Oe+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-Oe,!0)+" ms ("+Oe+"dts) overlapping between fragments detected"),Y=V;var Ne=x[0].pts-Oe;x[0].dts=Y,x[0].pts=Ne,P.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Ne,!0)+"/"+Object(y.toMsFromMpegTsClock)(Y,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(Oe,!0)+" ms")}}o&&(Y=Math.max(0,Y));for(var je=0,Ue=0,Ie=0;Ie<U;Ie++){for(var Me=x[Ie],Ke=Me.units,Ze=Ke.length,$e=0,Qe=0;Qe<Ze;Qe++)$e+=Ke[Qe].data.length;Ue+=$e,je+=Ze,Me.length=$e,Me.dts=Math.max(Me.dts,Y),Me.pts=Math.max(Me.pts,Me.dts,0),ae=Math.min(Me.pts,ae),de=Math.max(Me.pts,de)}ee=x[U-1].dts;var lt=Ue+4*je+8,tt;try{tt=new Uint8Array(lt)}catch(wt){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:lt,reason:"fail allocating video mdat "+lt});return}var rt=new DataView(tt.buffer);rt.setUint32(0,lt),tt.set(M.default.types.mdat,4);for(var Pe=0;Pe<U;Pe++){for(var ht=x[Pe],at=ht.units,Fe=0,Ve=0,xe=at.length;Ve<xe;Ve++){var ve=at[Ve],ye=ve.data,re=ve.data.byteLength;rt.setUint32(_,re),_+=4,tt.set(ye,_),_+=re,Fe+=4+re}if(Pe<U-1)I=x[Pe+1].dts-ht.dts;else{var ie=this.config,ue=ht.dts-x[Pe>0?Pe-1:Pe].dts;if(ie.stretchShortVideoTrack&&this.nextAudioPts!==null){var pe=Math.floor(ie.maxBufferHole*m),be=(b?ae+b*m:this.nextAudioPts)-ht.pts;be>pe?(I=be-ue,I<0&&(I=ue),P.logger.log("[mp4-remuxer]: It is approximately "+be/90+" ms to the next segment; using duration "+I/90+" ms for the last video frame.")):I=ue}else I=ue}var _e=Math.round(ht.pts-ht.dts);F.push(new v(ht.key,I,Fe,_e))}if(F.length&&T&&T<70){var He=F[0].flags;He.dependsOn=2,He.isNonSync=0}console.assert(I!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=V=ee+I,this.isVideoContiguous=!0;var nt=M.default.moof(c.sequenceNumber++,Y,A({},c,{samples:F})),mt="video",ft={data1:nt,data2:tt,startPTS:ae/m,endPTS:(de+I)/m,startDTS:Y/m,endDTS:V/m,type:mt,hasAudio:!1,hasVideo:!0,nb:F.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(tt.length,"MDAT length must not be zero"),ft},E.remuxAudio=function(c,u,a,b,m){var x=c.inputTimeScale,F=c.samplerate?c.samplerate:x,U=x/F,K=c.isAAC?L:C,V=K*U,_=this._initPTS,I=!c.isAAC&&this.typeSupported.mpeg,Y=[],ee=c.samples,ae=I?0:8,de=this.nextAudioPts||-1,De=u*x;if(this.isAudioContiguous=a=a||ee.length&&de>0&&(b&&Math.abs(De-de)<9e3||Math.abs(d(ee[0].pts-_,De)-de)<20*V),ee.forEach(function(ye){ye.pts=d(ye.pts-_,De)}),!a||de<0){if(ee=ee.filter(function(ye){return ye.pts>=0}),!ee.length)return;m===0?de=0:b?de=Math.max(0,De):de=ee[0].pts}if(c.isAAC)for(var Se=m!==void 0,we=this.config.maxAudioFramesDrift,Ce=0,Te=de;Ce<ee.length;Ce++){var ge=ee[Ce],le=ge.pts,te=le-Te,ce=Math.abs(1e3*te/x);if(te<=-we*V&&Se)Ce===0&&(P.logger.warn("Audio frame @ "+(le/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/x)+" ms."),this.nextAudioPts=de=Te=le);else if(te>=we*V&&ce<O&&Se){var ne=Math.round(te/V);Te=le-ne*V,Te<0&&(ne--,Te+=V),Ce===0&&(this.nextAudioPts=de=Te),P.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(Te/x).toFixed(3)+"s due to "+Math.round(1e3*te/x)+" ms gap.");for(var Le=0;Le<ne;Le++){var Oe=Math.max(Te,0),Ee=B.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);Ee||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ee=ge.unit.subarray()),ee.splice(Ce,0,{unit:Ee,pts:Oe}),Te+=V,Ce++}}ge.pts=Te,Te+=V}for(var Re=null,Ne=null,je,Ue=0,Ie=ee.length;Ie--;)Ue+=ee[Ie].unit.byteLength;for(var Me=0,Ke=ee.length;Me<Ke;Me++){var Ze=ee[Me],$e=Ze.unit,Qe=Ze.pts;if(Ne!==null){var lt=Y[Me-1];lt.duration=Math.round((Qe-Ne)/U)}else if(a&&c.isAAC&&(Qe=de),Re=Qe,Ue>0){Ue+=ae;try{je=new Uint8Array(Ue)}catch(ye){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ue,reason:"fail allocating audio mdat "+Ue});return}if(!I){var tt=new DataView(je.buffer);tt.setUint32(0,Ue),je.set(M.default.types.mdat,4)}}else return;je.set($e,ae);var rt=$e.byteLength;ae+=rt,Y.push(new v(!0,K,rt,0)),Ne=Qe}var Pe=Y.length;if(!Pe)return;var ht=Y[Y.length-1];this.nextAudioPts=de=Ne+U*ht.duration;var at=I?new Uint8Array(0):M.default.moof(c.sequenceNumber++,Re/U,A({},c,{samples:Y}));c.samples=[];var Fe=Re/x,Ve=de/x,xe="audio",ve={data1:at,data2:je,startPTS:Fe,endPTS:Ve,startDTS:Fe,endDTS:Ve,type:xe,hasAudio:!0,hasVideo:!1,nb:Pe};return this.isAudioContiguous=!0,console.assert(je.length,"MDAT length must not be zero"),ve},E.remuxEmptyAudio=function(c,u,a,b){var m=c.inputTimeScale,x=c.samplerate?c.samplerate:m,F=m/x,U=this.nextAudioPts,K=(U!==null?U:b.startDTS*m)+this._initDTS,V=b.endDTS*m+this._initDTS,_=F*L,I=Math.ceil((V-K)/_),Y=B.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!Y){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ee=[],ae=0;ae<I;ae++){var de=K+ae*_;ee.push({unit:Y,pts:de,dts:de})}return c.samples=ee,this.remuxAudio(c,u,a,!1)},E.remuxID3=function(c,u){var a=c.samples.length;if(!a)return;for(var b=c.inputTimeScale,m=this._initPTS,x=this._initDTS,F=0;F<a;F++){var U=c.samples[F];U.pts=d(U.pts-m,u*b)/b,U.dts=d(U.dts-x,u*b)/b}var K=c.samples;return c.samples=[],{samples:K}},E.remuxText=function(c,u){var a=c.samples.length;if(!a)return;for(var b=c.inputTimeScale,m=this._initPTS,x=0;x<a;x++){var F=c.samples[x];F.pts=d(F.pts-m,u*b)/b}c.samples.sort(function(K,V){return K.pts-V.pts});var U=c.samples;return c.samples=[],{samples:U}},k}();function d(k,E){var p;if(E===null)return k;for(E<k?p=-8589934592:p=8589934592;Math.abs(k-E)>4294967296;)k+=p;return k}function w(k){for(var E=0;E<k.length;E++)if(k[E].key)return E;return-1}var v=function(E,p,c,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=p,this.size=c,this.cts=u,this.flags=new g(E)},g=function(E){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=E?2:1,this.isNonSync=E?0:1}},"./src/remux/passthrough-remuxer.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/polyfills/number.ts"),B=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/fragment.ts"),z=D("./src/utils/logger.ts"),W=function(){function y(){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 A=y.prototype;return A.destroy=function(){},A.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(L,C,T){this.audioCodec=C,this.videoCodec=T,this.generateInitSegment(L),this.emitInitSegment=!0},A.generateInitSegment=function(L){var C=this.audioCodec,T=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(B.parseInitSegment)(L);C||(C=R(h.audio,M.ElementaryStreamTypes.AUDIO)),T||(T=R(h.video,M.ElementaryStreamTypes.VIDEO));var o={};h.audio&&h.video?o.audiovideo={container:"video/mp4",codec:C+","+T,initSegment:L,id:"main"}:h.audio?o.audio={container:"audio/mp4",codec:C,initSegment:L,id:"audio"}:h.video?o.video={container:"video/mp4",codec:T,initSegment:L,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},A.remux=function(L,C,T,h,o){var l=this.initPTS,d=this.lastEndDTS,w={audio:void 0,video:void 0,text:h,id3:T,initSegment:void 0};Object($.isFiniteNumber)(d)||(d=this.lastEndDTS=o||0);var v=C.samples;if(!v||!v.length)return w;var g={initPTS:void 0,timescale:1},k=this.initData;if((!k||!k.length)&&(this.generateInitSegment(v),k=this.initData),!k||!k.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1),Object($.isFiniteNumber)(l)||(this.initPTS=g.initPTS=l=P(k,v,d));var E=Object(B.getDuration)(v,k),p=d,c=E+p;Object(B.offsetStartDTS)(k,v,l),E>0?this.lastEndDTS=c:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!k.audio,a=!!k.video,b="";u&&(b+="audio"),a&&(b+="video");var m={data1:v,startPTS:p,startDTS:p,endPTS:c,endDTS:c,type:b,hasAudio:u,hasVideo:a,nb:1,dropped:0};return w.audio=m.type==="audio"?m:void 0,w.video=m.type!=="audio"?m:void 0,w.text=h,w.id3=T,w.initSegment=g,w},y}(),P=function(A,O,L){return Object(B.getStartDTS)(A,O)-L};function R(y,A){var O=y==null?void 0:y.codec;return O&&O.length>4?O:O==="hvc1"?"hvc1.1.c.L120.90":O==="av01"?"av01.0.04M.08":O==="avc1"||A===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Z.default=W},"./src/task-loop.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return $});var $=function(){function B(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=B.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(W){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,W),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},B}()},"./src/types/cmcd.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"CMCDVersion",function(){return $}),D.d(Z,"CMCDObjectType",function(){return B}),D.d(Z,"CMCDStreamingFormat",function(){return M}),D.d(Z,"CMCDStreamType",function(){return z});var $=1,B;(function(W){W.MANIFEST="m",W.AUDIO="a",W.VIDEO="v",W.MUXED="av",W.INIT="i",W.CAPTION="c",W.TIMED_TEXT="tt",W.KEY="k",W.OTHER="o"})(B||(B={}));var M;(function(W){W.DASH="d",W.HLS="h",W.SMOOTH="s",W.OTHER="o"})(M||(M={}));var z;(function(W){W.VOD="v",W.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"HlsSkip",function(){return M}),D.d(Z,"getSkipValue",function(){return z}),D.d(Z,"HlsUrlParameters",function(){return W}),D.d(Z,"Level",function(){return P});function $(R,y){for(var A=0;A<y.length;A++){var O=y[A];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function B(R,y,A){return y&&$(R.prototype,y),A&&$(R,A),R}var M;(function(R){R.No="",R.Yes="YES",R.v2="v2"})(M||(M={}));function z(R,y){var A=R.canSkipUntil,O=R.canSkipDateRanges,L=R.endSN,C=y!==void 0?y-L:0;return A&&C<A?O?M.v2:M.Yes:M.No}var W=function(){function R(A,O,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=O,this.skip=L}var y=R.prototype;return y.addDirectives=function(O){var L=new self.URL(O);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()},R}(),P=function(){function R(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return B(R,[{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(A){var O=A%this.url.length;this._urlId!==O&&(this.details=void 0,this._urlId=O)}}]),R}()},"./src/types/loader.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"PlaylistContextType",function(){return $}),D.d(Z,"PlaylistLevelType",function(){return B});var $;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})($||($={}));var B;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(B||(B={}))},"./src/types/transmuxer.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"ChunkMetadata",function(){return $});var $=function(z,W,P,R,y,A){R===void 0&&(R=0),y===void 0&&(y=-1),A===void 0&&(A=!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=B(),this.buffering={audio:B(),video:B(),audiovideo:B()},this.level=z,this.sn=W,this.id=P,this.size=R,this.part=y,this.partial=A};function B(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"AttrList",function(){return M});var $=/^(\d+)x(\d+)$/,B=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function z(P){typeof P=="string"&&(P=z.parseAttrList(P));for(var R in P)P.hasOwnProperty(R)&&(this[R]=P[R])}var W=z.prototype;return W.decimalInteger=function(R){var y=parseInt(this[R],10);return y>Number.MAX_SAFE_INTEGER?Infinity:y},W.hexadecimalInteger=function(R){if(this[R]){var y=(this[R]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var A=new Uint8Array(y.length/2),O=0;O<y.length/2;O++)A[O]=parseInt(y.slice(O*2,O*2+2),16);return A}else return null},W.hexadecimalIntegerAsNumber=function(R){var y=parseInt(this[R],16);return y>Number.MAX_SAFE_INTEGER?Infinity:y},W.decimalFloatingPoint=function(R){return parseFloat(this[R])},W.optionalFloat=function(R,y){var A=this[R];return A?parseFloat(A):y},W.enumeratedString=function(R){return this[R]},W.bool=function(R){return this[R]==="YES"},W.decimalResolution=function(R){var y=$.exec(this[R]);return y===null?void 0:{width:parseInt(y[1],10),height:parseInt(y[2],10)}},z.parseAttrList=function(R){var y,A={},O='"';for(B.lastIndex=0;(y=B.exec(R))!==null;){var L=y[2];L.indexOf(O)===0&&L.lastIndexOf(O)===L.length-1&&(L=L.slice(1,-1)),A[y[1]]=L}return A},z}()},"./src/utils/binary-search.ts":function(oe,Z,D){"use strict";D.r(Z);var $={search:function(M,z){for(var W=0,P=M.length-1,R=null,y=null;W<=P;){R=(W+P)/2|0,y=M[R];var A=z(y);if(A>0)W=R+1;else if(A<0)P=R-1;else return y}return null}};Z.default=$},"./src/utils/buffer-helper.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"BufferHelper",function(){return M});var $=D("./src/utils/logger.ts"),B={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function z(){}return z.isBuffered=function(P,R){try{if(P){for(var y=z.getBuffered(P),A=0;A<y.length;A++)if(R>=y.start(A)&&R<=y.end(A))return!0}}catch(O){}return!1},z.bufferInfo=function(P,R,y){try{if(P){var A=z.getBuffered(P),O=[],L;for(L=0;L<A.length;L++)O.push({start:A.start(L),end:A.end(L)});return this.bufferedInfo(O,R,y)}}catch(C){}return{len:0,start:R,end:R,nextStart:void 0}},z.bufferedInfo=function(P,R,y){R=Math.max(0,R),P.sort(function(g,k){var E=g.start-k.start;return E||k.end-g.end});var A=[];if(y)for(var O=0;O<P.length;O++){var L=A.length;if(L){var C=A[L-1].end;P[O].start-C<y?P[O].end>C&&(A[L-1].end=P[O].end):A.push(P[O])}else A.push(P[O])}else A=P;for(var T=0,h,o=R,l=R,d=0;d<A.length;d++){var w=A[d].start,v=A[d].end;if(R+y>=w&&R<v)o=w,l=v,T=l-R;else if(R+y<w){h=w;break}}return{len:T,start:o||0,end:l||0,nextStart:h}},z.getBuffered=function(P){try{return P.buffered}catch(R){return $.logger.log("failed to get media.buffered",R),B}},z}()},"./src/utils/cea-608-parser.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"Row",function(){return l}),D.d(Z,"CaptionScreen",function(){return d});var $=D("./src/utils/logger.ts"),B={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},M=function(c){var u=c;return B.hasOwnProperty(c)&&(u=B[c]),String.fromCharCode(u)},z=15,W=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},R={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},O=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(function(p){p[p.ERROR=0]="ERROR",p[p.TEXT=1]="TEXT",p[p.WARNING=2]="WARNING",p[p.INFO=2]="INFO",p[p.DEBUG=3]="DEBUG",p[p.DATA=3]="DATA"})(L||(L={}));var C=function(){function p(){this.time=null,this.verboseLevel=L.ERROR}var c=p.prototype;return c.log=function(a,b){this.verboseLevel>=a&&$.logger.log(this.time+" ["+a+"] "+b)},p}(),T=function(c){for(var u=[],a=0;a<c.length;a++)u.push(c[a].toString(16));return u},h=function(){function p(u,a,b,m,x){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=a||!1,this.italics=b||!1,this.background=m||"black",this.flash=x||!1}var c=p.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var b=["foreground","underline","italics","background","flash"],m=0;m<b.length;m++){var x=b[m];a.hasOwnProperty(x)&&(this[x]=a[x])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},p}(),o=function(){function p(u,a,b,m,x,F){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new h(a,b,m,x,F)}var c=p.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,b){this.uchar=a,this.penState.copy(b)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},p}(),l=function(){function p(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 a=0;a<W;a++)this.chars.push(new o);this.logger=u,this.pos=0,this.currPenState=new h}var c=p.prototype;return c.equals=function(a){for(var b=!0,m=0;m<W;m++)if(!this.chars[m].equals(a.chars[m])){b=!1;break}return b},c.copy=function(a){for(var b=0;b<W;b++)this.chars[b].copy(a.chars[b])},c.isEmpty=function(){for(var a=!0,b=0;b<W;b++)if(!this.chars[b].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>W&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=W)},c.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var m=this.pos+1;m<b+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(b)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var b=M(a);if(this.pos>=W){this.logger.log(L.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var b;for(b=a;b<W;b++)this.chars[b].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],b=!0,m=0;m<W;m++){var x=this.chars[m].uchar;x!==" "&&(b=!1),a.push(x)}return b?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.setPenState(this.currPenState)},p}(),d=function(){function p(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 a=0;a<z;a++)this.rows.push(new l(u));this.logger=u,this.currRow=z-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=p.prototype;return c.reset=function(){for(var a=0;a<z;a++)this.rows[a].clear();this.currRow=z-1},c.equals=function(a){for(var b=!0,m=0;m<z;m++)if(!this.rows[m].equals(a.rows[m])){b=!1;break}return b},c.copy=function(a){for(var b=0;b<z;b++)this.rows[b].copy(a.rows[b])},c.isEmpty=function(){for(var a=!0,b=0;b<z;b++)if(!this.rows[b].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var b=this.rows[this.currRow];b.insertChar(a)},c.setPen=function(a){var b=this.rows[this.currRow];b.setPenStyles(a)},c.moveCursor=function(a){var b=this.rows[this.currRow];b.moveCursor(a)},c.setCursor=function(a){this.logger.log(L.INFO,"setCursor: "+a);var b=this.rows[this.currRow];b.setCursor(a)},c.setPAC=function(a){this.logger.log(L.INFO,"pacData = "+JSON.stringify(a));var b=a.row-1;if(this.nrRollUpRows&&b<this.nrRollUpRows-1&&(b=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==b){for(var m=0;m<z;m++)this.rows[m].clear();var x=this.currRow+1-this.nrRollUpRows,F=this.lastOutputScreen;if(F){var U=F.rows[x].cueStartTime,K=this.logger.time;if(U&&K!==null&&U<K)for(var V=0;V<this.nrRollUpRows;V++)this.rows[b-this.nrRollUpRows+V+1].copy(F.rows[x+V])}}this.currRow=b;var _=this.rows[this.currRow];if(a.indent!==null){var I=a.indent,Y=Math.max(I-1,0);_.setCursor(a.indent),a.color=_.chars[Y].penState.foreground}var ee={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ee)},c.setBkgData=function(a){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,b=this.rows.splice(a,1)[0];b.clear(),this.rows.splice(this.currRow,0,b),this.logger.log(L.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var b=[],m="",x=-1,F=0;F<z;F++){var U=this.rows[F].getTextString();U&&(x=F+1,a?b.push("Row "+x+": '"+U+"'"):b.push(U.trim()))}return b.length>0&&(a?m="["+b.join(" | ")+"]":m=b.join(`
`)),m},c.getTextAndFormat=function(){return this.rows},p}(),w=function(){function p(u,a,b){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new d(b),this.nonDisplayedMemory=new d(b),this.lastOutputScreen=new d(b),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}var c=p.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[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(L.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},c.insertChars=function(a){for(var b=0;b<a.length;b++)this.writeScreen.insertChar(a[b]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,m+": "+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(a){this.logger.log(L.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},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 a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(L.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var b={flash:!1};if(b.underline=a%2===1,b.italics=a>=46,b.italics)b.foreground="white";else{var m=Math.floor(a/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=x[m]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},p}(),v=function(){function p(u,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new C;this.channels=[null,new w(u,a,m),new w(u+1,b,m)],this.cmdHistory=E(),this.logger=m}var c=p.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,b){this.channels[a].setHandler(b)},c.addData=function(a,b){var m,x,F,U=!1;this.logger.time=a;for(var K=0;K<b.length;K+=2){if(x=b[K]&127,F=b[K+1]&127,x===0&&F===0)continue;if(this.logger.log(L.DATA,"["+T([b[K],b[K+1]])+"] -> ("+T([x,F])+")"),m=this.parseCmd(x,F),m||(m=this.parseMidrow(x,F)),m||(m=this.parsePAC(x,F)),m||(m=this.parseBackgroundAttributes(x,F)),!m&&(U=this.parseChars(x,F),U)){var V=this.currentChannel;if(V&&V>0){var _=this.channels[V];_.insertChars(U)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!U&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+T([x,F])+" orig: "+T([b[K],b[K+1]]))}},c.parseCmd=function(a,b){var m=this.cmdHistory,x=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,F=(a===23||a===31)&&b>=33&&b<=35;if(!(x||F))return!1;if(k(a,b,m))return g(null,null,m),this.logger.log(L.DEBUG,"Repeated command ("+T([a,b])+") is dropped"),!0;var U=a===20||a===21||a===23?1:2,K=this.channels[U];return a===20||a===21||a===28||a===29?b===32?K.ccRCL():b===33?K.ccBS():b===34?K.ccAOF():b===35?K.ccAON():b===36?K.ccDER():b===37?K.ccRU(2):b===38?K.ccRU(3):b===39?K.ccRU(4):b===40?K.ccFON():b===41?K.ccRDC():b===42?K.ccTR():b===43?K.ccRTD():b===44?K.ccEDM():b===45?K.ccCR():b===46?K.ccENM():b===47&&K.ccEOC():K.ccTO(b-32),g(a,b,m),this.currentChannel=U,!0},c.parseMidrow=function(a,b){var m=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[m];return x?(x.ccMIDROW(b),this.logger.log(L.DEBUG,"MIDROW ("+T([a,b])+")"),!0):!1}return!1},c.parsePAC=function(a,b){var m,x=this.cmdHistory,F=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,U=(a===16||a===24)&&b>=64&&b<=95;if(!(F||U))return!1;if(k(a,b,x))return g(null,null,x),!0;var K=a<=23?1:2;b>=64&&b<=95?m=K===1?P[a]:y[a]:m=K===1?R[a]:A[a];var V=this.channels[K];return V?(V.setPAC(this.interpretPAC(m,b)),g(a,b,x),this.currentChannel=K,!0):!1},c.interpretPAC=function(a,b){var m,x={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?m=b-96:m=b-64,x.underline=(m&1)===1,m<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((m-16)/2)*4,x},c.parseChars=function(a,b){var m,x=null,F=null;if(a>=25?(m=2,F=a-8):(m=1,F=a),F>=17&&F<=19){var U;F===17?U=b+80:F===18?U=b+112:U=b+144,this.logger.log(L.INFO,"Special char '"+M(U)+"' in channel "+m),x=[U]}else a>=32&&a<=127&&(x=b===0?[a]:[a,b]);if(x){var K=T(x);this.logger.log(L.DEBUG,"Char codes = "+K.join(",")),g(a,b,this.cmdHistory)}return x},c.parseBackgroundAttributes=function(a,b){var m=(a===16||a===24)&&b>=32&&b<=47,x=(a===23||a===31)&&b>=45&&b<=47;if(!(m||x))return!1;var F,U={};a===16||a===24?(F=Math.floor((b-32)/2),U.background=O[F],b%2===1&&(U.background=U.background+"_semi")):b===45?U.background="transparent":(U.foreground="black",b===47&&(U.underline=!0));var K=a<=23?1:2,V=this.channels[K];return V.setBkgData(U),g(a,b,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var b=this.channels[a];b&&b.reset()}this.cmdHistory=E()},c.cueSplitAtTime=function(a){for(var b=0;b<this.channels.length;b++){var m=this.channels[b];m&&m.cueSplitAtTime(a)}},p}();function g(p,c,u){u.a=p,u.b=c}function k(p,c,u){return u.a===p&&u.b===c}function E(){return{a:null,b:null}}Z.default=v},"./src/utils/codecs.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"isCodecType",function(){return B}),D.d(Z,"isCodecSupportedInMp4",function(){return M});var $={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function B(z,W){var P=$[W];return!!P&&P[z.slice(0,4)]===!0}function M(z,W){return MediaSource.isTypeSupported((W||"video")+'/mp4;codecs="'+z+'"')}},"./src/utils/cues.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/utils/vttparser.ts"),B=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),z=/\s/,W={newCue:function(R,y,A,O){for(var L=[],C,T,h,o,l,d=self.VTTCue||self.TextTrackCue,w=0;w<O.rows.length;w++)if(C=O.rows[w],h=!0,o=0,l="",!C.isEmpty()){for(var v=0;v<C.chars.length;v++)z.test(C.chars[v].uchar)&&h?o++:(l+=C.chars[v].uchar,h=!1);C.cueStartTime=y,y===A&&(A+=1e-4),o>=16?o--:o++;var g=Object($.fixLineBreaks)(l.trim()),k=Object(B.generateCueId)(y,A,g);(!R||!R.cues||!R.cues.getCueById(k))&&(T=new d(y,A,g),T.id=k,T.line=w+1,T.align="left",T.position=10+Math.min(80,Math.floor(o*8/32)*10),L.push(T))}return R&&L.length&&(L.sort(function(E,p){return E.line==="auto"||p.line==="auto"?0:E.line>8&&p.line>8?p.line-E.line:E.line-p.line}),L.forEach(function(E){return Object(M.addCueToTrack)(R,E)})),L}};Z.default=W},"./src/utils/discontinuities.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"findFirstFragWithCC",function(){return z}),D.d(Z,"shouldAlignOnDiscontinuities",function(){return W}),D.d(Z,"findDiscontinuousReferenceFrag",function(){return P}),D.d(Z,"adjustSlidingStart",function(){return y}),D.d(Z,"alignStream",function(){return A}),D.d(Z,"alignPDT",function(){return L}),D.d(Z,"alignFragmentByPDTDelta",function(){return C}),D.d(Z,"alignMediaPlaylistByPDT",function(){return T});var $=D("./src/polyfills/number.ts"),B=D("./src/utils/logger.ts"),M=D("./src/controller/level-helper.ts");function z(h,o){for(var l=null,d=0,w=h.length;d<w;d++){var v=h[d];if(v&&v.cc===o){l=v;break}}return l}function W(h,o,l){return!!(o.details&&(l.endCC>l.startCC||h&&h.cc<l.startCC))}function P(h,o){var l=h.fragments,d=o.fragments;if(!d.length||!l.length){B.logger.log("No fragments to align");return}var w=z(l,d[0].cc);if(!w||w&&!w.startPTS){B.logger.log("No frag in previous level to align on");return}return w}function R(h,o){if(h){var l=h.start+o;h.start=h.startPTS=l,h.endPTS=l+h.duration}}function y(h,o){for(var l=o.fragments,d=0,w=l.length;d<w;d++)R(l[d],h);o.fragmentHint&&R(o.fragmentHint,h),o.alignedSliding=!0}function A(h,o,l){if(!o)return;O(h,l,o),!l.alignedSliding&&o.details&&L(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(M.adjustSliding)(o.details,l)}function O(h,o,l){if(W(h,l,o)){var d=P(l.details,o);d&&Object($.isFiniteNumber)(d.start)&&(B.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),y(d.start,o))}}function L(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,d=h.fragments[0].programDateTime,w=(d-l)/1e3+o.fragments[0].start;w&&Object($.isFiniteNumber)(w)&&(B.logger.log("Adjusting PTS using programDateTime delta "+(d-l)+"ms, sliding:"+w.toFixed(3)+" "+h.url+" "),y(w,h))}function C(h,o){var l=h.programDateTime;if(!l)return;var d=(l-o)/1e3;h.start=h.startPTS=d,h.endPTS=d+h.duration}function T(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,d=o.fragments[0].start,w=l-d*1e3;h.fragments.forEach(function(v){C(v,w)}),h.fragmentHint&&C(h.fragmentHint,w),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/utils/ewma.ts"),B=function(){function M(W,P,R){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=R,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new $.default(W),this.fast_=new $.default(P)}var z=M.prototype;return z.update=function(P,R){var y=this.slow_,A=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new $.default(P,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==R&&(this.fast_=new $.default(R,A.getEstimate(),A.getTotalWeight()))},z.sample=function(P,R){P=Math.max(P,this.minDelayMs_);var y=8*R,A=P/1e3,O=y/A;this.fast_.sample(A,O),this.slow_.sample(A,O)},z.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},z.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},z.destroy=function(){},M}();Z.default=B},"./src/utils/ewma.ts":function(oe,Z,D){"use strict";D.r(Z);var $=function(){function B(z,W,P){W===void 0&&(W=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=z,this.alpha_=z?Math.exp(Math.log(.5)/z):0,this.estimate_=W,this.totalWeight_=P}var M=B.prototype;return M.sample=function(W,P){var R=Math.pow(this.alpha_,W);this.estimate_=P*(1-R)+R*this.estimate_,this.totalWeight_+=W},M.getTotalWeight=function(){return this.totalWeight_},M.getEstimate=function(){if(this.alpha_){var W=1-Math.pow(this.alpha_,this.totalWeight_);if(W)return this.estimate_/W}return this.estimate_},B}();Z.default=$},"./src/utils/fetch-loader.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"fetchSupported",function(){return C});var $=D("./src/polyfills/number.ts"),B=D("./src/loader/load-stats.ts"),M=D("./src/demux/chunk-cache.ts");function z(d,w){d.prototype=Object.create(w.prototype),d.prototype.constructor=d,A(d,w)}function W(d){var w=typeof Map=="function"?new Map:void 0;return W=function(g){if(g===null||!y(g))return g;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(typeof w!="undefined"){if(w.has(g))return w.get(g);w.set(g,k)}function k(){return P(g,arguments,O(this).constructor)}return k.prototype=Object.create(g.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),A(k,g)},W(d)}function P(d,w,v){return R()?P=Reflect.construct:P=function(k,E,p){var c=[null];c.push.apply(c,E);var u=Function.bind.apply(k,c),a=new u;return p&&A(a,p.prototype),a},P.apply(null,arguments)}function R(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function y(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function A(d,w){return A=Object.setPrototypeOf||function(g,k){return g.__proto__=k,g},A(d,w)}function O(d){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},O(d)}function L(){return L=Object.assign||function(d){for(var w=1;w<arguments.length;w++){var v=arguments[w];for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(d[g]=v[g])}return d},L.apply(this,arguments)}function C(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var T=function(){function d(v){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=v.fetchSetup||o,this.controller=new self.AbortController,this.stats=new B.LoadStats}var w=d.prototype;return w.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},w.abortInternal=function(){var g=this.response;(!g||!g.ok)&&(this.stats.aborted=!0,this.controller.abort())},w.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},w.load=function(g,k,E){var p=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=h(g,this.controller.signal),a=E.onProgress,b=g.responseType==="arraybuffer",m=b?"byteLength":"length";this.context=g,this.config=k,this.callbacks=E,this.request=this.fetchSetup(g,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){p.abortInternal(),E.onTimeout(c,g,p.response)},k.timeout),self.fetch(this.request).then(function(x){if(p.response=p.loader=x,!x.ok){var F=x.status,U=x.statusText;throw new l(U||"fetch, bad network response",F,x)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(x.headers.get("Content-Length")||"0"),a&&Object($.isFiniteNumber)(k.highWaterMark)?p.loadProgressively(x,c,g,k.highWaterMark,a):b?x.arrayBuffer():x.text()}).then(function(x){var F=p.response;self.clearTimeout(p.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=x[m];var U={url:F.url,data:x};a&&!Object($.isFiniteNumber)(k.highWaterMark)&&a(c,g,x,F),E.onSuccess(U,c,g,F)}).catch(function(x){if(self.clearTimeout(p.requestTimeout),c.aborted)return;var F=x.code||0;E.onError({code:F,text:x.message},g,x.details)})},w.getCacheAge=function(){var g=null;if(this.response){var k=this.response.headers.get("age");g=k?parseFloat(k):null}return g},w.loadProgressively=function(g,k,E,p,c){p===void 0&&(p=0);var u=new M.default,a=g.body.getReader(),b=function m(){return a.read().then(function(x){if(x.done)return u.dataLength&&c(k,E,u.flush(),g),Promise.resolve(new ArrayBuffer(0));var F=x.value,U=F.length;return k.loaded+=U,U<p||u.dataLength?(u.push(F),u.dataLength>=p&&c(k,E,u.flush(),g)):c(k,E,F,g),m()}).catch(function(){return Promise.reject()})};return b()},d}();function h(d,w){var v={method:"GET",mode:"cors",credentials:"same-origin",signal:w,headers:new self.Headers(L({},d.headers))};return d.rangeEnd&&v.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),v}function o(d,w){return new self.Request(d.url,w)}var l=function(d){z(w,d);function w(v,g,k){var E;return E=d.call(this,v)||this,E.code=void 0,E.details=void 0,E.code=g,E.details=k,E}return w}(W(Error));Z.default=T},"./src/utils/imsc1-ttml-parser.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"IMSC1_CODEC",function(){return y}),D.d(Z,"parseIMSC1",function(){return C});var $=D("./src/utils/mp4-tools.ts"),B=D("./src/utils/vttparser.ts"),M=D("./src/utils/vttcue.ts"),z=D("./src/demux/id3.ts"),W=D("./src/utils/timescale-conversion.ts"),P=D("./src/utils/webvtt-parser.ts");function R(){return R=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(p[a]=u[a])}return p},R.apply(this,arguments)}var y="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,O=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function C(p,c,u,a,b){var m=Object($.findBox)(new Uint8Array(p),["mdat"]);if(m.length===0){b(new Error("Could not parse IMSC1 mdat"));return}var x=m[0],F=Object(z.utf8ArrayToStr)(new Uint8Array(p,x.start,x.end-x.start)),U=Object(W.toTimescaleFromScale)(c,1,u);try{a(T(F,U))}catch(K){b(K)}}function T(p,c){var u=new DOMParser,a=u.parseFromString(p,"text/xml"),b=a.getElementsByTagName("tt")[0];if(!b)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(m).reduce(function(_,I){return _[I]=b.getAttribute("ttp:"+I)||m[I],_},{}),F=b.getAttribute("xml:space")!=="preserve",U=o(h(b,"styling","style")),K=o(h(b,"layout","region")),V=h(b,"body","[begin]");return[].map.call(V,function(_){var I=l(_,F);if(!I||!_.hasAttribute("begin"))return null;var Y=g(_.getAttribute("begin"),x),ee=g(_.getAttribute("dur"),x),ae=g(_.getAttribute("end"),x);if(Y===null)throw v(_);if(ae===null){if(ee===null)throw v(_);ae=Y+ee}var de=new M.default(Y-c,ae-c,I);de.id=Object(P.generateCueId)(de.startTime,de.endTime,de.text);var De=K[_.getAttribute("region")],Se=U[_.getAttribute("style")];de.position=10,de.size=80;var we=d(De,Se),Ce=we.textAlign;if(Ce){var Te=L[Ce];Te&&(de.lineAlign=Te),de.align=Ce}return R(de,we),de}).filter(function(_){return _!==null})}function h(p,c,u){var a=p.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function o(p){return p.reduce(function(c,u){var a=u.getAttribute("xml:id");return a&&(c[a]=u),c},{})}function l(p,c){return[].slice.call(p.childNodes).reduce(function(u,a,b){var m;return a.nodeName==="br"&&b?u+`
`:(m=a.childNodes)!==null&&m!==void 0&&m.length?l(a,c):c?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function d(p,c){var u="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(b,m){var x=w(c,u,m)||w(p,u,m);return x&&(b[m]=x),b},{})}function w(p,c,u){return p.hasAttributeNS(c,u)?p.getAttributeNS(c,u):null}function v(p){return new Error("Could not parse ttml timestamp "+p)}function g(p,c){if(!p)return null;var u=Object(B.parseTimeStamp)(p);return u===null&&(A.test(p)?u=k(p,c):O.test(p)&&(u=E(p,c))),u}function k(p,c){var u=A.exec(p),a=(u[4]|0)+(u[5]|0)/c.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/c.frameRate}function E(p,c){var u=O.exec(p),a=Number(u[1]),b=u[2];switch(b){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"enableLogs",function(){return P}),D.d(Z,"logger",function(){return R});var $=function(){},B={trace:$,debug:$,log:$,warn:$,info:$,error:$},M=B;function z(y){var A=self.console[y];return A?A.bind(self.console,"["+y+"] >"):$}function W(y){for(var A=arguments.length,O=new Array(A>1?A-1:0),L=1;L<A;L++)O[L-1]=arguments[L];O.forEach(function(C){M[C]=y[C]?y[C].bind(y):z(C)})}function P(y){if(self.console&&y===!0||typeof y=="object"){W(y,"debug","log","info","warn","error");try{M.log()}catch(A){M=B}}else M=B}var R=M},"./src/utils/mediakeys-helper.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"KeySystems",function(){return $}),D.d(Z,"requestMediaKeySystemAccess",function(){return B});var $;(function(M){M.WIDEVINE="com.widevine.alpha",M.PLAYREADY="com.microsoft.playready"})($||($={}));var B=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"getMediaSource",function(){return $});function $(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"bin2str",function(){return W}),D.d(Z,"readUint16",function(){return P}),D.d(Z,"readUint32",function(){return R}),D.d(Z,"writeUint32",function(){return y}),D.d(Z,"findBox",function(){return A}),D.d(Z,"parseSegmentIndex",function(){return O}),D.d(Z,"parseInitSegment",function(){return L}),D.d(Z,"getStartDTS",function(){return C}),D.d(Z,"getDuration",function(){return T}),D.d(Z,"computeRawDurationFromSamples",function(){return h}),D.d(Z,"offsetStartDTS",function(){return o}),D.d(Z,"segmentValidRange",function(){return l}),D.d(Z,"appendUint8Array",function(){return d});var $=D("./src/utils/typed-array.ts"),B=D("./src/loader/fragment.ts"),M=Math.pow(2,32)-1,z=[].push;function W(w){return String.fromCharCode.apply(null,w)}function P(w,v){"data"in w&&(v+=w.start,w=w.data);var g=w[v]<<8|w[v+1];return g<0?65536+g:g}function R(w,v){"data"in w&&(v+=w.start,w=w.data);var g=w[v]<<24|w[v+1]<<16|w[v+2]<<8|w[v+3];return g<0?4294967296+g:g}function y(w,v,g){"data"in w&&(v+=w.start,w=w.data),w[v]=g>>24,w[v+1]=g>>16&255,w[v+2]=g>>8&255,w[v+3]=g&255}function A(w,v){var g=[];if(!v.length)return g;var k,E,p;"data"in w?(k=w.data,E=w.start,p=w.end):(k=w,E=0,p=k.byteLength);for(var c=E;c<p;){var u=R(k,c),a=W(k.subarray(c+4,c+8)),b=u>1?c+u:p;if(a===v[0])if(v.length===1)g.push({data:k,start:c+8,end:b});else{var m=A({data:k,start:c+8,end:b},v.slice(1));m.length&&z.apply(g,m)}c=b}return g}function O(w){var v=A(w,["moov"]),g=v[0],k=g?g.end:null,E=A(w,["sidx"]);if(!E||!E[0])return null;var p=[],c=E[0],u=c.data[0],a=u===0?8:16,b=R(c,a);a+=4;var m=0,x=0;u===0?a+=8:a+=16,a+=2;var F=c.end+x,U=P(c,a);a+=2;for(var K=0;K<U;K++){var V=a,_=R(c,V);V+=4;var I=_&2147483647,Y=(_&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ee=R(c,V);V+=4,p.push({referenceSize:I,subsegmentDuration:ee,info:{duration:ee/b,start:F,end:F+I-1}}),F+=I,V+=4,a=V}return{earliestPresentationTime:m,timescale:b,version:u,referencesCount:U,references:p,moovEndOffset:k}}function L(w){for(var v=[],g=A(w,["moov","trak"]),k=0;k<g.length;k++){var E=g[k],p=A(E,["tkhd"])[0];if(p){var c=p.data[p.start],u=c===0?12:20,a=R(p,u),b=A(E,["mdia","mdhd"])[0];if(b){c=b.data[b.start],u=c===0?12:20;var m=R(b,u),x=A(E,["mdia","hdlr"])[0];if(x){var F=W(x.data.subarray(x.start+8,x.start+12)),U={soun:B.ElementaryStreamTypes.AUDIO,vide:B.ElementaryStreamTypes.VIDEO}[F];if(U){var K=A(E,["mdia","minf","stbl","stsd"])[0],V=void 0;K&&(V=W(K.data.subarray(K.start+12,K.start+16))),v[a]={timescale:m,type:U},v[U]={timescale:m,id:a,codec:V}}}}}}var _=A(w,["moov","mvex","trex"]);return _.forEach(function(I){var Y=R(I,4),ee=v[Y];ee&&(ee.default={duration:R(I,12),flags:R(I,20)})}),v}function C(w,v){return A(v,["moof","traf"]).reduce(function(g,k){var E=A(k,["tfdt"])[0],p=E.data[E.start],c=A(k,["tfhd"]).reduce(function(u,a){var b=R(a,4),m=w[b];if(m){var x=R(E,4);p===1&&(x*=Math.pow(2,32),x+=R(E,8));var F=m.timescale||9e4,U=x/F;if(isFinite(U)&&(u===null||U<u))return U}return u},null);return c!==null&&isFinite(c)&&(g===null||c<g)?c:g},null)||0}function T(w,v){for(var g=0,k=0,E=0,p=A(w,["moof","traf"]),c=0;c<p.length;c++){var u=p[c],a=A(u,["tfhd"])[0],b=R(a,4),m=v[b];if(!m)continue;var x=m.default,F=R(a,0)|(x==null?void 0:x.flags),U=x==null?void 0:x.duration;F&8&&(F&2?U=R(a,12):U=R(a,8));for(var K=m.timescale||9e4,V=A(u,["trun"]),_=0;_<V.length;_++){if(U){var I=R(V[_],4);g=U*I}else g=h(V[_]);m.type===B.ElementaryStreamTypes.VIDEO?k+=g/K:m.type===B.ElementaryStreamTypes.AUDIO&&(E+=g/K)}}if(k===0&&E===0){var Y=O(w);if(Y!=null&&Y.references)return Y.references.reduce(function(ee,ae){return ee+ae.info.duration||0},0)}return k||E}function h(w){var v=R(w,0),g=8;v&1&&(g+=4),v&4&&(g+=4);for(var k=0,E=R(w,4),p=0;p<E;p++){if(v&256){var c=R(w,g);k+=c,g+=4}v&512&&(g+=4),v&1024&&(g+=4),v&2048&&(g+=4)}return k}function o(w,v,g){A(v,["moof","traf"]).forEach(function(k){A(k,["tfhd"]).forEach(function(E){var p=R(E,4),c=w[p];if(!c)return;var u=c.timescale||9e4;A(k,["tfdt"]).forEach(function(a){var b=a.data[a.start],m=R(a,4);if(b===0)y(a,4,m-g*u);else{m*=Math.pow(2,32),m+=R(a,8),m-=g*u,m=Math.max(m,0);var x=Math.floor(m/(M+1)),F=Math.floor(m%(M+1));y(a,4,x),y(a,8,F)}})})})}function l(w){var v={valid:null,remainder:null},g=A(w,["moof"]);if(g){if(g.length<2)return v.remainder=w,v}else return v;var k=g[g.length-1];return v.valid=Object($.sliceUint8)(w,0,k.start-8),v.remainder=Object($.sliceUint8)(w,k.start-8),v}function d(w,v){var g=new Uint8Array(w.length+v.length);return g.set(w),g.set(v,w.length),g}},"./src/utils/output-filter.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return $});var $=function(){function B(z,W){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=W}var M=B.prototype;return M.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},M.newCue=function(W,P,R){(this.startTime===null||this.startTime>W)&&(this.startTime=W),this.endTime=P,this.screen=R,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[]},B}()},"./src/utils/texttrack-utils.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"sendAddTrackEvent",function(){return B}),D.d(Z,"addCueToTrack",function(){return M}),D.d(Z,"clearCurrentCues",function(){return z}),D.d(Z,"removeCuesInRange",function(){return W}),D.d(Z,"getCuesInRange",function(){return R});var $=D("./src/utils/logger.ts");function B(y,A){var O;try{O=new Event("addtrack")}catch(L){O=document.createEvent("Event"),O.initEvent("addtrack",!1,!1)}O.track=y,A.dispatchEvent(O)}function M(y,A){var O=y.mode;if(O==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(A.id))try{if(y.addCue(A),!y.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(C){$.logger.debug("[texttrack-utils]: "+C);var L=new self.TextTrackCue(A.startTime,A.endTime,A.text);L.id=A.id,y.addCue(L)}O==="disabled"&&(y.mode=O)}function z(y){var A=y.mode;if(A==="disabled"&&(y.mode="hidden"),y.cues)for(var O=y.cues.length;O--;)y.removeCue(y.cues[O]);A==="disabled"&&(y.mode=A)}function W(y,A,O){var L=y.mode;if(L==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var C=R(y.cues,A,O),T=0;T<C.length;T++)y.removeCue(C[T]);L==="disabled"&&(y.mode=L)}function P(y,A){if(A<y[0].startTime)return 0;var O=y.length-1;if(A>y[O].endTime)return-1;for(var L=0,C=O;L<=C;){var T=Math.floor((C+L)/2);if(A<y[T].startTime)C=T-1;else if(A>y[T].startTime&&L<O)L=T+1;else return T}return y[L].startTime-A<A-y[C].startTime?L:C}function R(y,A,O){var L=[],C=P(y,A);if(C>-1)for(var T=C,h=y.length;T<h;T++){var o=y[T];if(o.startTime>=A&&o.endTime<=O)L.push(o);else if(o.startTime>O)return L}return L}},"./src/utils/time-ranges.ts":function(oe,Z,D){"use strict";D.r(Z);var $={toString:function(M){for(var z="",W=M.length,P=0;P<W;P++)z+="["+M.start(P).toFixed(3)+","+M.end(P).toFixed(3)+"]";return z}};Z.default=$},"./src/utils/timescale-conversion.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"toTimescaleFromBase",function(){return B}),D.d(Z,"toTimescaleFromScale",function(){return M}),D.d(Z,"toMsFromMpegTsClock",function(){return z}),D.d(Z,"toMpegTsClockFromTimescale",function(){return W});var $=9e4;function B(P,R,y,A){y===void 0&&(y=1),A===void 0&&(A=!1);var O=P*R*y;return A?Math.round(O):O}function M(P,R,y,A){return y===void 0&&(y=1),A===void 0&&(A=!1),B(P,R,1/y,A)}function z(P,R){return R===void 0&&(R=!1),B(P,1e3,1/$,R)}function W(P,R){return R===void 0&&(R=1),B(P,$,1/R)}},"./src/utils/typed-array.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"sliceUint8",function(){return $});function $(B,M,z){return Uint8Array.prototype.slice?B.slice(M,z):new Uint8Array(Array.prototype.slice.call(B,M,z))}},"./src/utils/vttcue.ts":function(oe,Z,D){"use strict";D.r(Z),Z.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var $=["","lr","rl"],B=["start","middle","end","left","right"];function M(y,A){if(typeof A!="string")return!1;if(!Array.isArray(y))return!1;var O=A.toLowerCase();return~y.indexOf(O)?O:!1}function z(y){return M($,y)}function W(y){return M(B,y)}function P(y){for(var A=arguments.length,O=new Array(A>1?A-1:0),L=1;L<A;L++)O[L-1]=arguments[L];for(var C=1;C<arguments.length;C++){var T=arguments[C];for(var h in T)y[h]=T[h]}return y}function R(y,A,O){var L=this,C={enumerable:!0};L.hasBeenReset=!1;var T="",h=!1,o=y,l=A,d=O,w=null,v="",g=!0,k="auto",E="start",p=50,c="middle",u=50,a="middle";Object.defineProperty(L,"id",P({},C,{get:function(){return T},set:function(m){T=""+m}})),Object.defineProperty(L,"pauseOnExit",P({},C,{get:function(){return h},set:function(m){h=!!m}})),Object.defineProperty(L,"startTime",P({},C,{get:function(){return o},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");o=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",P({},C,{get:function(){return l},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",P({},C,{get:function(){return d},set:function(m){d=""+m,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",P({},C,{get:function(){return w},set:function(m){w=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",P({},C,{get:function(){return v},set:function(m){var x=z(m);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");v=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",P({},C,{get:function(){return g},set:function(m){g=!!m,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",P({},C,{get:function(){return k},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");k=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",P({},C,{get:function(){return E},set:function(m){var x=W(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");E=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",P({},C,{get:function(){return p},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");p=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",P({},C,{get:function(){return c},set:function(m){var x=W(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");c=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",P({},C,{get:function(){return u},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");u=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",P({},C,{get:function(){return a},set:function(m){var x=W(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");a=x,this.hasBeenReset=!0}})),L.displayState=void 0}return R.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},R}()},"./src/utils/vttparser.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"parseTimeStamp",function(){return M}),D.d(Z,"fixLineBreaks",function(){return A}),D.d(Z,"VTTParser",function(){return O});var $=D("./src/utils/vttcue.ts"),B=function(){function L(){}var C=L.prototype;return C.decode=function(h,o){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},L}();function M(L){function C(h,o,l,d){return(h|0)*3600+(o|0)*60+(l|0)+parseFloat(d||0)}var T=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return T?parseFloat(T[2])>59?C(T[2],T[3],0,T[4]):C(T[1],T[2],T[3],T[4]):null}var z=function(){function L(){this.values=Object.create(null)}var C=L.prototype;return C.set=function(h,o){!this.get(h)&&o!==""&&(this.values[h]=o)},C.get=function(h,o,l){return l?this.has(h)?this.values[h]:o[l]:this.has(h)?this.values[h]:o},C.has=function(h){return h in this.values},C.alt=function(h,o,l){for(var d=0;d<l.length;++d)if(o===l[d]){this.set(h,o);break}},C.integer=function(h,o){/^-?\d+$/.test(o)&&this.set(h,parseInt(o,10))},C.percent=function(h,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var l=parseFloat(o);if(l>=0&&l<=100)return this.set(h,l),!0}return!1},L}();function W(L,C,T,h){var o=h?L.split(h):[L];for(var l in o){if(typeof o[l]!="string")continue;var d=o[l].split(T);if(d.length!==2)continue;var w=d[0],v=d[1];C(w,v)}}var P=new $.default(0,0,""),R=P.align==="middle"?"middle":"center";function y(L,C,T){var h=L;function o(){var w=M(L);if(w===null)throw new Error("Malformed timestamp: "+h);return L=L.replace(/^[^\sa-zA-Z-]+/,""),w}function l(w,v){var g=new z;W(w,function(p,c){var u;switch(p){case"region":for(var a=T.length-1;a>=0;a--)if(T[a].id===c){g.set(p,T[a].region);break}break;case"vertical":g.alt(p,c,["rl","lr"]);break;case"line":u=c.split(","),g.integer(p,u[0]),g.percent(p,u[0])&&g.set("snapToLines",!1),g.alt(p,u[0],["auto"]),u.length===2&&g.alt("lineAlign",u[1],["start",R,"end"]);break;case"position":u=c.split(","),g.percent(p,u[0]),u.length===2&&g.alt("positionAlign",u[1],["start",R,"end","line-left","line-right","auto"]);break;case"size":g.percent(p,c);break;case"align":g.alt(p,c,["start",R,"end","left","right"]);break}},/:/,/\s/),v.region=g.get("region",null),v.vertical=g.get("vertical","");var k=g.get("line","auto");k==="auto"&&P.line===-1&&(k=-1),v.line=k,v.lineAlign=g.get("lineAlign","start"),v.snapToLines=g.get("snapToLines",!0),v.size=g.get("size",100),v.align=g.get("align",R);var E=g.get("position","auto");E==="auto"&&P.position===50&&(E=v.align==="start"||v.align==="left"?0:v.align==="end"||v.align==="right"?100:50),v.position=E}function d(){L=L.replace(/^\s+/,"")}if(d(),C.startTime=o(),d(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);L=L.substr(3),d(),C.endTime=o(),d(),l(L,C)}function A(L){return L.replace(/<br(?: \/)?>/gi,`
`)}var O=function(){function L(){this.state="INITIAL",this.buffer="",this.decoder=new B,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var C=L.prototype;return C.parse=function(h){var o=this;h&&(o.buffer+=o.decoder.decode(h,{stream:!0}));function l(){var E=o.buffer,p=0;for(E=A(E);p<E.length&&E[p]!=="\r"&&E[p]!==`
`;)++p;var c=E.substr(0,p);return E[p]==="\r"&&++p,E[p]===`
`&&++p,o.buffer=E.substr(p),c}function d(E){W(E,function(p,c){},/:/)}try{var w="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;w=l();var v=w.match(/^()?WEBVTT([ \t].*)?$/);if(!v||!v[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var g=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;g?g=!1:w=l();switch(o.state){case"HEADER":/:/.test(w)?d(w):w||(o.state="ID");continue;case"NOTE":w||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(w)){o.state="NOTE";break}if(!w)continue;if(o.cue=new $.default(0,0,""),o.state="CUE",w.indexOf("-->")===-1){o.cue.id=w;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{y(w,o.cue,o.regionList)}catch(E){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var k=w.indexOf("-->")!==-1;if(!w||k&&(g=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
`),o.cue.text+=w}continue;case"BADCUE":w||(o.state="ID")}}}catch(E){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},C.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){h.onparsingerror&&h.onparsingerror(o)}return h.onflush&&h.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(oe,Z,D){"use strict";D.r(Z),D.d(Z,"generateCueId",function(){return O}),D.d(Z,"parseWebVTT",function(){return C});var $=D("./src/polyfills/number.ts"),B=D("./src/utils/vttparser.ts"),M=D("./src/demux/id3.ts"),z=D("./src/utils/timescale-conversion.ts"),W=D("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,R=function(h,o,l){return l===void 0&&(l=0),h.substr(l,o.length)===o},y=function(h){var o=parseInt(h.substr(-3)),l=parseInt(h.substr(-6,2)),d=parseInt(h.substr(-9,2)),w=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object($.isFiniteNumber)(o)||!Object($.isFiniteNumber)(l)||!Object($.isFiniteNumber)(d)||!Object($.isFiniteNumber)(w))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*l,o+=60*1e3*d,o+=60*60*1e3*w,o},A=function(h){for(var o=5381,l=h.length;l;)o=o*33^h.charCodeAt(--l);return(o>>>0).toString()};function O(T,h,o){return A(T.toString())+A(h.toString())+A(o)}var L=function(h,o,l){var d=h[o],w=h[d.prevCC];if(!w||!w.new&&d.new){h.ccOffset=h.presentationOffset=d.start,d.new=!1;return}for(;(v=w)!==null&&v!==void 0&&v.new;){var v;h.ccOffset+=d.start-w.start,d.new=!1,d=w,w=h[d.prevCC]}h.presentationOffset=l};function C(T,h,o,l,d,w,v,g){var k=new B.VTTParser,E=Object(M.utf8ArrayToStr)(new Uint8Array(T)).trim().replace(P,`
`).split(`
`),p=[],c=Object(z.toMpegTsClockFromTimescale)(h,o),u="00:00.000",a=0,b=0,m,x=!0,F=!1;k.oncue=function(U){var K=l[d],V=l.ccOffset,_=(a-c)/9e4;if(K!=null&&K.new&&(b!==void 0?V=l.ccOffset=K.start:L(l,d,_)),_&&(V=_-l.presentationOffset),F){var I=U.endTime-U.startTime,Y=Object(W.normalizePts)((U.startTime+V-b)*9e4,w*9e4)/9e4;U.startTime=Y,U.endTime=Y+I}var ee=U.text.trim();U.text=decodeURIComponent(encodeURIComponent(ee)),U.id||(U.id=O(U.startTime,U.endTime,ee)),U.endTime>0&&p.push(U)},k.onparsingerror=function(U){m=U},k.onflush=function(){if(m){g(m);return}v(p)},E.forEach(function(U){if(x)if(R(U,"X-TIMESTAMP-MAP=")){x=!1,F=!0,U.substr(16).split(",").forEach(function(K){R(K,"LOCAL:")?u=K.substr(6):R(K,"MPEGTS:")&&(a=parseInt(K.substr(7)))});try{b=y(u)/1e3}catch(K){F=!1,m=K}return}else U===""&&(x=!1);k.parse(U+`
`)}),k.flush()}},"./src/utils/xhr-loader.ts":function(oe,Z,D){"use strict";D.r(Z);var $=D("./src/utils/logger.ts"),B=D("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,z=function(){function W(R){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=R?R.xhrSetup:null,this.stats=new B.LoadStats,this.retryDelay=0}var P=W.prototype;return P.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},P.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},P.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},P.load=function(y,A,O){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=A,this.callbacks=O,this.retryDelay=A.retryDelay,this.loadInternal()},P.loadInternal=function(){var y=this.config,A=this.context;if(!y)return;var O=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var C=this.xhrSetup;try{if(C)try{C(O,A.url)}catch(o){O.open("GET",A.url,!0),C(O,A.url)}O.readyState||O.open("GET",A.url,!0);var T=this.context.headers;if(T)for(var h in T)O.setRequestHeader(h,T[h])}catch(o){this.callbacks.onError({code:O.status,text:o.message},A,O);return}A.rangeEnd&&O.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),O.onreadystatechange=this.readystatechange.bind(this),O.onprogress=this.loadprogress.bind(this),O.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),O.send()},P.readystatechange=function(){var y=this.context,A=this.loader,O=this.stats;if(!y||!A)return;var L=A.readyState,C=this.config;if(O.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),O.loading.first===0&&(O.loading.first=Math.max(self.performance.now(),O.loading.start)),L===4){A.onreadystatechange=null,A.onprogress=null;var T=A.status;if(T>=200&&T<300){O.loading.end=Math.max(self.performance.now(),O.loading.first);var h,o;if(y.responseType==="arraybuffer"?(h=A.response,o=h.byteLength):(h=A.responseText,o=h.length),O.loaded=O.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(O,y,h,A),!this.callbacks)return;var d={url:A.responseURL,data:h};this.callbacks.onSuccess(d,O,y,A)}else O.retry>=C.maxRetry||T>=400&&T<499?($.logger.error(T+" while loading "+y.url),this.callbacks.onError({code:T,text:A.statusText},y,A)):($.logger.warn(T+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,C.maxRetryDelay),O.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),C.timeout)},P.loadtimeout=function(){$.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},P.loadprogress=function(y){var A=this.stats;A.loaded=y.loaded,y.lengthComputable&&(A.total=y.total)},P.getCacheAge=function(){var y=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");y=A?parseFloat(A):null}return y},W}();Z.default=z}}).default})},vHTk:function(xt,it,se){xt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},wzkS:function(xt,it,se){"use strict";se.d(it,"c",function(){return B}),se.d(it,"b",function(){return M}),se.d(it,"d",function(){return z}),se.d(it,"a",function(){return P}),se.d(it,"e",function(){return R});var oe=se("9og8"),Z=se("WmNS"),D=se.n(Z),$=se("ErOA");function B(y){return Object($.c)("libraries/".concat(y,".json"))}function M(){return Object($.c)("library_tags.json")}function z(y){return W.apply(this,arguments)}function W(){return W=Object(oe.a)(D.a.mark(function y(A){var O;return D.a.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,Object($.b)("attachments/".concat(A,".json"));case 2:return O=C.sent,C.abrupt("return",O.status===0);case 4:case"end":return C.stop()}},y)})),W.apply(this,arguments)}function P(y){return Object($.f)("libraries.json",y)}function R(y,A){return Object($.g)("libraries/".concat(y,".json"),A)}}}]);