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

431 lines
1.0 MiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[160,5,7],{"+NIl":function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){"use strict";ae.defineMode("stex",function(Z,k){"use strict";function V(h,a){h.cmdState.push(a)}function F(h){return h.cmdState.length>0?h.cmdState[h.cmdState.length-1]:null}function D(h){var a=h.cmdState.pop();a&&a.closeBracket()}function G(h){for(var a=h.cmdState,c=a.length-1;c>=0;c--){var o=a[c];if(o.name=="DEFAULT")continue;return o}return{styleIdentifier:function(){return null}}}function j(h,a,c){return function(){this.name=h,this.bracketNo=0,this.style=a,this.styles=c,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var M={};M.importmodule=j("importmodule","tag",["string","builtin"]),M.documentclass=j("documentclass","tag",["","atom"]),M.usepackage=j("usepackage","tag",["atom"]),M.begin=j("begin","tag",["atom"]),M.end=j("end","tag",["atom"]),M.label=j("label","tag",["atom"]),M.ref=j("ref","tag",["atom"]),M.eqref=j("eqref","tag",["atom"]),M.cite=j("cite","tag",["atom"]),M.bibitem=j("bibitem","tag",["atom"]),M.Bibitem=j("Bibitem","tag",["atom"]),M.RBibitem=j("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function I(h,a){h.f=a}function g(h,a){var c;if(h.match(/^\\[a-zA-Z@]+/)){var o=h.current().slice(1);return c=M.hasOwnProperty(o)?M[o]:M.DEFAULT,c=new c,V(a,c),I(a,f),c.style}if(h.match(/^\\[$&%#{}_]/))return"tag";if(h.match(/^\\[,;!\/\\]/))return"tag";if(h.match("\\["))return I(a,function(l,d){return p(l,d,"\\]")}),"keyword";if(h.match("\\("))return I(a,function(l,d){return p(l,d,"\\)")}),"keyword";if(h.match("$$"))return I(a,function(l,d){return p(l,d,"$$")}),"keyword";if(h.match("$"))return I(a,function(l,d){return p(l,d,"$")}),"keyword";var s=h.next();if(s=="%")return h.skipToEnd(),"comment";if(s=="}"||s=="]"){if(c=F(a),c)c.closeBracket(s),I(a,f);else return"error";return"bracket"}else return s=="{"||s=="["?(c=M.DEFAULT,c=new c,V(a,c),"bracket"):/\d/.test(s)?(h.eatWhile(/[\w.%]/),"atom"):(h.eatWhile(/[\w\-_]/),c=G(a),c.name=="begin"&&(c.argument=h.current()),c.styleIdentifier())}function p(h,a,c){if(h.eatSpace())return null;if(c&&h.match(c))return I(a,g),"keyword";if(h.match(/^\\[a-zA-Z@]+/))return"tag";if(h.match(/^[a-zA-Z]+/))return"variable-2";if(h.match(/^\\[$&%#{}_]/))return"tag";if(h.match(/^\\[,;!\/]/))return"tag";if(h.match(/^[\^_&]/))return"tag";if(h.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(h.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var o=h.next();return o=="{"||o=="}"||o=="["||o=="]"||o=="("||o==")"?"bracket":o=="%"?(h.skipToEnd(),"comment"):"error"}function f(h,a){var c=h.peek(),o;return c=="{"||c=="["?(o=F(a),o.openBracket(c),h.eat(c),I(a,g),"bracket"):/[ \t\r]/.test(c)?(h.eat(c),null):(I(a,g),D(a),g(h,a))}return{startState:function(){var h=k.inMathMode?function(a,c){return p(a,c)}:g;return{cmdState:[],f:h}},copyState:function(h){return{cmdState:h.cmdState.slice(),f:h.f}},token:function(h,a){return a.f(h,a)},blankLine:function(h){h.f=g,h.cmdState.length=0},lineComment:"%"}}),ae.defineMIME("text/x-stex","stex"),ae.defineMIME("text/x-latex","stex")})},"+ua5":function(_t,lt,ne){},"19Vz":function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){ae.defineOption("placeholder","",function(j,M,I){var g=I&&I!=ae.Init;if(M&&!g)j.on("blur",F),j.on("change",D),j.on("swapDoc",D),ae.on(j.getInputField(),"compositionupdate",j.state.placeholderCompose=function(){V(j)}),D(j);else if(!M&&g){j.off("blur",F),j.off("change",D),j.off("swapDoc",D),ae.off(j.getInputField(),"compositionupdate",j.state.placeholderCompose),Z(j);var p=j.getWrapperElement();p.className=p.className.replace(" CodeMirror-empty","")}M&&!j.hasFocus()&&F(j)});function Z(j){j.state.placeholder&&(j.state.placeholder.parentNode.removeChild(j.state.placeholder),j.state.placeholder=null)}function k(j){Z(j);var M=j.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=j.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var I=j.getOption("placeholder");typeof I=="string"&&(I=document.createTextNode(I)),M.appendChild(I),j.display.lineSpace.insertBefore(M,j.display.lineSpace.firstChild)}function V(j){setTimeout(function(){var M=!1,I=j.getInputField();I.nodeName=="TEXTAREA"?M=!I.value:j.lineCount()==1&&(M=!/[^\u200b]/.test(I.querySelector(".CodeMirror-line").textContent)),M?k(j):Z(j)},20)}function F(j){G(j)&&k(j)}function D(j){var M=j.getWrapperElement(),I=G(j);M.className=M.className.replace(" CodeMirror-empty","")+(I?" CodeMirror-empty":""),I?k(j):Z(j)}function G(j){return j.lineCount()===1&&j.getLine(0)===""}})},"1eCo":function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){"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},k={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ae.defineMode("xml",function(V,F){var D=V.indentUnit,G={},j=F.htmlMode?Z:k;for(var M in j)G[M]=j[M];for(var M in F)G[M]=F[M];var I,g;function p(u,_){function m(N){return _.tokenize=N,N(u,_)}var b=u.next();if(b=="<")return u.eat("!")?u.eat("[")?u.match("CDATA[")?m(a("atom","]]>")):null:u.match("--")?m(a("comment","-->")):u.match("DOCTYPE",!0,!0)?(u.eatWhile(/[\w\._\-]/),m(c(1))):null:u.eat("?")?(u.eatWhile(/[\w\._\-]/),_.tokenize=a("meta","?>"),"meta"):(I=u.eat("/")?"closeTag":"openTag",_.tokenize=f,"tag bracket");if(b=="&"){var P;return u.eat("#")?u.eat("x")?P=u.eatWhile(/[a-fA-F\d]/)&&u.eat(";"):P=u.eatWhile(/[\d]/)&&u.eat(";"):P=u.eatWhile(/[\w\.\-:]/)&&u.eat(";"),P?"atom":"error"}else return u.eatWhile(/[^&<]/),null}p.isInText=!0;function f(u,_){var m=u.next();if(m==">"||m=="/"&&u.eat(">"))return _.tokenize=p,I=m==">"?"endTag":"selfcloseTag","tag bracket";if(m=="=")return I="equals",null;if(m=="<"){_.tokenize=p,_.state=d,_.tagName=_.tagStart=null;var b=_.tokenize(u,_);return b?b+" tag error":"tag error"}else return/[\'\"]/.test(m)?(_.tokenize=h(m),_.stringStartCol=u.column(),_.tokenize(u,_)):(u.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function h(u){var _=function(m,b){for(;!m.eol();)if(m.next()==u){b.tokenize=f;break}return"string"};return _.isInAttribute=!0,_}function a(u,_){return function(m,b){for(;!m.eol();){if(m.match(_)){b.tokenize=p;break}m.next()}return u}}function c(u){return function(_,m){for(var b;(b=_.next())!=null;){if(b=="<")return m.tokenize=c(u+1),m.tokenize(_,m);if(b==">")if(u==1){m.tokenize=p;break}else return m.tokenize=c(u-1),m.tokenize(_,m)}return"meta"}}function o(u,_,m){this.prev=u.context,this.tagName=_,this.indent=u.indented,this.startOfLine=m,(G.doNotIndent.hasOwnProperty(_)||u.context&&u.context.noIndent)&&(this.noIndent=!0)}function s(u){u.context&&(u.context=u.context.prev)}function l(u,_){for(var m;;){if(!u.context)return;if(m=u.context.tagName,!G.contextGrabbers.hasOwnProperty(m)||!G.contextGrabbers[m].hasOwnProperty(_))return;s(u)}}function d(u,_,m){return u=="openTag"?(m.tagStart=_.column(),O):u=="closeTag"?w:d}function O(u,_,m){return u=="word"?(m.tagName=_.current(),g="tag",A):G.allowMissingTagName&&u=="endTag"?(g="tag bracket",A(u,_,m)):(g="error",O)}function w(u,_,m){if(u=="word"){var b=_.current();return m.context&&m.context.tagName!=b&&G.implicitlyClosed.hasOwnProperty(m.context.tagName)&&s(m),m.context&&m.context.tagName==b||G.matchClosing===!1?(g="tag",x):(g="tag error",R)}else return G.allowMissingTagName&&u=="endTag"?(g="tag bracket",x(u,_,m)):(g="error",R)}function x(u,_,m){return u!="endTag"?(g="error",x):(s(m),d)}function R(u,_,m){return g="error",x(u,_,m)}function A(u,_,m){if(u=="word")return g="attribute",T;if(u=="endTag"||u=="selfcloseTag"){var b=m.tagName,P=m.tagStart;return m.tagName=m.tagStart=null,u=="selfcloseTag"||G.autoSelfClosers.hasOwnProperty(b)?l(m,b):(l(m,b),m.context=new o(m,b,P==m.indented)),d}return g="error",A}function T(u,_,m){return u=="equals"?E:(G.allowMissing||(g="error"),A(u,_,m))}function E(u,_,m){return u=="string"?y:u=="word"&&G.allowUnquoted?(g="string",A):(g="error",A(u,_,m))}function y(u,_,m){return u=="string"?y:A(u,_,m)}return{startState:function(u){var _={tokenize:p,state:d,indented:u||0,tagName:null,tagStart:null,context:null};return u!=null&&(_.baseIndent=u),_},token:function(u,_){if(!_.tagName&&u.sol()&&(_.indented=u.indentation()),u.eatSpace())return null;I=null;var m=_.tokenize(u,_);return(m||I)&&m!="comment"&&(g=null,_.state=_.state(I||m,u,_),g&&(m=g=="error"?m+" error":g)),m},indent:function(u,_,m){var b=u.context;if(u.tokenize.isInAttribute)return u.tagStart==u.indented?u.stringStartCol+1:u.indented+D;if(b&&b.noIndent)return ae.Pass;if(u.tokenize!=f&&u.tokenize!=p)return m?m.match(/^(\s*)/)[0].length:0;if(u.tagName)return G.multilineTagIndentPastTag!==!1?u.tagStart+u.tagName.length+2:u.tagStart+D*(G.multilineTagIndentFactor||1);if(G.alignCDATA&&/<!\[CDATA\[/.test(_))return 0;var P=_&&/^<(\/)?([\w_:\.-]*)/.exec(_);if(P&&P[1])for(;b;)if(b.tagName==P[2]){b=b.prev;break}else if(G.implicitlyClosed.hasOwnProperty(b.tagName))b=b.prev;else break;else if(P)for(;b;){var N=G.contextGrabbers[b.tagName];if(N&&N.hasOwnProperty(P[2]))b=b.prev;else break}for(;b&&b.prev&&!b.startOfLine;)b=b.prev;return b?b.indent+D:u.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:G.htmlMode?"html":"xml",helperType:G.htmlMode?"html":"xml",skipAttribute:function(u){u.state==E&&(u.state=A)},xmlCurrentTag:function(u){return u.tagName?{name:u.tagName,close:u.type=="closeTag"}:null},xmlCurrentContext:function(u){for(var _=[],m=u.context;m;m=m.prev)m.tagName&&_.push(m.tagName);return _.reverse()}}}),ae.defineMIME("text/xml","xml"),ae.defineMIME("application/xml","xml"),ae.mimeModes.hasOwnProperty("text/html")||ae.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return l});var ae=ne("Ty5D"),Z=ne("dI71"),k=ne("q1tI"),V=ne.n(k),F=ne("YS25"),D=ne("17x9"),G=ne.n(D),j=ne("wx14"),M=ne("zLVn"),I=ne("9R94"),g=function(E){Object(Z.a)(y,E);function y(){for(var _,m=arguments.length,b=new Array(m),P=0;P<m;P++)b[P]=arguments[P];return _=E.call.apply(E,[this].concat(b))||this,_.history=Object(F.a)(_.props),_}var u=y.prototype;return u.render=function(){return V.a.createElement(ae.c,{history:this.history,children:this.props.children})},y}(V.a.Component),p=function(E){Object(Z.a)(y,E);function y(){for(var _,m=arguments.length,b=new Array(m),P=0;P<m;P++)b[P]=arguments[P];return _=E.call.apply(E,[this].concat(b))||this,_.history=Object(F.b)(_.props),_}var u=y.prototype;return u.render=function(){return V.a.createElement(ae.c,{history:this.history,children:this.props.children})},y}(V.a.Component),f=function(y,u){return typeof y=="function"?y(u):y},h=function(y,u){return typeof y=="string"?Object(F.c)(y,null,null,u):y},a=function(y){return y},c=V.a.forwardRef;typeof c=="undefined"&&(c=a);function o(E){return!!(E.metaKey||E.altKey||E.ctrlKey||E.shiftKey)}var s=c(function(E,y){var u=E.innerRef,_=E.navigate,m=E.onClick,b=Object(M.a)(E,["innerRef","navigate","onClick"]),P=b.target,N=Object(j.a)({},b,{onClick:function(X){try{m&&m(X)}catch(B){throw X.preventDefault(),B}!X.defaultPrevented&&X.button===0&&(!P||P==="_self")&&!o(X)&&(X.preventDefault(),_())}});return a!==c?N.ref=y||u:N.ref=u,V.a.createElement("a",N)}),l=c(function(E,y){var u=E.component,_=u===void 0?s:u,m=E.replace,b=E.to,P=E.innerRef,N=Object(M.a)(E,["component","replace","to","innerRef"]);return V.a.createElement(ae.e.Consumer,null,function(K){K||Object(I.a)(!1);var X=K.history,B=h(f(b,K.location),K.location),S=B?X.createHref(B):"",Y=Object(j.a)({},N,{href:S,navigate:function(){var re=f(b,K.location),ce=m?X.replace:X.push;ce(re)}});return a!==c?Y.ref=y||P:Y.innerRef=P,V.a.createElement(_,Y)})});if(!1)var d,O;var w=function(y){return y},x=V.a.forwardRef;typeof x=="undefined"&&(x=w);function R(){for(var E=arguments.length,y=new Array(E),u=0;u<E;u++)y[u]=arguments[u];return y.filter(function(_){return _}).join(" ")}var A=x(function(E,y){var u=E["aria-current"],_=u===void 0?"page":u,m=E.activeClassName,b=m===void 0?"active":m,P=E.activeStyle,N=E.className,K=E.exact,X=E.isActive,B=E.location,S=E.sensitive,Y=E.strict,te=E.style,re=E.to,ce=E.innerRef,Te=Object(M.a)(E,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return V.a.createElement(ae.e.Consumer,null,function(ye){ye||Object(I.a)(!1);var be=B||ye.location,we=h(f(re,be),be),xe=we.pathname,ve=xe&&xe.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),oe=ve?Object(ae.f)(be.pathname,{path:ve,exact:K,sensitive:S,strict:Y}):null,Re=!!(X?X(oe,be):oe),Ye=Re?R(N,b):N,Ue=Re?Object(j.a)({},te,{},P):te,rt=Object(j.a)({"aria-current":Re&&_||null,className:Ye,style:Ue,to:we},Te);return w!==x?rt.ref=y||ce:rt.innerRef=ce,V.a.createElement(l,rt)})});if(!1)var T},"5VLF":function(_t,lt,ne){"use strict";var ae,Z;function k(V,F,D){var G=function(j,M){return V.js_beautify(j,M)};return G.js=V.js_beautify,G.css=F.css_beautify,G.html=D.html_beautify,G.js_beautify=V.js_beautify,G.css_beautify=F.css_beautify,G.html_beautify=D.html_beautify,G}!(ae=[ne("6UM0"),ne("TXwP"),ne("psGv")],Z=function(V,F,D){return k(V,F,D)}.apply(lt,ae),Z!==void 0&&(_t.exports=Z))},"6UM0":function(_t,lt,ne){var ae,Z;(function(){var k;(function(){"use strict";var F=[function(M,I,g){var p=g(1).Beautifier,f=g(5).Options;function h(a,c){var o=new p(a,c);return o.beautify()}M.exports=h,M.exports.defaultOptions=function(){return new f}},function(M,I,g){var p=g(2).Output,f=g(3).Token,h=g(4),a=g(5).Options,c=g(7).Tokenizer,o=g(7).line_starters,s=g(7).positionable_operators,l=g(7).TOKEN;function d(S,Y){return Y.indexOf(S)!==-1}function O(S){return S.replace(/^\s+/g,"")}function w(S){for(var Y={},te=0;te<S.length;te++)Y[S[te].replace(/-/g,"_")]=S[te];return Y}function x(S,Y){return S&&S.type===l.RESERVED&&S.text===Y}function R(S,Y){return S&&S.type===l.RESERVED&&d(S.text,Y)}var A=["case","return","do","if","throw","else","await","break","continue","async"],T=["before-newline","after-newline","preserve-newline"],E=w(T),y=[E.before_newline,E.preserve_newline],u={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"};function _(S,Y){if(Y.multiline_frame||Y.mode===u.ForInitializer||Y.mode===u.Conditional)return;S.remove_indent(Y.start_line_index)}function m(S){S=S.replace(h.allLineBreaks,`
`);for(var Y=[],te=S.indexOf(`
`);te!==-1;)Y.push(S.substring(0,te)),S=S.substring(te+1),te=S.indexOf(`
`);return S.length&&Y.push(S),Y}function b(S){return S===u.ArrayLiteral}function P(S){return d(S,[u.Expression,u.ForInitializer,u.Conditional])}function N(S,Y){for(var te=0;te<S.length;te++){var re=S[te].trim();if(re.charAt(0)!==Y)return!1}return!0}function K(S,Y){for(var te=0,re=S.length,ce;te<re;te++)if(ce=S[te],ce&&ce.indexOf(Y)!==0)return!1;return!0}function X(S,Y){Y=Y||{},this._source_text=S||"",this._output=null,this._tokens=null,this._last_last_text=null,this._flags=null,this._previous_flags=null,this._flag_store=null,this._options=new a(Y)}X.prototype.create_flags=function(S,Y){var te=0;S&&(te=S.indentation_level,!this._output.just_added_newline()&&S.line_indent_level>te&&(te=S.line_indent_level));var re={mode:Y,parent:S,last_token:S?S.last_token:new f(l.START_BLOCK,""),last_word:S?S.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,class_start_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,case_block:!1,indentation_level:te,alignment:0,line_indent_level:S?S.line_indent_level:te,start_line_index:this._output.get_line_number(),ternary_depth:0};return re},X.prototype._reset=function(S){var Y=S.match(/^[\t ]*/)[0];this._last_last_text="",this._output=new p(this._options,Y),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(u.BlockStatement);var te=new c(S,this._options);return this._tokens=te.tokenize(),S},X.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var S,Y=this._reset(this._source_text),te=this._options.eol;this._options.eol==="auto"&&(te=`
`,Y&&h.lineBreak.test(Y||"")&&(te=Y.match(h.lineBreak)[0]));for(var re=this._tokens.next();re;)this.handle_token(re),this._last_last_text=this._flags.last_token.text,this._flags.last_token=re,re=this._tokens.next();return S=this._output.get_code(te),S},X.prototype.handle_token=function(S,Y){S.type===l.START_EXPR?this.handle_start_expr(S):S.type===l.END_EXPR?this.handle_end_expr(S):S.type===l.START_BLOCK?this.handle_start_block(S):S.type===l.END_BLOCK?this.handle_end_block(S):S.type===l.WORD?this.handle_word(S):S.type===l.RESERVED?this.handle_word(S):S.type===l.SEMICOLON?this.handle_semicolon(S):S.type===l.STRING?this.handle_string(S):S.type===l.EQUALS?this.handle_equals(S):S.type===l.OPERATOR?this.handle_operator(S):S.type===l.COMMA?this.handle_comma(S):S.type===l.BLOCK_COMMENT?this.handle_block_comment(S,Y):S.type===l.COMMENT?this.handle_comment(S,Y):S.type===l.DOT?this.handle_dot(S):S.type===l.EOF?this.handle_eof(S):S.type===l.UNKNOWN?this.handle_unknown(S,Y):this.handle_unknown(S,Y)},X.prototype.handle_whitespace_and_comments=function(S,Y){var te=S.newlines,re=this._options.keep_array_indentation&&b(this._flags.mode);if(S.comments_before)for(var ce=S.comments_before.next();ce;)this.handle_whitespace_and_comments(ce,Y),this.handle_token(ce,Y),ce=S.comments_before.next();if(re)for(var Te=0;Te<te;Te+=1)this.print_newline(Te>0,Y);else if(this._options.max_preserve_newlines&&te>this._options.max_preserve_newlines&&(te=this._options.max_preserve_newlines),this._options.preserve_newlines&&te>1){this.print_newline(!1,Y);for(var ye=1;ye<te;ye+=1)this.print_newline(!0,Y)}};var B=["async","break","continue","return","throw","yield"];X.prototype.allow_wrap_or_preserved_newline=function(S,Y){if(Y=Y===void 0?!1:Y,this._output.just_added_newline())return;var te=this._options.preserve_newlines&&S.newlines||Y,re=d(this._flags.last_token.text,s)||d(S.text,s);if(re){var ce=d(this._flags.last_token.text,s)&&d(this._options.operator_position,y)||d(S.text,s);te=te&&ce}if(te)this.print_newline(!1,!0);else if(this._options.wrap_line_length){if(R(this._flags.last_token,B))return;this._output.set_wrap_point()}},X.prototype.print_newline=function(S,Y){if(!Y&&(this._flags.last_token.text!==";"&&this._flags.last_token.text!==","&&this._flags.last_token.text!=="="&&(this._flags.last_token.type!==l.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++")))for(var te=this._tokens.peek();this._flags.mode===u.Statement&&!(this._flags.if_block&&x(te,"else"))&&!this._flags.do_block;)this.restore_mode();this._output.add_new_line(S)&&(this._flags.multiline_frame=!0)},X.prototype.print_token_line_indentation=function(S){this._output.just_added_newline()&&(this._options.keep_array_indentation&&S.newlines&&(S.text==="["||b(this._flags.mode))?(this._output.current_line.set_indent(-1),this._output.current_line.push(S.whitespace_before),this._output.space_before_token=!1):this._output.set_indent(this._flags.indentation_level,this._flags.alignment)&&(this._flags.line_indent_level=this._flags.indentation_level))},X.prototype.print_token=function(S){if(this._output.raw){this._output.add_raw_token(S);return}if(this._options.comma_first&&S.previous&&S.previous.type===l.COMMA&&this._output.just_added_newline()&&this._output.previous_line.last()===","){var Y=this._output.previous_line.pop();this._output.previous_line.is_empty()&&(this._output.previous_line.push(Y),this._output.trim(!0),this._output.current_line.pop(),this._output.trim()),this.print_token_line_indentation(S),this._output.add_token(","),this._output.space_before_token=!0}this.print_token_line_indentation(S),this._output.non_breaking_space=!0,this._output.add_token(S.text),this._output.previous_token_wrapped&&(this._flags.multiline_frame=!0)},X.prototype.indent=function(){this._flags.indentation_level+=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},X.prototype.deindent=function(){this._flags.indentation_level>0&&(!this._flags.parent||this._flags.indentation_level>this._flags.parent.indentation_level)&&(this._flags.indentation_level-=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},X.prototype.set_mode=function(S){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,S),this._flags=this.create_flags(this._previous_flags,S),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},X.prototype.restore_mode=function(){this._flag_store.length>0&&(this._previous_flags=this._flags,this._flags=this._flag_store.pop(),this._previous_flags.mode===u.Statement&&_(this._output,this._previous_flags),this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},X.prototype.start_of_object_property=function(){return this._flags.parent.mode===u.ObjectLiteral&&this._flags.mode===u.Statement&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||R(this._flags.last_token,["get","set"]))},X.prototype.start_of_statement=function(S){var Y=!1;return Y=Y||R(this._flags.last_token,["var","let","const"])&&S.type===l.WORD,Y=Y||x(this._flags.last_token,"do"),Y=Y||!(this._flags.parent.mode===u.ObjectLiteral&&this._flags.mode===u.Statement)&&R(this._flags.last_token,B)&&!S.newlines,Y=Y||x(this._flags.last_token,"else")&&!(x(S,"if")&&!S.comments_before),Y=Y||this._flags.last_token.type===l.END_EXPR&&(this._previous_flags.mode===u.ForInitializer||this._previous_flags.mode===u.Conditional),Y=Y||this._flags.last_token.type===l.WORD&&this._flags.mode===u.BlockStatement&&!this._flags.in_case&&!(S.text==="--"||S.text==="++")&&this._last_last_text!=="function"&&S.type!==l.WORD&&S.type!==l.RESERVED,Y=Y||this._flags.mode===u.ObjectLiteral&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||R(this._flags.last_token,["get","set"])),Y?(this.set_mode(u.Statement),this.indent(),this.handle_whitespace_and_comments(S,!0),this.start_of_object_property()||this.allow_wrap_or_preserved_newline(S,R(S,["do","for","if","while"])),!0):!1},X.prototype.handle_start_expr=function(S){this.start_of_statement(S)||this.handle_whitespace_and_comments(S);var Y=u.Expression;if(S.text==="["){if(this._flags.last_token.type===l.WORD||this._flags.last_token.text===")"){R(this._flags.last_token,o)&&(this._output.space_before_token=!0),this.print_token(S),this.set_mode(Y),this.indent(),this._options.space_in_paren&&(this._output.space_before_token=!0);return}Y=u.ArrayLiteral,b(this._flags.mode)&&((this._flags.last_token.text==="["||this._flags.last_token.text===","&&(this._last_last_text==="]"||this._last_last_text==="}"))&&(this._options.keep_array_indentation||this.print_newline())),d(this._flags.last_token.type,[l.START_EXPR,l.END_EXPR,l.WORD,l.OPERATOR,l.DOT])||(this._output.space_before_token=!0)}else{if(this._flags.last_token.type===l.RESERVED)this._flags.last_token.text==="for"?(this._output.space_before_token=this._options.space_before_conditional,Y=u.ForInitializer):d(this._flags.last_token.text,["if","while","switch"])?(this._output.space_before_token=this._options.space_before_conditional,Y=u.Conditional):d(this._flags.last_word,["await","async"])?this._output.space_before_token=!0:this._flags.last_token.text==="import"&&S.whitespace_before===""?this._output.space_before_token=!1:(d(this._flags.last_token.text,o)||this._flags.last_token.text==="catch")&&(this._output.space_before_token=!0);else if(this._flags.last_token.type===l.EQUALS||this._flags.last_token.type===l.OPERATOR)this.start_of_object_property()||this.allow_wrap_or_preserved_newline(S);else if(this._flags.last_token.type===l.WORD){this._output.space_before_token=!1;var te=this._tokens.peek(-3);if(this._options.space_after_named_function&&te){var re=this._tokens.peek(-4);R(te,["async","function"])||te.text==="*"&&R(re,["async","function"])?this._output.space_before_token=!0:this._flags.mode===u.ObjectLiteral?(te.text==="{"||te.text===","||te.text==="*"&&(re.text==="{"||re.text===","))&&(this._output.space_before_token=!0):this._flags.parent&&this._flags.parent.class_start_block&&(this._output.space_before_token=!0)}}else this.allow_wrap_or_preserved_newline(S);(this._flags.last_token.type===l.RESERVED&&(this._flags.last_word==="function"||this._flags.last_word==="typeof")||this._flags.last_token.text==="*"&&(d(this._last_last_text,["function","yield"])||this._flags.mode===u.ObjectLiteral&&d(this._last_last_text,["{",","])))&&(this._output.space_before_token=this._options.space_after_anon_function)}this._flags.last_token.text===";"||this._flags.last_token.type===l.START_BLOCK?this.print_newline():(this._flags.last_token.type===l.END_EXPR||this._flags.last_token.type===l.START_EXPR||this._flags.last_token.type===l.END_BLOCK||this._flags.last_token.text==="."||this._flags.last_token.type===l.COMMA)&&this.allow_wrap_or_preserved_newline(S,S.newlines),this.print_token(S),this.set_mode(Y),this._options.space_in_paren&&(this._output.space_before_token=!0),this.indent()},X.prototype.handle_end_expr=function(S){for(;this._flags.mode===u.Statement;)this.restore_mode();this.handle_whitespace_and_comments(S),this._flags.multiline_frame&&this.allow_wrap_or_preserved_newline(S,S.text==="]"&&b(this._flags.mode)&&!this._options.keep_array_indentation),this._options.space_in_paren&&(this._flags.last_token.type===l.START_EXPR&&!this._options.space_in_empty_paren?(this._output.trim(),this._output.space_before_token=!1):this._output.space_before_token=!0),this.deindent(),this.print_token(S),this.restore_mode(),_(this._output,this._previous_flags),this._flags.do_while&&this._previous_flags.mode===u.Conditional&&(this._previous_flags.mode=u.Expression,this._flags.do_block=!1,this._flags.do_while=!1)},X.prototype.handle_start_block=function(S){this.handle_whitespace_and_comments(S);var Y=this._tokens.peek(),te=this._tokens.peek(1);this._flags.last_word==="switch"&&this._flags.last_token.type===l.END_EXPR?(this.set_mode(u.BlockStatement),this._flags.in_case_statement=!0):this._flags.case_body?this.set_mode(u.BlockStatement):te&&(d(te.text,[":",","])&&d(Y.type,[l.STRING,l.WORD,l.RESERVED])||d(Y.text,["get","set","..."])&&d(te.type,[l.WORD,l.RESERVED]))?d(this._last_last_text,["class","interface"])&&!d(te.text,[":",","])?this.set_mode(u.BlockStatement):this.set_mode(u.ObjectLiteral):this._flags.last_token.type===l.OPERATOR&&this._flags.last_token.text==="=>"?this.set_mode(u.BlockStatement):d(this._flags.last_token.type,[l.EQUALS,l.START_EXPR,l.COMMA,l.OPERATOR])||R(this._flags.last_token,["return","throw","import","default"])?this.set_mode(u.ObjectLiteral):this.set_mode(u.BlockStatement),this._flags.last_token&&(R(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0));var re=!Y.comments_before&&Y.text==="}",ce=re&&this._flags.last_word==="function"&&this._flags.last_token.type===l.END_EXPR;if(this._options.brace_preserve_inline){var Te=0,ye=null;this._flags.inline_frame=!0;do if(Te+=1,ye=this._tokens.peek(Te-1),ye.newlines){this._flags.inline_frame=!1;break}while(ye.type!==l.EOF&&!(ye.type===l.END_BLOCK&&ye.opened===S))}(this._options.brace_style==="expand"||this._options.brace_style==="none"&&S.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==l.OPERATOR&&(ce||this._flags.last_token.type===l.EQUALS||R(this._flags.last_token,A)&&this._flags.last_token.text!=="else")?this._output.space_before_token=!0:this.print_newline(!1,!0):(b(this._previous_flags.mode)&&(this._flags.last_token.type===l.START_EXPR||this._flags.last_token.type===l.COMMA)&&((this._flags.last_token.type===l.COMMA||this._options.space_in_paren)&&(this._output.space_before_token=!0),(this._flags.last_token.type===l.COMMA||this._flags.last_token.type===l.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(S),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==l.OPERATOR&&this._flags.last_token.type!==l.START_EXPR&&(this._flags.last_token.type===l.START_BLOCK&&!this._flags.inline_frame?this.print_newline():this._output.space_before_token=!0)),this.print_token(S),this.indent(),!re&&!(this._options.brace_preserve_inline&&this._flags.inline_frame)&&this.print_newline()},X.prototype.handle_end_block=function(S){for(this.handle_whitespace_and_comments(S);this._flags.mode===u.Statement;)this.restore_mode();var Y=this._flags.last_token.type===l.START_BLOCK;this._flags.inline_frame&&!Y?this._output.space_before_token=!0:this._options.brace_style==="expand"?Y||this.print_newline():Y||(b(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(S)},X.prototype.handle_word=function(S){if(S.type===l.RESERVED){if(d(S.text,["set","get"])&&this._flags.mode!==u.ObjectLiteral)S.type=l.WORD;else if(S.text==="import"&&d(this._tokens.peek().text,["(","."]))S.type=l.WORD;else if(d(S.text,["as","from"])&&!this._flags.import_block)S.type=l.WORD;else if(this._flags.mode===u.ObjectLiteral){var Y=this._tokens.peek();Y.text===":"&&(S.type=l.WORD)}}if(this.start_of_statement(S)?R(this._flags.last_token,["var","let","const"])&&S.type===l.WORD&&(this._flags.declaration_statement=!0):S.newlines&&!P(this._flags.mode)&&(this._flags.last_token.type!==l.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++")&&this._flags.last_token.type!==l.EQUALS&&(this._options.preserve_newlines||!R(this._flags.last_token,["var","let","const","set","get"]))?(this.handle_whitespace_and_comments(S),this.print_newline()):this.handle_whitespace_and_comments(S),this._flags.do_block&&!this._flags.do_while)if(x(S,"while")){this._output.space_before_token=!0,this.print_token(S),this._output.space_before_token=!0,this._flags.do_while=!0;return}else this.print_newline(),this._flags.do_block=!1;if(this._flags.if_block)if(!this._flags.else_block&&x(S,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===u.Statement;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}if(this._flags.in_case_statement&&R(S,["case","default"])){this.print_newline(),!this._flags.case_block&&(this._flags.case_body||this._options.jslint_happy)&&this.deindent(),this._flags.case_body=!1,this.print_token(S),this._flags.in_case=!0;return}if((this._flags.last_token.type===l.COMMA||this._flags.last_token.type===l.START_EXPR||this._flags.last_token.type===l.EQUALS||this._flags.last_token.type===l.OPERATOR)&&(this.start_of_object_property()||this.allow_wrap_or_preserved_newline(S)),x(S,"function")){(d(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!(d(this._flags.last_token.text,["(","[","{",":","=",","])||this._flags.last_token.type===l.OPERATOR))&&(!this._output.just_added_blankline()&&!S.comments_before&&(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===l.RESERVED||this._flags.last_token.type===l.WORD?R(this._flags.last_token,["get","set","new","export"])||R(this._flags.last_token,B)?this._output.space_before_token=!0:x(this._flags.last_token,"default")&&this._last_last_text==="export"?this._output.space_before_token=!0:this._flags.last_token.text==="declare"?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===l.OPERATOR||this._flags.last_token.text==="="?this._output.space_before_token=!0:!this._flags.multiline_frame&&(P(this._flags.mode)||b(this._flags.mode))||this.print_newline(),this.print_token(S),this._flags.last_word=S.text;return}var te="NONE";if(this._flags.last_token.type===l.END_BLOCK?this._previous_flags.inline_frame?te="SPACE":R(S,["else","catch","finally","from"])?this._options.brace_style==="expand"||this._options.brace_style==="end-expand"||this._options.brace_style==="none"&&S.newlines?te="NEWLINE":(te="SPACE",this._output.space_before_token=!0):te="NEWLINE":this._flags.last_token.type===l.SEMICOLON&&this._flags.mode===u.BlockStatement?te="NEWLINE":this._flags.last_token.type===l.SEMICOLON&&P(this._flags.mode)?te="SPACE":this._flags.last_token.type===l.STRING?te="NEWLINE":this._flags.last_token.type===l.RESERVED||this._flags.last_token.type===l.WORD||this._flags.last_token.text==="*"&&(d(this._last_last_text,["function","yield"])||this._flags.mode===u.ObjectLiteral&&d(this._last_last_text,["{",","]))?te="SPACE":this._flags.last_token.type===l.START_BLOCK?this._flags.inline_frame?te="SPACE":te="NEWLINE":this._flags.last_token.type===l.END_EXPR&&(this._output.space_before_token=!0,te="NEWLINE"),R(S,o)&&this._flags.last_token.text!==")"&&(this._flags.inline_frame||this._flags.last_token.text==="else"||this._flags.last_token.text==="export"?te="SPACE":te="NEWLINE"),R(S,["else","catch","finally"]))if((!(this._flags.last_token.type===l.END_BLOCK&&this._previous_flags.mode===u.BlockStatement)||this._options.brace_style==="expand"||this._options.brace_style==="end-expand"||this._options.brace_style==="none"&&S.newlines)&&!this._flags.inline_frame)this.print_newline();else{this._output.trim(!0);var re=this._output.current_line;re.last()!=="}"&&this.print_newline(),this._output.space_before_token=!0}else te==="NEWLINE"?R(this._flags.last_token,A)?this._output.space_before_token=!0:this._flags.last_token.text==="declare"&&R(S,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==l.END_EXPR?(this._flags.last_token.type!==l.START_EXPR||!R(S,["var","let","const"]))&&this._flags.last_token.text!==":"&&(x(S,"if")&&x(S.previous,"else")?this._output.space_before_token=!0:this.print_newline()):R(S,o)&&this._flags.last_token.text!==")"&&this.print_newline():this._flags.multiline_frame&&b(this._flags.mode)&&this._flags.last_token.text===","&&this._last_last_text==="}"?this.print_newline():te==="SPACE"&&(this._output.space_before_token=!0);S.previous&&(S.previous.type===l.WORD||S.previous.type===l.RESERVED)&&(this._output.space_before_token=!0),this.print_token(S),this._flags.last_word=S.text,S.type===l.RESERVED&&(S.text==="do"?this._flags.do_block=!0:S.text==="if"?this._flags.if_block=!0:S.text==="import"?this._flags.import_block=!0:this._flags.import_block&&x(S,"from")&&(this._flags.import_block=!1))},X.prototype.handle_semicolon=function(S){this.start_of_statement(S)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(S);for(var Y=this._tokens.peek();this._flags.mode===u.Statement&&!(this._flags.if_block&&x(Y,"else"))&&!this._flags.do_block;)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(S)},X.prototype.handle_string=function(S){S.text.startsWith("`")&&S.newlines===0&&S.whitespace_before===""&&(S.previous.text===")"||this._flags.last_token.type===l.WORD)||(this.start_of_statement(S)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(S),this._flags.last_token.type===l.RESERVED||this._flags.last_token.type===l.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===l.COMMA||this._flags.last_token.type===l.START_EXPR||this._flags.last_token.type===l.EQUALS||this._flags.last_token.type===l.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(S):S.text.startsWith("`")&&this._flags.last_token.type===l.END_EXPR&&(S.previous.text==="]"||S.previous.text===")")&&S.newlines===0?this._output.space_before_token=!0:this.print_newline())),this.print_token(S)},X.prototype.handle_equals=function(S){this.start_of_statement(S)||this.handle_whitespace_and_comments(S),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(S),this._output.space_before_token=!0},X.prototype.handle_comma=function(S){this.handle_whitespace_and_comments(S,!0),this.print_token(S),this._output.space_before_token=!0,this._flags.declaration_statement?(P(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(S)):this._flags.mode===u.ObjectLiteral||this._flags.mode===u.Statement&&this._flags.parent.mode===u.ObjectLiteral?(this._flags.mode===u.Statement&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(S)},X.prototype.handle_operator=function(S){var Y=S.text==="*"&&(R(this._flags.last_token,["function","yield"])||d(this._flags.last_token.type,[l.START_BLOCK,l.COMMA,l.END_BLOCK,l.SEMICOLON])),te=d(S.text,["-","+"])&&(d(this._flags.last_token.type,[l.START_BLOCK,l.START_EXPR,l.EQUALS,l.OPERATOR])||d(this._flags.last_token.text,o)||this._flags.last_token.text===",");if(!this.start_of_statement(S)){var re=!Y;this.handle_whitespace_and_comments(S,re)}if(S.text==="*"&&this._flags.last_token.type===l.DOT){this.print_token(S);return}if(S.text==="::"){this.print_token(S);return}if(this._flags.last_token.type===l.OPERATOR&&d(this._options.operator_position,y)&&this.allow_wrap_or_preserved_newline(S),S.text===":"&&this._flags.in_case){this.print_token(S),this._flags.in_case=!1,this._flags.case_body=!0,this._tokens.peek().type!==l.START_BLOCK?(this.indent(),this.print_newline(),this._flags.case_block=!1):(this._flags.case_block=!0,this._output.space_before_token=!0);return}var ce=!0,Te=!0,ye=!1;if(S.text===":"?this._flags.ternary_depth===0?ce=!1:(this._flags.ternary_depth-=1,ye=!0):S.text==="?"&&(this._flags.ternary_depth+=1),!te&&!Y&&this._options.preserve_newlines&&d(S.text,s)){var be=S.text===":",we=be&&ye,xe=be&&!ye;switch(this._options.operator_position){case E.before_newline:this._output.space_before_token=!xe,this.print_token(S),(!be||we)&&this.allow_wrap_or_preserved_newline(S),this._output.space_before_token=!0;return;case E.after_newline:this._output.space_before_token=!0,!be||we?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(S):this._output.space_before_token=!1,this.print_token(S),this._output.space_before_token=!0;return;case E.preserve_newline:xe||this.allow_wrap_or_preserved_newline(S),ce=!(this._output.just_added_newline()||xe),this._output.space_before_token=ce,this.print_token(S),this._output.space_before_token=!0;return}}if(Y){this.allow_wrap_or_preserved_newline(S),ce=!1;var ve=this._tokens.peek();Te=ve&&d(ve.type,[l.WORD,l.RESERVED])}else if(S.text==="...")this.allow_wrap_or_preserved_newline(S),ce=this._flags.last_token.type===l.START_BLOCK,Te=!1;else if(d(S.text,["--","++","!","~"])||te){if((this._flags.last_token.type===l.COMMA||this._flags.last_token.type===l.START_EXPR)&&this.allow_wrap_or_preserved_newline(S),ce=!1,Te=!1,S.newlines&&(S.text==="--"||S.text==="++"||S.text==="~")){var oe=R(this._flags.last_token,A)&&S.newlines;oe&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(oe,!0)}this._flags.last_token.text===";"&&P(this._flags.mode)&&(ce=!0),this._flags.last_token.type===l.RESERVED?ce=!0:this._flags.last_token.type===l.END_EXPR?ce=!(this._flags.last_token.text==="]"&&(S.text==="--"||S.text==="++")):this._flags.last_token.type===l.OPERATOR&&(ce=d(S.text,["--","-","++","+"])&&d(this._flags.last_token.text,["--","-","++","+"]),d(S.text,["+","-"])&&d(this._flags.last_token.text,["--","++"])&&(Te=!0)),(this._flags.mode===u.BlockStatement&&!this._flags.inline_frame||this._flags.mode===u.Statement)&&(this._flags.last_token.text==="{"||this._flags.last_token.text===";")&&this.print_newline()}this._output.space_before_token=this._output.space_before_token||ce,this.print_token(S),this._output.space_before_token=Te},X.prototype.handle_block_comment=function(S,Y){if(this._output.raw){this._output.add_raw_token(S),S.directives&&S.directives.preserve==="end"&&(this._output.raw=this._options.test_output_raw);return}if(S.directives){this.print_newline(!1,Y),this.print_token(S),S.directives.preserve==="start"&&(this._output.raw=!0),this.print_newline(!1,!0);return}if(!h.newline.test(S.text)&&!S.newlines){this._output.space_before_token=!0,this.print_token(S),this._output.space_before_token=!0;return}else this.print_block_commment(S,Y)},X.prototype.print_block_commment=function(S,Y){var te=m(S.text),re,ce=!1,Te=!1,ye=S.whitespace_before,be=ye.length;if(this.print_newline(!1,Y),this.print_token_line_indentation(S),this._output.add_token(te[0]),this.print_newline(!1,Y),te.length>1){for(te=te.slice(1),ce=N(te,"*"),Te=K(te,ye),ce&&(this._flags.alignment=1),re=0;re<te.length;re++)ce?(this.print_token_line_indentation(S),this._output.add_token(O(te[re]))):Te&&te[re]?(this.print_token_line_indentation(S),this._output.add_token(te[re].substring(be))):(this._output.current_line.set_indent(-1),this._output.add_token(te[re])),this.print_newline(!1,Y);this._flags.alignment=0}},X.prototype.handle_comment=function(S,Y){S.newlines?this.print_newline(!1,Y):this._output.trim(!0),this._output.space_before_token=!0,this.print_token(S),this.print_newline(!1,Y)},X.prototype.handle_dot=function(S){this.start_of_statement(S)||this.handle_whitespace_and_comments(S,!0),this._flags.last_token.text.match("^[0-9]+$")&&(this._output.space_before_token=!0),R(this._flags.last_token,A)?this._output.space_before_token=!1:this.allow_wrap_or_preserved_newline(S,this._flags.last_token.text===")"&&this._options.break_chained_methods),this._options.unindent_chained_methods&&this._output.just_added_newline()&&this.deindent(),this.print_token(S)},X.prototype.handle_unknown=function(S,Y){this.print_token(S),S.text[S.text.length-1]===`
`&&this.print_newline(!1,Y)},X.prototype.handle_eof=function(S){for(;this._flags.mode===u.Statement;)this.restore_mode();this.handle_whitespace_and_comments(S)},M.exports.Beautifier=X},function(M){function I(f){this.__parent=f,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}I.prototype.clone_empty=function(){var f=new I(this.__parent);return f.set_indent(this.__indent_count,this.__alignment_count),f},I.prototype.item=function(f){return f<0?this.__items[this.__items.length+f]:this.__items[f]},I.prototype.has_match=function(f){for(var h=this.__items.length-1;h>=0;h--)if(this.__items[h].match(f))return!0;return!1},I.prototype.set_indent=function(f,h){this.is_empty()&&(this.__indent_count=f||0,this.__alignment_count=h||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},I.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},I.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},I.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var f=this.__parent.current_line;return f.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),f.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),f.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,f.__items[0]===" "&&(f.__items.splice(0,1),f.__character_count-=1),!0}return!1},I.prototype.is_empty=function(){return this.__items.length===0},I.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},I.prototype.push=function(f){this.__items.push(f);var h=f.lastIndexOf(`
`);h!==-1?this.__character_count=f.length-h:this.__character_count+=f.length},I.prototype.pop=function(){var f=null;return this.is_empty()||(f=this.__items.pop(),this.__character_count-=f.length),f},I.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},I.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},I.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},I.prototype.toString=function(){var f="";return this.is_empty()?this.__parent.indent_empty_lines&&(f=this.__parent.get_indent_string(this.__indent_count)):(f=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),f+=this.__items.join("")),f};function g(f,h){this.__cache=[""],this.__indent_size=f.indent_size,this.__indent_string=f.indent_char,f.indent_with_tabs||(this.__indent_string=new Array(f.indent_size+1).join(f.indent_char)),h=h||"",f.indent_level>0&&(h=new Array(f.indent_level+1).join(this.__indent_string)),this.__base_string=h,this.__base_string_length=h.length}g.prototype.get_indent_size=function(f,h){var a=this.__base_string_length;return h=h||0,f<0&&(a=0),a+=f*this.__indent_size,a+=h,a},g.prototype.get_indent_string=function(f,h){var a=this.__base_string;return h=h||0,f<0&&(f=0,a=""),h+=f*this.__indent_size,this.__ensure_cache(h),a+=this.__cache[h],a},g.prototype.__ensure_cache=function(f){for(;f>=this.__cache.length;)this.__add_column()},g.prototype.__add_column=function(){var f=this.__cache.length,h=0,a="";this.__indent_size&&f>=this.__indent_size&&(h=Math.floor(f/this.__indent_size),f-=h*this.__indent_size,a=new Array(h+1).join(this.__indent_string)),f&&(a+=new Array(f+1).join(" ")),this.__cache.push(a)};function p(f,h){this.__indent_cache=new g(f,h),this.raw=!1,this._end_with_newline=f.end_with_newline,this.indent_size=f.indent_size,this.wrap_line_length=f.wrap_line_length,this.indent_empty_lines=f.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new I(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}p.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},p.prototype.get_line_number=function(){return this.__lines.length},p.prototype.get_indent_string=function(f,h){return this.__indent_cache.get_indent_string(f,h)},p.prototype.get_indent_size=function(f,h){return this.__indent_cache.get_indent_size(f,h)},p.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},p.prototype.add_new_line=function(f){return this.is_empty()||!f&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},p.prototype.get_code=function(f){this.trim(!0);var h=this.current_line.pop();h&&(h[h.length-1]===`
`&&(h=h.replace(/\n+$/g,"")),this.current_line.push(h)),this._end_with_newline&&this.__add_outputline();var a=this.__lines.join(`
`);return f!==`
`&&(a=a.replace(/[\n]/g,f)),a},p.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},p.prototype.set_indent=function(f,h){return f=f||0,h=h||0,this.next_line.set_indent(f,h),this.__lines.length>1?(this.current_line.set_indent(f,h),!0):(this.current_line.set_indent(),!1)},p.prototype.add_raw_token=function(f){for(var h=0;h<f.newlines;h++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(f.whitespace_before),this.current_line.push(f.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},p.prototype.add_token=function(f){this.__add_space_before_token(),this.current_line.push(f),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},p.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},p.prototype.remove_indent=function(f){for(var h=this.__lines.length;f<h;)this.__lines[f]._remove_indent(),f++;this.current_line._remove_wrap_indent()},p.prototype.trim=function(f){for(f=f===void 0?!1:f,this.current_line.trim();f&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},p.prototype.just_added_newline=function(){return this.current_line.is_empty()},p.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},p.prototype.ensure_empty_line_above=function(f,h){for(var a=this.__lines.length-2;a>=0;){var c=this.__lines[a];if(c.is_empty())break;if(c.item(0).indexOf(f)!==0&&c.item(-1)!==h){this.__lines.splice(a+1,0,new I(this)),this.previous_line=this.__lines[this.__lines.length-2];break}a--}},M.exports.Output=p},function(M){function I(g,p,f,h){this.type=g,this.text=p,this.comments_before=null,this.newlines=f||0,this.whitespace_before=h||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}M.exports.Token=I},function(M,I){var g="\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a",p="\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a",f="\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc",h="\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f",a="(?:\\\\u[0-9a-fA-F]{4}|["+g+f+"])",c="(?:\\\\u[0-9a-fA-F]{4}|["+p+f+h+"])*";I.identifier=new RegExp(a+c,"g"),I.identifierStart=new RegExp(a),I.identifierMatch=new RegExp("(?:\\\\u[0-9a-fA-F]{4}|["+p+f+h+"])+");var o=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;I.newline=/[\n\r\u2028\u2029]/,I.lineBreak=new RegExp(`\r
|`+I.newline.source),I.allLineBreaks=new RegExp(I.lineBreak.source,"g")},function(M,I,g){var p=g(6).Options,f=["before-newline","after-newline","preserve-newline"];function h(a){p.call(this,a,"js");var c=this.raw_options.brace_style||null;c==="expand-strict"?this.raw_options.brace_style="expand":c==="collapse-preserve-inline"?this.raw_options.brace_style="collapse,preserve-inline":this.raw_options.braces_on_own_line!==void 0&&(this.raw_options.brace_style=this.raw_options.braces_on_own_line?"expand":"collapse");var o=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_preserve_inline=!1,this.brace_style="collapse";for(var s=0;s<o.length;s++)o[s]==="preserve-inline"?this.brace_preserve_inline=!0:this.brace_style=o[s];this.unindent_chained_methods=this._get_boolean("unindent_chained_methods"),this.break_chained_methods=this._get_boolean("break_chained_methods"),this.space_in_paren=this._get_boolean("space_in_paren"),this.space_in_empty_paren=this._get_boolean("space_in_empty_paren"),this.jslint_happy=this._get_boolean("jslint_happy"),this.space_after_anon_function=this._get_boolean("space_after_anon_function"),this.space_after_named_function=this._get_boolean("space_after_named_function"),this.keep_array_indentation=this._get_boolean("keep_array_indentation"),this.space_before_conditional=this._get_boolean("space_before_conditional",!0),this.unescape_strings=this._get_boolean("unescape_strings"),this.e4x=this._get_boolean("e4x"),this.comma_first=this._get_boolean("comma_first"),this.operator_position=this._get_selection("operator_position",f),this.test_output_raw=this._get_boolean("test_output_raw"),this.jslint_happy&&(this.space_after_anon_function=!0)}h.prototype=new p,M.exports.Options=h},function(M){function I(f,h){this.raw_options=g(f,h),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}I.prototype._get_array=function(f,h){var a=this.raw_options[f],c=h||[];return typeof a=="object"?a!==null&&typeof a.concat=="function"&&(c=a.concat()):typeof a=="string"&&(c=a.split(/[^a-zA-Z0-9_\/\-]+/)),c},I.prototype._get_boolean=function(f,h){var a=this.raw_options[f],c=a===void 0?!!h:!!a;return c},I.prototype._get_characters=function(f,h){var a=this.raw_options[f],c=h||"";return typeof a=="string"&&(c=a.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),c},I.prototype._get_number=function(f,h){var a=this.raw_options[f];h=parseInt(h,10),isNaN(h)&&(h=0);var c=parseInt(a,10);return isNaN(c)&&(c=h),c},I.prototype._get_selection=function(f,h,a){var c=this._get_selection_list(f,h,a);if(c.length!==1)throw new Error("Invalid Option Value: The option '"+f+`' can only be one of the following values:
`+h+`
You passed in: '`+this.raw_options[f]+"'");return c[0]},I.prototype._get_selection_list=function(f,h,a){if(!h||h.length===0)throw new Error("Selection list cannot be empty.");if(a=a||[h[0]],!this._is_valid_selection(a,h))throw new Error("Invalid Default Value!");var c=this._get_array(f,a);if(!this._is_valid_selection(c,h))throw new Error("Invalid Option Value: The option '"+f+`' can contain only the following values:
`+h+`
You passed in: '`+this.raw_options[f]+"'");return c},I.prototype._is_valid_selection=function(f,h){return f.length&&h.length&&!f.some(function(a){return h.indexOf(a)===-1})};function g(f,h){var a={};f=p(f);var c;for(c in f)c!==h&&(a[c]=f[c]);if(h&&f[h])for(c in f[h])a[c]=f[h][c];return a}function p(f){var h={},a;for(a in f){var c=a.replace(/-/g,"_");h[c]=f[a]}return h}M.exports.Options=I,M.exports.normalizeOpts=p,M.exports.mergeOpts=g},function(M,I,g){var p=g(8).InputScanner,f=g(9).Tokenizer,h=g(9).TOKEN,a=g(13).Directives,c=g(4),o=g(12).Pattern,s=g(14).TemplatablePattern;function l(N,K){return K.indexOf(N)!==-1}var d={START_EXPR:"TK_START_EXPR",END_EXPR:"TK_END_EXPR",START_BLOCK:"TK_START_BLOCK",END_BLOCK:"TK_END_BLOCK",WORD:"TK_WORD",RESERVED:"TK_RESERVED",SEMICOLON:"TK_SEMICOLON",STRING:"TK_STRING",EQUALS:"TK_EQUALS",OPERATOR:"TK_OPERATOR",COMMA:"TK_COMMA",BLOCK_COMMENT:"TK_BLOCK_COMMENT",COMMENT:"TK_COMMENT",DOT:"TK_DOT",UNKNOWN:"TK_UNKNOWN",START:h.START,RAW:h.RAW,EOF:h.EOF},O=new a(/\/\*/,/\*\//),w=/0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/,x=/[0-9]/,R=/[^\d\.]/,A=">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),T=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";T=T.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"),T="\\?\\.(?!\\d) "+T,T=T.replace(/ /g,"|");var E=new RegExp(T),y="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),u=y.concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),_=new RegExp("^(?:"+u.join("|")+")$"),m,b=function(N,K){f.call(this,N,K),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source);var X=new o(this._input),B=new s(this._input).read_options(this._options);this.__patterns={template:B,identifier:B.starting_with(c.identifier).matching(c.identifierMatch),number:X.matching(w),punct:X.matching(E),comment:X.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:X.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:X.matching(/<!--/),html_comment_end:X.matching(/-->/),include:X.starting_with(/#include/).until_after(c.lineBreak),shebang:X.starting_with(/#!/).until_after(c.lineBreak),xml:X.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),single_quote:B.until(/['\\\n\r\u2028\u2029]/),double_quote:B.until(/["\\\n\r\u2028\u2029]/),template_text:B.until(/[`\\$]/),template_expression:B.until(/[`}\\]/)}};b.prototype=new f,b.prototype._is_comment=function(N){return N.type===d.COMMENT||N.type===d.BLOCK_COMMENT||N.type===d.UNKNOWN},b.prototype._is_opening=function(N){return N.type===d.START_BLOCK||N.type===d.START_EXPR},b.prototype._is_closing=function(N,K){return(N.type===d.END_BLOCK||N.type===d.END_EXPR)&&K&&(N.text==="]"&&K.text==="["||N.text===")"&&K.text==="("||N.text==="}"&&K.text==="{")},b.prototype._reset=function(){m=!1},b.prototype._get_next_token=function(N,K){var X=null;this._readWhitespace();var B=this._input.peek();return B===null?this._create_token(d.EOF,""):(X=X||this._read_non_javascript(B),X=X||this._read_string(B),X=X||this._read_word(N),X=X||this._read_singles(B),X=X||this._read_comment(B),X=X||this._read_regexp(B,N),X=X||this._read_xml(B,N),X=X||this._read_punctuation(),X=X||this._create_token(d.UNKNOWN,this._input.next()),X)},b.prototype._read_word=function(N){var K;if(K=this.__patterns.identifier.read(),K!=="")return K=K.replace(c.allLineBreaks,`
`),!(N.type===d.DOT||N.type===d.RESERVED&&(N.text==="set"||N.text==="get"))&&_.test(K)?(K==="in"||K==="of")&&(N.type===d.WORD||N.type===d.STRING)?this._create_token(d.OPERATOR,K):this._create_token(d.RESERVED,K):this._create_token(d.WORD,K);if(K=this.__patterns.number.read(),K!=="")return this._create_token(d.WORD,K)},b.prototype._read_singles=function(N){var K=null;return N==="("||N==="["?K=this._create_token(d.START_EXPR,N):N===")"||N==="]"?K=this._create_token(d.END_EXPR,N):N==="{"?K=this._create_token(d.START_BLOCK,N):N==="}"?K=this._create_token(d.END_BLOCK,N):N===";"?K=this._create_token(d.SEMICOLON,N):N==="."&&R.test(this._input.peek(1))?K=this._create_token(d.DOT,N):N===","&&(K=this._create_token(d.COMMA,N)),K&&this._input.next(),K},b.prototype._read_punctuation=function(){var N=this.__patterns.punct.read();if(N!=="")return N==="="?this._create_token(d.EQUALS,N):N==="?."?this._create_token(d.DOT,N):this._create_token(d.OPERATOR,N)},b.prototype._read_non_javascript=function(N){var K="";if(N==="#"){if(this._is_first_token()&&(K=this.__patterns.shebang.read(),K))return this._create_token(d.UNKNOWN,K.trim()+`
`);if(K=this.__patterns.include.read(),K)return this._create_token(d.UNKNOWN,K.trim()+`
`);N=this._input.next();var X="#";if(this._input.hasNext()&&this._input.testChar(x)){do N=this._input.next(),X+=N;while(this._input.hasNext()&&N!=="#"&&N!=="=");return N==="#"||(this._input.peek()==="["&&this._input.peek(1)==="]"?(X+="[]",this._input.next(),this._input.next()):this._input.peek()==="{"&&this._input.peek(1)==="}"&&(X+="{}",this._input.next(),this._input.next())),this._create_token(d.WORD,X)}this._input.back()}else if(N==="<"&&this._is_first_token()){if(K=this.__patterns.html_comment_start.read(),K){for(;this._input.hasNext()&&!this._input.testChar(c.newline);)K+=this._input.next();return m=!0,this._create_token(d.COMMENT,K)}}else if(m&&N==="-"&&(K=this.__patterns.html_comment_end.read(),K))return m=!1,this._create_token(d.COMMENT,K);return null},b.prototype._read_comment=function(N){var K=null;if(N==="/"){var X="";if(this._input.peek(1)==="*"){X=this.__patterns.block_comment.read();var B=O.get_directives(X);B&&B.ignore==="start"&&(X+=O.readIgnored(this._input)),X=X.replace(c.allLineBreaks,`
`),K=this._create_token(d.BLOCK_COMMENT,X),K.directives=B}else this._input.peek(1)==="/"&&(X=this.__patterns.comment.read(),K=this._create_token(d.COMMENT,X))}return K},b.prototype._read_string=function(N){if(N==="`"||N==="'"||N==='"'){var K=this._input.next();return this.has_char_escapes=!1,N==="`"?K+=this._read_string_recursive("`",!0,"${"):K+=this._read_string_recursive(N),this.has_char_escapes&&this._options.unescape_strings&&(K=P(K)),this._input.peek()===N&&(K+=this._input.next()),K=K.replace(c.allLineBreaks,`
`),this._create_token(d.STRING,K)}return null},b.prototype._allow_regexp_or_xml=function(N){return N.type===d.RESERVED&&l(N.text,["return","case","throw","else","do","typeof","yield"])||N.type===d.END_EXPR&&N.text===")"&&N.opened.previous.type===d.RESERVED&&l(N.opened.previous.text,["if","while","for"])||l(N.type,[d.COMMENT,d.START_EXPR,d.START_BLOCK,d.START,d.END_BLOCK,d.OPERATOR,d.EQUALS,d.EOF,d.SEMICOLON,d.COMMA])},b.prototype._read_regexp=function(N,K){if(N==="/"&&this._allow_regexp_or_xml(K)){for(var X=this._input.next(),B=!1,S=!1;this._input.hasNext()&&(B||S||this._input.peek()!==N)&&!this._input.testChar(c.newline);)X+=this._input.peek(),B?B=!1:(B=this._input.peek()==="\\",this._input.peek()==="["?S=!0:this._input.peek()==="]"&&(S=!1)),this._input.next();return this._input.peek()===N&&(X+=this._input.next(),X+=this._input.read(c.identifier)),this._create_token(d.STRING,X)}return null},b.prototype._read_xml=function(N,K){if(this._options.e4x&&N==="<"&&this._allow_regexp_or_xml(K)){var X="",B=this.__patterns.xml.read_match();if(B){for(var S=B[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}"),Y=S.indexOf("{")===0,te=0;B;){var re=!!B[1],ce=B[2],Te=!!B[B.length-1]||ce.slice(0,8)==="![CDATA[";if(!Te&&(ce===S||Y&&ce.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(re?--te:++te),X+=B[0],te<=0)break;B=this.__patterns.xml.read_match()}return B||(X+=this._input.match(/[\s\S]*/g)[0]),X=X.replace(c.allLineBreaks,`
`),this._create_token(d.STRING,X)}}return null};function P(N){for(var K="",X=0,B=new p(N),S=null;B.hasNext();)if(S=B.match(/([\s]|[^\\]|\\\\)+/g),S&&(K+=S[0]),B.peek()==="\\"){if(B.next(),B.peek()==="x")S=B.match(/x([0-9A-Fa-f]{2})/g);else if(B.peek()==="u")S=B.match(/u([0-9A-Fa-f]{4})/g);else{K+="\\",B.hasNext()&&(K+=B.next());continue}if(!S)return N;if(X=parseInt(S[1],16),X>126&&X<=255&&S[0].indexOf("x")===0)return N;if(X>=0&&X<32){K+="\\"+S[0];continue}else X===34||X===39||X===92?K+="\\"+String.fromCharCode(X):K+=String.fromCharCode(X)}return K}b.prototype._read_string_recursive=function(N,K,X){var B,S;N==="'"?S=this.__patterns.single_quote:N==='"'?S=this.__patterns.double_quote:N==="`"?S=this.__patterns.template_text:N==="}"&&(S=this.__patterns.template_expression);for(var Y=S.read(),te="";this._input.hasNext();){if(te=this._input.next(),te===N||!K&&c.newline.test(te)){this._input.back();break}else te==="\\"&&this._input.hasNext()?(B=this._input.peek(),B==="x"||B==="u"?this.has_char_escapes=!0:B==="\r"&&this._input.peek(1)===`
`&&this._input.next(),te+=this._input.next()):X&&(X==="${"&&te==="$"&&this._input.peek()==="{"&&(te+=this._input.next()),X===te&&(N==="`"?te+=this._read_string_recursive("}",K,"`"):te+=this._read_string_recursive("`",K,"${"),this._input.hasNext()&&(te+=this._input.next())));te+=S.read(),Y+=te}return Y},M.exports.Tokenizer=b,M.exports.TOKEN=d,M.exports.positionable_operators=A.slice(),M.exports.line_starters=y.slice()},function(M){var I=RegExp.prototype.hasOwnProperty("sticky");function g(p){this.__input=p||"",this.__input_length=this.__input.length,this.__position=0}g.prototype.restart=function(){this.__position=0},g.prototype.back=function(){this.__position>0&&(this.__position-=1)},g.prototype.hasNext=function(){return this.__position<this.__input_length},g.prototype.next=function(){var p=null;return this.hasNext()&&(p=this.__input.charAt(this.__position),this.__position+=1),p},g.prototype.peek=function(p){var f=null;return p=p||0,p+=this.__position,p>=0&&p<this.__input_length&&(f=this.__input.charAt(p)),f},g.prototype.__match=function(p,f){p.lastIndex=f;var h=p.exec(this.__input);return h&&!(I&&p.sticky)&&(h.index!==f&&(h=null)),h},g.prototype.test=function(p,f){return f=f||0,f+=this.__position,f>=0&&f<this.__input_length?!!this.__match(p,f):!1},g.prototype.testChar=function(p,f){var h=this.peek(f);return p.lastIndex=0,h!==null&&p.test(h)},g.prototype.match=function(p){var f=this.__match(p,this.__position);return f?this.__position+=f[0].length:f=null,f},g.prototype.read=function(p,f,h){var a="",c;return p&&(c=this.match(p),c&&(a+=c[0])),f&&(c||!p)&&(a+=this.readUntil(f,h)),a},g.prototype.readUntil=function(p,f){var h="",a=this.__position;p.lastIndex=this.__position;var c=p.exec(this.__input);return c?(a=c.index,f&&(a+=c[0].length)):a=this.__input_length,h=this.__input.substring(this.__position,a),this.__position=a,h},g.prototype.readUntilAfter=function(p){return this.readUntil(p,!0)},g.prototype.get_regexp=function(p,f){var h=null,a="g";return f&&I&&(a="y"),typeof p=="string"&&p!==""?h=new RegExp(p,a):p&&(h=new RegExp(p.source,a)),h},g.prototype.get_literal_regexp=function(p){return RegExp(p.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},g.prototype.peekUntilAfter=function(p){var f=this.__position,h=this.readUntilAfter(p);return this.__position=f,h},g.prototype.lookBack=function(p){var f=this.__position-1;return f>=p.length&&this.__input.substring(f-p.length,f).toLowerCase()===p},M.exports.InputScanner=g},function(M,I,g){var p=g(8).InputScanner,f=g(3).Token,h=g(10).TokenStream,a=g(11).WhitespacePattern,c={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},o=function(s,l){this._input=new p(s),this._options=l||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new a(this._input)};o.prototype.tokenize=function(){this._input.restart(),this.__tokens=new h,this._reset();for(var s,l=new f(c.START,""),d=null,O=[],w=new h;l.type!==c.EOF;){for(s=this._get_next_token(l,d);this._is_comment(s);)w.add(s),s=this._get_next_token(l,d);w.isEmpty()||(s.comments_before=w,w=new h),s.parent=d,this._is_opening(s)?(O.push(d),d=s):d&&this._is_closing(s,d)&&(s.opened=d,d.closed=s,d=O.pop(),s.parent=d),s.previous=l,l.next=s,this.__tokens.add(s),l=s}return this.__tokens},o.prototype._is_first_token=function(){return this.__tokens.isEmpty()},o.prototype._reset=function(){},o.prototype._get_next_token=function(s,l){this._readWhitespace();var d=this._input.read(/.+/g);return d?this._create_token(c.RAW,d):this._create_token(c.EOF,"")},o.prototype._is_comment=function(s){return!1},o.prototype._is_opening=function(s){return!1},o.prototype._is_closing=function(s,l){return!1},o.prototype._create_token=function(s,l){var d=new f(s,l,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return d},o.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},M.exports.Tokenizer=o,M.exports.TOKEN=c},function(M){function I(g){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=g}I.prototype.restart=function(){this.__position=0},I.prototype.isEmpty=function(){return this.__tokens_length===0},I.prototype.hasNext=function(){return this.__position<this.__tokens_length},I.prototype.next=function(){var g=null;return this.hasNext()&&(g=this.__tokens[this.__position],this.__position+=1),g},I.prototype.peek=function(g){var p=null;return g=g||0,g+=this.__position,g>=0&&g<this.__tokens_length&&(p=this.__tokens[g]),p},I.prototype.add=function(g){this.__parent_token&&(g.parent=this.__parent_token),this.__tokens.push(g),this.__tokens_length+=1},M.exports.TokenStream=I},function(M,I,g){var p=g(12).Pattern;function f(h,a){p.call(this,h,a),a?this._line_regexp=this._input.get_regexp(a._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}f.prototype=new p,f.prototype.__set_whitespace_patterns=function(h,a){h+="\\t ",a+="\\n\\r",this._match_pattern=this._input.get_regexp("["+h+a+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+a+"]")},f.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var h=this._input.read(this._match_pattern);if(h===" ")this.whitespace_before_token=" ";else if(h){var a=this.__split(this._newline_regexp,h);this.newline_count=a.length-1,this.whitespace_before_token=a[this.newline_count]}return h},f.prototype.matching=function(h,a){var c=this._create();return c.__set_whitespace_patterns(h,a),c._update(),c},f.prototype._create=function(){return new f(this._input,this)},f.prototype.__split=function(h,a){h.lastIndex=0;for(var c=0,o=[],s=h.exec(a);s;)o.push(a.substring(c,s.index)),c=s.index+s[0].length,s=h.exec(a);return c<a.length?o.push(a.substring(c,a.length)):o.push(""),o},M.exports.WhitespacePattern=f},function(M){function I(g,p){this._input=g,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,p&&(this._starting_pattern=this._input.get_regexp(p._starting_pattern,!0),this._match_pattern=this._input.get_regexp(p._match_pattern,!0),this._until_pattern=this._input.get_regexp(p._until_pattern),this._until_after=p._until_after)}I.prototype.read=function(){var g=this._input.read(this._starting_pattern);return(!this._starting_pattern||g)&&(g+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),g},I.prototype.read_match=function(){return this._input.match(this._match_pattern)},I.prototype.until_after=function(g){var p=this._create();return p._until_after=!0,p._until_pattern=this._input.get_regexp(g),p._update(),p},I.prototype.until=function(g){var p=this._create();return p._until_after=!1,p._until_pattern=this._input.get_regexp(g),p._update(),p},I.prototype.starting_with=function(g){var p=this._create();return p._starting_pattern=this._input.get_regexp(g,!0),p._update(),p},I.prototype.matching=function(g){var p=this._create();return p._match_pattern=this._input.get_regexp(g,!0),p._update(),p},I.prototype._create=function(){return new I(this._input,this)},I.prototype._update=function(){},M.exports.Pattern=I},function(M){function I(g,p){g=typeof g=="string"?g:g.source,p=typeof p=="string"?p:p.source,this.__directives_block_pattern=new RegExp(g+/ beautify( \w+[:]\w+)+ /.source+p,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(g+/\sbeautify\signore:end\s/.source+p,"g")}I.prototype.get_directives=function(g){if(!g.match(this.__directives_block_pattern))return null;var p={};this.__directive_pattern.lastIndex=0;for(var f=this.__directive_pattern.exec(g);f;)p[f[1]]=f[2],f=this.__directive_pattern.exec(g);return p},I.prototype.readIgnored=function(g){return g.readUntilAfter(this.__directives_end_ignore_pattern)},M.exports.Directives=I},function(M,I,g){var p=g(12).Pattern,f={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1};function h(a,c){p.call(this,a,c),this.__template_pattern=null,this._disabled=Object.assign({},f),this._excluded=Object.assign({},f),c&&(this.__template_pattern=this._input.get_regexp(c.__template_pattern),this._excluded=Object.assign(this._excluded,c._excluded),this._disabled=Object.assign(this._disabled,c._disabled));var o=new p(a);this.__patterns={handlebars_comment:o.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:o.starting_with(/{{{/).until_after(/}}}/),handlebars:o.starting_with(/{{/).until_after(/}}/),php:o.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:o.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:o.starting_with(/{%/).until_after(/%}/),django_value:o.starting_with(/{{/).until_after(/}}/),django_comment:o.starting_with(/{#/).until_after(/#}/),smarty:o.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:o.starting_with(/{\*/).until_after(/\*}/),smarty_literal:o.starting_with(/{literal}/).until_after(/{\/literal}/)}}h.prototype=new p,h.prototype._create=function(){return new h(this._input,this)},h.prototype._update=function(){this.__set_templated_pattern()},h.prototype.disable=function(a){var c=this._create();return c._disabled[a]=!0,c._update(),c},h.prototype.read_options=function(a){var c=this._create();for(var o in f)c._disabled[o]=a.templating.indexOf(o)===-1;return c._update(),c},h.prototype.exclude=function(a){var c=this._create();return c._excluded[a]=!0,c._update(),c},h.prototype.read=function(){var a="";this._match_pattern?a=this._input.read(this._starting_pattern):a=this._input.read(this._starting_pattern,this.__template_pattern);for(var c=this._read_template();c;)this._match_pattern?c+=this._input.read(this._match_pattern):c+=this._input.readUntil(this.__template_pattern),a+=c,c=this._read_template();return this._until_after&&(a+=this._input.readUntilAfter(this._until_pattern)),a},h.prototype.__set_templated_pattern=function(){var a=[];this._disabled.php||a.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||a.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||a.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(a.push(this.__patterns.django._starting_pattern.source),a.push(this.__patterns.django_value._starting_pattern.source),a.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||a.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&a.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+a.join("|")+")")},h.prototype._read_template=function(){var a="",c=this._input.peek();if(c==="<"){var o=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&o==="?"&&(a=a||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&o==="%"&&(a=a||this.__patterns.erb.read())}else c==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(a=a||this.__patterns.handlebars_comment.read(),a=a||this.__patterns.handlebars_unescaped.read(),a=a||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(a=a||this.__patterns.django_value.read()),this._excluded.django||(a=a||this.__patterns.django_comment.read(),a=a||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(a=a||this.__patterns.smarty_comment.read(),a=a||this.__patterns.smarty_literal.read(),a=a||this.__patterns.smarty.read()));return a},M.exports.TemplatablePattern=h}],D={};function G(M){var I=D[M];if(I!==void 0)return I.exports;var g=D[M]={exports:{}};return F[M](g,g.exports,G),g.exports}var j=G(0);k=j})();var V=k;!(ae=[],Z=function(){return{js_beautify:V}}.apply(lt,ae),Z!==void 0&&(_t.exports=Z))})()},"7Cbv":function(_t,lt,ne){"use strict";var ae=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 k(){if(!ae)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ae(Z)}var V=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function F(f){return typeof f=="string"&&V.test(f)}for(var D=F,G=[],j=0;j<256;++j)G.push((j+256).toString(16).substr(1));function M(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=(G[f[h+0]]+G[f[h+1]]+G[f[h+2]]+G[f[h+3]]+"-"+G[f[h+4]]+G[f[h+5]]+"-"+G[f[h+6]]+G[f[h+7]]+"-"+G[f[h+8]]+G[f[h+9]]+"-"+G[f[h+10]]+G[f[h+11]]+G[f[h+12]]+G[f[h+13]]+G[f[h+14]]+G[f[h+15]]).toLowerCase();if(!D(a))throw TypeError("Stringified UUID is invalid");return a}var I=M;function g(f,h,a){f=f||{};var c=f.random||(f.rng||k)();if(c[6]=c[6]&15|64,c[8]=c[8]&63|128,h){a=a||0;for(var o=0;o<16;++o)h[a+o]=c[o];return h}return I(c)}var p=lt.a=g},"7ahc":function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return O});var ae=ne("k1fw"),Z=ne("0Owb"),k=ne("+L6B"),V=ne("2/Rp"),F=ne("y8nQ"),D=ne("Vl3Y"),G=ne("tJVT"),j=ne("OaEy"),M=ne("2fM7"),I=ne("q1tI"),g=ne.n(I),p=ne("VrN/"),f=ne.n(p),h=ne("p77/"),a=ne.n(h),c=ne("c5Ni"),o=ne.n(c),s=M.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"]};lt.b=function(w){var x=w.callback,R=w.onCancel,A=Object(I.useState)("python"),T=Object(G.a)(A,2),E=T[0],y=T[1];function u(m){y(d[m][1])}function _(m){x(m)}return g.a.createElement(D.a,Object(Z.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:_}),g.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},g.a.createElement(M.a,{onChange:u},Object.keys(d).map(function(m){return g.a.createElement(s,{key:m,value:m},d[m][0])}))),g.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},g.a.createElement(O,{mode:E})),g.a.createElement("div",{className:"flex-container flex-end"},g.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),g.a.createElement(V.a,{type:"ghost",onClick:R},"\u53D6\u6D88")))};function O(w){var x=w.value,R=w.onChange,A=w.mode,T=w.options,E=T===void 0?{}:T,y=Object(I.useRef)(),u=Object(I.useState)(),_=Object(G.a)(u,2),m=_[0],b=_[1];return Object(I.useEffect)(function(){if(m){function P(N){var K=N.getValue();R&&R(K)}return m.on("change",P),function(){m.off("change",P)}}},[m,R]),Object(I.useEffect)(function(){m&&m.setOption("mode",A)},[m,A]),Object(I.useEffect)(function(){m&&((x!==m.getValue()||x==="")&&setTimeout(function(){m.setValue(x||" ")},300))},[m,x]),Object(I.useEffect)(function(){if(y.current&&!m){var P=f.a.fromTextArea(y.current,Object(ae.a)({mode:A,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},E));b(P)}},[y.current,m]),g.a.createElement("div",{className:"my-codemirror-container"},g.a.createElement("textarea",{ref:y}))}},"8EBN":function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){"use strict";ae.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<ae.modeInfo.length;Z++){var k=ae.modeInfo[Z];k.mimes&&(k.mime=k.mimes[0])}ae.findModeByMIME=function(V){V=V.toLowerCase();for(var F=0;F<ae.modeInfo.length;F++){var D=ae.modeInfo[F];if(D.mime==V)return D;if(D.mimes){for(var G=0;G<D.mimes.length;G++)if(D.mimes[G]==V)return D}}if(/\+xml$/.test(V))return ae.findModeByMIME("application/xml");if(/\+json$/.test(V))return ae.findModeByMIME("application/json")},ae.findModeByExtension=function(V){V=V.toLowerCase();for(var F=0;F<ae.modeInfo.length;F++){var D=ae.modeInfo[F];if(D.ext){for(var G=0;G<D.ext.length;G++)if(D.ext[G]==V)return D}}},ae.findModeByFileName=function(V){for(var F=0;F<ae.modeInfo.length;F++){var D=ae.modeInfo[F];if(D.file&&D.file.test(V))return D}var G=V.lastIndexOf("."),j=G>-1&&V.substring(G+1,V.length);if(j)return ae.findModeByExtension(j)},ae.findModeByName=function(V){V=V.toLowerCase();for(var F=0;F<ae.modeInfo.length;F++){var D=ae.modeInfo[F];if(D.name.toLowerCase()==V)return D;if(D.alias){for(var G=0;G<D.alias.length;G++)if(D.alias[G].toLowerCase()==V)return D}}}})},"8JLL":function(_t,lt,ne){_t.exports={flex_box_center:"flex_box_center___15KPT",flex_space_between:"flex_space_between___1QiSE",flex_box_vertical_center:"flex_box_vertical_center___3bNXy",flex_box_center_end:"flex_box_center_end___1hLE4",flex_box_column:"flex_box_column___3CCm3",reply:"reply___eY1t0",replyList:"replyList___3g6Og",comment:"comment___LHpQl",content:"content___XWl90",commentItem:"commentItem___2Y_u_"}},"8hTe":function(_t,lt,ne){_t.exports={button:"button___1wy9m"}},"9Bee":function(_t,lt,ne){"use strict";var ae=ne("DYRE"),Z=ne("zeV3"),k=ne("+L6B"),V=ne("2/Rp"),F=ne("k1fw"),D=ne("9og8"),G=ne("tJVT"),j=ne("WmNS"),M=ne.n(j),I=ne("q1tI"),g=ne.n(I),p=ne("vg9a"),f=ne("DlQD"),h=ne.n(f),a=ne("rUJ1");function c(z,v){var C=z.match(/^(\s+)(?:```)/);if(C===null)return v;var U=C[1];return v.split(`
`).map(function(J){var W=J.match(/^\s+/);if(W===null)return J;var pe=Object(G.a)(W,1),De=pe[0];return De.length>=U.length?J.slice(U.length):J}).join(`
`)}var o=[],s=["<ul>"],l=new h.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function O(){o.length=0,s=["<ul>"]}var w={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function x(z,v,C,U){if(v>=z.length||z[v].level<=C)return v;var J=z[v];U.push("<li><a href='#"+J.anchor+"'>"+J.text+"</a>"),v++;var W=[];return v=x(z,v,J.level,W),W.length>0&&(U.push("<ul>"),W.forEach(function(pe){U.push(pe)}),U.push("</ul>")),U.push("</li>"),v=x(z,v,C,U),v}function R(){return x(o,0,0,s),s.push("</ul>"),s.join("")}var A={heading:function(v){var C=d.exec(v);if(C)return{type:"heading",raw:C[0],depth:C[1].length,text:C[2]}},fences:function(v){var C=this.rules.block.fences.exec(v);if(C){var U=C[0],J=c(U,C[3]||""),W=C[2]?C[2].trim():C[2];if(["latex","katex","math"].indexOf(W)>=0){var pe=y(),De=J;J=pe,u[pe]={type:"block",expression:De}}return{type:"code",raw:U,lang:W,text:J}}}},T=/(?:\${2})([^\n`]+?)(?:\${2})/gi,E=0,y=function(){return"__special_katext_id_".concat(E++,"__")},u={};function _(){return u}function m(){E=0,u={}}function b(z){return z=z.replace(T,function(v,C){var U=y();return u[U]={type:"inline",expression:C},U}),z}var P=l.listitem;l.listitem=function(z){return P(b(z))};var N=l.paragraph;l.paragraph=function(z){return N(b(z))};var K=l.tablecell;l.tablecell=function(z,v){return K(b(z),v)},l.code=function(z,v,C){var U=(v||"").match(/\S*/)[0];return U?["latex","katex","math"].indexOf(U)>=0?"<p class='editormd-tex'>".concat(z,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(v,'">').concat(C?z:Object(a.escape)(z,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(C?z:Object(a.escape)(z,!0))+"</code></pre>"},l.heading=function(z,v,C){var U=this.options.headerPrefix+C.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return o.push({anchor:U,level:v,text:z}),"<h"+v+' id="'+U+'">'+z+"</h"+v+">"},h.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),h.a.use({tokenizer:A,renderer:l});var X=h.a,B=ne("SJMd"),S=ne("ulZh"),Y=ne.n(S),te=ne("m3rI"),re=ne("Oy/b"),ce=ne("p5ED"),Te=ne("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 ye=function(z,v){return(ye=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,U){C.__proto__=U}||function(C,U){for(var J in U)Object.prototype.hasOwnProperty.call(U,J)&&(C[J]=U[J])})(z,v)};function be(z,v){function C(){this.constructor=z}ye(z,v),z.prototype=v===null?Object.create(v):(C.prototype=v.prototype,new C)}function we(z,v,C,U){return new(C||(C=Promise))(function(J,W){function pe(gt){try{it(U.next(gt))}catch(Ne){W(Ne)}}function De(gt){try{it(U.throw(gt))}catch(Ne){W(Ne)}}function it(gt){var Ne;gt.done?J(gt.value):(Ne=gt.value,Ne instanceof C?Ne:new C(function(Tt){Tt(Ne)})).then(pe,De)}it((U=U.apply(z,v||[])).next())})}function xe(z,v){var C,U,J,W,pe={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return W={next:De(0),throw:De(1),return:De(2)},typeof Symbol=="function"&&(W[Symbol.iterator]=function(){return this}),W;function De(it){return function(gt){return function(Ne){if(C)throw new TypeError("Generator is already executing.");for(;pe;)try{if(C=1,U&&(J=2&Ne[0]?U.return:Ne[0]?U.throw||((J=U.return)&&J.call(U),0):U.next)&&!(J=J.call(U,Ne[1])).done)return J;switch(U=0,J&&(Ne=[2&Ne[0],J.value]),Ne[0]){case 0:case 1:J=Ne;break;case 4:return pe.label++,{value:Ne[1],done:!1};case 5:pe.label++,U=Ne[1],Ne=[0];continue;case 7:Ne=pe.ops.pop(),pe.trys.pop();continue;default:if(!(J=pe.trys,(J=J.length>0&&J[J.length-1])||Ne[0]!==6&&Ne[0]!==2)){pe=0;continue}if(Ne[0]===3&&(!J||Ne[1]>J[0]&&Ne[1]<J[3])){pe.label=Ne[1];break}if(Ne[0]===6&&pe.label<J[1]){pe.label=J[1],J=Ne;break}if(J&&pe.label<J[2]){pe.label=J[2],pe.ops.push(Ne);break}J[2]&&pe.ops.pop(),pe.trys.pop();continue}Ne=v.call(z,pe)}catch(Tt){Ne=[6,Tt],U=0}finally{C=J=0}if(5&Ne[0])throw Ne[1];return{value:Ne[0]?Ne[1]:void 0,done:!0}}([it,gt])}}}function ve(){for(var z=0,v=0,C=arguments.length;v<C;v++)z+=arguments[v].length;var U=Array(z),J=0;for(v=0;v<C;v++)for(var W=arguments[v],pe=0,De=W.length;pe<De;pe++,J++)U[J]=W[pe];return U}var oe=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(v,C){for(var U=0,J=C;U<J.length;U++){var W=J[U],pe=W[0],De=W[1];v.setAttribute(pe,De)}},z.createRect=function(v,C,U){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",v.toString()),J.setAttribute("height",C.toString()),U&&z.setAttributes(J,U),J},z.createLine=function(v,C,U,J,W){var pe=document.createElementNS("http://www.w3.org/2000/svg","line");return pe.setAttribute("x1",v.toString()),pe.setAttribute("y1",C.toString()),pe.setAttribute("x2",U.toString()),pe.setAttribute("y2",J.toString()),W&&z.setAttributes(pe,W),pe},z.createPolygon=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","polygon");return U.setAttribute("points",v),C&&z.setAttributes(U,C),U},z.createCircle=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","circle");return U.setAttribute("cx",(v/2).toString()),U.setAttribute("cy",(v/2).toString()),U.setAttribute("r",v.toString()),C&&z.setAttributes(U,C),U},z.createEllipse=function(v,C,U){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(v/2).toString()),J.setAttribute("cy",(C/2).toString()),J.setAttribute("rx",(v/2).toString()),J.setAttribute("ry",(C/2).toString()),U&&z.setAttributes(J,U),J},z.createGroup=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","g");return v&&z.setAttributes(C,v),C},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(v,C,U,J,W,pe,De){var it=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(it,[["id",v],["orient",C],["markerWidth",U.toString()],["markerHeight",J.toString()],["refX",W.toString()],["refY",pe.toString()]]),it.appendChild(De),it},z.createText=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","text");return C.setAttribute("x","0"),C.setAttribute("y","0"),v&&z.setAttributes(C,v),C},z.createTSpan=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","tspan");return U.textContent=v,C&&z.setAttributes(U,C),U},z.createImage=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","image");return v&&z.setAttributes(C,v),C},z.createPoint=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return U.x=v,U.y=C,U},z.createPath=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","path");return U.setAttribute("d",v),C&&z.setAttributes(U,C),U},z}(),Re=function(){function z(){}return z.addKey=function(v){z.key=v},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),Ye=function(){function z(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return z.prototype.rasterize=function(v,C,U){var J=this;return new Promise(function(W){var pe=U!==void 0?U:document.createElement("canvas");v===null&&(J.markersOnly=!0,J.naturalSize=!1);var De=document.createElementNS("http://www.w3.org/2000/svg","svg");De.setAttribute("xmlns","http://www.w3.org/2000/svg"),De.setAttribute("width",C.width.baseVal.valueAsString),De.setAttribute("height",C.height.baseVal.valueAsString),De.setAttribute("viewBox","0 0 "+C.viewBox.baseVal.width.toString()+" "+C.viewBox.baseVal.height.toString()),De.innerHTML=C.innerHTML,J.naturalSize===!0?(De.width.baseVal.value=v.naturalWidth,De.height.baseVal.value=v.naturalHeight):J.width!==void 0&&J.height!==void 0&&(De.width.baseVal.value=J.width,De.height.baseVal.value=J.height),pe.width=De.width.baseVal.value,pe.height=De.height.baseVal.value;var it=De.outerHTML,gt=pe.getContext("2d");J.markersOnly!==!0&&gt.drawImage(v,0,0,pe.width,pe.height);var Ne=window.URL,Tt=new Image(pe.width,pe.height);Tt.setAttribute("crossOrigin","anonymous");var zt=new Blob([it],{type:"image/svg+xml"}),qt=Ne.createObjectURL(zt);Tt.onload=function(){gt.drawImage(Tt,0,0),Ne.revokeObjectURL(qt);var Bi=pe.toDataURL(J.imageType,J.imageQuality);W(Bi)},Tt.src=qt})},z}(),Ue=function(){},rt=function(){function z(v){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+v+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(v){return this.styleSheet===void 0&&this.addStyleSheet(),v.name=""+this.classNamePrefix+v.localName,this.classes.push(v),this.styleSheet.sheet.insertRule("."+v.name+" {"+v.style+"}",this.styleSheet.sheet.cssRules.length),v},z.prototype.addRule=function(v){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(v),this.styleSheet.sheet.insertRule(v.selector+" {"+v.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var v;this.styleSheet=document.createElement("style"),((v=this.styleSheetRoot)!==null&&v!==void 0?v:document.head).appendChild(this.styleSheet),this.addRule(new ot("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new ot("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new ot("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new Oe("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new Oe("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},z.prototype.removeStyleSheet=function(){var v;this.styleSheet&&(((v=this.styleSheetRoot)!==null&&v!==void 0?v:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),ot=function(z,v){this.selector=z,this.style=v},Oe=function(z,v){this.localName=z,this.style=v},Me=function(){function z(v,C,U,J,W){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=v,this.displayMode=C,this.markerItems=U,this.uiStyleSettings=J,this.styles=W,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return z.prototype.show=function(v){var C=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=v,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var U=document.createElement("div");U.className=this.toolbarBlockStyleClass.name,U.style.whiteSpace="nowrap",this.uiContainer.appendChild(U),this.addActionButton(U,'<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(U,'<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(U,'<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(U,'<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(U,'<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(U,'<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(U,'<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(U,'<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(W){var pe=document.createElement("div");pe.className=""+C.toolbarButtonStyleClass.name,pe.setAttribute("data-type-name",W.typeName),pe.innerHTML=W.icon,pe.addEventListener("click",function(){C.markerToolbarButtonClicked(pe,W)}),C.buttons.push(pe),C.markerButtons.push(pe)}),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 J=document.createElement("div");J.className=this.toolbarBlockStyleClass.name,J.style.whiteSpace="nowrap",J.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(J),this.addActionButton(J,'<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(J,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},z.prototype.addButtonClickListener=function(v){this.buttonClickListeners.push(v)},z.prototype.removeButtonClickListener=function(v){this.buttonClickListeners.indexOf(v)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(v),1)},z.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},z.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var v=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var C=0;C<this.markerButtons.length;C++)C<v||C===v&&this.markerButtons.length-1===v?this.markerButtonBlock.appendChild(this.markerButtons[C]):(C===v&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[C]))}},z.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},z.prototype.resetButtonStyles=function(){var v=this;this.buttons.forEach(function(C){C.className=C.className.replace(v.uiStyleSettings.toolbarButtonStyleColorsClassName?v.uiStyleSettings.toolbarButtonStyleColorsClassName:v.toolbarButtonStyleColorsClass.name,"").trim(),C.className=C.className.replace(v.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?v.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:v.toolbarActiveButtonStyleColorsClass.name,"").trim(),C.className+=" "+(v.uiStyleSettings.toolbarButtonStyleColorsClassName?v.uiStyleSettings.toolbarButtonStyleColorsClassName:v.toolbarButtonStyleColorsClass.name)})},z.prototype.addActionButton=function(v,C,U){var J=this,W=document.createElement("div");switch(W.className=""+this.toolbarButtonStyleClass.name,W.innerHTML=C,W.setAttribute("data-action",U),W.addEventListener("click",function(){J.actionToolbarButtonClicked(W,U)}),U){case"select":W.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":W.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":W.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":W.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":W.style.fill=this.uiStyleSettings.closeButtonColor}v.appendChild(W),this.buttons.push(W)},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Oe("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 Oe("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Oe("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Oe("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 Oe("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var v=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Oe("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
padding: `+v+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Oe("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Oe("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new ot("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new ot("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},z.prototype.markerToolbarButtonClicked=function(v,C){this.setActiveButton(v),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(U){return U("marker",C)}),this.markerButtonOverflowBlock.style.display="none"},z.prototype.actionToolbarButtonClicked=function(v,C){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(U){return U("action",C)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},z.prototype.setActiveButton=function(v){this.resetButtonStyles(),v.className=v.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),v.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},z.prototype.setActiveMarkerButton=function(v){var C=this.markerButtons.find(function(U){return U.getAttribute("data-type-name")===v});C&&this.setActiveButton(C)},z.prototype.setCurrentMarker=function(v){var C=this;this.currentMarker=v,this.buttons.filter(function(U){return/delete|notes/.test(U.getAttribute("data-action"))}).forEach(function(U){C.currentMarker===void 0?(U.style.fillOpacity="0.4",U.style.pointerEvents="none"):(U.style.fillOpacity="1",U.style.pointerEvents="all")})},z}(),We=function(){function z(v,C,U,J){this.panels=[],this.panelButtons=[],this.markerjsContainer=v,this.displayMode=C,this.uiStyleSettings=U,this.styles=J,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return z.prototype.addStyles=function(){var v;this.toolboxStyleClass=this.styles.addClass(new Oe("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 Oe("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var C=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Oe("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Oe("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Oe("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 Oe("toolbox-panel-row_colors",`
background-color: `+((v=this.uiStyleSettings.toolboxBackgroundColor)!==null&&v!==void 0?v:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Oe("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*C)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*C)+`px;
padding: `+C+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Oe("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Oe("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new ot("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new ot("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},z.prototype.show=function(v){var C;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=v,this.uiContainer.className=this.toolboxStyleClass.name+" "+((C=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&C!==void 0?C:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},z.prototype.setPanelButtons=function(v){var C,U,J=this;this.panels=v,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((C=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&C!==void 0?C:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((U=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&U!==void 0?U:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(W){var pe;W.uiStyleSettings=J.uiStyleSettings;var De=document.createElement("div");De.className=J.toolboxButtonStyleClass.name+" "+((pe=J.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&pe!==void 0?pe:J.toolboxButtonStyleColorsClass.name),De.innerHTML=W.icon,De.title=W.title,De.addEventListener("click",function(){J.panelButtonClick(W)}),J.panelButtons.push(De),J.buttonRow.appendChild(De)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},z.prototype.panelButtonClick=function(v){var C=this,U=-1;if(v!==this.activePanel){U=this.panels.indexOf(v),this.panelRow.innerHTML="";var J=v.getUi();J.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(J),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=v}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){C.displayMode==="inline"?C.panelRow.style.display="none":C.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(W,pe){var De,it;W.className=C.toolboxButtonStyleClass.name+" "+(pe===U?""+((De=C.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&De!==void 0?De:C.toolboxActiveButtonStyleColorsClass.name):""+((it=C.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&it!==void 0?it:C.toolboxButtonStyleColorsClass.name))})},z}(),qe=function(z,v){this.title=z,this.icon=v},Ve=function(z){function v(C,U,J,W){var pe=z.call(this,C,W||'<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 pe.colors=[],pe.addTransparent=!1,pe.colorBoxes=[],pe.colors=U,pe.currentColor=J,pe.setCurrentColor=pe.setCurrentColor.bind(pe),pe.getColorBox=pe.getColorBox.bind(pe),pe}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");return U.style.overflow="hidden",U.style.whiteSpace="nowrap",this.colors.forEach(function(J){var W=C.getColorBox(J);U.appendChild(W),C.colorBoxes.push(W)}),U},v.prototype.getColorBox=function(C){var U=this,J=this.uiStyleSettings.toolbarHeight/4,W=this.uiStyleSettings.toolbarHeight-J,pe=document.createElement("div");pe.style.display="inline-block",pe.style.boxSizing="content-box",pe.style.width=W-2+"px",pe.style.height=W-2+"px",pe.style.padding="1px",pe.style.marginRight="2px",pe.style.marginBottom="2px",pe.style.borderWidth="2px",pe.style.borderStyle="solid",pe.style.borderRadius=(W+2)/2+"px",pe.style.borderColor=C===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",pe.addEventListener("click",function(){U.setCurrentColor(C,pe)});var De=document.createElement("div");return De.style.display="inline-block",De.style.width=W-2+"px",De.style.height=W-2+"px",De.style.backgroundColor=C,De.style.borderRadius=W/2+"px",C==="transparent"&&(De.style.fill=this.uiStyleSettings.toolboxAccentColor,De.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>`),pe.appendChild(De),pe},v.prototype.setCurrentColor=function(C,U){var J=this;this.currentColor=C,this.colorBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(C)},v}(qe),je=function(){function z(v,C,U){this._state="new",this._isSelected=!1,this._container=v,this._overlayContainer=C,this.globalSettings=U,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(z.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),z.prototype.ownsTarget=function(v){return!1},Object.defineProperty(z.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),z.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},z.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},z.prototype.pointerDown=function(v,C){},z.prototype.dblClick=function(v,C){},z.prototype.manipulate=function(v){},z.prototype.pointerUp=function(v){this.stateChanged()},z.prototype.dispose=function(){},z.prototype.addMarkerVisualToContainer=function(v){this.container.childNodes.length>0?this.container.insertBefore(v,this.container.childNodes[0]):this.container.appendChild(v)},z.prototype.getState=function(){return{typeName:z.typeName,state:this.state,notes:this.notes}},z.prototype.restoreState=function(v){this._state=v.state,this.notes=v.notes},z.prototype.scale=function(v,C){},z.prototype.colorChanged=function(v){this.onColorChanged&&this.onColorChanged(v),this.stateChanged()},z.prototype.fillColorChanged=function(v){this.onFillColorChanged&&this.onFillColorChanged(v),this.stateChanged()},z.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var v=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),v.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(v)&&this.onStateChanged(this)}},z.typeName="MarkerBase",z}(),Fe=function(){function z(){this.findGripByVisual=this.findGripByVisual.bind(this)}return z.prototype.findGripByVisual=function(v){return this.topLeft.ownsTarget(v)?this.topLeft:this.topCenter.ownsTarget(v)?this.topCenter:this.topRight.ownsTarget(v)?this.topRight:this.centerLeft.ownsTarget(v)?this.centerLeft:this.centerRight.ownsTarget(v)?this.centerRight:this.bottomLeft.ownsTarget(v)?this.bottomLeft:this.bottomCenter.ownsTarget(v)?this.bottomCenter:this.bottomRight.ownsTarget(v)?this.bottomRight:void 0},z}(),ht=function(){function z(){this.GRIP_SIZE=10,this.visual=oe.createGroup(),this.visual.appendChild(oe.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(oe.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(v){return v===this.visual||v===this.visual.childNodes[0]||v===this.visual.childNodes[1]},z}(),He=function(){function z(){}return z.toITransformMatrix=function(v){return{a:v.a,b:v.b,c:v.c,d:v.d,e:v.e,f:v.f}},z.toSVGMatrix=function(v,C){return v.a=C.a,v.b=C.b,v.c=C.c,v.d=C.d,v.e=C.e,v.f=C.f,v},z}(),Pe=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.left=0,W.top=0,W.width=0,W.height=0,W.defaultSize={x:50,y:20},W.offsetX=0,W.offsetY=0,W.rotationAngle=0,W.CB_DISTANCE=10,W._suppressMarkerCreateEvent=!1,W.container.transform.baseVal.appendItem(oe.createTransform()),W.setupControlBox(),W}return be(v,z),Object.defineProperty(v.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"visual",{get:function(){return this._visual},set:function(C){this._visual=C;var U=oe.createTransform();this._visual.transform.baseVal.appendItem(U)},enumerable:!1,configurable:!0}),v.prototype.ownsTarget=function(C){return!!z.prototype.ownsTarget.call(this,C)||!!(this.controlGrips.findGripByVisual(C)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(C))},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="new"&&(this.left=C.x,this.top=C.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var J=this.unrotatePoint(C);if(this.manipulationStartX=J.x,this.manipulationStartY=J.y,this.offsetX=J.x-this.left,this.offsetY=J.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(U),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(U)){this.activeGrip=this.rotatorGrip;var W=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=W.x-this.width/2,this.top=W.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var pe=this.container.transform.baseVal.getItem(0);pe.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(pe,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},v.prototype.pointerUp=function(C){var U=this.state;z.prototype.pointerUp.call(this,C),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(C),this._state="select",U==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},v.prototype.moveVisual=function(C){this.visual.style.transform="translate("+C.x+"px, "+C.y+"px)"},v.prototype.manipulate=function(C){var U=this.unrotatePoint(C);this.state==="creating"?this.resize(C):this.state==="move"?(this.left=this.manipulationStartLeft+(U.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(U.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(U):this.state==="rotate"&&this.rotate(C)},v.prototype.resize=function(C){var U=this.manipulationStartLeft,J=this.manipulationStartWidth,W=this.manipulationStartTop,pe=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:U=this.manipulationStartLeft+C.x-this.manipulationStartX,J=this.manipulationStartWidth+this.manipulationStartLeft-U;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:J=this.manipulationStartWidth+C.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:W=this.manipulationStartTop+C.y-this.manipulationStartY,pe=this.manipulationStartHeight+this.manipulationStartTop-W;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:pe=this.manipulationStartHeight+C.y-this.manipulationStartY}J>=0?(this.left=U,this.width=J):(this.left=U+J,this.width=-J),pe>=0?(this.top=W,this.height=pe):(this.top=W+pe,this.height=-pe),this.setSize()},v.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},v.prototype.rotate=function(C){if(Math.abs(C.x-this.centerX)>.1){var U=Math.sign(C.x-this.centerX);this.rotationAngle=180*Math.atan((C.y-this.centerY)/(C.x-this.centerX))/Math.PI+90*U,this.applyRotation()}},v.prototype.applyRotation=function(){var C=this.container.transform.baseVal.getItem(0);C.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(C,0)},v.prototype.rotatePoint=function(C){if(this.rotationAngle===0)return C;var U=this.container.getCTM(),J=oe.createPoint(C.x,C.y);return{x:(J=J.matrixTransform(U)).x,y:J.y}},v.prototype.unrotatePoint=function(C){if(this.rotationAngle===0)return C;var U=this.container.getCTM();U=U.inverse();var J=oe.createPoint(C.x,C.y);return{x:(J=J.matrixTransform(U)).x,y:J.y}},v.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},v.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},v.prototype.setupControlBox=function(){this.controlBox=oe.createGroup();var C=oe.createTransform();C.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(C),this.container.appendChild(this.controlBox),this.controlRect=oe.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=oe.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 Fe,this.addControlGrips(),this.controlBox.style.display="none"},v.prototype.adjustControlBox=function(){var C=this.controlBox.transform.baseVal.getItem(0);C.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(C,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()},v.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()},v.prototype.createGrip=function(){var C=new ht;return C.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(C.visual),C},v.prototype.positionGrips=function(){var C=this.controlGrips.topLeft.GRIP_SIZE,U=-C/2,J=U,W=(this.width+this.CB_DISTANCE)/2-C/2,pe=(this.height+this.CB_DISTANCE)/2-C/2,De=this.height+this.CB_DISTANCE-C/2,it=this.width+this.CB_DISTANCE-C/2;this.positionGrip(this.controlGrips.topLeft.visual,U,J),this.positionGrip(this.controlGrips.topCenter.visual,W,J),this.positionGrip(this.controlGrips.topRight.visual,it,J),this.positionGrip(this.controlGrips.centerLeft.visual,U,pe),this.positionGrip(this.controlGrips.centerRight.visual,it,pe),this.positionGrip(this.controlGrips.bottomLeft.visual,U,De),this.positionGrip(this.controlGrips.bottomCenter.visual,W,De),this.positionGrip(this.controlGrips.bottomRight.visual,it,De),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,W,J-3*this.CB_DISTANCE)},v.prototype.positionGrip=function(C,U,J){var W=C.transform.baseVal.getItem(0);W.setTranslate(U,J),C.transform.baseVal.replaceItem(W,0)},v.prototype.hideControlBox=function(){this.controlBox.style.display="none"},v.prototype.showControlBox=function(){this.controlBox.style.display=""},v.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:He.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:He.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},z.prototype.getState.call(this))},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C);var U=C;this.left=U.left,this.top=U.top,this.width=U.width,this.height=U.height,this.rotationAngle=U.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(He.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,U.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(He.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,U.containerTransformMatrix))},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U);var J=this.rotatePoint({x:this.left,y:this.top}),W=this.unrotatePoint({x:J.x*C,y:J.y*U});this.left=W.x,this.top=W.y,this.width=this.width*C,this.height=this.height*U,this.adjustControlBox()},v}(je),Xe=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.fillColor="transparent",W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.opacity=1,W.setStrokeColor=W.setStrokeColor.bind(W),W.setFillColor=W.setFillColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.createVisual=W.createVisual.bind(W),W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.visual)},v.prototype.createVisual=function(){this.visual=oe.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)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="new"&&(this.createVisual(),this.moveVisual(C),this._state="creating")},v.prototype.manipulate=function(C){z.prototype.manipulate.call(this,C)},v.prototype.resize=function(C){z.prototype.resize.call(this,C),this.setSize()},v.prototype.setSize=function(){z.prototype.setSize.call(this),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},v.prototype.pointerUp=function(C){z.prototype.pointerUp.call(this,C),this.setSize()},v.prototype.setStrokeColor=function(C){this.strokeColor=C,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(C),this.stateChanged()},v.prototype.setFillColor=function(C){this.fillColor=C,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},v.prototype.setStrokeWidth=function(C){this.strokeWidth=C,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},v.prototype.setStrokeDasharray=function(C){this.strokeDasharray=C,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},v.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this))},v.prototype.restoreState=function(C){var U=C;this.fillColor=U.fillColor,this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.opacity=U.opacity,this.createVisual(),z.prototype.restoreState.call(this,C),this.setSize()},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.setSize()},v.title="Rectangle marker",v}(Pe),tt=function(z){function v(C,U,J,W){var pe=z.call(this,C,W||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return pe.widths=[],pe.widthBoxes=[],pe.widths=U,pe.currentWidth=J,pe.setCurrentWidth=pe.setCurrentWidth.bind(pe),pe}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",this.widths.forEach(function(J){var W=document.createElement("div");W.style.display="flex",W.style.flexGrow="2",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.borderColor=J===C.currentWidth?C.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){C.setCurrentWidth(J,W)}),U.appendChild(W);var pe=document.createElement("div");pe.innerText=J.toString(),pe.style.marginRight="5px",W.appendChild(pe);var De=document.createElement("div");De.style.minHeight="20px",De.style.flexGrow="2",De.style.display="flex",De.style.alignItems="center";var it=document.createElement("hr");it.style.minWidth="20px",it.style.border="0px",it.style.borderTop=J+"px solid "+C.uiStyleSettings.toolboxColor,it.style.flexGrow="2",De.appendChild(it),W.appendChild(De),C.widthBoxes.push(W)}),U},v.prototype.setCurrentWidth=function(C,U){var J=this;this.currentWidth=C,this.widthBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},v}(qe),Ke=function(z){function v(C,U,J,W){var pe=z.call(this,C,W||'<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 pe.styles=[],pe.styleBoxes=[],pe.styles=U,pe.currentStyle=J,pe.setCurrentStyle=pe.setCurrentStyle.bind(pe),pe}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",this.styles.forEach(function(J){var W=document.createElement("div");W.style.display="flex",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.overflow="hidden",W.style.maxWidth=100/C.styles.length-5+"%",W.style.borderColor=J===C.currentStyle?C.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){C.setCurrentStyle(J,W)}),U.appendChild(W);var pe=document.createElement("div");pe.style.minHeight="20px",pe.style.flexGrow="2",pe.style.overflow="hidden";var De=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+C.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(J!==""?'stroke-dasharray="'+J+'"':"")+` />
</svg>`;pe.innerHTML=De,W.appendChild(pe),C.styleBoxes.push(W)}),U},v.prototype.setCurrentStyle=function(C,U){var J=this;this.currentStyle=C,this.styleBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},v}(qe),et=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.strokeColor=J.defaultColor,W.strokeWidth=J.defaultStrokeWidth,W.strokeDasharray=J.defaultStrokeDasharray,W.strokePanel=new Ve("Line color",J.defaultColorSet,J.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new tt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new Ke("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return be(v,z),Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=z.prototype.getState.call(this);return C.typeName=v.typeName,C},v.typeName="FrameMarker",v.title="Frame marker",v.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',v}(Xe),Ae=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},nt=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.x1=0,W.y1=0,W.x2=0,W.y2=0,W.defaultLength=50,W.manipulationStartX=0,W.manipulationStartY=0,W.manipulationStartX1=0,W.manipulationStartY1=0,W.manipulationStartX2=0,W.manipulationStartY2=0,W.setupControlBox(),W}return be(v,z),v.prototype.ownsTarget=function(C){return!!z.prototype.ownsTarget.call(this,C)||!(!this.grip1.ownsTarget(C)&&!this.grip2.ownsTarget(C))},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.manipulationStartX=C.x,this.manipulationStartY=C.y,this.state==="new"&&(this.x1=C.x,this.y1=C.y,this.x2=C.x,this.y2=C.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(U)?this.activeGrip=this.grip1:this.grip2.ownsTarget(U)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},v.prototype.pointerUp=function(C){var U=this.state;z.prototype.pointerUp.call(this,C),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(C),this._state="select",U==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},v.prototype.adjustVisual=function(){},v.prototype.manipulate=function(C){this.state==="creating"?this.resize(C):this.state==="move"?(this.x1=this.manipulationStartX1+C.x-this.manipulationStartX,this.y1=this.manipulationStartY1+C.y-this.manipulationStartY,this.x2=this.manipulationStartX2+C.x-this.manipulationStartX,this.y2=this.manipulationStartY2+C.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(C)},v.prototype.resize=function(C){switch(this.activeGrip){case this.grip1:this.x1=C.x,this.y1=C.y;break;case this.grip2:case void 0:this.x2=C.x,this.y2=C.y}this.adjustVisual(),this.adjustControlBox()},v.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},v.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},v.prototype.setupControlBox=function(){this.controlBox=oe.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},v.prototype.adjustControlBox=function(){this.positionGrips()},v.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},v.prototype.createGrip=function(){var C=new ht;return C.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(C.visual),C},v.prototype.positionGrips=function(){var C=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-C/2,this.y1-C/2),this.positionGrip(this.grip2.visual,this.x2-C/2,this.y2-C/2)},v.prototype.positionGrip=function(C,U,J){var W=C.transform.baseVal.getItem(0);W.setTranslate(U,J),C.transform.baseVal.replaceItem(W,0)},v.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},z.prototype.getState.call(this))},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C);var U=C;this.x1=U.x1,this.y1=U.y1,this.x2=U.x2,this.y2=U.y2},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.x1=this.x1*C,this.y1=this.y1*U,this.x2=this.x2*C,this.y2=this.y2*U,this.adjustVisual(),this.adjustControlBox()},v}(je),Je=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.setStrokeColor=W.setStrokeColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.strokeColor=J.defaultColor,W.strokeWidth=J.defaultStrokeWidth,W.strokeDasharray=J.defaultStrokeDasharray,W.strokePanel=new Ve("Line color",J.defaultColorSet,J.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new tt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new Ke("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.visual&&C!==this.selectorLine&&C!==this.visibleLine)},v.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorLine=oe.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=oe.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)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},v.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()),oe.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},v.prototype.setStrokeColor=function(C){this.strokeColor=C,this.adjustVisual(),this.colorChanged(C)},v.prototype.setStrokeWidth=function(C){this.strokeWidth=C,this.adjustVisual()},v.prototype.setStrokeDasharray=function(C){this.strokeDasharray=C,this.adjustVisual(),this.stateChanged()},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C);var U=C;this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.createVisual(),this.adjustVisual()},v.typeName="LineMarker",v.title="Line marker",v.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',v}(nt),Se=function(z){function v(C,U,J,W){var pe=z.call(this,C,W||'<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 pe.fonts=[],pe.fontBoxes=[],pe.fonts=U,pe.currentFont=J,pe.setCurrentFont=pe.setCurrentFont.bind(pe),pe}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");return U.style.overflow="hidden",U.style.flexGrow="2",this.fonts.forEach(function(J){var W=document.createElement("div");W.style.display="inline-block",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.overflow="hidden",W.style.maxWidth=100/C.fonts.length-5+"%",W.style.borderColor=J===C.currentFont?C.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){C.setCurrentFont(J,W)}),U.appendChild(W);var pe=document.createElement("div");pe.style.display="flex",pe.style.minHeight="20px",pe.style.flexGrow="2",pe.style.fontFamily=J,pe.style.overflow="hidden";var De=document.createElement("div");De.style.whiteSpace="nowrap",De.style.overflow="hidden",De.style.textOverflow="ellipsis",De.innerHTML="The quick brown fox jumps over the lazy dog",pe.appendChild(De),W.appendChild(pe),C.fontBoxes.push(W)}),U},v.prototype.setCurrentFont=function(C,U){var J=this;this.currentFont=C,this.fontBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},v}(qe),ke=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.color="transparent",W.padding=5,W.DEFAULT_TEXT="your text here",W.text=W.DEFAULT_TEXT,W.isMoved=!1,W.color=J.defaultColor,W.fontFamily=J.defaultFontFamily,W.defaultSize={x:100,y:30},W.setColor=W.setColor.bind(W),W.setFont=W.setFont.bind(W),W.renderText=W.renderText.bind(W),W.sizeText=W.sizeText.bind(W),W.textEditDivClicked=W.textEditDivClicked.bind(W),W.showTextEditor=W.showTextEditor.bind(W),W.setSize=W.setSize.bind(W),W.positionTextEditor=W.positionTextEditor.bind(W),W.colorPanel=new Ve("Color",J.defaultColorSet,J.defaultColor),W.colorPanel.onColorChanged=W.setColor,W.fontFamilyPanel=new Se("Font",J.defaultFontFamilies,J.defaultFontFamily),W.fontFamilyPanel.onFontChanged=W.setFont,W}return be(v,z),v.prototype.ownsTarget=function(C){if(z.prototype.ownsTarget.call(this,C)||C===this.visual||C===this.textElement||C===this.bgRectangle)return!0;var U=!1;return this.textElement.childNodes.forEach(function(J){J===C&&(U=!0)}),U},v.prototype.createVisual=function(){this.visual=oe.createGroup(),this.bgRectangle=oe.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=oe.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.isMoved=!1,this.pointerDownPoint=C,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(C),this._state="creating")},v.prototype.renderText=function(){var C=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(U){C.textElement.appendChild(oe.createTSpan(U.trim()===""?" ":U.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},v.prototype.getTextScale=function(){var C=this.textElement.getBBox(),U=1;if(C.width>0&&C.height>0){var J=(1*this.width-this.width*this.padding*2/100)/C.width,W=(1*this.height-this.height*this.padding*2/100)/C.height;U=Math.min(J,W)}return U},v.prototype.getTextPosition=function(C){var U=this.textElement.getBBox(),J=0,W=0;return U.width>0&&U.height>0&&(J=(this.width-U.width*C)/2,W=this.height/2-U.height*C/2),{x:J,y:W}},v.prototype.sizeText=function(){var C=this.textElement.getBBox(),U=this.getTextScale(),J=this.getTextPosition(U);J.y-=C.y*U,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+J.x+"px, "+J.y+"px) scale("+U+", "+U+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(J.x,J.y),this.textElement.transform.baseVal.getItem(1).setScale(U,U))},v.prototype.manipulate=function(C){z.prototype.manipulate.call(this,C),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(C.x-this.pointerDownPoint.x)>5||Math.abs(C.y-this.pointerDownPoint.y)>5)},v.prototype.resize=function(C){z.prototype.resize.call(this,C),this.isMoved=!0,this.setSize(),this.sizeText()},v.prototype.setSize=function(){z.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},v.prototype.pointerUp=function(C){var U=this.state;U==="creating"&&(this._suppressMarkerCreateEvent=!0),z.prototype.pointerUp.call(this,C),this.setSize(),(U==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},v.prototype.showTextEditor=function(){var C=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(U){U.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var U=Number.parseFloat(C.textEditor.style.fontSize);C.textEditor.clientWidth>=Number.parseInt(C.textEditor.style.maxWidth)&&U>.9;)U-=.1,C.textEditor.style.fontSize=Math.max(U,.9)+"em"}),this.textEditor.addEventListener("keyup",function(U){U.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(U){if(U.clipboardData){var J=U.clipboardData.getData("text"),W=window.getSelection();if(!W.rangeCount)return!1;W.deleteFromDocument(),W.getRangeAt(0).insertNode(document.createTextNode(J)),U.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){C.textEditDivClicked(C.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},v.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var C=this.getTextScale(),U=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),J=this.textElement.getBBox(),W={x:J.width*C,y:J.height*C};U.x-=W.x/2,U.y-=W.y/2,this.textEditor.style.top=U.y+"px",this.textEditor.style.left=U.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-U.x+"px",this.textEditor.style.fontSize=Math.max(16*C,12)+"px",this.textElement.style.display="none"}},v.prototype.textEditDivClicked=function(C){this.text=C.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},v.prototype.select=function(){z.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},v.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),z.prototype.deselect.call(this)},v.prototype.dblClick=function(C,U){z.prototype.dblClick.call(this,C,U),this.showTextEditor()},v.prototype.setColor=function(C){this.textElement&&oe.setAttributes(this.textElement,[["fill",C]]),this.color=C,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(C)},v.prototype.setFont=function(C){this.textElement&&oe.setAttributes(this.textElement,[["font-family",C]]),this.fontFamily=C,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},v.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},v.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){var U=C;this.color=U.color,this.fontFamily=U.fontFamily,this.padding=U.padding,this.text=U.text,this.createVisual(),z.prototype.restoreState.call(this,C),this.setSize()},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.setSize(),this.sizeText(),this.positionTextEditor()},v.typeName="TextMarker",v.title="Text marker",v.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>',v}(Pe),me=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.color="transparent",W.lineWidth=3,W.drawing=!1,W.pixelRatio=1,W.color=J.defaultColor,W.lineWidth=J.defaultStrokeWidth,W.pixelRatio=J.freehandPixelRatio,W.setColor=W.setColor.bind(W),W.addCanvas=W.addCanvas.bind(W),W.finishCreation=W.finishCreation.bind(W),W.setLineWidth=W.setLineWidth.bind(W),W.colorPanel=new Ve("Color",J.defaultColorSet,J.defaultColor),W.colorPanel.onColorChanged=W.setColor,W.lineWidthPanel=new tt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),W.lineWidthPanel.onWidthChanged=W.setLineWidth,W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.visual&&C!==this.drawingImage)},v.prototype.createVisual=function(){this.visual=oe.createGroup(),this.drawingImage=oe.createImage(),this.visual.appendChild(this.drawingImage);var C=oe.createTransform();this.visual.transform.baseVal.appendItem(C),this.addMarkerVisualToContainer(this.visual)},v.prototype.pointerDown=function(C,U){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(C.x,C.y),this.drawing=!0):z.prototype.pointerDown.call(this,C,U)},v.prototype.manipulate=function(C){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(C.x,C.y),this.canvasContext.stroke()):z.prototype.manipulate.call(this,C)},v.prototype.resize=function(C){z.prototype.resize.call(this,C),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},v.prototype.pointerUp=function(C){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):z.prototype.pointerUp.call(this,C)},v.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)},v.prototype.select=function(){this.state==="creating"&&this.finishCreation(),z.prototype.select.call(this)},v.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),z.prototype.deselect.call(this)},v.prototype.finishCreation=function(){for(var C=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),U=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],J=U[0],W=U[1],pe=U[2],De=U[3],it=!1,gt=0;gt<this.canvasElement.height;gt++)for(var Ne=0;Ne<this.canvasElement.width;Ne++)C.data[gt*this.canvasElement.width*4+4*Ne+3]>0&&(it=!0,gt<W&&(W=gt),Ne<J&&(J=Ne),gt>De&&(De=gt),Ne>pe&&(pe=Ne));if(it){this.left=J/this.pixelRatio,this.top=W/this.pixelRatio,this.width=(pe-J)/this.pixelRatio,this.height=(De-W)/this.pixelRatio;var Tt=document.createElement("canvas");Tt.width=pe-J,Tt.height=De-W,Tt.getContext("2d").putImageData(this.canvasContext.getImageData(J,W,pe-J,De-W),0,0),this.drawingImgUrl=Tt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},v.prototype.setDrawingImage=function(){oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},v.prototype.setColor=function(C){this.color=C,this.colorChanged(C)},v.prototype.setLineWidth=function(C){this.lineWidth=C},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({drawingImgUrl:this.drawingImgUrl},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){this.createVisual(),z.prototype.restoreState.call(this,C),this.drawingImgUrl=C.drawingImgUrl,this.setDrawingImage()},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.setDrawingImage()},v.typeName="FreehandMarker",v.title="Freehand marker",v.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>',v}(Pe),he=function(z){function v(C,U,J){var W=z.call(this,C,J||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return W.typeBoxes=[],W.currentType=U,W.setCurrentType=W.setCurrentType.bind(W),W}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2";for(var J=function(De){var it="both";switch(De){case 0:it="both";break;case 1:it="start";break;case 2:it="end";break;case 3:it="none"}var gt=document.createElement("div");if(gt.style.display="flex",gt.style.flexGrow="2",gt.style.alignItems="center",gt.style.justifyContent="space-between",gt.style.padding="5px",gt.style.borderWidth="2px",gt.style.borderStyle="solid",gt.style.borderColor=it===W.currentType?W.uiStyleSettings.toolboxAccentColor:"transparent",gt.addEventListener("click",function(){C.setCurrentType(it,gt)}),U.appendChild(gt),it==="both"||it==="start"){var Ne=document.createElement("div");Ne.style.display="flex",Ne.style.alignItems="center",Ne.style.minHeight="20px",Ne.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,5 10,0 10,10" fill="`+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Ne.style.marginLeft="5px",gt.appendChild(Ne)}var Tt=document.createElement("div");Tt.style.display="flex",Tt.style.alignItems="center",Tt.style.minHeight="20px",Tt.style.flexGrow="2";var zt=document.createElement("hr");if(zt.style.minWidth="20px",zt.style.border="0px",zt.style.borderTop="3px solid "+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee"),zt.style.flexGrow="2",Tt.appendChild(zt),gt.appendChild(Tt),it==="both"||it==="end"){var qt=document.createElement("div");qt.style.display="flex",qt.style.alignItems="center",qt.style.minHeight="20px",qt.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="`+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,qt.style.marginRight="5px",gt.appendChild(qt)}W.typeBoxes.push(gt)},W=this,pe=0;pe<4;pe++)J(pe);return U},v.prototype.setCurrentType=function(C,U){var J=this;this.currentType=C,this.typeBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings!==void 0?J.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},v}(qe),de=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.arrowType="end",W.arrowBaseHeight=10,W.arrowBaseWidth=10,W.getArrowPoints=W.getArrowPoints.bind(W),W.setArrowType=W.setArrowType.bind(W),W.arrowTypePanel=new he("Arrow type","end"),W.arrowTypePanel.onArrowTypeChanged=W.setArrowType,W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.arrow1&&C!==this.arrow2)},v.prototype.getArrowPoints=function(C,U){var J=this.arrowBaseWidth+2*this.strokeWidth,W=this.arrowBaseHeight+2*this.strokeWidth;return C-J/2+","+(U+W/2)+" "+C+","+(U-W/2)+" "+(C+J/2)+","+(U+W/2)},v.prototype.createTips=function(){this.arrow1=oe.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=oe.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow2)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="creating"&&this.createTips()},v.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",oe.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),oe.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var C=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),U=this.arrow1.transform.baseVal.getItem(0);U.setRotate(C,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(U,0);var J=this.arrow2.transform.baseVal.getItem(0);J.setRotate(C+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(J,0)}},v.prototype.setArrowType=function(C){this.arrowType=C,this.adjustVisual(),this.stateChanged()},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({arrowType:this.arrowType},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C);var U=C;this.arrowType=U.arrowType,this.createTips(),this.adjustVisual()},v.typeName="ArrowMarker",v.title="Arrow marker",v.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',v}(Je),ie=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.fillColor=J.defaultFillColor,W.strokeWidth=0,W.fillPanel=new Ve("Color",J.defaultColorSet,J.defaultFillColor),W.fillPanel.onColorChanged=W.setFillColor,W}return be(v,z),Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=z.prototype.getState.call(this);return C.typeName=v.typeName,C},v.typeName="CoverMarker",v.title="Cover marker",v.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',v}(Xe),q=function(z){function v(C,U,J,W){var pe=z.call(this,C,W||'<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 pe.opacities=[],pe.opacityBoxes=[],pe.opacities=U,pe.currentOpacity=J,pe.setCurrentOpacity=pe.setCurrentOpacity.bind(pe),pe}return be(v,z),v.prototype.getUi=function(){var C=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",U.style.justifyContent="space-between",this.opacities.forEach(function(J){var W=document.createElement("div");W.style.display="flex",W.style.alignItems="center",W.style.justifyContent="center",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.borderColor=J===C.currentOpacity?C.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){C.setCurrentOpacity(J,W)}),U.appendChild(W);var pe=document.createElement("div");pe.innerText=100*J+"%",W.appendChild(pe),C.opacityBoxes.push(W)}),U},v.prototype.setCurrentOpacity=function(C,U){var J=this;this.currentOpacity=C,this.opacityBoxes.forEach(function(W){W.style.borderColor=W===U?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},v}(qe),se=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.setOpacity=W.setOpacity.bind(W),W.fillColor=J.defaultHighlightColor,W.strokeWidth=0,W.opacity=J.defaultHighlightOpacity,W.fillPanel=new Ve("Color",J.defaultColorSet,W.fillColor),W.fillPanel.onColorChanged=W.setFillColor,W.opacityPanel=new q("Opacity",J.defaultOpacitySteps,W.opacity),W.opacityPanel.onOpacityChanged=W.setOpacity,W}return be(v,z),v.prototype.setOpacity=function(C){this.opacity=C,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=z.prototype.getState.call(this);return C.typeName=v.typeName,C},v.typeName="HighlightMarker",v.title="Highlight marker",v.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>',v}(ie),ue='<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>',ge=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.bgColor="transparent",W.tipPosition={x:0,y:0},W.tipBase1Position={x:0,y:0},W.tipBase2Position={x:0,y:0},W.tipMoving=!1,W.color=J.defaultStrokeColor,W.bgColor=J.defaultFillColor,W.fontFamily=J.defaultFontFamily,W.defaultSize={x:100,y:30},W.setBgColor=W.setBgColor.bind(W),W.getTipPoints=W.getTipPoints.bind(W),W.positionTip=W.positionTip.bind(W),W.setTipPoints=W.setTipPoints.bind(W),W.colorPanel=new Ve("Text color",J.defaultColorSet,W.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>'),W.colorPanel.onColorChanged=W.setColor,W.bgColorPanel=new Ve("Fill color",J.defaultColorSet,W.bgColor,ue),W.bgColorPanel.onColorChanged=W.setBgColor,W.fontFamilyPanel=new Se("Font",J.defaultFontFamilies,J.defaultFontFamily),W.fontFamilyPanel.onFontChanged=W.setFont,W.tipGrip=new ht,W.tipGrip.visual.transform.baseVal.appendItem(oe.createTransform()),W.controlBox.appendChild(W.tipGrip.visual),W}return be(v,z),v.prototype.ownsTarget=function(C){return z.prototype.ownsTarget.call(this,C)||this.tipGrip.ownsTarget(C)||this.tip===C},v.prototype.createTip=function(){oe.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=oe.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},v.prototype.pointerDown=function(C,U){this.state==="new"&&z.prototype.pointerDown.call(this,C,U),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(U)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):z.prototype.pointerDown.call(this,C,U)},v.prototype.pointerUp=function(C){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,z.prototype.pointerUp.call(this,C);else{var U=this.state==="creating";z.prototype.pointerUp.call(this,C),this.setTipPoints(U),this.positionTip()}},v.prototype.manipulate=function(C){if(this.tipMoving){var U=this.unrotatePoint(C);this.tipPosition={x:U.x-this.manipulationStartLeft,y:U.y-this.manipulationStartTop},this.positionTip()}else z.prototype.manipulate.call(this,C)},v.prototype.setBgColor=function(C){this.bgRectangle&&this.tip&&(oe.setAttributes(this.bgRectangle,[["fill",C]]),oe.setAttributes(this.tip,[["fill",C]])),this.bgColor=C,this.fillColorChanged(C)},v.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},v.prototype.setTipPoints=function(C){C===void 0&&(C=!1);var U=Math.min(this.height/2,15),J=this.height/5;C&&(this.tipPosition={x:U+J/2,y:this.height+20});var W=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?W<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(J=this.width/5,U=Math.min(this.width/2,15),this.tipBase1Position={x:U,y:0},this.tipBase2Position={x:U+J,y:0}):(this.tipBase1Position={x:0,y:U},this.tipBase2Position={x:0,y:U+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?W<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(J=this.width/5,U=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-U-J,y:0},this.tipBase2Position={x:this.width-U,y:0}):(this.tipBase1Position={x:this.width,y:U},this.tipBase2Position={x:this.width,y:U+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?W<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(J=this.width/5,U=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-U-J,y:this.height},this.tipBase2Position={x:this.width-U,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-U-J},this.tipBase2Position={x:this.width,y:this.height-U}):W<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(J=this.width/5,U=Math.min(this.width/2,15),this.tipBase1Position={x:U,y:this.height},this.tipBase2Position={x:U+J,y:this.height}):(this.tipBase1Position={x:0,y:this.height-U},this.tipBase2Position={x:0,y:this.height-U-J})},v.prototype.resize=function(C){z.prototype.resize.call(this,C),this.positionTip()},v.prototype.positionTip=function(){oe.setAttributes(this.tip,[["points",this.getTipPoints()]]);var C=this.tipGrip.visual.transform.baseVal.getItem(0);C.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(C,0)},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),v.prototype.select=function(){this.positionTip(),z.prototype.select.call(this)},v.prototype.getState=function(){var C=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){var U=C;this.bgColor=U.bgColor,this.tipPosition=U.tipPosition,z.prototype.restoreState.call(this,C),this.createTip(),this.setTipPoints()},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.tipPosition={x:this.tipPosition.x*C,y:this.tipPosition.y*U},this.positionTip()},v.typeName="CalloutMarker",v.title="Callout marker",v.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>',v}(ke),Ce=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.fillColor="transparent",W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.opacity=1,W.strokeColor=J.defaultColor,W.strokeWidth=J.defaultStrokeWidth,W.strokeDasharray=J.defaultStrokeDasharray,W.fillColor=J.defaultFillColor,W.setStrokeColor=W.setStrokeColor.bind(W),W.setFillColor=W.setFillColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.setOpacity=W.setOpacity.bind(W),W.createVisual=W.createVisual.bind(W),W.strokePanel=new Ve("Line color",ve(J.defaultColorSet,["transparent"]),J.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.fillPanel=new Ve("Fill color",ve(J.defaultColorSet,["transparent"]),W.fillColor,ue),W.fillPanel.onColorChanged=W.setFillColor,W.strokeWidthPanel=new tt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new Ke("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W.opacityPanel=new q("Opacity",J.defaultOpacitySteps,W.opacity),W.opacityPanel.onOpacityChanged=W.setOpacity,W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.visual)},v.prototype.createVisual=function(){this.visual=oe.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)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="new"&&(this.createVisual(),this.moveVisual(C),this._state="creating")},v.prototype.manipulate=function(C){z.prototype.manipulate.call(this,C)},v.prototype.resize=function(C){z.prototype.resize.call(this,C),this.setSize()},v.prototype.setSize=function(){z.prototype.setSize.call(this),oe.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},v.prototype.pointerUp=function(C){z.prototype.pointerUp.call(this,C),this.setSize()},v.prototype.setStrokeColor=function(C){this.strokeColor=C,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(C),this.stateChanged()},v.prototype.setFillColor=function(C){this.fillColor=C,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(C),this.stateChanged()},v.prototype.setStrokeWidth=function(C){this.strokeWidth=C,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},v.prototype.setStrokeDasharray=function(C){this.strokeDasharray=C,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},v.prototype.setOpacity=function(C){this.opacity=C,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){var U=C;this.fillColor=U.fillColor,this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.opacity=U.opacity,this.createVisual(),z.prototype.restoreState.call(this,C),this.setSize()},v.prototype.scale=function(C,U){z.prototype.scale.call(this,C,U),this.setSize()},v.typeName="EllipseMarker",v.title="Ellipse marker",v.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>',v}(Pe),Le=function(z){function v(C,U,J){return z.call(this,C,U,J)||this}return be(v,z),Object.defineProperty(v.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.tip1&&C!==this.tip2)},v.prototype.createTips=function(){this.tip1=oe.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(oe.createTransform()),this.visual.appendChild(this.tip1),this.tip2=oe.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(oe.createTransform()),this.visual.appendChild(this.tip2)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.state==="creating"&&this.createTips()},v.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(oe.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()]]),oe.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 C=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),U=this.tip1.transform.baseVal.getItem(0);U.setRotate(C,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(U,0);var J=this.tip2.transform.baseVal.getItem(0);J.setRotate(C+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(J,0)}},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=z.prototype.getState.call(this);return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C),this.createTips(),this.adjustVisual()},v.typeName="MeasurementMarker",v.title="Measurement marker",v.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>',v}(Je),ze=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.strokePanel.colors=J.defaultColorSet,W.fillColor="transparent",W}return be(v,z),Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=z.prototype.getState.call(this);return C.typeName=v.typeName,C},v.typeName="EllipseFrameMarker",v.title="Ellipse frame marker",v.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>',v}(Ce),pt=function(){function z(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),z.prototype.addUndoStep=function(v){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(v)||(this.undoStack.push(v),JSON.stringify(this.lastRedoStep)!==JSON.stringify(v)&&this.redoStack.splice(0,this.redoStack.length))},z.prototype.replaceLastUndoStep=function(v){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=v)},z.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},z.prototype.undo=function(){if(this.undoStack.length>1){var v=this.undoStack.pop();return v!==void 0&&this.redoStack.push(v),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},z.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},z}(),ct=function(z){function v(C,U,J){var W=z.call(this,C,U,J)||this;return W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.curveX=0,W.curveY=0,W.manipulationStartCurveX=0,W.manipulationStartCurveY=0,W.setStrokeColor=W.setStrokeColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.positionGrips=W.positionGrips.bind(W),W.addControlGrips=W.addControlGrips.bind(W),W.adjustVisual=W.adjustVisual.bind(W),W.setupControlBox=W.setupControlBox.bind(W),W.resize=W.resize.bind(W),W.strokeColor=J.defaultColor,W.strokeWidth=J.defaultStrokeWidth,W.strokeDasharray=J.defaultStrokeDasharray,W.strokePanel=new Ve("Line color",J.defaultColorSet,J.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new tt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new Ke("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return be(v,z),v.prototype.ownsTarget=function(C){return!(!z.prototype.ownsTarget.call(this,C)&&C!==this.visual&&C!==this.selectorCurve&&C!==this.visibleCurve&&!this.curveGrip.ownsTarget(C))},v.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},v.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorCurve=oe.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=oe.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)},v.prototype.pointerDown=function(C,U){z.prototype.pointerDown.call(this,C,U),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=C.x,this.curveY=C.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(U)&&(this.activeGrip=this.curveGrip,this._state="resize")},v.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),oe.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},v.prototype.setupControlBox=function(){z.prototype.setupControlBox.call(this),this.curveControlLine1=oe.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=oe.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)},v.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,z.prototype.addControlGrips.call(this)},v.prototype.positionGrips=function(){z.prototype.positionGrips.call(this);var C=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-C/2,this.curveY-C/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()))},v.prototype.manipulate=function(C){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+C.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+C.y-this.manipulationStartY),z.prototype.manipulate.call(this,C)},v.prototype.resize=function(C){this.activeGrip===this.curveGrip&&(this.curveX=C.x,this.curveY=C.y),z.prototype.resize.call(this,C),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},v.prototype.setStrokeColor=function(C){this.strokeColor=C,this.adjustVisual(),this.colorChanged(C)},v.prototype.setStrokeWidth=function(C){this.strokeWidth=C,this.adjustVisual()},v.prototype.setStrokeDasharray=function(C){this.strokeDasharray=C,this.adjustVisual()},v.prototype.scale=function(C,U){this.curveX=this.curveX*C,this.curveY=this.curveY*U,z.prototype.scale.call(this,C,U)},Object.defineProperty(v.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),v.prototype.getState=function(){var C=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},z.prototype.getState.call(this));return C.typeName=v.typeName,C},v.prototype.restoreState=function(C){z.prototype.restoreState.call(this,C);var U=C;this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.curveX=U.curveX,this.curveY=U.curveY,this.createVisual(),this.adjustVisual()},v.typeName="CurveMarker",v.title="Curve marker",v.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>',v}(nt),Ct=function(){function z(v,C){C===void 0&&(C=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=v,this.cancelable=C}return Object.defineProperty(z.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),z.prototype.preventDefault=function(){this._defaultPrevented=!0},z}(),xt=function(z){function v(C,U,J){var W=z.call(this,C,!1)||this;return W.dataUrl=U,W.state=J,W}return be(v,z),v}(Ct),$e=function(z){function v(C,U,J){J===void 0&&(J=!1);var W=z.call(this,C,J)||this;return W.marker=U,W}return be(v,z),v}(Ct),Rt=function(){function z(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return z.prototype.addEventListener=function(v,C){this[v].push(C)},z.prototype.removeEventListener=function(v,C){var U=this[v].indexOf(C);U>-1&&this[v].splice(U,1)},z}(),vt=function(){function z(v){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Ae,this._isOpen=!1,this.undoRedoManager=new pt,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 Rt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=z.instanceCounter++,this.styles=new rt(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=v,this.targetRoot=document.body,this.width=v.clientWidth,this.height=v.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(z.prototype,"ALL_MARKER_TYPES",{get:function(){return[et,me,de,ke,ze,Ce,se,ge,Le,ie,Je,ct]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[et,me,de,ke,Ce,se,ge]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"BASIC_MARKER_TYPES",{get:function(){return[et,me,de,ke,se]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(v){var C=this;this._availableMarkerTypes.splice(0),v.forEach(function(U){if(typeof U=="string"){var J=C.ALL_MARKER_TYPES.find(function(W){return W.typeName===U});J!==void 0&&C._availableMarkerTypes.push(J)}else C._availableMarkerTypes.push(U)})},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(v){this._zoomLevel=v,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Re.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},z.prototype.show=function(){var v=this;this.styles.styleSheetRoot===void 0&&Ue.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ue.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(C){return C(new Ct(v))})},z.prototype.render=function(){return we(this,void 0,void 0,function(){var v;return xe(this,function(C){switch(C.label){case 0:return this.setCurrentMarker(),(v=new Ye).naturalSize=this.renderAtNaturalSize,v.imageType=this.renderImageType,v.imageQuality=this.renderImageQuality,v.markersOnly=this.renderMarkersOnly,v.width=this.renderWidth,v.height=this.renderHeight,[4,v.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return C.sent(),[4,v.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,C.sent()]}})})},z.prototype.close=function(v){var C=this;if(v===void 0&&(v=!1),this.isOpen){var U=!1;v||this.eventListeners.beforeclose.forEach(function(J){var W=new Ct(C,!0);J(W),W.defaultPrevented&&(U=!0)}),U||(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(J){return J(new Ct(C))}),this.detachEvents(),this._isOpen=!1)}},z.prototype.addMarkersToToolbar=function(){for(var v,C=[],U=0;U<arguments.length;U++)C[U]=arguments[U];(v=this._availableMarkerTypes).push.apply(v,C)},z.prototype.addRenderEventListener=function(v){this.addEventListener("render",function(C){v(C.dataUrl,C.state)})},z.prototype.removeRenderEventListener=function(v){},z.prototype.addCloseEventListener=function(v){this.addEventListener("close",function(){v()})},z.prototype.removeCloseEventListener=function(v){},z.prototype.setupResizeObserver=function(){var v=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){v.resize(v.target.clientWidth,v.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return v.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},z.prototype.onPopupTargetResize=function(){var v=1*this.target.clientWidth/this.target.clientHeight,C=this.editorCanvas.clientWidth/v>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*v:this.editorCanvas.clientWidth,U=C<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/v;this.resize(C,U)},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.resize=function(v,C){this._isResizing=!0;var U=v/this.imageWidth,J=C/this.imageHeight;this.imageWidth=Math.round(v),this.imageHeight=Math.round(C),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(U,J),this._isResizing=!1},z.prototype.scaleMarkers=function(v,C){var U,J=this;this._currentMarker&&this._currentMarker instanceof ke?this._currentMarker.scale(v,C):(U=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(W){W!==J._currentMarker&&W.scale(v,C)}),U!==void 0&&this.setCurrentMarker(U)},z.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},z.prototype.setTopLeft=function(){var v=this.editingTarget.getBoundingClientRect(),C=this.editorCanvas.getBoundingClientRect();this.left=v.left-C.left,this.top=v.top-C.top},z.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},z.prototype.addDefs=function(){for(var v,C=[],U=0;U<arguments.length;U++)C[U]=arguments[U];this.defs=oe.createDefs(),this.addDefsToImage(),(v=this.defs).append.apply(v,C)},z.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},z.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},z.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},z.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},z.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},z.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},z.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},z.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var v=document.createElement("a");v.href="https://markerjs.com/",v.target="_blank",v.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>',v.title="Powered by marker.js",v.style.display="grid",v.style.alignItems="center",v.style.justifyItems="center",v.style.padding="3px",v.style.width="20px",v.style.height="20px",this.logoUI.appendChild(v),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},z.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},z.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var v=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=v+"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 Me(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 We(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},z.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.removeMarker=function(v){this.markerImage.removeChild(v.container),this.markers.indexOf(v)>-1&&this.markers.splice(this.markers.indexOf(v),1),v.dispose()},z.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},z.prototype.toolbarButtonClicked=function(v,C){if(v==="marker"&&C!==void 0)this.createNewMarker(C);else if(v==="action")switch(C){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},z.prototype.deleteSelectedMarker=function(){var v=this;if(this._currentMarker!==void 0){var C=!1;if(this.eventListeners.markerbeforedelete.forEach(function(J){var W=new $e(v,v._currentMarker,!0);J(W),W.defaultPrevented&&(C=!0)}),!C){var U=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(J){return J(new $e(v,U))})}}},z.prototype.clear=function(){var v=this,C=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(pe){var De=new $e(v,void 0,!0);pe(De),De.defaultPrevented&&(C=!0)}),!C)){this.setCurrentMarker();for(var U=function(pe){var De=J.markers[pe];J.setCurrentMarker(J.markers[pe]),J._currentMarker.dispose(),J.markerImage.removeChild(J._currentMarker.container),J.markers.splice(J.markers.indexOf(J._currentMarker),1),J.eventListeners.markerdelete.forEach(function(it){return it(new $e(v,De))})},J=this,W=this.markers.length-1;W>=0;W--)U(W);this.addUndoStep()}},Object.defineProperty(z.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),z.prototype.showNotesEditor=function(){var v;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=(v=this._currentMarker.notes)!==null&&v!==void 0?v:"",this.overlayContainer.appendChild(this.notesArea))},z.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},z.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},z.prototype.addUndoStep=function(){var v=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var C=this.getState(),U=this.undoRedoManager.getLastUndoStep();if(!U||U.width===C.width&&U.height===C.height){var J=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(C),J<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(W){return W(new Ct(v))})}else this.undoRedoManager.replaceLastUndoStep(C),this.eventListeners.statechange.forEach(function(W){return W(new Ct(v))})}},z.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},z.prototype.undoStep=function(){var v=this,C=this.undoRedoManager.undo();C!==void 0&&(this.restoreState(C),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(U){return U(new Ct(v))}))},z.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},z.prototype.redoStep=function(){var v=this,C=this.undoRedoManager.redo();C!==void 0&&(this.restoreState(C),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(U){return U(new Ct(v))}))},z.prototype.stepZoom=function(){var v=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=v<this.zoomSteps.length-1?this.zoomSteps[v+1]:this.zoomSteps[0]},z.prototype.panTo=function(v){this.contentDiv.scrollBy({left:this.prevPanPoint.x-v.x,top:this.prevPanPoint.y-v.y}),this.prevPanPoint=v},z.prototype.startRenderAndClose=function(){return we(this,void 0,void 0,function(){var v,C,U=this;return xe(this,function(J){switch(J.label){case 0:return[4,this.render()];case 1:return v=J.sent(),C=this.getState(),this.eventListeners.render.forEach(function(W){return W(new xt(U,v,C))}),this.close(!0),[2]}})})},z.prototype.getState=function(v){v===!0&&this.setCurrentMarker();var C={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(U){return C.markers.push(U.getState())}),C},z.prototype.restoreState=function(v){var C=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);v.markers.forEach(function(U){var J=C._availableMarkerTypes.find(function(pe){return pe.typeName===U.typeName});if(J!==void 0){var W=C.addNewMarker(J);W.restoreState(U),C.markers.push(W)}}),v.width&&v.height&&(v.width!==this.imageWidth||v.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/v.width,this.imageHeight/v.height),this.eventListeners.restorestate.forEach(function(U){return U(new Ct(C))})},z.prototype.addNewMarker=function(v){var C=oe.createGroup();return this.markerImage.appendChild(C),new v(C,this.overlayContainer,this.settings)},z.prototype.createNewMarker=function(v){var C,U=this;(C=typeof v=="string"?this._availableMarkerTypes.find(function(J){return J.typeName===v}):v)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(C),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(C.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(J){return J(new $e(U,U._currentMarker))}))},z.prototype.markerCreated=function(v){var C=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(v),this.setCurrentMarker(v),v instanceof me&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(me):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(U){return U(new $e(C,C._currentMarker))})},z.prototype.colorChanged=function(v){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=v,this.settings.defaultStrokeColor=v)},z.prototype.fillColorChanged=function(v){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=v)},z.prototype.markerStateChanged=function(v){var C=this;this.eventListeners.markerchange.forEach(function(U){return U(new $e(C,v))})},z.prototype.setCurrentMarker=function(v){var C=this;this._currentMarker!==v&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(U){return U(new $e(C,C._currentMarker))})),this._currentMarker=v,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(U){return U(new $e(C,C._currentMarker))}))},z.prototype.onPointerDown=function(v){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||v.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var C=this.markers.find(function(U){return U.ownsTarget(v.target)});C!==void 0?(this.setCurrentMarker(C),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(v.clientX,v.clientY),v.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:v.clientX,y:v.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(v.clientX,v.clientY))},z.prototype.onDblClick=function(v){if(this._isFocused||this.focus(),this.mode==="select"){var C=this.markers.find(function(U){return U.ownsTarget(v.target)});C!==void 0&&C!==this._currentMarker&&this.setCurrentMarker(C),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(v.clientX,v.clientY),v.target):this.setCurrentMarker()}},z.prototype.onPointerMove=function(v){this.touchPoints!==1&&v.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||v.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(v.clientX,v.clientY)):this.zoomLevel>1&&this.panTo({x:v.clientX,y:v.clientY}))},z.prototype.onPointerUp=function(v){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(v.clientX,v.clientY)),this.isDragging=!1,this.addUndoStep()},z.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},z.prototype.onKeyUp=function(v){this._currentMarker===void 0||this.notesArea!==void 0||v.key!=="Delete"&&v.key!=="Backspace"||this.deleteSelectedMarker()},z.prototype.clientToLocalCoordinates=function(v,C){var U=this.markerImage.getBoundingClientRect();return{x:(v-U.left)/this.zoomLevel,y:(C-U.top)/this.zoomLevel}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var v=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=v+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},z.prototype.addLicenseKey=function(v){Re.addKey(v)},z.prototype.addEventListener=function(v,C){this.eventListeners.addEventListener(v,C)},z.prototype.removeEventListener=function(v,C){this.eventListeners.removeEventListener(v,C)},z.prototype.renderState=function(v){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(v),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(z.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),z.prototype.focus=function(){var v=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(C){return C(new Ct(v))}))},z.prototype.blur=function(){var v=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(C){return C(new Ct(v))}))},z.instanceCounter=0,z}();/* **********************************
cropro version 1.2.0
@license SEE LICENSE IN LICENSE
copyright Alan Mendelevich
see README and LICENSE for details
********************************** *//*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Nt=function(z,v){return(Nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,U){C.__proto__=U}||function(C,U){for(var J in U)Object.prototype.hasOwnProperty.call(U,J)&&(C[J]=U[J])})(z,v)};function It(z,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");function C(){this.constructor=z}Nt(z,v),z.prototype=v===null?Object.create(v):(C.prototype=v.prototype,new C)}function At(z,v,C,U){return new(C||(C=Promise))(function(J,W){function pe(gt){try{it(U.next(gt))}catch(Ne){W(Ne)}}function De(gt){try{it(U.throw(gt))}catch(Ne){W(Ne)}}function it(gt){var Ne;gt.done?J(gt.value):(Ne=gt.value,Ne instanceof C?Ne:new C(function(Tt){Tt(Ne)})).then(pe,De)}it((U=U.apply(z,v||[])).next())})}function di(z,v){var C,U,J,W,pe={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return W={next:De(0),throw:De(1),return:De(2)},typeof Symbol=="function"&&(W[Symbol.iterator]=function(){return this}),W;function De(it){return function(gt){return function(Ne){if(C)throw new TypeError("Generator is already executing.");for(;pe;)try{if(C=1,U&&(J=2&Ne[0]?U.return:Ne[0]?U.throw||((J=U.return)&&J.call(U),0):U.next)&&!(J=J.call(U,Ne[1])).done)return J;switch(U=0,J&&(Ne=[2&Ne[0],J.value]),Ne[0]){case 0:case 1:J=Ne;break;case 4:return pe.label++,{value:Ne[1],done:!1};case 5:pe.label++,U=Ne[1],Ne=[0];continue;case 7:Ne=pe.ops.pop(),pe.trys.pop();continue;default:if(!(J=pe.trys,(J=J.length>0&&J[J.length-1])||Ne[0]!==6&&Ne[0]!==2)){pe=0;continue}if(Ne[0]===3&&(!J||Ne[1]>J[0]&&Ne[1]<J[3])){pe.label=Ne[1];break}if(Ne[0]===6&&pe.label<J[1]){pe.label=J[1],J=Ne;break}if(J&&pe.label<J[2]){pe.label=J[2],pe.ops.push(Ne);break}J[2]&&pe.ops.pop(),pe.trys.pop();continue}Ne=v.call(z,pe)}catch(Tt){Ne=[6,Tt],U=0}finally{C=J=0}if(5&Ne[0])throw Ne[1];return{value:Ne[0]?Ne[1]:void 0,done:!0}}([it,gt])}}}var ri=function(){function z(){}return z.addKey=function(v){z.key=v},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),Qe=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(v,C){for(var U=0,J=C;U<J.length;U++){var W=J[U],pe=W[0],De=W[1];v.setAttribute(pe,De)}},z.createRect=function(v,C,U){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",v.toString()),J.setAttribute("height",C.toString()),U&&z.setAttributes(J,U),J},z.createLine=function(v,C,U,J,W){var pe=document.createElementNS("http://www.w3.org/2000/svg","line");return pe.setAttribute("x1",v.toString()),pe.setAttribute("y1",C.toString()),pe.setAttribute("x2",U.toString()),pe.setAttribute("y2",J.toString()),W&&z.setAttributes(pe,W),pe},z.createPolygon=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","polygon");return U.setAttribute("points",v),C&&z.setAttributes(U,C),U},z.createCircle=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","circle");return U.setAttribute("cx",(v/2).toString()),U.setAttribute("cy",(v/2).toString()),U.setAttribute("r",v.toString()),C&&z.setAttributes(U,C),U},z.createEllipse=function(v,C,U){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(v/2).toString()),J.setAttribute("cy",(C/2).toString()),J.setAttribute("rx",(v/2).toString()),J.setAttribute("ry",(C/2).toString()),U&&z.setAttributes(J,U),J},z.createGroup=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","g");return v&&z.setAttributes(C,v),C},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(v,C,U,J,W,pe,De){var it=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(it,[["id",v],["orient",C],["markerWidth",U.toString()],["markerHeight",J.toString()],["refX",W.toString()],["refY",pe.toString()]]),it.appendChild(De),it},z.createText=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","text");return C.setAttribute("x","0"),C.setAttribute("y","0"),v&&z.setAttributes(C,v),C},z.createTSpan=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","tspan");return U.textContent=v,C&&z.setAttributes(U,C),U},z.createImage=function(v){var C=document.createElementNS("http://www.w3.org/2000/svg","image");return v&&z.setAttributes(C,v),C},z.createPoint=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return U.x=v,U.y=C,U},z.createPath=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg","path");return U.setAttribute("d",v),C&&z.setAttributes(U,C),U},z.createElement=function(v,C){var U=document.createElementNS("http://www.w3.org/2000/svg",v);return C&&z.setAttributes(U,C),U},z.getHollowRectanglePath=function(v,C,U,J,W,pe,De,it){return"M"+v+","+C+"V"+(C+J)+"H"+(v+U)+"V"+C+"H"+W+"V"+pe+"H"+(W+De)+"V"+(pe+it)+"H"+W+"V"+C+"Z"},z}(),bt=function(){function z(v){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+v+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(v){return this.styleSheet===void 0&&this.addStyleSheet(),v.name=""+this.classNamePrefix+v.localName,this.classes.push(v),this.styleSheet.sheet.insertRule("."+v.name+" {"+v.style+"}",this.styleSheet.sheet.cssRules.length),v},z.prototype.addRule=function(v){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(v),this.styleSheet.sheet.insertRule(v.selector+" {"+v.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var v;this.styleSheet=document.createElement("style"),((v=this.styleSheetRoot)!==null&&v!==void 0?v:document.head).appendChild(this.styleSheet),this.addRule(new kt("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new kt("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new kt("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new Mt("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new Mt("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},z.prototype.removeStyleSheet=function(){var v;this.styleSheet&&(((v=this.styleSheetRoot)!==null&&v!==void 0?v:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),kt=function(z,v){this.selector=z,this.style=v},Mt=function(z,v){this.localName=z,this.style=v},ei=function(){function z(){this.blocks=[],this.display=""}return z.prototype.addButtonBlock=function(v){v.className=this.blockClassName,v.buttonClassName=this.buttonClassName,v.buttonColorsClassName=this.buttonColorsClassName,v.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(v)},z.prototype.addElementBlock=function(v){v.className===void 0&&(v.className=this.blockClassName),this.blocks.push(v)},z.prototype.getUI=function(){var v=document.createElement("div");return v.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,v.style.display=this.display,this.blocks.forEach(function(C){return v.appendChild(C.getUI())}),v},z}(),Gi=function(){function z(){}return z.prototype.getUI=function(){var v=document.createElement("div");if(v.className=this.className,this.minWidth!==void 0&&(v.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":v.style.justifyContent="flex-start";break;case"center":v.style.justifyContent="center";break;case"end":v.style.justifyContent="flex-end"}return v.style.whiteSpace="nowrap",v},z}(),Xi=function(z){function v(){var C=z!==null&&z.apply(this,arguments)||this;return C.buttons=[],C}return It(v,z),v.prototype.addButton=function(C){C.className=this.buttonClassName,C.colorsClassName=this.buttonColorsClassName,C.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(C)},v.prototype.getUI=function(){var C=z.prototype.getUI.call(this);return this.buttons.forEach(function(U){return C.appendChild(U.getUI())}),C},v}(Gi),ft=function(){function z(v,C){this._isActive=!1,this._isHidden=!1,this._icon=v,this.title=C,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(z.prototype,"icon",{get:function(){return this._icon},set:function(v){this._icon=v,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isActive",{get:function(){return this._isActive},set:function(v){this._isActive=v,this.adjustClassName()},enumerable:!1,configurable:!0}),z.prototype.getUI=function(){var v=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return v.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},z.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},z.prototype.hide=function(){this._isHidden=!0},z}(),ut=function(z){function v(){var C=z!==null&&z.apply(this,arguments)||this;return C.elements=[],C}return It(v,z),v.prototype.addElement=function(C){this.elements.push(C)},v.prototype.getUI=function(){var C=z.prototype.getUI.call(this);return this.elements.forEach(function(U){return C.appendChild(U)}),C},v}(Gi),ti=function(){function z(v,C){this.horizontal=v,this.vertical=C}return Object.defineProperty(z.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),z.prototype.getVerticalLength=function(v){return v/this.ratio},z.prototype.getHorizontalLength=function(v){return v*this.ratio},z}(),Wt=function(){function z(){}return z.getIcon=function(v,C){if(v>0&&C>0){var U=new ti(v,C),J=U.ratio>=1?20:U.getHorizontalLength(20),W=U.ratio<1?20:U.getVerticalLength(20),pe=document.createElementNS("http://www.w3.org/2000/svg","svg");pe.setAttribute("xmlns","http://www.w3.org/2000/svg"),pe.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(pe);var De=Qe.createDefs();pe.appendChild(De);var it=Qe.createElement("clipPath",[["id","text-bg-clip"]]);De.appendChild(it);var gt=Qe.createPath(Qe.getHollowRectanglePath((24-J)/2,(24-W)/2,J,W,(24-J)/2+2,(24-W)/2+2,J-4,W-4));pe.appendChild(gt);var Ne=Qe.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ne.appendChild(Qe.createTSpan(v+":"+C)),pe.appendChild(Ne);var Tt=Ne.getBBox();Qe.setAttributes(Ne,[["x",((24-Tt.width)/2).toString()],["y",((24-Tt.height)/2-Tt.y).toString()]]);var zt=Qe.createPath(Qe.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Tt.width))/2,(24-Math.ceil(Tt.height))/2,Math.ceil(Tt.width),Math.ceil(Tt.height)));return it.appendChild(zt),Qe.setAttributes(gt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(pe),pe.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},z}(),Ut=function(z){function v(C,U,J){var W=z.call(this,C,U)||this;return W.isDropdownOpen=!1,W.onClick=W.dropdownButtonClicked,W.dropdownButtons=J,W}return It(v,z),v.prototype.setupDropdown=function(){var C=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(U){U.className=C.className,U.colorsClassName=C.colorsClassName,C.dropdownBlock.appendChild(U.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},v.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},v.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},v.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},v.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},v.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},v}(ft),Dt=function(){function z(v,C){this.GRIP_SIZE=10,this.color=v,this.fillColor=C,this.visual=Qe.createGroup(),this.visual.appendChild(Qe.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Qe.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(v){return v===this.visual||v===this.visual.childNodes[0]||v===this.visual.childNodes[1]},z.prototype.setCenter=function(v,C){this.visual.childNodes.forEach(function(U){return Qe.setAttributes(U,[["cx",v.toString()],["cy",C.toString()]])})},z}(),Vt=function(){function z(v,C,U,J){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=v,this.canvasHeight=C,this.margin=U,this.container=J,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(z.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(v){this._aspectRatio=v,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(v){this._isGridVisible=v,this.gridContainer&&Qe.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(v){this._zoomFactor=v,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),z.prototype.open=function(){var v=this;this.cropShadeElement=Qe.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Qe.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var C=0;C<this.numberOfGridLines;C++)this.horizontalGridLines.push(Qe.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Qe.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(U){return v.gridContainer.appendChild(U)}),this.verticalGridLines.forEach(function(U){return v.gridContainer.appendChild(U)}),this.cropRectElement=Qe.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},z.prototype.setCropRectangle=function(v){this.cropRect=v;var C=Object.assign({},this.cropRect);this.zoomFactor!==1&&(C.width=this.cropRect.width*this.zoomFactor,C.height=this.cropRect.height*this.zoomFactor,C.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-C.width/2,C.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-C.height/2),Qe.setAttributes(this.cropRectElement,[["x",C.x.toString()],["y",C.y.toString()],["width",C.width.toString()],["height",C.height.toString()]]);var U=C.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(W,pe){var De=C.y+U*(pe+1);Qe.setAttributes(W,[["x1",""+C.x],["y1",""+De],["x2",""+(C.x+C.width)],["y2",""+De]])});var J=C.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(W,pe){var De=C.x+J*(pe+1);Qe.setAttributes(W,[["x1",""+De],["y1",""+C.y],["x2",""+De],["y2",""+(C.y+C.height)]])}),Qe.setAttributes(this.cropShadeElement,[["d",Qe.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,C.x,C.y,C.width,C.height)]]),this.topLeftGrip.setCenter(C.x,C.y),this.topRightGrip.setCenter(C.x+C.width,C.y),this.bottomLeftGrip.setCenter(C.x,C.y+C.height),this.bottomRightGrip.setCenter(C.x+C.width,C.y+C.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},z.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},z.prototype.clientToLocalCoordinates=function(v,C){var U=this.container.getBoundingClientRect();return{x:v-U.left+this.margin,y:C-U.top+this.margin}},z.prototype.onPointerDown=function(v){this.container.setPointerCapture(v.pointerId),this.previousPoint=this.clientToLocalCoordinates(v.clientX,v.clientY),this.cropRectElement===v.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(v.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(v.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(v.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(v.target)&&(this.activeGrip=this.bottomRightGrip)},z.prototype.onPointerMove=function(v){if(this.isMoving)this.move(this.clientToLocalCoordinates(v.clientX,v.clientY));else if(this.activeGrip){var C=this.clientToLocalCoordinates(v.clientX,v.clientY);this.resize(C)}v.preventDefault()},z.prototype.onPointerUp=function(v){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(v.pointerId)},z.prototype.move=function(v){var C=v.x-this.previousPoint.x,U=v.y-this.previousPoint.y;this.zoomFactor!==1&&(C=-C/this.zoomFactor,U=-U/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+C),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+U),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=v},z.prototype.resize=function(v){var C=Object.assign({},this.cropRect),U=v.x-this.previousPoint.x,J=v.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:C.x+U<this.margin&&(U=this.margin-C.x),C.x+=U,C.width=this.cropRect.x+this.cropRect.width-C.x;break;case this.bottomRightGrip:case this.topRightGrip:C.width+U>this.canvasWidth*this.zoomFactor&&(U=this.canvasWidth*this.zoomFactor-C.width),C.width+=U}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(C.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(U),C.height=this.aspectRatio.getVerticalLength(C.width)):(C.y+=J,C.height=this.cropRect.y+this.cropRect.height-C.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?C.height=this.aspectRatio.getVerticalLength(C.width):C.height+=J}C.width<10&&(C.x=this.cropRect.x,C.width=10),C.height<10&&(C.y=this.cropRect.y,C.height=10),this.previousPoint=v,C.x>=this.margin&&C.y>=this.margin&&C.x-this.margin+C.width<=this.canvasWidth&&C.y-this.margin+C.height<=this.canvasHeight&&(this.cropRect=C,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},z.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var v=this.cropRect.x+this.cropRect.width/2,C=this.cropRect.y+this.cropRect.height/2,U=this.aspectRatio.getHorizontalLength(this.cropRect.height),J=this.aspectRatio.getVerticalLength(this.cropRect.width);U/this.canvasWidth<J/this.canvasHeight?this.cropRect.width=U:this.cropRect.height=J,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=v-this.cropRect.width/2,this.cropRect.y=C-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},z.prototype.getRescaledRect=function(v,C,U,J,W,pe){var De=U/v,it=J/C;return{x:(W.x-pe)*De+pe,y:(W.y-pe)*it+pe,width:W.width*De,height:W.height*it}},z.prototype.scaleCanvas=function(v,C){var U=this.getRescaledRect(this.canvasWidth,this.canvasHeight,v,C,this.cropRect,this.margin);this.canvasWidth=v,this.canvasHeight=C,this.onCropChange&&this.onCropChange(U),this.setCropRectangle(U)},z}(),Ti=function(){function z(v){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=v,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(z.prototype,"angle",{get:function(){return this._angle},set:function(v){this._angle=v,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),z.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},z.prototype.onPointerDown=function(v){this.controlContainer.setPointerCapture(v.pointerId),this.isDragging=!0,this.previousPoint={x:v.clientX,y:v.clientY}},z.prototype.onPointerMove=function(v){this.isDragging&&(this.onAngleChange&&this.onAngleChange((v.clientX-this.previousPoint.x)/5),this.previousPoint.x=v.clientX)},z.prototype.onPointerUp=function(v){this.isDragging&&this.onAngleChange&&this.onAngleChange((v.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(v.pointerId)},z.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var v=this.angleLabelText.getBBox();Qe.setAttributes(this.angleLabelElement,[["x",((this.width-v.width)/2).toString()],["y",(this.height/2).toString()]])}},z.prototype.positionScaleShape=function(){if(this.scaleShape){var v=this.scaleShape.transform.baseVal.getItem(0);v.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(v,0)}},z.prototype.getVisual=function(){var v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("xmlns","http://www.w3.org/2000/svg"),v.setAttribute("width",this.width+"px"),v.setAttribute("height",this.height+"px"),v.setAttribute("viewBox","0 0 "+this.width+" "+this.height),v.style.flexShrink="0",document.body.appendChild(v);for(var C="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,U=1;U<=this.width/5+10;U++){var J=U%5==0?this.height/3:this.height/6;C+="h4v"+-J+"h1v"+J}C+="v1H0Z",this.scaleShape=Qe.createPath(C);var W=Qe.createTransform();this.scaleShape.transform.baseVal.appendItem(W),v.appendChild(this.scaleShape),this.angleLabelElement=Qe.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Qe.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var pe=Qe.createTSpan("");return pe.innerHTML="&deg;",this.angleLabelElement.appendChild(pe),v.appendChild(this.angleLabelElement),document.body.removeChild(v),v},z}(),pn=function(){function z(){this.naturalSize=!1,this.imageType="image/png"}return z.prototype.rasterize=function(v,C,U,J,W,pe,De){var it=this;return new Promise(function(gt){var Ne=document.createElement("canvas");Ne.width=v.width.baseVal.value-2*J,Ne.height=v.height.baseVal.value-2*J;var Tt=1,zt=1;it.naturalSize===!0?(Tt=C.naturalWidth/(v.width.baseVal.value-2*J)/pe,zt=C.naturalHeight/(v.height.baseVal.value-2*J)/De,Ne.width=C.naturalWidth/pe,Ne.height=C.naturalHeight/De):it.width!==void 0&&it.height!==void 0&&(Tt=it.width/U.width,zt=it.height/U.height,Ne.width*=Tt,Ne.height*=zt);var qt=Ne.getContext("2d");qt.translate(Ne.width/2,Ne.height/2),qt.rotate(W*Math.PI/180),qt.scale(pe,De),qt.translate(-Ne.width/2,-Ne.height/2),qt.drawImage(C,0,0,Ne.width,Ne.height);var Bi=document.createElement("canvas");Bi.width=U.width*Tt,Bi.height=U.height*zt,Bi.getContext("2d").putImageData(qt.getImageData((U.x-J)*Tt,(U.y-J)*zt,U.width*Tt,U.height*zt),0,0),gt(Bi.toDataURL(it.imageType,it.imageQuality))})},z}(),Ge=function(){function z(v){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=z.instanceCounter++,this.styles=new bt(this.instanceNo),this.target=v,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(v){this._zoomToCropEnabled=v,v?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(v){this._isGridVisible=v,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"gridLines",{get:function(){return this._gridLines},set:function(v){this._gridLines=v,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(v){this._rotationAngle=v,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"aspectRatio",{get:function(){var v;return(v=this._aspectRatio)!==null&&v!==void 0?v:this.aspectRatios[0]},set:function(v){this._aspectRatio=v},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},z.prototype.show=function(){this.showUI(),this.open()},z.prototype.close=function(v){v===void 0&&(v=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),v||this.closeEventListeners.forEach(function(C){return C()}),this._isOpen=!1)},z.prototype.addRenderEventListener=function(v){this.renderEventListeners.push(v)},z.prototype.removeRenderEventListener=function(v){this.renderEventListeners.indexOf(v)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(v),1)},z.prototype.addCloseEventListener=function(v){this.closeEventListeners.push(v)},z.prototype.removeCloseEventListener=function(v){this.closeEventListeners.indexOf(v)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(v),1)},z.prototype.setupResizeObserver=function(){var v=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){v.resize(v.target.clientWidth,v.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},z.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var v=1*this.target.clientWidth/this.target.clientHeight,C=this.contentDiv.clientWidth/v>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*v:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,U=C+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/v;this.resize(C,U)}},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",Qe.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},z.prototype.resize=function(v,C){this.imageWidth=Math.round(v),this.imageHeight=Math.round(C),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},z.prototype.setEditingTarget=function(){var v=document.createElement("canvas");v.width=this.target.naturalWidth,v.height=this.target.naturalHeight,v.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var C=v.toDataURL();Qe.setAttributes(this.editingTarget,[["href",C]]),this.setEditingTargetSize()},z.prototype.setTopLeft=function(){var v=this.target.getBoundingClientRect(),C=this.editorCanvas.getBoundingClientRect();this.left=v.left-C.left-this.CANVAS_MARGIN,this.top=v.top-C.top-this.CANVAS_MARGIN},z.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=Qe.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Qe.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Qe.createGroup(),this.editingTargetRotationScaleContainer=Qe.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var v=Qe.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(v);var C=Qe.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(C),this.editingTargetContainer=Qe.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},z.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},z.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Qe.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Vt(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},z.prototype.zoomToCrop=function(){if(this.cropRect){var v=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,C=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=v+"px "+C+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-v+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-C+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},z.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},z.prototype.cropRectChanged=function(v){this.cropRect=v,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},z.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},z.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var v=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,C=this.target.offsetTop>v+this.CANVAS_MARGIN?this.target.offsetTop-(v+this.CANVAS_MARGIN):0;this.coverDiv.style.top=C+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},z.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},z.prototype.addTopToolbar=function(){var v=this;this.topToolbar=new ei,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 C=new Xi;C.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(C);var U=[];this.aspectRatios.forEach(function(zt){var qt=new ft(Wt.getIcon(zt.horizontal,zt.vertical),zt.horizontal===0&&zt.vertical===0?"FREE":zt.horizontal+":"+zt.vertical);qt.onClick=function(){return v.ratioButtonClicked(zt)},U.push(qt)}),this.aspectRatioButton=new Ut(Wt.getIcon(0,0),"Aspect ratio",U),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,C.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var J=new ft('<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");J.isActive=this.isGridVisible,J.onClick=function(){v.isGridVisible=!v.isGridVisible,J.isActive=v.isGridVisible},C.addButton(J);var W=new ft('<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(W.isActive=this.zoomToCropEnabled,W.onClick=function(){v.zoomToCropEnabled=!v.zoomToCropEnabled,W.isActive=v.zoomToCropEnabled},C.addButton(W),!ri.isLicensed){var pe=new ut;this.topToolbar.addElementBlock(pe);var De=document.createElement("div");De.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var it=document.createElement("a");it.style.color="currentColor",it.href="https://markerjs.com/products/cropro",it.target="_blank",it.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>',De.appendChild(it),pe.addElement(De)}var gt=new Xi;gt.minWidth=3*this.toolbarHeight+"px",gt.contentAlign="end",this.topToolbar.addButtonBlock(gt);var Ne=new ft('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");Ne.onClick=this.startRenderAndClose,gt.addButton(Ne),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ne.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Tt=new ft('<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");Tt.onClick=this.close,gt.addButton(Tt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Tt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},z.prototype.addBottomToolbar=function(){var v=this;this.bottomToolbar=new ei,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 C=new Xi;C.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(C);var U=new ft('<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");U.onClick=this.rotateLeftButtonClicked,C.addButton(U);var J=new ft('<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");J.onClick=this.rotateRightButtonClicked,C.addButton(J);var W=new ut;W.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(W),this.straightener=new Ti("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(gt){v.rotateBy(gt),v.straightener.angle=v.rotationAngle},W.addElement(this.straightener.getUI());var pe=new Xi;pe.minWidth=2*this.toolbarHeight+"px",pe.contentAlign="end",this.bottomToolbar.addButtonBlock(pe);var De=new ft('<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");De.onClick=this.flipHorizontallyButtonClicked,pe.addButton(De);var it=new ft('<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");it.onClick=this.flipVerticallyButtonClicked,pe.addButton(it)},z.prototype.ratioButtonClicked=function(v){this.aspectRatio=v,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},z.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Wt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},z.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new ti(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},z.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},z.prototype.restoreState=function(v){if(v){var C=this.cropLayer.getRescaledRect(v.width,v.height,this.imageWidth,this.imageHeight,v.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(C),this.cropRectChanged(C),this.flippedHorizontally=v.flippedHorizontally,this.flippedVertically=v.flippedVertically,this.applyFlip(),this.rotationAngle=v.rotationAngle,this.applyRotation()}},z.prototype.clientToLocalCoordinates=function(v,C){var U=this.cropImage.getBoundingClientRect();return{x:v-U.left,y:C-U.top}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var v=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=v+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},z.prototype.rotateLeftButtonClicked=function(){var v=this.rotationAngle-90;this.rotationAngle%90!=0&&(v+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(v)},z.prototype.rotateRightButtonClicked=function(){var v=this.rotationAngle+90;this.rotationAngle%90!=0&&(v-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(v)},z.prototype.rotateTo=function(v){v=(v=v>180?v-360:v)<=-180?v+360:v,this.rotationAngle=v,this.applyRotation()},z.prototype.rotateBy=function(v){this.rotateTo((this.rotationAngle+v)%360)},z.prototype.applyRotation=function(){var v=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var C=this.editingTargetRotationContainer.transform.baseVal.getItem(0);C.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(C,0);var U=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/U.width,this.imageHeight/U.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=v},z.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},z.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},z.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},z.prototype.startRenderAndClose=function(){return At(this,void 0,void 0,function(){var v,C;return di(this,function(U){switch(U.label){case 0:return[4,this.render()];case 1:return v=U.sent(),C=this.getState(),this.renderEventListeners.forEach(function(J){return J(v,C)}),this.close(!0),[2]}})})},z.prototype.render=function(){return At(this,void 0,void 0,function(){var v;return di(this,function(C){switch(C.label){case 0:return(v=new pn).naturalSize=this.renderAtNaturalSize,v.imageType=this.renderImageType,v.imageQuality=this.renderImageQuality,v.width=this.renderWidth,v.height=this.renderHeight,this.unzoomFromCrop(),Qe.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,v.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return C.sent(),[4,v.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,C.sent()]}})})},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Mt("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 Mt("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Mt("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var v=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Mt("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*v)+`px;
height: `+(this.toolbarHeight-2*v)+`px;
padding: `+v+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Mt("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Mt("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new kt("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new kt("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new Mt("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 Mt("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Mt("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 Mt("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*v)+`px;
padding: `+v+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Mt("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},z.instanceCounter=0,z}(),Ot=ne("8hTe"),mn=ne.n(Ot),gn=/<pre[^>]*>/g;function vn(z){var v=document.createElement("div");return v.innerHTML=z,v.childNodes.length===0?"":v.childNodes[0].nodeValue}var yn=lt.a=function(z){var v=z.value,C=v===void 0?"":v,U=z.edit,J=U===void 0?!1:U,W=z.className,pe=z.showTextOnly,De=z.showLines,it=z.replaces,gt=z.zoomImg,Ne=z.hasMask,Tt=z.style,zt=Tt===void 0?{}:Tt,qt=z.stylesPrev,Bi=qt===void 0?{}:qt,wi=String(C),Si=Object(I.useRef)(),Qi=Object(I.useRef)(),Dn=Object(I.useState)(""),pi=Object(G.a)(Dn,2),zi=pi[0],ln=pi[1],un=Object(I.useState)("office"),ji=Object(G.a)(un,2),kn=ji[0],_n=ji[1],Kn=function(){var Kt=new Ge(Qi.current);Kt.displayMode="popup",Kt.addRenderEventListener(function(){var bi=Object(D.a)(M.a.mark(function Bt(li){var $t;return M.a.wrap(function(mi){for(;;)switch(mi.prev=mi.next){case 0:return Si.current.style.display="none",mi.next=3,Object(Te.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:li}});case 3:$t=mi.sent,$t!=null&&$t.id&&it(Qi.current.getAttribute("src").replace(te.a.API_SERVER,""),"/api/attachments/".concat($t==null?void 0:$t.id,"?type=").concat($t.content_type));case 5:case"end":return mi.stop()}},Bt)}));return function(Bt){return bi.apply(this,arguments)}}()),Kt.show()},Vn=function(){var Kt=new vt(Qi.current);Kt.settings.displayMode="popup",Kt.addEventListener("render",function(){var bi=Object(D.a)(M.a.mark(function Bt(li){var $t;return M.a.wrap(function(mi){for(;;)switch(mi.prev=mi.next){case 0:if(Si.current.style.display="none",!Qi.current){mi.next=6;break}return mi.next=4,Object(Te.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:li.dataUrl}});case 4:$t=mi.sent,$t!=null&&$t.id&&it(Qi.current.getAttribute("src").replace(te.a.API_SERVER,""),"/api/attachments/".concat($t==null?void 0:$t.id,"?type=").concat($t.content_type));case 6:case"end":return mi.stop()}},Bt)}));return function(Bt){return bi.apply(this,arguments)}}()),Kt.show(),window.markerArea=Kt},Zi=Object(I.useMemo)(function(){Si.current&&(Si.current.style.zIndex=-1);try{var si=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Kt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,bi=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;wi=wi.replace(si,"("+te.a.API_SERVER+"/api/attachments/").replace(Kt,'"'+te.a.API_SERVER+"/api/attachments/").replace(bi,'"'+te.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(nn){}var Bt=X(wi),li=_();if(wi.match(/\[TOC\]/)&&(Bt=Bt.replace("<p>[TOC]</p>",R()),O()),Bt=Bt.replace(/(__special_katext_id_\d+__)/g,function(nn,mi){var Oi=li[mi],Xn=Oi.type,xn=Oi.expression;return Object(re.renderToString)(vn(xn)||"",{displayMode:Xn==="block",throwOnError:!1,output:"html"})}),Bt=Bt.replace(/▁/g,"\u2581\u2581\u2581"),m(),pe){var $t=document.createElement("div");return $t.innerHTML=Bt,$t.innerText}return setTimeout(function(){return dr()},500),Bt},[wi]),Yi=Object(I.useRef)();w.WebkitLineClamp=De,De&&(zt=Object(F.a)(Object(F.a)({},zt),w));function bn(si){var Kt=si.target;if(Kt.tagName.toUpperCase()==="IMG"){if(gt){var bi=Kt.getAttribute("src");ln(bi),_n("image")}}else if(Kt.tagName.toUpperCase()==="A"){var Bt=Kt.getAttribute("href");if(Bt.indexOf("office")>-1)si.preventDefault(),ln(Bt),_n("office");else if(Bt.indexOf("application/pdf")>-1)si.preventDefault(),ln(Bt),_n("pdf");else if(Bt.indexOf("text/html")>-1)si.preventDefault(),ln(Bt),_n("html");else if(Bt.startsWith("#")){si.preventDefault();var li=document.getElementById(Bt.replace("#",""));li&&li.scrollIntoView(!0)}}}var dr=function(){var Kt,bi=(Kt=Yi.current)===null||Kt===void 0?void 0:Kt.querySelectorAll("video");bi==null||bi.forEach(function(Bt){if(Bt.oncontextmenu=function(){return!1},Bt.src.indexOf(".m3u8")>-1&&!Bt.canPlayType("application/vnd.apple.mpegurl")){if(Y.a.isSupported()){var li=new Y.a;li.loadSource(Bt.src),li.attachMedia(Bt)}}})};Object(I.useEffect)(function(){if(Yi.current&&Zi&&(Zi.match(gn)&&window.PR.prettyPrint()),Yi.current)return Yi.current.addEventListener("click",bn),function(){Yi.current.removeEventListener("click",bn),m(),O()}},[Zi,Yi.current,bn]);var En=function(Kt){if(!J)return;Kt.target.nodeName==="IMG"?(Si.current.style.zIndex=1,Si.current.style.display="flex",Si.current.style.width=Kt.target.clientWidth+"px",Si.current.style.height=Kt.target.clientHeight+"px",Si.current.style.top=Kt.target.offsetTop+"px",Si.current.style.left=Kt.target.offsetLeft+"px",Qi.current.src=Kt.target.getAttribute("src")):Si.current.style.display="none"};return g.a.createElement("div",{style:{position:"relative"}},g.a.createElement("div",{ref:Yi,style:Object(F.a)({},zt),className:"".concat(W||""," markdown-body ").concat(mn.a.mdBody),onMouseOver:En,dangerouslySetInnerHTML:{__html:Zi}}),g.a.createElement("div",{ref:Si,className:mn.a.button},g.a.createElement(Z.a,null,g.a.createElement(V.a,{onClick:function(){return Kn()}},"\u88C1\u526A"),g.a.createElement(V.a,{onClick:function(){return Vn()}},"\u7F16\u8F91"))),g.a.createElement("img",{ref:Qi,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),g.a.createElement(ce.a,{close:!0,data:zi,type:zi!=null&&zi.length?kn:"",style:Object(F.a)({},Bi),onClose:function(){return ln("")}}))}},"9VGf":function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return k});var ae=ne("q1tI"),Z=ne.n(ae);function k(V,F){var D=Object(ae.useRef)();Object(ae.useEffect)(function(){D.current=V}),Object(ae.useEffect)(function(){function G(){D.current()}if(F!==null){var j=setInterval(G,F);return function(){return clearInterval(j)}}},[F])}},BU3w:function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return D});var ae=ne("MNnm"),Z="rc-util-key";function k(G){if(G.attachTo)return G.attachTo;var j=document.querySelector("head");return j||document.body}function V(G){var j,M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(ae.a)())return null;var I=document.createElement("style");if((j=M.csp)===null||j===void 0?void 0:j.nonce){var g;I.nonce=(g=M.csp)===null||g===void 0?void 0:g.nonce}I.innerHTML=G;var p=k(M),f=p.firstChild;return M.prepend&&p.prepend?p.prepend(I):M.prepend&&f?p.insertBefore(I,f):p.appendChild(I),I}var F=new Map;function D(G,j){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},I=k(M);if(!F.has(I)){var g=V("",M),p=g.parentNode;F.set(I,p),p.removeChild(g)}var f=Array.from(F.get(I).children).find(function(s){return s.tagName==="STYLE"&&s[Z]===j});if(f){var h,a;if(((h=M.csp)===null||h===void 0?void 0:h.nonce)&&f.nonce!==((a=M.csp)===null||a===void 0?void 0:a.nonce)){var c;f.nonce=(c=M.csp)===null||c===void 0?void 0:c.nonce}return f.innerHTML!==G&&(f.innerHTML=G),f}var o=V(G,M);return o[Z]=j,o}},Bd2K:function(_t,lt,ne){(function(ae){ae(ne("VrN/"),ne("osHv"))})(function(ae){ae.defineOption("autoCloseTags",!1,function(M,I,g){if(g!=ae.Init&&g&&M.removeKeyMap("autoCloseTags"),!I)return;var p={name:"autoCloseTags"};(typeof I!="object"||I.whenClosing!==!1)&&(p["'/'"]=function(f){return D(f)}),(typeof I!="object"||I.whenOpening!==!1)&&(p["'>'"]=function(f){return V(f)}),M.addKeyMap(p)});var Z=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],k=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function V(M){if(M.getOption("disableInput"))return ae.Pass;for(var I=M.listSelections(),g=[],p=M.getOption("autoCloseTags"),f=0;f<I.length;f++){if(!I[f].empty())return ae.Pass;var h=I[f].head,a=M.getTokenAt(h),c=ae.innerMode(M.getMode(),a.state),o=c.state,s=c.mode.xmlCurrentTag&&c.mode.xmlCurrentTag(o),l=s&&s.name;if(!l)return ae.Pass;var d=c.mode.configuration=="html",O=typeof p=="object"&&p.dontCloseTags||d&&Z,w=typeof p=="object"&&p.indentTags||d&&k;a.end>h.ch&&(l=l.slice(0,l.length-a.end+h.ch));var x=l.toLowerCase();if(!l||a.type=="string"&&(a.end!=h.ch||!/[\"\']/.test(a.string.charAt(a.string.length-1))||a.string.length==1)||a.type=="tag"&&s.close||a.string.indexOf("/")==h.ch-a.start-1||O&&G(O,x)>-1||j(M,c.mode.xmlCurrentContext&&c.mode.xmlCurrentContext(o)||[],l,h,!0))return ae.Pass;var R=typeof p=="object"&&p.emptyTags;if(R&&G(R,l)>-1){g[f]={text:"/>",newPos:ae.Pos(h.line,h.ch+2)};continue}var A=w&&G(w,x)>-1;g[f]={indent:A,text:">"+(A?`
`:"")+"</"+l+">",newPos:A?ae.Pos(h.line+1,0):ae.Pos(h.line,h.ch+1)}}for(var T=typeof p=="object"&&p.dontIndentOnAutoClose,f=I.length-1;f>=0;f--){var E=g[f];M.replaceRange(E.text,I[f].head,I[f].anchor,"+insert");var y=M.listSelections().slice(0);y[f]={head:E.newPos,anchor:E.newPos},M.setSelections(y),!T&&E.indent&&(M.indentLine(E.newPos.line,null,!0),M.indentLine(E.newPos.line+1,null,!0))}}function F(M,I){for(var g=M.listSelections(),p=[],f=I?"/":"</",h=M.getOption("autoCloseTags"),a=typeof h=="object"&&h.dontIndentOnSlash,c=0;c<g.length;c++){if(!g[c].empty())return ae.Pass;var o=g[c].head,s=M.getTokenAt(o),l=ae.innerMode(M.getMode(),s.state),d=l.state;if(I&&(s.type=="string"||s.string.charAt(0)!="<"||s.start!=o.ch-1))return ae.Pass;var O,w=l.mode.name!="xml"&&M.getMode().name=="htmlmixed";if(w&&l.mode.name=="javascript")O=f+"script";else if(w&&l.mode.name=="css")O=f+"style";else{var x=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(d);if(!x||x.length&&j(M,x,x[x.length-1],o))return ae.Pass;O=f+x[x.length-1]}M.getLine(o.line).charAt(s.end)!=">"&&(O+=">"),p[c]=O}if(M.replaceSelections(p),g=M.listSelections(),!a)for(var c=0;c<g.length;c++)(c==g.length-1||g[c].head.line<g[c+1].head.line)&&M.indentLine(g[c].head.line)}function D(M){return M.getOption("disableInput")?ae.Pass:F(M,!0)}ae.commands.closeTag=function(M){return F(M)};function G(M,I){if(M.indexOf)return M.indexOf(I);for(var g=0,p=M.length;g<p;++g)if(M[g]==I)return g;return-1}function j(M,I,g,p,f){if(!ae.scanForClosingTag)return!1;var h=Math.min(M.lastLine()+1,p.line+500),a=ae.scanForClosingTag(M,p,null,h);if(!a||a.tag!=g)return!1;for(var c=f?1:0,o=I.length-1;o>=0&&I[o]==g;o--)++c;p=a.to;for(var o=1;o<c;o++){var s=ae.scanForClosingTag(M,p,null,h);if(!s||s.tag!=g)return!1;p=s.to}return!0}})},BjJ7:function(_t,lt,ne){"use strict";ne.d(lt,"d",function(){return Z}),ne.d(lt,"c",function(){return k}),ne.d(lt,"e",function(){return V}),ne.d(lt,"b",function(){return F}),ne.d(lt,"a",function(){return G});var ae=ne("m3rI");function Z(j){var M=!0;if(j.length>0){for(var I=0;I<j.length;I++)if(j[I].compile_success==0||!j[I].compile_success){M=!1;break}}else M=!1;return M}function k(j){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",I=[],g=0;g<j.length;g++){var p=j[g],f=M?"".concat(M,"/").concat(p.name):"".concat(p.name);I.push({title:p.name,isLeaf:!(p.type==="tree"),key:f})}return I}function V(j,M,I){for(var g=0;g<j.length;g++){var p=j[g];if(p.key===M){p.children=I;break}p.children&&V(p.children,M,I)}return j}function F(j,M,I){var g;return function(){var p=this,f=arguments,h=function(){g=null,I||j.apply(p,f)},a=I&&!g;clearTimeout(g),g=setTimeout(h,M),a&&j.apply(p,f)}}var D=!0,G=ae.a.API_SERVER},"C+DQ":function(_t,lt,ne){},DlQD:function(_t,lt,ne){(function(ae,Z){_t.exports=Z()})(this,function(){"use strict";function ae(me,he){for(var de=0;de<he.length;de++){var ie=he[de];ie.enumerable=ie.enumerable||!1,ie.configurable=!0,"value"in ie&&(ie.writable=!0),Object.defineProperty(me,ie.key,ie)}}function Z(me,he,de){return he&&ae(me.prototype,he),de&&ae(me,de),me}function k(me,he){if(!me)return;if(typeof me=="string")return V(me,he);var de=Object.prototype.toString.call(me).slice(8,-1);if(de==="Object"&&me.constructor&&(de=me.constructor.name),de==="Map"||de==="Set")return Array.from(me);if(de==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(de))return V(me,he)}function V(me,he){(he==null||he>me.length)&&(he=me.length);for(var de=0,ie=new Array(he);de<he;de++)ie[de]=me[de];return ie}function F(me,he){var de;if(typeof Symbol=="undefined"||me[Symbol.iterator]==null){if(Array.isArray(me)||(de=k(me))||he&&me&&typeof me.length=="number"){de&&(me=de);var ie=0;return function(){return ie>=me.length?{done:!0}:{done:!1,value:me[ie++]}}}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 de=me[Symbol.iterator](),de.next.bind(de)}function D(me,he){return he={exports:{}},me(he,he.exports),he.exports}var G=D(function(me){function he(){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 de(ie){me.exports.defaults=ie}me.exports={defaults:he(),getDefaults:he,changeDefaults:de}}),j=G.defaults,M=G.getDefaults,I=G.changeDefaults,g=/[&<>"']/,p=/[&<>"']/g,f=/[<>"']|&(?!#?\w+;)/,h=/[<>"']|&(?!#?\w+;)/g,a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},c=function(he){return a[he]};function o(me,he){if(he){if(g.test(me))return me.replace(p,c)}else if(f.test(me))return me.replace(h,c);return me}var s=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(me){return me.replace(s,function(he,de){return de=de.toLowerCase(),de==="colon"?":":de.charAt(0)==="#"?de.charAt(1)==="x"?String.fromCharCode(parseInt(de.substring(2),16)):String.fromCharCode(+de.substring(1)):""})}var d=/(^|[^\[])\^/g;function O(me,he){me=me.source||me,he=he||"";var de={replace:function(q,se){return se=se.source||se,se=se.replace(d,"$1"),me=me.replace(q,se),de},getRegex:function(){return new RegExp(me,he)}};return de}var w=/[^\w:]/g,x=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(me,he,de){if(me){var ie;try{ie=decodeURIComponent(l(de)).replace(w,"").toLowerCase()}catch(q){return null}if(ie.indexOf("javascript:")===0||ie.indexOf("vbscript:")===0||ie.indexOf("data:")===0)return null}he&&!x.test(de)&&(de=u(he,de));try{de=encodeURI(de).replace(/%25/g,"%")}catch(q){return null}return de}var A={},T=/^[^:]+:\/*[^/]*$/,E=/^([^:]+:)[\s\S]*$/,y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function u(me,he){A[" "+me]||(T.test(me)?A[" "+me]=me+"/":A[" "+me]=P(me,"/",!0)),me=A[" "+me];var de=me.indexOf(":")===-1;return he.substring(0,2)==="//"?de?he:me.replace(E,"$1")+he:he.charAt(0)==="/"?de?he:me.replace(y,"$1")+he:me+he}var _={exec:function(){}};function m(me){for(var he=1,de,ie;he<arguments.length;he++){de=arguments[he];for(ie in de)Object.prototype.hasOwnProperty.call(de,ie)&&(me[ie]=de[ie])}return me}function b(me,he){var de=me.replace(/\|/g,function(se,ue,ge){for(var Ce=!1,Le=ue;--Le>=0&&ge[Le]==="\\";)Ce=!Ce;return Ce?"|":" |"}),ie=de.split(/ \|/),q=0;if(ie.length>he)ie.splice(he);else for(;ie.length<he;)ie.push("");for(;q<ie.length;q++)ie[q]=ie[q].trim().replace(/\\\|/g,"|");return ie}function P(me,he,de){var ie=me.length;if(ie===0)return"";for(var q=0;q<ie;){var se=me.charAt(ie-q-1);if(se===he&&!de)q++;else if(se!==he&&de)q++;else break}return me.substr(0,ie-q)}function N(me,he){if(me.indexOf(he[1])===-1)return-1;for(var de=me.length,ie=0,q=0;q<de;q++)if(me[q]==="\\")q++;else if(me[q]===he[0])ie++;else if(me[q]===he[1]&&(ie--,ie<0))return q;return-1}function K(me){me&&me.sanitize&&!me.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var X={escape:o,unescape:l,edit:O,cleanUrl:R,resolveUrl:u,noopTest:_,merge:m,splitCells:b,rtrim:P,findClosingBracket:N,checkSanitizeDeprecation:K},B=G.defaults,S=X.rtrim,Y=X.splitCells,te=X.escape,re=X.findClosingBracket;function ce(me,he,de){var ie=he.href,q=he.title?te(he.title):null,se=me[1].replace(/\\([\[\]])/g,"$1");return me[0].charAt(0)!=="!"?{type:"link",raw:de,href:ie,title:q,text:se}:{type:"image",raw:de,href:ie,title:q,text:te(se)}}function Te(me,he){var de=me.match(/^(\s+)(?:```)/);if(de===null)return he;var ie=de[1];return he.split(`
`).map(function(q){var se=q.match(/^\s+/);if(se===null)return q;var ue=se[0];return ue.length>=ie.length?q.slice(ie.length):q}).join(`
`)}var ye=function(){function me(de){this.options=de||B}var he=me.prototype;return he.space=function(ie){var q=this.rules.block.newline.exec(ie);if(q)return q[0].length>1?{type:"space",raw:q[0]}:{raw:`
`}},he.code=function(ie,q){var se=this.rules.block.code.exec(ie);if(se){var ue=q[q.length-1];if(ue&&ue.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var ge=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?ge:S(ge,`
`)}}},he.fences=function(ie){var q=this.rules.block.fences.exec(ie);if(q){var se=q[0],ue=Te(se,q[3]||"");return{type:"code",raw:se,lang:q[2]?q[2].trim():q[2],text:ue}}},he.heading=function(ie){var q=this.rules.block.heading.exec(ie);if(q)return{type:"heading",raw:q[0],depth:q[1].length,text:q[2]}},he.nptable=function(ie){var q=this.rules.block.nptable.exec(ie);if(q){var se={type:"table",header:Y(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(`
`):[],raw:q[0]};if(se.header.length===se.align.length){var ue=se.align.length,ge;for(ge=0;ge<ue;ge++)/^ *-+: *$/.test(se.align[ge])?se.align[ge]="right":/^ *:-+: *$/.test(se.align[ge])?se.align[ge]="center":/^ *:-+ *$/.test(se.align[ge])?se.align[ge]="left":se.align[ge]=null;for(ue=se.cells.length,ge=0;ge<ue;ge++)se.cells[ge]=Y(se.cells[ge],se.header.length);return se}}},he.hr=function(ie){var q=this.rules.block.hr.exec(ie);if(q)return{type:"hr",raw:q[0]}},he.blockquote=function(ie){var q=this.rules.block.blockquote.exec(ie);if(q){var se=q[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:q[0],text:se}}},he.list=function(ie){var q=this.rules.block.list.exec(ie);if(q){for(var se=q[0],ue=q[2],ge=ue.length>1,Ce=ue[ue.length-1]===")",Le={type:"list",raw:se,ordered:ge,start:ge?+ue.slice(0,-1):"",loose:!1,items:[]},ze=q[0].match(this.rules.block.item),pt=!1,ct,Ct,xt,$e,Rt,vt,Nt,It=ze.length,At=0;At<It;At++)ct=ze[At],se=ct,Ct=ct.length,ct=ct.replace(/^ *([*+-]|\d+[.)]) */,""),~ct.indexOf(`
`)&&(Ct-=ct.length,ct=this.options.pedantic?ct.replace(/^ {1,4}/gm,""):ct.replace(new RegExp("^ {1,"+Ct+"}","gm"),"")),At!==It-1&&(xt=this.rules.block.bullet.exec(ze[At+1])[0],(ge?xt.length===1||!Ce&&xt[xt.length-1]===")":xt.length>1||this.options.smartLists&&xt!==ue)&&($e=ze.slice(At+1).join(`
`),Le.raw=Le.raw.substring(0,Le.raw.length-$e.length),At=It-1)),Rt=pt||/\n\n(?!\s*$)/.test(ct),At!==It-1&&(pt=ct.charAt(ct.length-1)===`
`,Rt||(Rt=pt)),Rt&&(Le.loose=!0),vt=/^\[[ xX]\] /.test(ct),Nt=void 0,vt&&(Nt=ct[1]!==" ",ct=ct.replace(/^\[[ xX]\] +/,"")),Le.items.push({type:"list_item",raw:se,task:vt,checked:Nt,loose:Rt,text:ct});return Le}},he.html=function(ie){var q=this.rules.block.html.exec(ie);if(q)return{type:this.options.sanitize?"paragraph":"html",raw:q[0],pre:!this.options.sanitizer&&(q[1]==="pre"||q[1]==="script"||q[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):te(q[0]):q[0]}},he.def=function(ie){var q=this.rules.block.def.exec(ie);if(q){q[3]&&(q[3]=q[3].substring(1,q[3].length-1));var se=q[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:q[0],href:q[2],title:q[3]}}},he.table=function(ie){var q=this.rules.block.table.exec(ie);if(q){var se={type:"table",header:Y(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(`
`):[]};if(se.header.length===se.align.length){se.raw=q[0];var ue=se.align.length,ge;for(ge=0;ge<ue;ge++)/^ *-+: *$/.test(se.align[ge])?se.align[ge]="right":/^ *:-+: *$/.test(se.align[ge])?se.align[ge]="center":/^ *:-+ *$/.test(se.align[ge])?se.align[ge]="left":se.align[ge]=null;for(ue=se.cells.length,ge=0;ge<ue;ge++)se.cells[ge]=Y(se.cells[ge].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},he.lheading=function(ie){var q=this.rules.block.lheading.exec(ie);if(q)return{type:"heading",raw:q[0],depth:q[2].charAt(0)==="="?1:2,text:q[1]}},he.paragraph=function(ie){var q=this.rules.block.paragraph.exec(ie);if(q)return{type:"paragraph",raw:q[0],text:q[1].charAt(q[1].length-1)===`
`?q[1].slice(0,-1):q[1]}},he.text=function(ie,q){var se=this.rules.block.text.exec(ie);if(se){var ue=q[q.length-1];return ue&&ue.type==="text"?{raw:se[0],text:se[0]}:{type:"text",raw:se[0],text:se[0]}}},he.escape=function(ie){var q=this.rules.inline.escape.exec(ie);if(q)return{type:"escape",raw:q[0],text:te(q[1])}},he.tag=function(ie,q,se){var ue=this.rules.inline.tag.exec(ie);if(ue)return!q&&/^<a /i.test(ue[0])?q=!0:q&&/^<\/a>/i.test(ue[0])&&(q=!1),!se&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?se=!0:se&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(se=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:q,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):te(ue[0]):ue[0]}},he.link=function(ie){var q=this.rules.inline.link.exec(ie);if(q){var se=re(q[2],"()");if(se>-1){var ue=q[0].indexOf("!")===0?5:4,ge=ue+q[1].length+se;q[2]=q[2].substring(0,se),q[0]=q[0].substring(0,ge).trim(),q[3]=""}var Ce=q[2],Le="";if(this.options.pedantic){var ze=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Ce);ze?(Ce=ze[1],Le=ze[3]):Le=""}else Le=q[3]?q[3].slice(1,-1):"";Ce=Ce.trim().replace(/^<([\s\S]*)>$/,"$1");var pt=ce(q,{href:Ce&&Ce.replace(this.rules.inline._escapes,"$1"),title:Le&&Le.replace(this.rules.inline._escapes,"$1")},q[0]);return pt}},he.reflink=function(ie,q){var se;if((se=this.rules.inline.reflink.exec(ie))||(se=this.rules.inline.nolink.exec(ie))){var ue=(se[2]||se[1]).replace(/\s+/g," ");if(ue=q[ue.toLowerCase()],!ue||!ue.href){var ge=se[0].charAt(0);return{type:"text",raw:ge,text:ge}}var Ce=ce(se,ue,se[0]);return Ce}},he.strong=function(ie,q,se){se===void 0&&(se="");var ue=this.rules.inline.strong.start.exec(ie);if(ue&&(!ue[1]||ue[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){q=q.slice(-1*ie.length);var ge=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ge.lastIndex=0;for(var Ce;(ue=ge.exec(q))!=null;)if(Ce=this.rules.inline.strong.middle.exec(q.slice(0,ue.index+3)),Ce)return{type:"strong",raw:ie.slice(0,Ce[0].length),text:ie.slice(2,Ce[0].length-2)}}},he.em=function(ie,q,se){se===void 0&&(se="");var ue=this.rules.inline.em.start.exec(ie);if(ue&&(!ue[1]||ue[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){q=q.slice(-1*ie.length);var ge=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ge.lastIndex=0;for(var Ce;(ue=ge.exec(q))!=null;)if(Ce=this.rules.inline.em.middle.exec(q.slice(0,ue.index+2)),Ce)return{type:"em",raw:ie.slice(0,Ce[0].length),text:ie.slice(1,Ce[0].length-1)}}},he.codespan=function(ie){var q=this.rules.inline.code.exec(ie);if(q){var se=q[2].replace(/\n/g," "),ue=/[^ ]/.test(se),ge=se.startsWith(" ")&&se.endsWith(" ");return ue&&ge&&(se=se.substring(1,se.length-1)),se=te(se,!0),{type:"codespan",raw:q[0],text:se}}},he.br=function(ie){var q=this.rules.inline.br.exec(ie);if(q)return{type:"br",raw:q[0]}},he.del=function(ie){var q=this.rules.inline.del.exec(ie);if(q)return{type:"del",raw:q[0],text:q[1]}},he.autolink=function(ie,q){var se=this.rules.inline.autolink.exec(ie);if(se){var ue,ge;return se[2]==="@"?(ue=te(this.options.mangle?q(se[1]):se[1]),ge="mailto:"+ue):(ue=te(se[1]),ge=ue),{type:"link",raw:se[0],text:ue,href:ge,tokens:[{type:"text",raw:ue,text:ue}]}}},he.url=function(ie,q){var se;if(se=this.rules.inline.url.exec(ie)){var ue,ge;if(se[2]==="@")ue=te(this.options.mangle?q(se[0]):se[0]),ge="mailto:"+ue;else{var Ce;do Ce=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(Ce!==se[0]);ue=te(se[0]),se[1]==="www."?ge="http://"+ue:ge=ue}return{type:"link",raw:se[0],text:ue,href:ge,tokens:[{type:"text",raw:ue,text:ue}]}}},he.inlineText=function(ie,q,se){var ue=this.rules.inline.text.exec(ie);if(ue){var ge;return q?ge=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):te(ue[0]):ue[0]:ge=te(this.options.smartypants?se(ue[0]):ue[0]),{type:"text",raw:ue[0],text:ge}}},me}(),be=X.noopTest,we=X.edit,xe=X.merge,ve={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:be,table:be,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=we(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ve.item=we(ve.item,"gm").replace(/bull/g,ve.bullet).getRegex(),ve.list=we(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?-->/,ve.html=we(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=we(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=we(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal=xe({},ve),ve.gfm=xe({},ve.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ve.gfm.nptable=we(ve.gfm.nptable).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.table=we(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic=xe({},ve.normal,{html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:be,paragraph:we(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var oe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:be,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:be,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};oe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",oe.punctuation=we(oe.punctuation).replace(/punctuation/g,oe._punctuation).getRegex(),oe._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",oe._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",oe.em.start=we(oe.em.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.middle=we(oe.em.middle).replace(/punctuation/g,oe._punctuation).replace(/overlapSkip/g,oe._overlapSkip).getRegex(),oe.em.endAst=we(oe.em.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.endUnd=we(oe.em.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.start=we(oe.strong.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.middle=we(oe.strong.middle).replace(/punctuation/g,oe._punctuation).replace(/blockSkip/g,oe._blockSkip).getRegex(),oe.strong.endAst=we(oe.strong.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.endUnd=we(oe.strong.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.blockSkip=we(oe._blockSkip,"g").getRegex(),oe.overlapSkip=we(oe._overlapSkip,"g").getRegex(),oe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,oe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,oe._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])?)+(?![-_])/,oe.autolink=we(oe.autolink).replace("scheme",oe._scheme).replace("email",oe._email).getRegex(),oe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,oe.tag=we(oe.tag).replace("comment",ve._comment).replace("attribute",oe._attribute).getRegex(),oe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,oe._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,oe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,oe.link=we(oe.link).replace("label",oe._label).replace("href",oe._href).replace("title",oe._title).getRegex(),oe.reflink=we(oe.reflink).replace("label",oe._label).getRegex(),oe.reflinkSearch=we(oe.reflinkSearch,"g").replace("reflink",oe.reflink).replace("nolink",oe.nolink).getRegex(),oe.normal=xe({},oe),oe.pedantic=xe({},oe.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:we(/^!?\[(label)\]\((.*?)\)/).replace("label",oe._label).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oe._label).getRegex()}),oe.gfm=xe({},oe.normal,{escape:we(oe.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),oe.gfm.url=we(oe.gfm.url,"i").replace("email",oe.gfm._extended_email).getRegex(),oe.breaks=xe({},oe.gfm,{br:we(oe.br).replace("{2,}","*").getRegex(),text:we(oe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Re={block:ve,inline:oe},Ye=G.defaults,Ue=Re.block,rt=Re.inline;function ot(me){return me.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 Oe(me){var he="",de,ie,q=me.length;for(de=0;de<q;de++)ie=me.charCodeAt(de),Math.random()>.5&&(ie="x"+ie.toString(16)),he+="&#"+ie+";";return he}var Me=function(){function me(de){this.tokens=[],this.tokens.links=Object.create(null),this.options=de||Ye,this.options.tokenizer=this.options.tokenizer||new ye,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ie={block:Ue.normal,inline:rt.normal};this.options.pedantic?(ie.block=Ue.pedantic,ie.inline=rt.pedantic):this.options.gfm&&(ie.block=Ue.gfm,this.options.breaks?ie.inline=rt.breaks:ie.inline=rt.gfm),this.tokenizer.rules=ie}me.lex=function(ie,q){var se=new me(q);return se.lex(ie)};var he=me.prototype;return he.lex=function(ie){return ie=ie.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(ie,this.tokens,!0),this.inline(this.tokens),this.tokens},he.blockTokens=function(ie,q,se){q===void 0&&(q=[]),se===void 0&&(se=!0),ie=ie.replace(/^ +$/gm,"");for(var ue,ge,Ce,Le;ie;){if(ue=this.tokenizer.space(ie)){ie=ie.substring(ue.raw.length),ue.type&&q.push(ue);continue}if(ue=this.tokenizer.code(ie,q)){ie=ie.substring(ue.raw.length),ue.type?q.push(ue):(Le=q[q.length-1],Le.raw+=`
`+ue.raw,Le.text+=`
`+ue.text);continue}if(ue=this.tokenizer.fences(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.heading(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.nptable(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.hr(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.blockquote(ie)){ie=ie.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],se),q.push(ue);continue}if(ue=this.tokenizer.list(ie)){for(ie=ie.substring(ue.raw.length),Ce=ue.items.length,ge=0;ge<Ce;ge++)ue.items[ge].tokens=this.blockTokens(ue.items[ge].text,[],!1);q.push(ue);continue}if(ue=this.tokenizer.html(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(se&&(ue=this.tokenizer.def(ie))){ie=ie.substring(ue.raw.length),this.tokens.links[ue.tag]||(this.tokens.links[ue.tag]={href:ue.href,title:ue.title});continue}if(ue=this.tokenizer.table(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.lheading(ie)){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(se&&(ue=this.tokenizer.paragraph(ie))){ie=ie.substring(ue.raw.length),q.push(ue);continue}if(ue=this.tokenizer.text(ie,q)){ie=ie.substring(ue.raw.length),ue.type?q.push(ue):(Le=q[q.length-1],Le.raw+=`
`+ue.raw,Le.text+=`
`+ue.text);continue}if(ie){var ze="Infinite loop on byte: "+ie.charCodeAt(0);if(this.options.silent){console.error(ze);break}else throw new Error(ze)}}return q},he.inline=function(ie){var q,se,ue,ge,Ce,Le,ze=ie.length;for(q=0;q<ze;q++){Le=ie[q];switch(Le.type){case"paragraph":case"text":case"heading":{Le.tokens=[],this.inlineTokens(Le.text,Le.tokens);break}case"table":{for(Le.tokens={header:[],cells:[]},ge=Le.header.length,se=0;se<ge;se++)Le.tokens.header[se]=[],this.inlineTokens(Le.header[se],Le.tokens.header[se]);for(ge=Le.cells.length,se=0;se<ge;se++)for(Ce=Le.cells[se],Le.tokens.cells[se]=[],ue=0;ue<Ce.length;ue++)Le.tokens.cells[se][ue]=[],this.inlineTokens(Ce[ue],Le.tokens.cells[se][ue]);break}case"blockquote":{this.inline(Le.tokens);break}case"list":{for(ge=Le.items.length,se=0;se<ge;se++)this.inline(Le.items[se].tokens);break}}}return ie},he.inlineTokens=function(ie,q,se,ue,ge){q===void 0&&(q=[]),se===void 0&&(se=!1),ue===void 0&&(ue=!1),ge===void 0&&(ge="");var Ce,Le=ie,ze;if(this.tokens.links){var pt=Object.keys(this.tokens.links);if(pt.length>0)for(;(ze=this.tokenizer.rules.inline.reflinkSearch.exec(Le))!=null;)pt.includes(ze[0].slice(ze[0].lastIndexOf("[")+1,-1))&&(Le=Le.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+Le.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(ze=this.tokenizer.rules.inline.blockSkip.exec(Le))!=null;)Le=Le.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+Le.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ie;){if(Ce=this.tokenizer.escape(ie)){ie=ie.substring(Ce.raw.length),q.push(Ce);continue}if(Ce=this.tokenizer.tag(ie,se,ue)){ie=ie.substring(Ce.raw.length),se=Ce.inLink,ue=Ce.inRawBlock,q.push(Ce);continue}if(Ce=this.tokenizer.link(ie)){ie=ie.substring(Ce.raw.length),Ce.type==="link"&&(Ce.tokens=this.inlineTokens(Ce.text,[],!0,ue)),q.push(Ce);continue}if(Ce=this.tokenizer.reflink(ie,this.tokens.links)){ie=ie.substring(Ce.raw.length),Ce.type==="link"&&(Ce.tokens=this.inlineTokens(Ce.text,[],!0,ue)),q.push(Ce);continue}if(Ce=this.tokenizer.strong(ie,Le,ge)){ie=ie.substring(Ce.raw.length),Ce.tokens=this.inlineTokens(Ce.text,[],se,ue),q.push(Ce);continue}if(Ce=this.tokenizer.em(ie,Le,ge)){ie=ie.substring(Ce.raw.length),Ce.tokens=this.inlineTokens(Ce.text,[],se,ue),q.push(Ce);continue}if(Ce=this.tokenizer.codespan(ie)){ie=ie.substring(Ce.raw.length),q.push(Ce);continue}if(Ce=this.tokenizer.br(ie)){ie=ie.substring(Ce.raw.length),q.push(Ce);continue}if(Ce=this.tokenizer.del(ie)){ie=ie.substring(Ce.raw.length),Ce.tokens=this.inlineTokens(Ce.text,[],se,ue),q.push(Ce);continue}if(Ce=this.tokenizer.autolink(ie,Oe)){ie=ie.substring(Ce.raw.length),q.push(Ce);continue}if(!se&&(Ce=this.tokenizer.url(ie,Oe))){ie=ie.substring(Ce.raw.length),q.push(Ce);continue}if(Ce=this.tokenizer.inlineText(ie,ue,ot)){ie=ie.substring(Ce.raw.length),ge=Ce.raw.slice(-1),q.push(Ce);continue}if(ie){var ct="Infinite loop on byte: "+ie.charCodeAt(0);if(this.options.silent){console.error(ct);break}else throw new Error(ct)}}return q},Z(me,null,[{key:"rules",get:function(){return{block:Ue,inline:rt}}}]),me}(),We=G.defaults,qe=X.cleanUrl,Ve=X.escape,je=function(){function me(de){this.options=de||We}var he=me.prototype;return he.code=function(ie,q,se){var ue=(q||"").match(/\S*/)[0];if(this.options.highlight){var ge=this.options.highlight(ie,ue);ge!=null&&ge!==ie&&(se=!0,ie=ge)}return ue?'<pre><code class="'+this.options.langPrefix+Ve(ue,!0)+'">'+(se?ie:Ve(ie,!0))+`</code></pre>
`:"<pre><code>"+(se?ie:Ve(ie,!0))+`</code></pre>
`},he.blockquote=function(ie){return`<blockquote>
`+ie+`</blockquote>
`},he.html=function(ie){return ie},he.heading=function(ie,q,se,ue){return this.options.headerIds?"<h"+q+' id="'+this.options.headerPrefix+ue.slug(se)+'">'+ie+"</h"+q+`>
`:"<h"+q+">"+ie+"</h"+q+`>
`},he.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},he.list=function(ie,q,se){var ue=q?"ol":"ul",ge=q&&se!==1?' start="'+se+'"':"";return"<"+ue+ge+`>
`+ie+"</"+ue+`>
`},he.listitem=function(ie){return"<li>"+ie+`</li>
`},he.checkbox=function(ie){return"<input "+(ie?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},he.paragraph=function(ie){return"<p>"+ie+`</p>
`},he.table=function(ie,q){return q&&(q="<tbody>"+q+"</tbody>"),`<table>
<thead>
`+ie+`</thead>
`+q+`</table>
`},he.tablerow=function(ie){return`<tr>
`+ie+`</tr>
`},he.tablecell=function(ie,q){var se=q.header?"th":"td",ue=q.align?"<"+se+' align="'+q.align+'">':"<"+se+">";return ue+ie+"</"+se+`>
`},he.strong=function(ie){return"<strong>"+ie+"</strong>"},he.em=function(ie){return"<em>"+ie+"</em>"},he.codespan=function(ie){return"<code>"+ie+"</code>"},he.br=function(){return this.options.xhtml?"<br/>":"<br>"},he.del=function(ie){return"<del>"+ie+"</del>"},he.link=function(ie,q,se){if(ie=qe(this.options.sanitize,this.options.baseUrl,ie),ie===null)return se;var ue='<a href="'+Ve(ie)+'"';return q&&(ue+=' title="'+q+'"'),ue+=">"+se+"</a>",ue},he.image=function(ie,q,se){if(ie=qe(this.options.sanitize,this.options.baseUrl,ie),ie===null)return se;var ue='<img src="'+ie+'" alt="'+se+'"';return q&&(ue+=' title="'+q+'"'),ue+=this.options.xhtml?"/>":">",ue},he.text=function(ie){return ie},me}(),Fe=function(){function me(){}var he=me.prototype;return he.strong=function(ie){return ie},he.em=function(ie){return ie},he.codespan=function(ie){return ie},he.del=function(ie){return ie},he.html=function(ie){return ie},he.text=function(ie){return ie},he.link=function(ie,q,se){return""+se},he.image=function(ie,q,se){return""+se},he.br=function(){return""},me}(),ht=function(){function me(){this.seen={}}var he=me.prototype;return he.slug=function(ie){var q=ie.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(q)){var se=q;do this.seen[se]++,q=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(q))}return this.seen[q]=0,q},me}(),He=G.defaults,Pe=X.unescape,Xe=function(){function me(de){this.options=de||He,this.options.renderer=this.options.renderer||new je,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Fe,this.slugger=new ht}me.parse=function(ie,q){var se=new me(q);return se.parse(ie)};var he=me.prototype;return he.parse=function(ie,q){q===void 0&&(q=!0);var se="",ue,ge,Ce,Le,ze,pt,ct,Ct,xt,$e,Rt,vt,Nt,It,At,di,ri,Qe,bt=ie.length;for(ue=0;ue<bt;ue++){$e=ie[ue];switch($e.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline($e.tokens),$e.depth,Pe(this.parseInline($e.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code($e.text,$e.lang,$e.escaped);continue}case"table":{for(Ct="",ct="",Le=$e.header.length,ge=0;ge<Le;ge++)ct+=this.renderer.tablecell(this.parseInline($e.tokens.header[ge]),{header:!0,align:$e.align[ge]});for(Ct+=this.renderer.tablerow(ct),xt="",Le=$e.cells.length,ge=0;ge<Le;ge++){for(pt=$e.tokens.cells[ge],ct="",ze=pt.length,Ce=0;Ce<ze;Ce++)ct+=this.renderer.tablecell(this.parseInline(pt[Ce]),{header:!1,align:$e.align[Ce]});xt+=this.renderer.tablerow(ct)}se+=this.renderer.table(Ct,xt);continue}case"blockquote":{xt=this.parse($e.tokens),se+=this.renderer.blockquote(xt);continue}case"list":{for(Rt=$e.ordered,vt=$e.start,Nt=$e.loose,Le=$e.items.length,xt="",ge=0;ge<Le;ge++)At=$e.items[ge],di=At.checked,ri=At.task,It="",At.task&&(Qe=this.renderer.checkbox(di),Nt?At.tokens.length>0&&At.tokens[0].type==="text"?(At.tokens[0].text=Qe+" "+At.tokens[0].text,At.tokens[0].tokens&&At.tokens[0].tokens.length>0&&At.tokens[0].tokens[0].type==="text"&&(At.tokens[0].tokens[0].text=Qe+" "+At.tokens[0].tokens[0].text)):At.tokens.unshift({type:"text",text:Qe}):It+=Qe),It+=this.parse(At.tokens,Nt),xt+=this.renderer.listitem(It,ri,di);se+=this.renderer.list(xt,Rt,vt);continue}case"html":{se+=this.renderer.html($e.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline($e.tokens));continue}case"text":{for(xt=$e.tokens?this.parseInline($e.tokens):$e.text;ue+1<bt&&ie[ue+1].type==="text";)$e=ie[++ue],xt+=`
`+($e.tokens?this.parseInline($e.tokens):$e.text);se+=q?this.renderer.paragraph(xt):xt;continue}default:{var kt='Token with "'+$e.type+'" type was not found.';if(this.options.silent){console.error(kt);return}else throw new Error(kt)}}}return se},he.parseInline=function(ie,q){q=q||this.renderer;var se="",ue,ge,Ce=ie.length;for(ue=0;ue<Ce;ue++){ge=ie[ue];switch(ge.type){case"escape":{se+=q.text(ge.text);break}case"html":{se+=q.html(ge.text);break}case"link":{se+=q.link(ge.href,ge.title,this.parseInline(ge.tokens,q));break}case"image":{se+=q.image(ge.href,ge.title,ge.text);break}case"strong":{se+=q.strong(this.parseInline(ge.tokens,q));break}case"em":{se+=q.em(this.parseInline(ge.tokens,q));break}case"codespan":{se+=q.codespan(ge.text);break}case"br":{se+=q.br();break}case"del":{se+=q.del(this.parseInline(ge.tokens,q));break}case"text":{se+=q.text(ge.text);break}default:{var Le='Token with "'+ge.type+'" type was not found.';if(this.options.silent){console.error(Le);return}else throw new Error(Le)}}}return se},me}(),tt=X.merge,Ke=X.checkSanitizeDeprecation,et=X.escape,Ae=G.getDefaults,nt=G.changeDefaults,Je=G.defaults;function Se(me,he,de){if(typeof me=="undefined"||me===null)throw new Error("marked(): input parameter is undefined or null");if(typeof me!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(me)+", string expected");if(typeof he=="function"&&(de=he,he=null),he=tt({},Se.defaults,he||{}),Ke(he),de){var ie=he.highlight,q;try{q=Me.lex(me,he)}catch(Ce){return de(Ce)}var se=function(Le){var ze;if(!Le)try{ze=Xe.parse(q,he)}catch(pt){Le=pt}return he.highlight=ie,Le?de(Le):de(null,ze)};if(!ie||ie.length<3)return se();if(delete he.highlight,!q.length)return se();var ue=0;Se.walkTokens(q,function(Ce){Ce.type==="code"&&(ue++,setTimeout(function(){ie(Ce.text,Ce.lang,function(Le,ze){if(Le)return se(Le);ze!=null&&ze!==Ce.text&&(Ce.text=ze,Ce.escaped=!0),ue--,ue===0&&se()})},0))}),ue===0&&se();return}try{var ge=Me.lex(me,he);return he.walkTokens&&Se.walkTokens(ge,he.walkTokens),Xe.parse(ge,he)}catch(Ce){if(Ce.message+=`
Please report this to https://github.com/markedjs/marked.`,he.silent)return"<p>An error occurred:</p><pre>"+et(Ce.message+"",!0)+"</pre>";throw Ce}}Se.options=Se.setOptions=function(me){return tt(Se.defaults,me),nt(Se.defaults),Se},Se.getDefaults=Ae,Se.defaults=Je,Se.use=function(me){var he=tt({},me);if(me.renderer&&function(){var ie=Se.defaults.renderer||new je,q=function(ge){var Ce=ie[ge];ie[ge]=function(){for(var Le=arguments.length,ze=new Array(Le),pt=0;pt<Le;pt++)ze[pt]=arguments[pt];var ct=me.renderer[ge].apply(ie,ze);return ct===!1&&(ct=Ce.apply(ie,ze)),ct}};for(var se in me.renderer)q(se);he.renderer=ie}(),me.tokenizer&&function(){var ie=Se.defaults.tokenizer||new ye,q=function(ge){var Ce=ie[ge];ie[ge]=function(){for(var Le=arguments.length,ze=new Array(Le),pt=0;pt<Le;pt++)ze[pt]=arguments[pt];var ct=me.tokenizer[ge].apply(ie,ze);return ct===!1&&(ct=Ce.apply(ie,ze)),ct}};for(var se in me.tokenizer)q(se);he.tokenizer=ie}(),me.walkTokens){var de=Se.defaults.walkTokens;he.walkTokens=function(ie){me.walkTokens(ie),de&&de(ie)}}Se.setOptions(he)},Se.walkTokens=function(me,he){for(var de=F(me),ie;!(ie=de()).done;){var q=ie.value;he(q);switch(q.type){case"table":{for(var se=F(q.tokens.header),ue;!(ue=se()).done;){var ge=ue.value;Se.walkTokens(ge,he)}for(var Ce=F(q.tokens.cells),Le;!(Le=Ce()).done;)for(var ze=Le.value,pt=F(ze),ct;!(ct=pt()).done;){var Ct=ct.value;Se.walkTokens(Ct,he)}break}case"list":{Se.walkTokens(q.items,he);break}default:q.tokens&&Se.walkTokens(q.tokens,he)}}},Se.Parser=Xe,Se.parser=Xe.parse,Se.Renderer=je,Se.TextRenderer=Fe,Se.Lexer=Me,Se.lexer=Me.lex,Se.Tokenizer=ye,Se.Slugger=ht,Se.parse=Se;var ke=Se;return ke})},ELLl:function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){var Z={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},k=ae.Pos;ae.defineOption("autoCloseBrackets",!1,function(a,c,o){o&&o!=ae.Init&&(a.removeKeyMap(F),a.state.closeBrackets=null),c&&(D(V(c,"pairs")),a.state.closeBrackets=c,a.addKeyMap(F))});function V(a,c){return c=="pairs"&&typeof a=="string"?a:typeof a=="object"&&a[c]!=null?a[c]:Z[c]}var F={Backspace:M,Enter:I};function D(a){for(var c=0;c<a.length;c++){var o=a.charAt(c),s="'"+o+"'";F[s]||(F[s]=G(o))}}D(Z.pairs+"`");function G(a){return function(c){return p(c,a)}}function j(a){var c=a.state.closeBrackets;if(!c||c.override)return c;var o=a.getModeAt(a.getCursor());return o.closeBrackets||c}function M(a){var c=j(a);if(!c||a.getOption("disableInput"))return ae.Pass;for(var o=V(c,"pairs"),s=a.listSelections(),l=0;l<s.length;l++){if(!s[l].empty())return ae.Pass;var d=f(a,s[l].head);if(!d||o.indexOf(d)%2!=0)return ae.Pass}for(var l=s.length-1;l>=0;l--){var O=s[l].head;a.replaceRange("",k(O.line,O.ch-1),k(O.line,O.ch+1),"+delete")}}function I(a){var c=j(a),o=c&&V(c,"explode");if(!o||a.getOption("disableInput"))return ae.Pass;for(var s=a.listSelections(),l=0;l<s.length;l++){if(!s[l].empty())return ae.Pass;var d=f(a,s[l].head);if(!d||o.indexOf(d)%2!=0)return ae.Pass}a.operation(function(){var O=a.lineSeparator()||`
`;a.replaceSelection(O+O,null),a.execCommand("goCharLeft"),s=a.listSelections();for(var w=0;w<s.length;w++){var x=s[w].head.line;a.indentLine(x,null,!0),a.indentLine(x+1,null,!0)}})}function g(a){var c=ae.cmpPos(a.anchor,a.head)>0;return{anchor:new k(a.anchor.line,a.anchor.ch+(c?-1:1)),head:new k(a.head.line,a.head.ch+(c?1:-1))}}function p(a,c){var o=j(a);if(!o||a.getOption("disableInput"))return ae.Pass;var s=V(o,"pairs"),l=s.indexOf(c);if(l==-1)return ae.Pass;for(var d=V(o,"closeBefore"),O=V(o,"triples"),w=s.charAt(l+1)==c,x=a.listSelections(),R=l%2==0,A,T=0;T<x.length;T++){var E=x[T],y=E.head,u,_=a.getRange(y,k(y.line,y.ch+1));if(R&&!E.empty())u="surround";else if((w||!R)&&_==c)w&&h(a,y)?u="both":O.indexOf(c)>=0&&a.getRange(y,k(y.line,y.ch+3))==c+c+c?u="skipThree":u="skip";else if(w&&y.ch>1&&O.indexOf(c)>=0&&a.getRange(k(y.line,y.ch-2),y)==c+c){if(y.ch>2&&/\bstring/.test(a.getTokenTypeAt(k(y.line,y.ch-2))))return ae.Pass;u="addFour"}else if(w){var m=y.ch==0?" ":a.getRange(k(y.line,y.ch-1),y);if(!ae.isWordChar(_)&&m!=c&&!ae.isWordChar(m))u="both";else return ae.Pass}else if(R&&(_.length===0||/\s/.test(_)||d.indexOf(_)>-1))u="both";else return ae.Pass;if(!A)A=u;else if(A!=u)return ae.Pass}var b=l%2?s.charAt(l-1):c,P=l%2?c:s.charAt(l+1);a.operation(function(){if(A=="skip")a.execCommand("goCharRight");else if(A=="skipThree")for(var N=0;N<3;N++)a.execCommand("goCharRight");else if(A=="surround"){for(var K=a.getSelections(),N=0;N<K.length;N++)K[N]=b+K[N]+P;a.replaceSelections(K,"around"),K=a.listSelections().slice();for(var N=0;N<K.length;N++)K[N]=g(K[N]);a.setSelections(K)}else A=="both"?(a.replaceSelection(b+P,null),a.triggerElectric(b+P),a.execCommand("goCharLeft")):A=="addFour"&&(a.replaceSelection(b+b+b+b,"before"),a.execCommand("goCharRight"))})}function f(a,c){var o=a.getRange(k(c.line,c.ch-1),k(c.line,c.ch+1));return o.length==2?o:null}function h(a,c){var o=a.getTokenAt(k(c.line,c.ch+1));return/\bstring/.test(o.type)&&o.start==c.ch&&(c.ch==0||!/\bstring/.test(a.getTokenTypeAt(c)))}})},G8my:function(_t,lt,ne){_t.exports={flex:"flex___1FMOA"}},HmJG:function(_t,lt,ne){},JkjM:function(_t,lt,ne){"use strict";ne.r(lt);var ae=ne("9og8"),Z=ne("PpiC"),k=ne("WmNS"),V=ne.n(k),F=ne("q1tI"),D=ne.n(F),G=ne("Ty5D"),j=ne("9kvl"),M=ne("14J3"),I=ne("BMrR"),g=ne("jCWc"),p=ne("kPKH"),f=ne("+L6B"),h=ne("2/Rp"),a=ne("k1fw"),c=ne("m3rI"),o=ne("LO5M"),s=ne.n(o),l=ne("h+Ho"),d=function(Pe){var Xe,tt,Ke,et,Ae=Pe.user,nt=Pe.forumsDetail,Je=Pe.globalSetting,Se=Pe.loading,ke=Pe.dispatch,me=Object(Z.a)(Pe,["user","forumsDetail","globalSetting","loading","dispatch"]),he=nt.forumsDetailData||{},de=he.author_info,ie=he.memo,q=he.recommend_shixuns,se=function(){var ue=Object(ae.a)(V.a.mark(function ge(){var Ce;return V.a.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(!(de!=null&&de.watched)){ze.next=6;break}return ze.next=3,Object(l.a)({user_id:de.user_id});case 3:ze.t0=ze.sent,ze.next=9;break;case 6:return ze.next=8,Object(l.o)({user_id:de.user_id});case 8:ze.t0=ze.sent;case 9:Ce=ze.t0,Ce&&ke({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},nt.forumsDetailData),{},{author_info:Object(a.a)(Object(a.a)({},de),{},{watched:!(de!=null&&de.watched)})})});case 11:case"end":return ze.stop()}},ge)}));return function(){return ue.apply(this,arguments)}}();return D.a.createElement("section",{className:s.a.wrap},D.a.createElement("aside",{className:"ml20"},D.a.createElement("div",{className:"bg-white pt40 pb40 pl20 pr20 ".concat(s.a.head)},D.a.createElement("a",{href:"/users/".concat(de==null?void 0:de.login),target:"_blank"},(de==null?void 0:de.image_url)&&D.a.createElement("img",{src:"".concat(c.a.API_SERVER,"/images/").concat(de==null?void 0:de.image_url)})),D.a.createElement("div",{className:"tc font20"},de==null?void 0:de.username),D.a.createElement("div",{className:"tc c-grey-999"},de==null?void 0:de.identity),((Xe=Ae.userInfo)===null||Xe===void 0?void 0:Xe.user_id)!==(de==null?void 0:de.user_id)&&D.a.createElement(I.a,{justify:"center",className:"mt30 ".concat(s.a.buttonWrap)},D.a.createElement(p.a,null,D.a.createElement(h.a,{type:"primary",className:"mr10",onClick:se},de!=null&&de.watched?"\u53D6\u6D88\u5173\u6CE8":"\u5173\u6CE8")),D.a.createElement(p.a,null,D.a.createElement(h.a,{ghost:!0,className:s.a.privateMessage,href:"/messages/".concat((tt=Ae.userInfo)===null||tt===void 0?void 0:tt.login,"/message_detail?target_ids=").concat(de==null?void 0:de.user_id),target:"_blank"},"\u79C1\u4FE1")))),!!(ie!=null&&(Ke=ie.tag)!==null&&Ke!==void 0&&Ke.length)&&D.a.createElement("div",{className:"bg-white mt10 pt40 pb40 pl20 pr20"},D.a.createElement("div",{className:"font16"},"\u8BDD\u9898\u6807\u7B7E"),D.a.createElement("div",{className:"mt30 ".concat(s.a.tag)},ie==null||((et=ie.tag)===null||et===void 0)?void 0:et.map(function(ue){return D.a.createElement("a",null,ue==null?void 0:ue.name)}))),D.a.createElement("div",{className:"pt10 pb10 pl10 pr10"},D.a.createElement("div",{className:"font16 mb20"},"\u63A8\u8350\u5B9E\u8BAD"),D.a.createElement("div",{className:s.a.recommend},q==null?void 0:q.map(function(ue){return D.a.createElement("div",{className:s.a.recommendItem},D.a.createElement("a",{href:"/shixuns/".concat(ue.identifier,"/challenges"),target:"_blank"},D.a.createElement("img",{alt:ue.id,src:"".concat(c.a.API_SERVER,"/").concat(ue.image_url)})),D.a.createElement("div",{className:"".concat(s.a.flex1," ml10")},D.a.createElement("a",{href:"/shixuns/".concat(ue.identifier,"/challenges"),target:"_blank",title:ue.name,className:"".concat(s.a.mWidth147," multi-llipsis1e c-grey-666 mb10")},ue.name),D.a.createElement("div",{className:"c-grey-999"},ue.myshixuns_count," \u4EBA\u5B66\u4E60")))})))))},O=Object(j.a)(function(He){var Pe=He.user,Xe=He.forumsDetail,tt=He.loading,Ke=He.globalSetting;return{user:Pe,forumsDetail:Xe,globalSetting:Ke,loading:tt.models.forumsDetail}})(d),w=ne("qVdP"),x=ne("jsC+"),R=ne("5Dmo"),A=ne("3S7+"),T=ne("sPJy"),E=ne("bE4q"),y=ne("lUTK"),u=ne("BvKs"),_=ne("5NDa"),m=ne("5rEg"),b=ne("2qtc"),P=ne("kLXV"),N=ne("miYZ"),K=ne("tsqr"),X=ne("55Ip"),B=ne("wd/R"),S=ne.n(B),Y=ne("9Bee"),te=ne("oBTY"),re=ne("tJVT"),ce=ne("Ot1p"),Te=ne("/MfK"),ye=ne("8JLL"),be=ne.n(ye);S.a.lang("ZH-cn");function we(He){var Pe=He.user,Xe=He.vlist,tt=Xe===void 0?[]:Xe,Ke=He.dispatch,et=He.params,Ae=He.id,nt=He.memo_replies,Je=He.forumsDetail;return D.a.createElement("aside",{className:be.a.comment},tt.map(function(Se,ke){var me,he;return D.a.createElement(I.a,{key:ke,className:be.a.commentItem},D.a.createElement(p.a,{span:24},D.a.createElement(I.a,null,D.a.createElement(p.a,{flex:"1"},D.a.createElement("a",{href:"/users/".concat(Se.user_login),target:"_blank",className:"c-light-black"},Se==null?void 0:Se.username),D.a.createElement("span",{className:"c-light-black ml10"},Se.time)),(Se.can_delete||Se.user_id===((me=Pe.userInfo)===null||me===void 0?void 0:me.user_id)||Se.user_login===((he=Pe.userInfo)===null||he===void 0?void 0:he.login))&&D.a.createElement(p.a,{className:"forums-comment-delete",style:{display:"none"}},D.a.createElement(A.a,{title:"\u5220\u9664"},D.a.createElement(Te.a,{className:"current",onClick:function(){P.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:D.a.createElement("div",{className:"font16 tc"},"\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u6761\u56DE\u590D\u5417\uFF1F"),onOk:function(){var ie=Object(ae.a)(V.a.mark(function se(){var ue,ge;return V.a.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return Le.next=2,Object(l.b)({id:Se.id});case 2:ue=Le.sent,ge=nt.find(function(ze){return ze.id===Ae}).children.filter(function(ze){return ze.id!==Se.id}),nt.find(function(ze){return ze.id===Ae}).children=ge,Ke({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Je.forumsDetailData),{},{memo_replies:Object(te.a)(nt)})});case 6:case"end":return Le.stop()}},se)}));function q(){return ie.apply(this,arguments)}return q}()})}}))))),D.a.createElement(p.a,null,D.a.createElement(Y.a,{value:Se.content})))}))}var xe=we,ve=ne("1vsH");S.a.lang("ZH-cn");var oe=function(Pe,Xe){var tt=Pe.user,Ke=Pe.forumsDetail,et=Pe.globalSetting,Ae=Pe.loading,nt=Pe.dispatch,Je=Pe.handleClick,Se=Object(Z.a)(Pe,["user","forumsDetail","globalSetting","loading","dispatch","handleClick"]),ke=Ke.forumsDetailData||{},me=ke.memo,he=ke.memo_replies,de=Object(G.i)(),ie=Object(F.useState)(""),q=Object(re.a)(ie,2),se=q[0],ue=q[1],ge=Object(F.useState)(""),Ce=Object(re.a)(ge,2),Le=Ce[0],ze=Ce[1],pt=Object(F.useState)(-1),ct=Object(re.a)(pt,2),Ct=ct[0],xt=ct[1],$e=Object(F.useState)(!1),Rt=Object(re.a)($e,2),vt=Rt[0],Nt=Rt[1],It=Object(F.useState)(1),At=Object(re.a)(It,2),di=At[0],ri=At[1],Qe=Object(F.useState)(!1),bt=Object(re.a)(Qe,2),kt=bt[0],Mt=bt[1];Object(F.useImperativeHandle)(Xe,function(){return{onMdFouch:Xi}}),Object(F.useEffect)(function(){Nt((me==null?void 0:me.replies_count)>10)},[me==null?void 0:me.replies_count]);var ei=function(){var ft=Object(ae.a)(V.a.mark(function ut(){var ti,Wt,Ut;return V.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:return ti=di+1,ri(ti),Vt.next=4,Object(l.h)({id:de.memoId,page:ti});case 4:Wt=Vt.sent,Wt!=null&&Wt.memo_replies&&(nt({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Ke.forumsDetailData),{},{memo_replies:[].concat(Object(te.a)(he),Object(te.a)(Wt.memo_replies))})}),Nt(((Ut=Wt.memo_replies)===null||Ut===void 0?void 0:Ut.length)===10));case 6:case"end":return Vt.stop()}},ut)}));return function(){return ft.apply(this,arguments)}}(),Gi=function(ut){var ti,Wt,Ut,Dt;return Object(a.a)(Object(a.a)({},ut),{},{image_url:(ti=tt.userInfo)===null||ti===void 0?void 0:ti.image_url,children:[],user_id:(Wt=tt.userInfo)===null||Wt===void 0?void 0:Wt.user_id,user_login:(Ut=tt.userInfo)===null||Ut===void 0?void 0:Ut.login,username:(Dt=tt.userInfo)===null||Dt===void 0?void 0:Dt.username,time:"".concat(Object(ve.bb)((new Date().getTime()-new Date(ut.created_at).getTime())/1e3),"\u524D")})},Xi=function(){Mt(!0)};return D.a.createElement("section",{className:be.a.wrap},!!(he!=null&&he.length)&&D.a.createElement("aside",{className:be.a.content},D.a.createElement("div",{style:{padding:"10px 15px 5px 15px",justifyContent:"space-between",display:"flex"}},D.a.createElement("span",null,"\u5168\u90E8\u56DE\u590D\uFF08",me.replies_count,"\uFF09")),D.a.createElement("aside",{className:be.a.replyList},he==null?void 0:he.map(function(ft,ut){var ti;return D.a.createElement(I.a,{gutter:[12,12],key:ut},D.a.createElement(p.a,{flex:"40px"},D.a.createElement("a",{href:"/users/".concat(ft.user_login),target:"_blank"},D.a.createElement("img",{alt:"\u7528\u6237\u5934\u50CF",width:"50",height:"50",src:"".concat(c.a.IMG_SERVER,"/images/").concat(ft==null?void 0:ft.image_url)}))),D.a.createElement(p.a,{flex:"1"},D.a.createElement(I.a,{align:"middle"},D.a.createElement(p.a,{span:24},D.a.createElement("a",{href:"/users/".concat(ft.user_login),target:"_blank"},D.a.createElement("span",{className:"c-light-black"},ft==null?void 0:ft.username)),D.a.createElement("span",{className:"c-light-black ml10"},ft.time)),D.a.createElement(p.a,{span:24},D.a.createElement("div",{onClick:Je},D.a.createElement(Y.a,{value:ft.content}))),!!(ft!=null&&(ti=ft.children)!==null&&ti!==void 0&&ti.length)&&D.a.createElement(xe,{user:tt,id:ft==null?void 0:ft.id,vlist:ft==null?void 0:ft.children,dispatch:nt,params:de,memo_replies:he,forumsDetail:Ke}),D.a.createElement(p.a,{span:24,className:"mt5 c-light-black"},Ct===ut?D.a.createElement("aside",null,D.a.createElement(ce.a,{onChange:function(Ut){ze(Ut)},height:150,isFocus:!0,placeholder:"\u6211\u8981\u56DE\u590D..."}),D.a.createElement(I.a,null,D.a.createElement(p.a,{span:24,className:"tr"},D.a.createElement(h.a,{type:"primary",size:"large",onClick:Object(ae.a)(V.a.mark(function Wt(){var Ut;return V.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:if(!(Le==="")){Vt.next=4;break}K.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),Vt.next=9;break;case 4:return Vt.next=6,Object(l.k)({parent_id:ft.id,content:Le});case 6:Ut=Vt.sent,ze(null),Ut&&(xt(-1),he.find(function(Ti){return Ti.id===Ut.parent_id}).children.push(Gi(Ut)),nt({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Ke.forumsDetailData),{},{memo:Object(a.a)(Object(a.a)({},me),{},{replies_count:me.replies_count+1}),memo_replies:Object(te.a)(he)})}));case 9:case"end":return Vt.stop()}},Wt)}))},"\u53D1\u9001")))):D.a.createElement("div",{className:"tr"},D.a.createElement("span",{className:"iconfont icon-huifu1 mr15 ml30 current",onClick:function(){return xt(ut)}}),D.a.createElement(A.a,{title:ft.user_praise?"\u53D6\u6D88\u70B9\u8D5E":"\u70B9\u8D5E"},D.a.createElement("span",{className:ft.user_praise?"c-orange":"c-gery-888"},D.a.createElement("i",{className:"iconfont icon-dianzan mr3 current",onClick:Object(ae.a)(V.a.mark(function Wt(){var Ut;return V.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:return Vt.next=2,Object(l.i)({id:ft.id,container_type:"Memo",type:ft.user_praise?0:1});case 2:Ut=Vt.sent,(Ut==null?void 0:Ut.praise_count)>=0&&(he.find(function(Ti){return Ti.id===ft.id}).user_praise=!ft.user_praise,he.find(function(Ti){return Ti.id===ft.id}).praise_count=Ut==null?void 0:Ut.praise_count,nt({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Ke.forumsDetailData),{},{memo_replies:Object(te.a)(he)})}));case 4:case"end":return Vt.stop()}},Wt)}))}),ft.praise_count>0?ft.praise_count:"")))))))}))),vt&&D.a.createElement("aside",{className:"bg-white pb20",style:{display:"flex",justifyContent:"center"}},D.a.createElement(I.a,{justify:"space-between"},D.a.createElement(p.a,null),D.a.createElement(p.a,null,vt&&D.a.createElement("a",{className:"c-black",onClick:ei},"\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA")))),D.a.createElement("aside",{className:be.a.reply},D.a.createElement(ce.a,{onBlur:function(){return Mt(!1)},isFocus:kt,defaultValue:se,id:"writeForumsReviewId",onChange:function(ut){ue(ut)},placeholder:"\u6211\u8981\u56DE\u590D...",height:240}),D.a.createElement(I.a,null,D.a.createElement(p.a,{flex:"1"}),D.a.createElement(p.a,null,D.a.createElement(h.a,{type:"primary",size:"large",onClick:Object(ae.a)(V.a.mark(function ft(){var ut;return V.a.wrap(function(Wt){for(;;)switch(Wt.prev=Wt.next){case 0:if(!(se==="")){Wt.next=4;break}K.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),Wt.next=9;break;case 4:return Wt.next=6,Object(l.k)({parent_id:me.id,content:se});case 6:ut=Wt.sent,ue(null),ut&&nt({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Ke.forumsDetailData),{},{memo:Object(a.a)(Object(a.a)({},me),{},{replies_count:me.replies_count+1}),memo_replies:[Gi(ut)].concat(Object(te.a)(he))})});case 9:case"end":return Wt.stop()}},ft)}))},"\u53D1\u9001")))))},Re=Object(j.a)(function(He){var Pe=He.user,Xe=He.forumsDetail,tt=He.loading,Ke=He.globalSetting;return{user:Pe,forumsDetail:Xe,globalSetting:Ke,loading:tt.models.forumsDetail}},null,null,{forwardRef:!0})(Object(F.forwardRef)(oe)),Ye=ne("smFo"),Ue=ne.n(Ye),rt=ne("RCxd"),ot=ne("kaH+"),Oe=ne("dhSg"),Me={5:"\u6280\u672F\u5206\u4EAB",3:"\u64CD\u4F5C\u6307\u5357",16:"\u901A\u77E5\u516C\u544A"},We=function(Pe){var Xe,tt,Ke,et,Ae,nt=Pe.user,Je=Pe.forumsDetail,Se=Pe.globalSetting,ke=Pe.loading,me=Pe.dispatch,he=Object(Z.a)(Pe,["user","forumsDetail","globalSetting","loading","dispatch"]),de=Je.forumsDetailData||{},ie=de.author_info,q=de.memo,se=de.attachments_list,ue=Object(F.useRef)(),ge=Object(F.useRef)(),Ce=function(){var $e=Object(ae.a)(V.a.mark(function Rt(){var vt,Nt;return V.a.wrap(function(At){for(;;)switch(At.prev=At.next){case 0:return vt={id:q.id,sticky:q.sticky?0:1},At.next=3,Object(l.m)(vt);case 3:Nt=At.sent,(Nt==null?void 0:Nt.status)===0&&me({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Je.forumsDetailData),{},{memo:Object(a.a)(Object(a.a)({},q),{},{sticky:!(q!=null&&q.sticky)})})});case 5:case"end":return At.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),Le=function(){var $e=Object(ae.a)(V.a.mark(function Rt(){var vt;return V.a.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return It.next=2,Object(l.b)({id:q==null?void 0:q.id});case 2:vt=It.sent,(vt==null?void 0:vt.status)===0&&(K.b.success("\u5220\u9664\u6210\u529F"),j.d.push("/forums")),(vt==null?void 0:vt.status)===-1&&j.d.push("/forums");case 5:case"end":return It.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),ze=function(){var $e=Object(ae.a)(V.a.mark(function Rt(){return V.a.wrap(function(Nt){for(;;)switch(Nt.prev=Nt.next){case 0:P.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u5956\u52B1\u8BBE\u7F6E",content:D.a.createElement("div",{className:"font14 tc"},D.a.createElement(m.a,{defaultValue:ue.current,onChange:function(At){return ue.current=At.target.value}})),onOk:function(){var It=Object(ae.a)(V.a.mark(function di(){var ri;return V.a.wrap(function(bt){for(;;)switch(bt.prev=bt.next){case 0:return bt.next=2,Object(l.l)({id:q==null?void 0:q.id,container_type:"Memo",score:ue.current?Number(ue.current):0,user_id:ie==null?void 0:ie.user_id});case 2:if(ri=bt.sent,ue.current=null,!((ri==null?void 0:ri.code)>0)){bt.next=8;break}return me({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Je.forumsDetailData),{},{memo:Object(a.a)(Object(a.a)({},q),{},{reward:ri==null?void 0:ri.code})})}),K.b.success("\u5956\u52B1\u6210\u529F"),bt.abrupt("return");case 8:K.b.success("\u5956\u52B1\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01");case 9:case"end":return bt.stop()}},di)}));function At(){return It.apply(this,arguments)}return At}()});case 1:case"end":return Nt.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),pt=function(){ge.current.onMdFouch&&ge.current.onMdFouch()},ct=function(){var $e=Object(ae.a)(V.a.mark(function Rt(){var vt;return V.a.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return It.next=2,Object(l.i)({id:q.id,container_type:"Memo",type:1});case 2:vt=It.sent,(vt==null?void 0:vt.praise_count)>=0&&me({type:"forumsDetail/setForumsDetailData",payload:Object(a.a)(Object(a.a)({},Je.forumsDetailData),{},{memo:Object(a.a)(Object(a.a)({},q),{},{user_praise:!(q!=null&&q.user_praise),memo_praise_count:vt==null?void 0:vt.praise_count})})});case 4:case"end":return It.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),Ct=D.a.createElement(u.a,{className:Ue.a.menu},((Xe=nt.userInfo)===null||Xe===void 0?void 0:Xe.admin)&&(q==null?void 0:q.sticky)&&D.a.createElement(u.a.Item,null,D.a.createElement("a",{onClick:function(){return Ce()}},"\u53D6\u6D88\u7F6E\u9876")),((tt=nt.userInfo)===null||tt===void 0?void 0:tt.admin)&&!(q!=null&&q.sticky)&&D.a.createElement(u.a.Item,null,D.a.createElement("a",{onClick:function(){return Ce()}},"\u7F6E\xA0\xA0\u9876")),D.a.createElement(u.a.Item,null,D.a.createElement(X.a,{to:"/forums/".concat(q==null?void 0:q.id,"/edit")},"\u7F16\xA0\xA0\u8F91")),D.a.createElement(u.a.Item,null,D.a.createElement("a",{onClick:function(){P.a.confirm({title:"\u63D0\u793A",icon:D.a.createElement(rt.a,null),content:"\u5E16\u5B50\u5C06\u88AB\u5220\u9664\uFF0C\u65E0\u6CD5\u6062\u590D\u3002\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",okText:"\u786E\u8BA4",onOk:function(){Le()},cancelText:"\u53D6\u6D88"})}},"\u5220\xA0\xA0\u9664"))),xt=function(Rt){var vt=Rt.target,Nt=vt.nodeName,It=vt.src;Nt==="IMG"&&(Oe.a.publish("preview-image",It),console.log("src:",It))};return Object(F.useEffect)(function(){},[]),D.a.createElement("section",{className:Ue.a.wrap},D.a.createElement(E.a,{separator:"/",className:"mb5"},D.a.createElement(E.a.Item,null,D.a.createElement(X.a,{to:"/forums/categories/".concat(q==null?void 0:q.forum_id)},Me[q==null?void 0:q.forum_id])),D.a.createElement(E.a.Item,null,"\u8BE6\u60C5")),D.a.createElement("header",{className:"bg-white pt40 pb40 pl30 pr30 ".concat(Ue.a.header)},D.a.createElement(I.a,{align:"middle"},D.a.createElement(p.a,{flex:1,className:"font24 mb5"},D.a.createElement("span",{className:Ue.a.title},q==null?void 0:q.subject),(q==null?void 0:q.sticky)&&D.a.createElement("span",{className:Ue.a.top},"\u7F6E\u9876"),!!(q!=null&&q.reward)&&D.a.createElement(A.a,{placement:"bottom",title:"\u83B7\u5F97\u5E73\u53F0\u5956\u52B1\u91D1\u5E01\uFF1A".concat(q==null?void 0:q.reward)},D.a.createElement("span",{className:"ml10 c-orange-ff7"},D.a.createElement("i",{className:"iconfont icon-gift font16 mr5"}),D.a.createElement("span",{className:"font14"},q==null?void 0:q.reward)))),D.a.createElement(p.a,null,(((Ke=nt.userInfo)===null||Ke===void 0?void 0:Ke.admin)||((et=nt.userInfo)===null||et===void 0?void 0:et.user_id)===(ie==null?void 0:ie.user_id))&&D.a.createElement(x.a,{overlay:Ct},D.a.createElement("i",{className:"fa fa-bars font-16 current c-grey-bcb"})))),D.a.createElement(I.a,{align:"middle",className:"font14"},D.a.createElement(p.a,{flex:1,className:"c-grey-999"},D.a.createElement("span",null,S()(q==null?void 0:q.time).fromNow()," \u53D1\u5E03")),D.a.createElement(p.a,{className:"c-grey-999"},((Ae=nt.userInfo)===null||Ae===void 0?void 0:Ae.admin)&&D.a.createElement(A.a,{placement:"bottom",title:"\u5E16\u5B50\u5956\u52B1"},D.a.createElement("span",{className:"current pr10 ".concat(Ue.a.line),onClick:ze},D.a.createElement("i",{className:"iconfont icon-jiangli font18 mr5"}))),D.a.createElement("span",{className:"pr10 pl10 ".concat(q!=null&&q.replies_count?Ue.a.line:"")},D.a.createElement("i",{className:"iconfont icon-liulanyan font18 mr5"}),q==null?void 0:q.viewed_count),!!(q!=null&&q.replies_count)&&D.a.createElement(A.a,{placement:"bottom",title:"\u5199\u8BC4\u8BBA"},D.a.createElement("span",{className:"current pl10",onClick:pt},D.a.createElement("i",{className:"iconfont icon-huifu1 font18 mr5"}),q==null?void 0:q.replies_count))))),D.a.createElement("main",{className:"bg-white pt40 pb40 pl40 pr40"},D.a.createElement("div",{onClick:xt},D.a.createElement(Y.a,{value:q==null?void 0:q.content})),D.a.createElement("div",{className:"bg-white pl40 pr40 mt40"},D.a.createElement("div",{className:"mt10 mb20 ".concat(Ue.a.flexCenter)},D.a.createElement("div",{className:"".concat(Ue.a.like," ").concat(q!=null&&q.user_praise?"":Ue.a.canLike),onClick:ct},D.a.createElement("i",{className:"iconfont icon-dianzan font18"}),D.a.createElement("br",null),D.a.createElement("span",null,q==null?void 0:q.memo_praise_count)))),!!(se!=null&&se.length)&&D.a.createElement("div",{className:"mt40"},se==null?void 0:se.map(function($e){return D.a.createElement("div",{className:"c-grey-888 ".concat(Ue.a.flexCenter)},D.a.createElement("i",{className:"iconfont icon-fujian mr10 font14 c-green-29b"}),D.a.createElement("a",{href:$e==null?void 0:$e.url,title:$e==null?void 0:$e.title,className:"".concat(Ue.a.attachmentName," mr10")},$e==null?void 0:$e.title),D.a.createElement("span",{className:"font12 c-grey-666 mt3"},$e==null?void 0:$e.filesize))}))),D.a.createElement(Re,{ref:ge,handleClick:xt}),D.a.createElement(ot.a,null))},qe=Object(j.a)(function(He){var Pe=He.user,Xe=He.forumsDetail,tt=He.loading,Ke=He.globalSetting;return{user:Pe,forumsDetail:Xe,globalSetting:Ke,loading:tt.effects}})(We),Ve=ne("G8my"),je=ne.n(Ve),Fe=function(Pe){var Xe=Pe.forumsDetail,tt=Pe.globalSetting,Ke=Pe.loading,et=Pe.dispatch,Ae=Object(Z.a)(Pe,["forumsDetail","globalSetting","loading","dispatch"]),nt=Object(G.i)();Object(F.useEffect)(function(){Je()},[nt.memoId]);var Je=function(){var Se=Object(ae.a)(V.a.mark(function ke(){return V.a.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:et({type:"forumsDetail/getForumsDetailData",payload:{id:nt.memoId}});case 1:case"end":return he.stop()}},ke)}));return function(){return Se.apply(this,arguments)}}();return D.a.createElement("section",{className:"edu-container mb20 mt30 ".concat(je.a.flex)},D.a.createElement(qe,null),D.a.createElement(O,null))},ht=lt.default=Object(j.a)(function(He){var Pe=He.forumsDetail,Xe=He.loading,tt=He.globalSetting;return{forumsDetail:Pe,globalSetting:tt,loading:Xe.models.forumsDetail}})(Fe)},LO5M:function(_t,lt,ne){_t.exports={wrap:"wrap___1d4rP",head:"head___1_Uzf",recommendItem:"recommendItem___IStR9",buttonWrap:"buttonWrap___3dpFm",privateMessage:"privateMessage___24GfS",flex1:"flex1___3wIqQ",mWidth147:"mWidth147___3ODny"}},LdHM:function(_t,lt,ne){"use strict";ne.d(lt,"b",function(){return d}),ne.d(lt,"a",function(){return w});var ae=ne("1OyB"),Z=ne("vuIU"),k=ne("Ji7U"),V=ne("LK+K"),F=ne("q1tI"),D=ne("rePB"),G=ne("Ff2n"),j=ne("ODXe"),M=ne("4IlW"),I=ne("bX4T"),g=ne("YrtM"),p=ne("TSYQ"),f=ne.n(p),h=ne("+nKL"),a=ne("8OUc"),c=function(Y,te){var re=Y.prefixCls,ce=Y.id,Te=Y.flattenOptions,ye=Y.childrenAsData,be=Y.values,we=Y.searchValue,xe=Y.multiple,ve=Y.defaultActiveFirstOption,oe=Y.height,Re=Y.itemHeight,Ye=Y.notFoundContent,Ue=Y.open,rt=Y.menuItemSelectedIcon,ot=Y.virtual,Oe=Y.onSelect,Me=Y.onToggleOpen,We=Y.onActiveValue,qe=Y.onScroll,Ve=Y.onMouseEnter,je="".concat(re,"-item"),Fe=Object(g.a)(function(){return Te},[Ue,Te],function(ke,me){return me[0]&&ke[1]!==me[1]}),ht=F.useRef(null),He=function(me){me.preventDefault()},Pe=function(me){ht.current&&ht.current.scrollTo({index:me})},Xe=function(me){for(var he=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,de=Fe.length,ie=0;ie<de;ie+=1){var q=(me+ie*he+de)%de,se=Fe[q],ue=se.group,ge=se.data;if(!ue&&!ge.disabled)return q}return-1},tt=F.useState(function(){return Xe(0)}),Ke=Object(j.a)(tt,2),et=Ke[0],Ae=Ke[1],nt=function(me){Ae(me);var he=Fe[me];if(!he){We(null,-1);return}We(he.data.value,me)};F.useEffect(function(){nt(ve!==!1?Xe(0):-1)},[Fe.length,we]),F.useEffect(function(){var ke=setTimeout(function(){if(!xe&&Ue&&be.size===1){var me=Array.from(be)[0],he=Fe.findIndex(function(de){var ie=de.data;return ie.value===me});nt(he),Pe(he)}});return function(){return clearTimeout(ke)}},[Ue]);var Je=function(me){me!==void 0&&Oe(me,{selected:!be.has(me)}),xe||Me(!1)};if(F.useImperativeHandle(te,function(){return{onKeyDown:function(me){var he=me.which;switch(he){case M.a.UP:case M.a.DOWN:{var de=0;if(he===M.a.UP?de=-1:he===M.a.DOWN&&(de=1),de!==0){var ie=Xe(et+de,de);Pe(ie),nt(ie)}break}case M.a.ENTER:{var q=Fe[et];q&&!q.data.disabled?Je(q.data.value):Je(void 0),Ue&&me.preventDefault();break}case M.a.ESC:Me(!1)}},onKeyUp:function(){},scrollTo:function(me){Pe(me)}}}),Fe.length===0)return F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),className:"".concat(je,"-empty"),onMouseDown:He},Ye);function Se(ke){var me=Fe[ke];if(!me)return null;var he=me.data||{},de=he.value,ie=he.label,q=he.children,se=Object(I.a)(he,!0),ue=ye?q:ie;return me?F.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},se,{key:ke,role:"option",id:"".concat(ce,"_list_").concat(ke),"aria-selected":be.has(de)}),de):null}return F.createElement(F.Fragment,null,F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),style:{height:0,width:0,overflow:"hidden"}},Se(et-1),Se(et),Se(et+1)),F.createElement(h.a,{itemKey:"key",ref:ht,data:Fe,height:oe,itemHeight:Re,fullHeight:!1,onMouseDown:He,onScroll:qe,virtual:ot,onMouseEnter:Ve},function(ke,me){var he,de=ke.group,ie=ke.groupOption,q=ke.data,se=q.label,ue=q.key;if(de)return F.createElement("div",{className:f()(je,"".concat(je,"-group"))},se!==void 0?se:ue);var ge=q.disabled,Ce=q.value,Le=q.title,ze=q.children,pt=q.style,ct=q.className,Ct=Object(G.a)(q,["disabled","value","title","children","style","className"]),xt=be.has(Ce),$e="".concat(je,"-option"),Rt=f()(je,$e,ct,(he={},Object(D.a)(he,"".concat($e,"-grouped"),ie),Object(D.a)(he,"".concat($e,"-active"),et===me&&!ge),Object(D.a)(he,"".concat($e,"-disabled"),ge),Object(D.a)(he,"".concat($e,"-selected"),xt),he)),vt=ye?ze:se,Nt=!rt||typeof rt=="function"||xt;return F.createElement("div",Object.assign({},Ct,{"aria-selected":xt,className:Rt,title:Le,onMouseMove:function(){if(et===me||ge)return;nt(me)},onClick:function(){ge||Je(Ce)},style:pt}),F.createElement("div",{className:"".concat($e,"-content")},vt||Ce),F.isValidElement(rt)||xt,Nt&&F.createElement(a.a,{className:"".concat(je,"-option-state"),customizeIcon:rt,customizeIconProps:{isSelected:xt}},xt?"\u2713":null))}))},o=F.forwardRef(c);o.displayName="OptionList";var s=o,l=function(){return null};l.isSelectOption=!0;var d=l,O=function(){return null};O.isSelectOptGroup=!0;var w=O,x=ne("VTBJ"),R=ne("Zm9Q");function A(S){var Y=S.key,te=S.props,re=te.children,ce=te.value,Te=Object(G.a)(te,["children","value"]);return Object(x.a)({key:Y,value:ce!==void 0?ce:Y,children:re},Te)}function T(S){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(R.a)(S).map(function(te,re){if(!F.isValidElement(te)||!te.type)return null;var ce=te.type.isSelectOptGroup,Te=te.key,ye=te.props,be=ye.children,we=Object(G.a)(ye,["children"]);return Y||!ce?A(te):Object(x.a)(Object(x.a)({key:"__RC_SELECT_GRP__".concat(Te===null?re:Te,"__"),label:Te},we),{},{options:T(be)})}).filter(function(te){return te})}var E=ne("2Qr1"),y=ne("qNPg"),u=ne("U8pU"),_=ne("Kwbf"),m=ne("WKfj");function b(S){var Y=S.mode,te=S.options,re=S.children,ce=S.backfill,Te=S.allowClear,ye=S.placeholder,be=S.getInputElement,we=S.showSearch,xe=S.onSearch,ve=S.defaultOpen,oe=S.autoFocus,Re=S.labelInValue,Ye=S.value,Ue=S.inputValue,rt=S.optionLabelProp,ot=Y==="multiple"||Y==="tags",Oe=we!==void 0?we:ot||Y==="combobox",Me=te||T(re);if(Object(_.a)(Y!=="tags"||Me.every(function(je){return!je.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),Y==="tags"||Y==="combobox"){var We=Me.some(function(je){return je.options?je.options.some(function(Fe){return typeof("value"in Fe?Fe.value:Fe.key)=="number"}):typeof("value"in je?je.value:je.key)=="number"});Object(_.a)(!We,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(_.a)(Y!=="combobox"||!rt,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(_.a)(Y==="combobox"||!ce,"`backfill` only works with `combobox` mode."),Object(_.a)(Y==="combobox"||!be,"`getInputElement` only work with `combobox` mode."),Object(_.b)(Y!=="combobox"||!be||!Te||!ye,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),xe&&!Oe&&Y!=="combobox"&&Y!=="tags"&&Object(_.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(_.b)(!ve||oe,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Ye!=null){var qe=Object(m.d)(Ye);Object(_.a)(!Re||qe.every(function(je){return Object(u.a)(je)==="object"&&("key"in je||"value"in je)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(_.a)(!ot||Array.isArray(Ye),"`value` should be array when `mode` is `multiple` or `tags`")}if(re){var Ve=null;Object(R.a)(re).some(function(je){if(!F.isValidElement(je)||!je.type)return!1;var Fe=je.type;if(Fe.isSelectOption)return!1;if(Fe.isSelectOptGroup){var ht=Object(R.a)(je.props.children).every(function(He){return!F.isValidElement(He)||!je.type||He.type.isSelectOption?!0:(Ve=He.type,!1)});return!ht}return Ve=Fe,!0}),Ve&&Object(_.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Ve.displayName||Ve.name||Ve,"`.")),Object(_.a)(Ue===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=b,N=Object(y.a)({prefixCls:"rc-select",components:{optionList:s},convertChildrenToData:T,flattenOptions:E.d,getLabeledValue:E.e,filterOptions:E.b,isValueDisabled:E.g,findValueOption:E.c,warningProps:P,fillOptionsWithMissingValue:E.a}),K=function(S){Object(k.a)(te,S);var Y=Object(V.a)(te);function te(){var re;return Object(ae.a)(this,te),re=Y.apply(this,arguments),re.selectRef=F.createRef(),re.focus=function(){re.selectRef.current.focus()},re.blur=function(){re.selectRef.current.blur()},re}return Object(Z.a)(te,[{key:"render",value:function(){return F.createElement(N,Object.assign({ref:this.selectRef},this.props))}}]),te}(F.Component);K.Option=d,K.OptGroup=w;var X=K,B=lt.c=X},M8RZ:function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return M});var ae=ne("fWQN"),Z=ne("mtLc"),k=ne("yKVA"),V=ne("879j"),F=ne("q1tI"),D=ne.n(F),G=ne("i8i4"),j=ne.n(G),M=function(I){Object(k.a)(p,I);var g=Object(V.a)(p);function p(f){var h;Object(ae.a)(this,p),h=g.call(this,f);var a=window.document;return h.node=a.createElement("div"),a.body.appendChild(h.node),h}return Object(Z.a)(p,[{key:"render",value:function(){var h=this.props.children;return Object(G.createPortal)(h,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),p}(D.a.Component)},Ot1p:function(_t,lt,ne){"use strict";var ae=ne("2qtc"),Z=ne("kLXV"),k=ne("rAM+"),V=ne("miYZ"),F=ne("tsqr"),D=ne("9og8"),G=ne("tJVT"),j=ne("jrin"),M=ne("WmNS"),I=ne.n(M),g=ne("q1tI"),p=ne.n(g),f=ne("VrN/"),h=ne.n(f),a=ne("bdgK"),c=ne("p77/"),o=ne("Bd2K"),s=ne("ELLl"),l=ne("19Vz"),d=ne("lZu9"),O=ne("+NIl"),w=ne("kSUc"),x=ne("9Bee"),R=function(ge){var Ce=ge.value,Le=Ce===void 0?"":Ce,ze=ge.className,pt=ge.showTextOnly,ct=ge.showLines,Ct=ge.style,xt=Ct===void 0?{}:Ct,$e=Object(g.useMemo)(function(){return""},[Le]);return p.a.createElement(p.a.Fragment,null,p.a.createElement("div",{dangerouslySetInnerHTML:{__html:$e}}))},A=ne("0Owb"),T=ne("dejd"),E=ne("C+DQ"),y=ne("1vsH"),u=ne("m3rI"),_=[{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(ge){var Ce=ge.onActionCallback,Le=ge.title,ze=ge.icon,pt=ge.actionName,ct=ge.className,Ct=ct===void 0?"":ct,xt=ge.children;function $e(){Ce(pt)}return p.a.createElement("a",{title:Le,className:Ct,onClick:$e},p.a.createElement("i",{className:"md-iconfont ".concat(ze)}),xt)}var b=function(ge){var Ce=ge.watch,Le=ge.showNullButton,ze=ge.onActionCallback,pt=ge.fullScreen,ct=ge.insertTemp,Ct=ge.hidetoolBar,xt=ge.uuid,$e=ge.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(y.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(y.F)("_educoder_session"),"&key=").concat(xt,"&api=").concat(encodeURIComponent(u.a.PROXY_SERVER)));var Rt=[].concat(_,[{title:"".concat(Ce?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Ce?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return p.a.createElement("ul",{className:"markdown-toolbar-container"},!Ct&&Rt.map(function(vt,Nt){return p.a.createElement("li",{key:Nt},vt.actionName?p.a.createElement(m,Object(A.a)({},vt,{onActionCallback:ze})):p.a.createElement("span",{className:"v-line"}))}),Le?p.a.createElement("li",null,p.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:ze},p.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,ct&&p.a.createElement("li",null,p.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(ct),onActionCallback:ze},p.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),p.a.createElement("li",{className:"btn-full-screen"},p.a.createElement(m,{icon:"".concat(pt?"icon-shrink":"icon-enlarge"),title:pt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:ze})))},P=ne("M8RZ"),N=ne("+L6B"),K=ne("2/Rp"),X=ne("y8nQ"),B=ne("Vl3Y"),S=ne("5NDa"),Y=ne("5rEg"),te={labelCol:{span:4},wrapperCol:{span:20}},re=function(ge){var Ce=ge.callback,Le=ge.onCancel;function ze(pt){Ce(pt)}return p.a.createElement(B.a,Object(A.a)({},te,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:ze}),p.a.createElement(B.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},p.a.createElement(Y.a,null)),p.a.createElement(B.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},p.a.createElement(Y.a,null)),p.a.createElement("div",{className:"flex-container flex-end"},p.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),p.a.createElement(K.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))},ce=ne("7ahc"),Te=ne("HmJG"),ye=ne("BjJ7"),be=B.a.useForm,we={width:280,marginRight:10},xe={labelCol:{span:5},wrapperCol:{span:19}},ve=function(ge){var Ce=ge.callback,Le=ge.onCancel,ze=be(),pt=Object(G.a)(ze,1),ct=pt[0];function Ct(Rt){Ce(Rt)}function xt(Rt,vt){if(Rt.status===-1){F.b.error(Rt.message);return}ct.setFieldsValue({src:"/api/attachments/".concat(Rt.id),type:vt.type})}function $e(Rt){var vt=Rt.target.files[0];Re(vt,xt)}return p.a.createElement(B.a,Object(A.a)({form:ct},xe,{className:"upload-image-panel",onFinish:Ct}),p.a.createElement(B.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},p.a.createElement("div",{className:"flex-container"},p.a.createElement(B.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},p.a.createElement(Y.a,{style:we})),p.a.createElement(oe,{onFileChange:$e}))),p.a.createElement(B.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},p.a.createElement(Y.a,{style:{width:264}})),p.a.createElement(B.a.Item,{style:{textAlign:"right"}},p.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),p.a.createElement(K.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))};function oe(ge){var Ce=ge.onFileChange;return p.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",p.a.createElement("input",{type:"file",onChange:Ce}))}function Re(ge,Ce){if(!ge)throw new String("\u6CA1\u6709\u6587\u4EF6");var Le=new FormData;Le.append("editormd-image-file",ge),Le.append("file_param_name","editormd-image-file"),Le.append("byxhr","true");var ze=new window.XMLHttpRequest;ze.withCredentials=!0,ze.addEventListener("load",function(pt){Ce(JSON.parse(pt.target.responseText),ge)},!1),ze.addEventListener("error",function(pt){console.error(pt)},!1),ze.open("POST","".concat(ye.a,"/api/attachments.json")),ze.send(Le)}var Ye=ne("giR+"),Ue=ne("fyUT"),rt=ne("7Kak"),ot=ne("9yH6"),Oe=ot.a.Group,Me={margin:"0 8px"},We=function(ge){var Ce=ge.callback,Le=ge.onCancel;function ze(pt){Ce(pt)}return p.a.createElement(B.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:ze},p.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},p.a.createElement("span",{style:Me},"\u5355\u5143\u683C\u6570\uFF1A"),p.a.createElement("span",{style:Me},"\u884C\u6570"),p.a.createElement(B.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},p.a.createElement(Ue.a,null)),p.a.createElement("span",{style:Me},"\u5217\u6570"),p.a.createElement(B.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},p.a.createElement(Ue.a,null))),p.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},p.a.createElement("span",{style:Me},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),p.a.createElement(B.a.Item,{name:"align"},p.a.createElement(Oe,null,p.a.createElement(ot.a,{value:"default"},p.a.createElement("i",{className:"fa fa-align-justify"})),p.a.createElement(ot.a,{value:"left"},p.a.createElement("i",{className:"fa fa-align-left"})),p.a.createElement(ot.a,{value:"center"},p.a.createElement("i",{className:"fa fa-align-center"})),p.a.createElement(ot.a,{value:"right"},p.a.createElement("i",{className:"fa fa-align-right"}))))),p.a.createElement("div",{className:"flex-container flex-end"},p.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),p.a.createElement(K.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))},qe=ne("ErOA"),Ve=ne("7Cbv"),je="link",Fe="upload-image",ht="code-block",He="add-table",Pe="------------",Xe={default:Pe,left:":".concat(Pe),center:":".concat(Pe,":"),right:"".concat(Pe,":")},tt=ne("9VGf"),Ke,et;function Ae(){}var nt=0,Je=1e4,Se="\u2581",ke=`
**\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 me(ge){return/^\d+$/.test(ge)?"".concat(ge,"px"):ge}var he=navigator.platform.toUpperCase().indexOf("MAC")>=0,de=he?"Cmd":"Ctrl",ie=["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"],q=(Ke={},Object(j.a)(Ke,de+"-B","bold"),Object(j.a)(Ke,de+"-I","italic"),Ke),se=(et={},Object(j.a)(et,je,"\u6DFB\u52A0\u94FE\u63A5"),Object(j.a)(et,ht,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(j.a)(et,Fe,"\u6DFB\u52A0\u6587\u4EF6"),Object(j.a)(et,He,"\u6DFB\u52A0\u8868\u683C"),et),ue=lt.a=function(ge){var Ce=ge.defaultValue,Le=Ce===void 0?"":Ce,ze=ge.onChange,pt=ge.width,ct=pt===void 0?"100%":pt,Ct=ge.height,xt=Ct===void 0?400:Ct,$e=ge.miniToolbar,Rt=$e===void 0?!1:$e,vt=ge.isFocus,Nt=vt===void 0?!1:vt,It=ge.watch,At=ge.insertTemp,di=ge.mode,ri=di===void 0?"markdown":di,Qe=ge.id,bt=Qe===void 0?"markdown-editor-id":Qe,kt=ge.showResizeBar,Mt=kt===void 0?!1:kt,ei=ge.noStorage,Gi=ei===void 0?!1:ei,Xi=ge.showNullButton,ft=Xi===void 0?!1:Xi,ut=ge.hidetoolBar,ti=ut===void 0?!1:ut,Wt=ge.fullScreen,Ut=Wt===void 0?!1:Wt,Dt=ge.onBlur,Vt=ge.onCMBeforeChange,Ti=ge.onFullScreen,pn=ge.className,Ge=pn===void 0?"":pn,Ot=ge.disablePaste,mn=Ot===void 0?!1:Ot,gn=ge.placeholder,vn=gn===void 0?"":gn,yn=ge.values,z=yn===void 0?"":yn,v=Object(g.useState)(null),C=Object(G.a)(v,2),U=C[0],J=C[1],W=Object(g.useState)(Le),pe=Object(G.a)(W,2),De=pe[0],it=pe[1],gt=Object(g.useState)(It),Ne=Object(G.a)(gt,2),Tt=Ne[0],zt=Ne[1],qt=Object(g.useState)(Ut),Bi=Object(G.a)(qt,2),wi=Bi[0],Si=Bi[1],Qi=Object(g.useState)(""),Dn=Object(G.a)(Qi,2),pi=Dn[0],zi=Dn[1],ln=Object(g.useState)(0),un=Object(G.a)(ln,2),ji=un[0],kn=un[1],_n=Object(g.useState)(xt),Kn=Object(G.a)(_n,2),Vn=Kn[0],Zi=Kn[1],Yi=Object(g.useState)(!1),bn=Object(G.a)(Yi,2),dr=bn[0],En=bn[1],si=Object(g.useRef)(Object(Ve.a)()),Kt=Object(g.useRef)(!1),bi=Object(g.useRef)(),Bt=Object(g.useRef)(),li=Object(g.useRef)(),$t=Object(g.useRef)(),nn=Object(g.useRef)(),mi=function(){var yt=Object(D.a)(I.a.mark(function Lt(){var wt,Ft;return I.a.wrap(function(Zt){for(;;)switch(Zt.prev=Zt.next){case 0:return Zt.next=2,Object(qe.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:si.current}});case 2:Ft=Zt.sent,Ft!=null&&(wt=Ft.attachments)!==null&&wt!==void 0&&wt.length&&(console.log("cm:",U,Bt),Ft.attachments.map(function(Ht){Ht.content_type.indexOf("image")>-1?U.replaceSelection("![,](/api/attachments/".concat(Ht.id,"?type=").concat(Ht.content_type,")")):Ht.content_type.indexOf("video")>-1?U.replaceSelection('<video width="100%" controls src="'.concat(u.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Ht.content_type.indexOf("pdf")>-1?U.replaceSelection('<a href="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Ht.id,"?type=").concat(Ht.content_type,'&disposition=inline" target="_blank">').concat(Ht.name,"</a>")):U.replaceSelection("[".concat(Ht.name,"](").concat(u.a.API_SERVER,"/api/attachments/").concat(Ht.id,"?type=").concat(Ht.content_type,")"))}));case 4:case"end":return Zt.stop()}},Lt)}));return function(){return yt.apply(this,arguments)}}();Object(g.useEffect)(function(){it(z),U==null||U.setValue(z)},[z]),Object(g.useEffect)(function(){Ti==null||Ti(wi)},[wi]),Object(g.useEffect)(function(){if(Bt.current){var yt=h.a.fromTextArea(Bt.current,{mode:ri,lineNumbers:!Rt,lineWrapping:!0,value:Le,autoCloseTags:!0,autoCloseBrackets:!0});Nt&&yt.focus();function Lt(wt,Ft){if(mn){Ft.preventDefault();return}var Gt=Ft.clipboardData;if(Gt){var Zt=Gt.types.toString(),Ht=Gt.items;if(Zt==="Files"||Gt.types.indexOf("Files")>-1){if(Ft.preventDefault(),ri=="stex")return;try{var ci,Di=Ht[1];((ci=Ht[0])===null||ci===void 0?void 0:ci.kind)==="file"&&(Di=Ht[0]);var jt=Di.getAsFile(),hn=jt.name.split(".").pop();Re(jt,function(Xt){if(Xt.id){var ki,Ci,$i;(jt==null||((ki=jt.type)===null||ki===void 0)?void 0:ki.indexOf("image"))>-1?yt.replaceSelection("![,](/api/attachments/".concat(Xt.id,"?type=").concat(Xt.content_type,")")):(jt==null||((Ci=jt.type)===null||Ci===void 0)?void 0:Ci.indexOf("video"))>-1?yt.replaceSelection('<video width="100%" controls src="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,'"></video>')):(jt==null||(($i=jt.type)===null||$i===void 0)?void 0:$i.indexOf("pdf"))>-1?yt.replaceSelection('<a href="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,"?type=").concat(jt.type,'&disposition=inline" target="_blank">').concat(jt.name,"</a>")):ie.includes(hn)?yt.replaceSelection('<a href="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,'?type=office&disposition=inline" target="_blank">').concat(jt.name,"</a>")):yt.replaceSelection("[".concat(jt.name,"](").concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,"?type=").concat(Xt.content_type,")"))}else(Xt==null?void 0:Xt.status)===401&&(document.location.href="/user/login")})}catch(Xt){F.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return yt.on("paste",Lt),yt.on("dragleave",function(wt,Ft){li.current.classList.remove("mouse-hover-md")}),yt.on("dragover",function(wt,Ft){li.current.classList.add("mouse-hover-md")}),yt.on("drop",function(wt,Ft){li.current.classList.add("mouse-hover-md");var Gt;if(Gt=Ft.dataTransfer.files,Gt.length>0){Ft.preventDefault(),Ft.stopPropagation();for(var Zt=function(Di){var jt=Gt[Di],hn=jt.name.split(".").pop();Re(jt,function(Xt){if(Xt.id){var ki,Ci,$i;(jt==null||((ki=jt.type)===null||ki===void 0)?void 0:ki.indexOf("image"))>-1?yt.replaceSelection("![,](/api/attachments/".concat(Xt.id,"?type=").concat(Xt.content_type,")")):(jt==null||((Ci=jt.type)===null||Ci===void 0)?void 0:Ci.indexOf("video"))>-1?yt.replaceSelection('<video width="100%" controls src="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,'"></video>')):(jt==null||(($i=jt.type)===null||$i===void 0)?void 0:$i.indexOf("pdf"))>-1?yt.replaceSelection('<a href="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,"?type=").concat(jt.type,'&disposition=inline" target="_blank">').concat(jt.name,"</a>")):ie.includes(hn)?yt.replaceSelection('<a href="'.concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,'?type=office&disposition=inline" target="_blank">').concat(jt.name,"</a>")):yt.replaceSelection("[".concat(jt.name,"](").concat(u.a.API_SERVER,"/api/attachments/").concat(Xt.id,"?type=").concat(Xt.content_type,")"))}else(Xt==null?void 0:Xt.status)===401&&(document.location.href="/user/login")})},Ht=0;Ht<Gt.length;Ht++)Zt(Ht)}}),J(yt),function(){yt.off("paste",Lt)}}},[]);var Oi=Object(g.useCallback)(function(){if(li.current)try{}catch(yt){console.log(yt,"---- to set md editor body height")}},[Vn,li,wi]);Object(g.useEffect)(function(){function yt(){var wt=new a.default(function(Ft){var Gt=Object(k.a)(Ft),Zt;try{for(Gt.s();!(Zt=Gt.n()).done;){var Ht=Zt.value;(Ht.target.offsetHeight>0||Ht.target.offsetWidth>0)&&(Oi(),U.setSize("100%","100%"),U.refresh())}}catch(ci){Gt.e(ci)}finally{Gt.f()}});return wt.observe(Bt.current.parentElement),wt}if(U){var Lt=yt();return function(){Lt.unobserve(Bt.current.parentElement)}}},[U,Oi]),Object(g.useEffect)(function(){if(U){for(var yt=[],Lt=function(){var Ht=Ft[wt];Gt=Object(G.a)(Ht,2);var ci=Gt[0],Di=Gt[1],jt=Object(j.a)({},ci,function(){Xn(Di)});yt.push(jt),U.addKeyMap(jt)},wt=0,Ft=Object.entries(q);wt<Ft.length;wt++){var Gt;Lt()}return bi.current=setInterval(function(){Kt.current&&mi()},4e3),function(){clearInterval(bi.current);var Zt=Object(k.a)(yt),Ht;try{for(Zt.s();!(Ht=Zt.n()).done;){var ci=Ht.value;U.removeKeyMap(ci)}}catch(Di){Zt.e(Di)}finally{Zt.f()}}}},[U]),Object(g.useEffect)(function(){Ut!==wi&&Si(Ut)},[Ut]),Object(tt.a)(function(){if(!Gi&&ji>0){var yt=new Date().getTime(),Lt=window.sessionStorage.getItem(bt);yt>=ji+Je&&(!Lt||Lt!==De)&&(window.sessionStorage.setItem(bt,De),En(!0))}},Je),Object(g.useEffect)(function(){zt(It)},[U,It]),Object(g.useEffect)(function(){U&&(Nt&&U.focus())},[U,Nt]),Object(g.useEffect)(function(){if(Tt&&U){var yt=U.getScrollerElement();function Lt(wt){var Ft=wt.target;if(nn.current){var Gt=Ft.scrollTop/Ft.scrollHeight;nn.current.scrollTop=nn.current.scrollHeight*Gt}}return yt.addEventListener("scroll",Lt),function(){yt.removeEventListener("scroll",Lt)}}},[U,Tt]),Object(g.useEffect)(function(){if(U&&Vt){function yt(Lt,wt){Vt(Lt,wt)}return U.on("beforeChange",yt),function(){U.off("beforeChange",yt)}}},[U,Vt]),Object(g.useEffect)(function(){if(U&&Dt){function yt(){Dt(U.getValue())}return U.on("blur",yt),function(){U.off("blur",yt)}}},[U,Dt]),Object(g.useEffect)(function(){if(U){function yt(Lt){var wt=Lt.getValue();it(wt),kn(new Date().getTime()),Lt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),ze&&ze(wt)}return U.on("change",yt),function(){U.off("change",yt)}}},[U,ze]),Object(g.useEffect)(function(){U&&(Le==null?(U.setValue(""),it("")):Le!==U.getValue()&&(U.setValue(Le),it(Le),U.setCursor(U.lineCount(),0)))},[U,Le]);var Xn=Object(g.useCallback)(function(yt){var Lt=U.getCursor(),wt=U.getSelection(),Ft=wt.split(`
`);switch(yt){case"bold":return U.replaceSelection("**"+wt+"**"),wt===""&&U.setCursor(Lt.line,Lt.ch+2),U.focus();case"italic":return U.replaceSelection("*"+wt+"*"),wt===""&&U.setCursor(Lt.line,Lt.ch+1),U.focus();case"code":return U.replaceSelection("`"+wt+"`"),wt===""&&U.setCursor(Lt.line,Lt.ch+1),U.focus();case"inline-latex":return U.replaceSelection("`$$"+wt+"$$`"),wt===""&&U.setCursor(Lt.line,Lt.ch+3),U.focus();case"latex":return U.replaceSelection("```latex\n"+wt+"\n```"),U.setCursor(Lt.line+1,wt.length+1),U.focus();case"line-break":return U.replaceSelection(`<br/>
`),U.focus();case"list-ul":return wt===""?U.replaceSelection("- "+wt):U.replaceSelection(Ft.map(function(Gt){return Gt===""?"":"- ".concat(Gt)}).join(`
`)),U.focus();case"list-ol":return wt===""?U.replaceSelection("1. "+wt):U.replaceSelection(Ft.map(function(Gt,Zt){return Gt===""?"":"".concat(Zt+1,". ").concat(Gt)}).join(`
`)),U.focus();case"add-null-ch":return wt===""&&U.setCursor(Lt.line,Lt.ch+1),U.replaceSelection(Se),U.focus();case"inster-template-1":return wt===""&&U.setCursor(Lt.line,Lt.ch),U.replaceSelection(ke),U.focus();case"eraser":return U.setValue(""),U.focus();case"trigger-watch":return zt(!Tt),U.focus();case"trigger-full-screen":return Si(!wi),U.focus();case je:zi(je);return;case ht:zi(ht);return;case Fe:zi(Fe);return;case He:zi(He);return;default:throw new Error}},[U,Tt,wi]),xn=Object(g.useCallback)(function(yt){zi("");switch(pi){case je:var Lt=yt.title,wt=yt.link;return U.replaceSelection("[".concat(Lt,"](").concat(wt,")")),U.focus();case ht:var Ft=yt.language,Gt=yt.content;return U.replaceSelection(["```"+Ft,Gt,"```"].join(`
`)),U.focus();case Fe:var Zt=yt.src,Ht=yt.alt;return Ht?U.replaceSelection("![ ".concat(Ht," ]( ").concat(Zt,' "').concat(Ht,'" )')):U.replaceSelection("![,](".concat(Zt,")")),U.focus();case He:for(var ci=yt.row,Di=yt.col,jt=yt.align,hn=`
`,Xt=0;Xt<ci;Xt++){for(var ki=[],Ci=[],$i=0;$i<Di;$i++)Xt===1&&Ci.push(Xe[jt]),ki.push(" ");Xt===1&&(hn+="| ".concat(Ci.join(" | "),` |
`)),hn+="| ".concat(ki.join(Di===1?"":" | "),` |
`)}return U.replaceSelection(hn+`
`),U.focus();default:throw new Error}},[U,pi]),cr=Object(g.useMemo)(function(){switch(pi){case je:return p.a.createElement(re,{callback:xn,onCancel:Tn});case ht:return p.a.createElement(ce.b,{callback:xn,onCancel:Tn});case Fe:return p.a.createElement(ve,{callback:xn,onCancel:Tn});case He:return p.a.createElement(We,{callback:xn,onCancel:Tn});default:return null}},[pi]);function Tn(){zi("")}Object(g.useEffect)(function(){if($t.current){var yt=$t.current,Lt=!1,wt=0;function Ft(Ht){Lt=!0,wt=Ht.pageY}function Gt(){Lt=!1}function Zt(Ht){if(Lt){var ci=Ht.pageY-wt;ci<0&&(ci=0),ci>300&&(ci=300);var Di=xt+ci+"px";Zi(Di)}}return yt.addEventListener("mousedown",Ft),document.addEventListener("mousemove",Zt),document.addEventListener("mouseup",Gt),function(){yt.removeEventListener("mousedown",Ft),document.removeEventListener("mousemove",Zt),document.removeEventListener("mouseup",Gt)}}},[U,$t]),Object(g.useEffect)(function(){Zi(xt)},[xt]);var rn=me(ct),fr=me(Vn),Ji={width:rn,height:fr},pr=Object(g.useMemo)(function(){if(ji){var yt=new Date(ji),Lt=yt.getHours(),wt=yt.getMinutes(),Ft=yt.getSeconds();return Lt=Lt<10?"0"+Lt:Lt,wt=wt<10?"0"+wt:wt,Ft=Ft<10?"0"+Ft:Ft,"".concat(Lt,":").concat(wt,":").concat(Ft)}return 0},[ji]);function jr(){window.sessionStorage.removeItem(bt),En(!1),kn(0)}function Mn(){En(!1),kn(0),U.setValue(window.sessionStorage.getItem(bt))}function ua(yt,Lt){var wt=U.getValue();wt=wt.replace(yt,Lt),it(wt),U==null||U.setValue(wt)}return p.a.createElement(g.Fragment,null,p.a.createElement("div",{className:"markdown-editor-wrapper",ref:li},p.a.createElement("div",{className:"markdown-editor-container ".concat(Ge," ").concat(Tt?"on-preview":""," ").concat(Rt?"mini":""," ").concat(wi?"full-screen":""),style:Ji},p.a.createElement(b,{insertTemp:At,watch:Tt,fullScreen:wi,showNullButton:ft,onActionCallback:Xn,hidetoolBar:ti,uuid:si.current,setOpenPhones:function(){Kt.current=!0}}),p.a.createElement("div",{className:"markdown-editor-body"},p.a.createElement("div",{className:"codemirror-container"},p.a.createElement("textarea",{ref:Bt,placeholder:vn})),Tt?p.a.createElement("div",{ref:nn,className:"preview-container"},ri==="stex"&&p.a.createElement(R,{value:De}),ri!=="stex"&&p.a.createElement(x.a,{edit:!0,value:De,replaces:ua})):null))),Mt?p.a.createElement("a",{ref:$t,className:"editor-resize"}):null,p.a.createElement(P.a,null,se[pi]?p.a.createElement(Z.a,{centered:!0,title:se[pi],visible:!0,onCancel:Tn,footer:null,className:"markdown-popup-form"},cr):null))}},SJMd:function(_t,lt){/**
* @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 ne,ae,Z,k=!1,V,F;window.PR_SHOULD_USE_CONTINUATION=!0;var D,G;(function(){var j=window,M=["break,continue,do,else,for,if,return,while"],I=[M,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],g=[I,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],p=[g,"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"],f=[g,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],h=[g,"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"],a="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",c=[g,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],o="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",s=[M,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[M,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],d=[M,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],O=[p,h,f,c,o,s,l,d],w=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,x="str",R="kwd",A="com",T="typ",E="lit",y="pun",u="pln",_="tag",m="dec",b="src",P="atn",N="atv",K="nocode",X="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function B(Oe){for(var Me=0,We=!1,qe=!1,Ve=0,je=Oe.length;Ve<je;++Ve){var Fe=Oe[Ve];if(Fe.ignoreCase)qe=!0;else if(/[a-z]/i.test(Fe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){We=!0,qe=!1;break}}var ht={b:8,t:9,n:10,v:11,f:12,r:13};function He(et){var Ae=et.charCodeAt(0);if(Ae!==92)return Ae;var nt=et.charAt(1);return Ae=ht[nt],Ae||("0"<=nt&&nt<="7"?parseInt(et.substring(1),8):nt==="u"||nt==="x"?parseInt(et.substring(2),16):et.charCodeAt(1))}function Pe(et){if(et<32)return(et<16?"\\x0":"\\x")+et.toString(16);var Ae=String.fromCharCode(et);return Ae==="\\"||Ae==="-"||Ae==="]"||Ae==="^"?"\\"+Ae:Ae}function Xe(et){var Ae=et.substring(1,et.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")),nt=[],Je=Ae[0]==="^",Se=["["];Je&&Se.push("^");for(var ke=Je?1:0,me=Ae.length;ke<me;++ke){var he=Ae[ke];if(/\\[bdsw]/i.test(he))Se.push(he);else{var de=He(he),ie;ke+2<me&&Ae[ke+1]==="-"?(ie=He(Ae[ke+2]),ke+=2):ie=de,nt.push([de,ie]),ie<65||de>122||(ie<65||de>90||nt.push([Math.max(65,de)|32,Math.min(ie,90)|32]),ie<97||de>122||nt.push([Math.max(97,de)&~32,Math.min(ie,122)&~32]))}}nt.sort(function(ge,Ce){return ge[0]-Ce[0]||Ce[1]-ge[1]});for(var q=[],se=[],ke=0;ke<nt.length;++ke){var ue=nt[ke];ue[0]<=se[1]+1?se[1]=Math.max(se[1],ue[1]):q.push(se=ue)}for(var ke=0;ke<q.length;++ke){var ue=q[ke];Se.push(Pe(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Se.push("-"),Se.push(Pe(ue[1])))}return Se.push("]"),Se.join("")}function tt(et){for(var Ae=et.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")),nt=Ae.length,Je=[],Se=0,ke=0;Se<nt;++Se){var me=Ae[Se];if(me==="(")++ke;else if(me.charAt(0)==="\\"){var he=+me.substring(1);he&&(he<=ke?Je[he]=-1:Ae[Se]=Pe(he))}}for(var Se=1;Se<Je.length;++Se)Je[Se]===-1&&(Je[Se]=++Me);for(var Se=0,ke=0;Se<nt;++Se){var me=Ae[Se];if(me==="(")++ke,Je[ke]||(Ae[Se]="(?:");else if(me.charAt(0)==="\\"){var he=+me.substring(1);he&&he<=ke&&(Ae[Se]="\\"+Je[he])}}for(var Se=0;Se<nt;++Se)Ae[Se]==="^"&&Ae[Se+1]!=="^"&&(Ae[Se]="");if(et.ignoreCase&&We)for(var Se=0;Se<nt;++Se){var me=Ae[Se],de=me.charAt(0);me.length>=2&&de==="["?Ae[Se]=Xe(me):de!=="\\"&&(Ae[Se]=me.replace(/[a-zA-Z]/g,function(se){var ue=se.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return Ae.join("")}for(var Ke=[],Ve=0,je=Oe.length;Ve<je;++Ve){var Fe=Oe[Ve];if(Fe.global||Fe.multiline)throw new Error(""+Fe);Ke.push("(?:"+tt(Fe)+")")}return new RegExp(Ke.join("|"),qe?"gi":"g")}function S(Oe,Me){var We=/(?:^|\s)nocode(?:\s|$)/,qe=[],Ve=0,je=[],Fe=0;function ht(He){var Pe=He.nodeType;if(Pe==1){if(We.test(He.className))return;for(var Xe=He.firstChild;Xe;Xe=Xe.nextSibling)ht(Xe);var tt=He.nodeName.toLowerCase();(tt==="br"||tt==="li")&&(qe[Fe]=`
`,je[Fe<<1]=Ve++,je[Fe++<<1|1]=He)}else if(Pe==3||Pe==4){var Ke=He.nodeValue;Ke.length&&(Me?Ke=Ke.replace(/\r\n?/g,`
`):Ke=Ke.replace(/[ \t\r\n]+/g," "),qe[Fe]=Ke,je[Fe<<1]=Ve,Ve+=Ke.length,je[Fe++<<1|1]=He)}}return ht(Oe),{sourceCode:qe.join("").replace(/\n$/,""),spans:je}}function Y(Oe,Me,We,qe,Ve){if(!We)return;var je={sourceNode:Oe,pre:1,langExtension:null,numberLines:null,sourceCode:We,spans:null,basePos:Me,decorations:null};qe(je),Ve.push.apply(Ve,je.decorations)}var te=/\S/;function re(Oe){for(var Me=void 0,We=Oe.firstChild;We;We=We.nextSibling){var qe=We.nodeType;Me=qe===1?Me?Oe:We:qe===3&&te.test(We.nodeValue)?Oe:Me}return Me===Oe?void 0:Me}function ce(Oe,Me){var We={},qe;(function(){for(var Fe=Oe.concat(Me),ht=[],He={},Pe=0,Xe=Fe.length;Pe<Xe;++Pe){var tt=Fe[Pe],Ke=tt[3];if(Ke)for(var et=Ke.length;--et>=0;)We[Ke.charAt(et)]=tt;var Ae=tt[1],nt=""+Ae;He.hasOwnProperty(nt)||(ht.push(Ae),He[nt]=null)}ht.push(/[\0-\uffff]/),qe=B(ht)})();var Ve=Me.length,je=function(Fe){for(var ht=Fe.sourceCode,He=Fe.basePos,Pe=Fe.sourceNode,Xe=[He,u],tt=0,Ke=ht.match(qe)||[],et={},Ae=0,nt=Ke.length;Ae<nt;++Ae){var Je=Ke[Ae],Se=et[Je],ke=void 0,me;if(typeof Se=="string")me=!1;else{var he=We[Je.charAt(0)];if(he)ke=Je.match(he[1]),Se=he[0];else{for(var de=0;de<Ve;++de)if(he=Me[de],ke=Je.match(he[1]),ke){Se=he[0];break}ke||(Se=u)}me=Se.length>=5&&Se.substring(0,5)==="lang-",me&&!(ke&&typeof ke[1]=="string")&&(me=!1,Se=b),me||(et[Je]=Se)}var ie=tt;if(tt+=Je.length,!me)Xe.push(He+ie,Se);else{var q=ke[1],se=Je.indexOf(q),ue=se+q.length;ke[2]&&(ue=Je.length-ke[2].length,se=ue-q.length);var ge=Se.substring(5);Y(Pe,He+ie,Je.substring(0,se),je,Xe),Y(Pe,He+ie+se,q,oe(ge,q),Xe),Y(Pe,He+ie+ue,Je.substring(ue),je,Xe)}}Fe.decorations=Xe};return je}function Te(Oe){var Me=[],We=[];Oe.tripleQuotedStrings?Me.push([x,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Oe.multiLineStrings?Me.push([x,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Me.push([x,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Oe.verbatimStrings&&We.push([x,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var qe=Oe.hashComments;qe&&(Oe.cStyleComments?(qe>1?Me.push([A,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([A,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),We.push([x,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([A,/^#[^\r\n]*/,null,"#"])),Oe.cStyleComments&&(We.push([A,/^\/\/[^\r\n]*/,null]),We.push([A,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ve=Oe.regexLiterals;if(Ve){var je=Ve>1?"":`
\r`,Fe=je?".":"[\\S\\s]",ht="/(?=[^/*"+je+"])(?:[^/\\x5B\\x5C"+je+"]|\\x5C"+Fe+"|\\x5B(?:[^\\x5C\\x5D"+je+"]|\\x5C"+Fe+")*(?:\\x5D|$))+/";We.push(["lang-regex",RegExp("^"+X+"("+ht+")")])}var He=Oe.types;He&&We.push([T,He]);var Pe=(""+Oe.keywords).replace(/^ | $/g,"");Pe.length&&We.push([R,new RegExp("^(?:"+Pe.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([u,/^\s+/,null,` \r
\xA0`]);var Xe="^.[^\\s\\w.$@'\"`/\\\\]*";return Oe.regexLiterals&&(Xe+="(?!s*/)"),We.push([E,/^@[a-z_$][a-z_$@0-9]*/i,null],[T,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[u,/^[a-z_$][a-z_$@0-9]*/i,null],[E,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[u,/^\\[\s\S]?/,null],[y,new RegExp(Xe),null]),ce(Me,We)}var ye=Te({keywords:O,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function be(Oe,Me,We){for(var qe=/(?:^|\s)nocode(?:\s|$)/,Ve=/\r\n?|\n/,je=Oe.ownerDocument,Fe=je.createElement("li");Oe.firstChild;)Fe.appendChild(Oe.firstChild);var ht=[Fe];function He(Ae){var nt=Ae.nodeType;if(nt==1&&!qe.test(Ae.className))if(Ae.nodeName==="br")Pe(Ae),Ae.parentNode&&Ae.parentNode.removeChild(Ae);else for(var Je=Ae.firstChild;Je;Je=Je.nextSibling)He(Je);else if((nt==3||nt==4)&&We){var Se=Ae.nodeValue,ke=Se.match(Ve);if(ke){var me=Se.substring(0,ke.index);Ae.nodeValue=me;var he=Se.substring(ke.index+ke[0].length);if(he){var de=Ae.parentNode;de.insertBefore(je.createTextNode(he),Ae.nextSibling)}Pe(Ae),me||Ae.parentNode.removeChild(Ae)}}}function Pe(Ae){for(;!Ae.nextSibling;)if(Ae=Ae.parentNode,!Ae)return;function nt(ke,me){var he=me?ke.cloneNode(!1):ke,de=ke.parentNode;if(de){var ie=nt(de,1),q=ke.nextSibling;ie.appendChild(he);for(var se=q;se;se=q)q=se.nextSibling,ie.appendChild(se)}return he}for(var Je=nt(Ae.nextSibling,0),Se;(Se=Je.parentNode)&&Se.nodeType===1;)Je=Se;ht.push(Je)}for(var Xe=0;Xe<ht.length;++Xe)He(ht[Xe]);Me===(Me|0)&&ht[0].setAttribute("value",Me);var tt=je.createElement("ol");tt.className="linenums";for(var Ke=Math.max(0,Me-1|0)||0,Xe=0,et=ht.length;Xe<et;++Xe)Fe=ht[Xe],Fe.className="L"+(Xe+Ke)%10,Fe.firstChild||Fe.appendChild(je.createTextNode("\xA0")),tt.appendChild(Fe);Oe.appendChild(tt)}function we(Oe){var Me=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Me=Me&&+Me[1]<=8;var We=/\n/g,qe=Oe.sourceCode,Ve=qe.length,je=0,Fe=Oe.spans,ht=Fe.length,He=0,Pe=Oe.decorations,Xe=Pe.length,tt=0;Pe[Xe]=Ve;var Ke,et;for(et=Ke=0;et<Xe;)Pe[et]!==Pe[et+2]?(Pe[Ke++]=Pe[et++],Pe[Ke++]=Pe[et++]):et+=2;for(Xe=Ke,et=Ke=0;et<Xe;){for(var Ae=Pe[et],nt=Pe[et+1],Je=et+2;Je+2<=Xe&&Pe[Je+1]===nt;)Je+=2;Pe[Ke++]=Ae,Pe[Ke++]=nt,et=Je}Xe=Pe.length=Ke;var Se=Oe.sourceNode,ke="";Se&&(ke=Se.style.display,Se.style.display="none");try{for(var me=null;He<ht;){var he=Fe[He],de=Fe[He+2]||Ve,ie=Pe[tt+2]||Ve,Je=Math.min(de,ie),q=Fe[He+1],se;if(q.nodeType!==1&&(se=qe.substring(je,Je))){Me&&(se=se.replace(We,"\r")),q.nodeValue=se;var ue=q.ownerDocument,ge=ue.createElement("span");ge.className=Pe[tt+1];var Ce=q.parentNode;Ce.replaceChild(ge,q),ge.appendChild(q),je<de&&(Fe[He+1]=q=ue.createTextNode(qe.substring(Je,de)),Ce.insertBefore(q,ge.nextSibling))}je=Je,je>=de&&(He+=2),je>=ie&&(tt+=2)}}finally{Se&&(Se.style.display=ke)}}var xe={};function ve(Oe,Me){for(var We=Me.length;--We>=0;){var qe=Me[We];xe.hasOwnProperty(qe)?j.console&&console.warn("cannot override language handler %s",qe):xe[qe]=Oe}}function oe(Oe,Me){return Oe&&xe.hasOwnProperty(Oe)||(Oe=/^\s*</.test(Me)?"default-markup":"default-code"),xe[Oe]}ve(ye,["default-code"]),ve(ce([],[[u,/^[^<?]+/],[m,/^<!\w[^>]*(?:>|$)/],[A,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[y,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),ve(ce([[u,/^[\s]+/,null,` \r
`],[N,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[_,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[y,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),ve(ce([],[[N,/^[\s\S]+/]]),["uq.val"]),ve(Te({keywords:p,hashComments:!0,cStyleComments:!0,types:w}),["c","cc","cpp","cxx","cyc","m"]),ve(Te({keywords:"null,true,false"}),["json"]),ve(Te({keywords:h,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:w}),["cs"]),ve(Te({keywords:f,cStyleComments:!0}),["java"]),ve(Te({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(Te({keywords:s,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(Te({keywords:o,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(Te({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(Te({keywords:c,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(Te({keywords:a,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(ce([],[[x,/^[\s\S]+/]]),["regex"]);function Re(Oe){var Me=Oe.langExtension;try{var We=S(Oe.sourceNode,Oe.pre),qe=We.sourceCode;Oe.sourceCode=qe,Oe.spans=We.spans,Oe.basePos=0,oe(Me,qe)(Oe),we(Oe)}catch(Ve){j.console&&console.log(Ve&&Ve.stack||Ve)}}function Ye(Oe,Me,We){var qe=We||!1,Ve=Me||null,je=document.createElement("div");je.innerHTML="<pre>"+Oe+"</pre>",je=je.firstChild,qe&&be(je,qe,!0);var Fe={langExtension:Ve,numberLines:qe,sourceNode:je,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Re(Fe),je.innerHTML}function Ue(Oe,Me){var We=Me||document.body,qe=We.ownerDocument||document;function Ve(he){return We.getElementsByTagName(he)}for(var je=[Ve("pre"),Ve("code"),Ve("xmp")],Fe=[],ht=0;ht<je.length;++ht)for(var He=0,Pe=je[ht].length;He<Pe;++He)Fe.push(je[ht][He]);je=null;var Xe=Date;Xe.now||(Xe={now:function(){return+new Date}});var tt=0,Ke=/\blang(?:uage)?-([\w.]+)(?!\S)/,et=/\bprettyprint\b/,Ae=/\bprettyprinted\b/,nt=/pre|xmp/i,Je=/^code$/i,Se=/^(?:pre|code|xmp)$/i,ke={};function me(){for(var he=j.PR_SHOULD_USE_CONTINUATION?Xe.now()+250:Infinity;tt<Fe.length&&Xe.now()<he;tt++){for(var de=Fe[tt],ie=ke,q=de;q=q.previousSibling;){var se=q.nodeType,ue=(se===7||se===8)&&q.nodeValue;if(ue?!/^\??prettify\b/.test(ue):se!==3||/\S/.test(q.nodeValue))break;if(ue){ie={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(It,At,di){ie[At]=di});break}}var ge=de.className;if((ie!==ke||et.test(ge))&&!Ae.test(ge)){for(var Ce=!1,Le=de.parentNode;Le;Le=Le.parentNode){var ze=Le.tagName;if(Se.test(ze)&&Le.className&&et.test(Le.className)){Ce=!0;break}}if(!Ce){de.className+=" prettyprinted";var pt=ie.lang;if(!pt){pt=ge.match(Ke);var ct;!pt&&(ct=re(de))&&Je.test(ct.tagName)&&(pt=ct.className.match(Ke)),pt&&(pt=pt[1])}var Ct;if(nt.test(de.tagName))Ct=1;else{var xt=de.currentStyle,$e=qe.defaultView,Rt=xt?xt.whiteSpace:$e&&$e.getComputedStyle?$e.getComputedStyle(de,null).getPropertyValue("white-space"):0;Ct=Rt&&Rt.substring(0,3)==="pre"}var vt=ie.linenums;(vt=vt==="true"||+vt)||(vt=ge.match(/\blinenums\b(?::(\d+))?/),vt=vt?vt[1]&&vt[1].length?+vt[1]:!0:!1),vt&&be(de,vt,Ct);var Nt={langExtension:pt,sourceNode:de,numberLines:vt,pre:Ct,sourceCode:null,basePos:null,spans:null,decorations:null};Re(Nt)}}}tt<Fe.length?j.setTimeout(me,250):typeof Oe=="function"&&Oe()}me()}var rt=j.PR={createSimpleLexer:ce,registerLangHandler:ve,sourceDecorator:Te,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:N,PR_COMMENT:A,PR_DECLARATION:m,PR_KEYWORD:R,PR_LITERAL:E,PR_NOCODE:K,PR_PLAIN:u,PR_PUNCTUATION:y,PR_SOURCE:b,PR_STRING:x,PR_TAG:_,PR_TYPE:T,prettyPrintOne:k?j.prettyPrintOne=Ye:D=Ye,prettyPrint:G=k?j.prettyPrint=Ue:G=Ue},ot=j.define;typeof ot=="function"&&ot.amd&&ot("google-code-prettify",[],function(){return rt})})()},TXwP:function(_t,lt,ne){var ae,Z;(function(){var k;(function(){"use strict";var F=[,,function(M){function I(f){this.__parent=f,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}I.prototype.clone_empty=function(){var f=new I(this.__parent);return f.set_indent(this.__indent_count,this.__alignment_count),f},I.prototype.item=function(f){return f<0?this.__items[this.__items.length+f]:this.__items[f]},I.prototype.has_match=function(f){for(var h=this.__items.length-1;h>=0;h--)if(this.__items[h].match(f))return!0;return!1},I.prototype.set_indent=function(f,h){this.is_empty()&&(this.__indent_count=f||0,this.__alignment_count=h||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},I.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},I.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},I.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var f=this.__parent.current_line;return f.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),f.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),f.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,f.__items[0]===" "&&(f.__items.splice(0,1),f.__character_count-=1),!0}return!1},I.prototype.is_empty=function(){return this.__items.length===0},I.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},I.prototype.push=function(f){this.__items.push(f);var h=f.lastIndexOf(`
`);h!==-1?this.__character_count=f.length-h:this.__character_count+=f.length},I.prototype.pop=function(){var f=null;return this.is_empty()||(f=this.__items.pop(),this.__character_count-=f.length),f},I.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},I.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},I.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},I.prototype.toString=function(){var f="";return this.is_empty()?this.__parent.indent_empty_lines&&(f=this.__parent.get_indent_string(this.__indent_count)):(f=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),f+=this.__items.join("")),f};function g(f,h){this.__cache=[""],this.__indent_size=f.indent_size,this.__indent_string=f.indent_char,f.indent_with_tabs||(this.__indent_string=new Array(f.indent_size+1).join(f.indent_char)),h=h||"",f.indent_level>0&&(h=new Array(f.indent_level+1).join(this.__indent_string)),this.__base_string=h,this.__base_string_length=h.length}g.prototype.get_indent_size=function(f,h){var a=this.__base_string_length;return h=h||0,f<0&&(a=0),a+=f*this.__indent_size,a+=h,a},g.prototype.get_indent_string=function(f,h){var a=this.__base_string;return h=h||0,f<0&&(f=0,a=""),h+=f*this.__indent_size,this.__ensure_cache(h),a+=this.__cache[h],a},g.prototype.__ensure_cache=function(f){for(;f>=this.__cache.length;)this.__add_column()},g.prototype.__add_column=function(){var f=this.__cache.length,h=0,a="";this.__indent_size&&f>=this.__indent_size&&(h=Math.floor(f/this.__indent_size),f-=h*this.__indent_size,a=new Array(h+1).join(this.__indent_string)),f&&(a+=new Array(f+1).join(" ")),this.__cache.push(a)};function p(f,h){this.__indent_cache=new g(f,h),this.raw=!1,this._end_with_newline=f.end_with_newline,this.indent_size=f.indent_size,this.wrap_line_length=f.wrap_line_length,this.indent_empty_lines=f.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new I(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}p.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},p.prototype.get_line_number=function(){return this.__lines.length},p.prototype.get_indent_string=function(f,h){return this.__indent_cache.get_indent_string(f,h)},p.prototype.get_indent_size=function(f,h){return this.__indent_cache.get_indent_size(f,h)},p.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},p.prototype.add_new_line=function(f){return this.is_empty()||!f&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},p.prototype.get_code=function(f){this.trim(!0);var h=this.current_line.pop();h&&(h[h.length-1]===`
`&&(h=h.replace(/\n+$/g,"")),this.current_line.push(h)),this._end_with_newline&&this.__add_outputline();var a=this.__lines.join(`
`);return f!==`
`&&(a=a.replace(/[\n]/g,f)),a},p.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},p.prototype.set_indent=function(f,h){return f=f||0,h=h||0,this.next_line.set_indent(f,h),this.__lines.length>1?(this.current_line.set_indent(f,h),!0):(this.current_line.set_indent(),!1)},p.prototype.add_raw_token=function(f){for(var h=0;h<f.newlines;h++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(f.whitespace_before),this.current_line.push(f.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},p.prototype.add_token=function(f){this.__add_space_before_token(),this.current_line.push(f),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},p.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},p.prototype.remove_indent=function(f){for(var h=this.__lines.length;f<h;)this.__lines[f]._remove_indent(),f++;this.current_line._remove_wrap_indent()},p.prototype.trim=function(f){for(f=f===void 0?!1:f,this.current_line.trim();f&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},p.prototype.just_added_newline=function(){return this.current_line.is_empty()},p.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},p.prototype.ensure_empty_line_above=function(f,h){for(var a=this.__lines.length-2;a>=0;){var c=this.__lines[a];if(c.is_empty())break;if(c.item(0).indexOf(f)!==0&&c.item(-1)!==h){this.__lines.splice(a+1,0,new I(this)),this.previous_line=this.__lines[this.__lines.length-2];break}a--}},M.exports.Output=p},,,,function(M){function I(f,h){this.raw_options=g(f,h),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}I.prototype._get_array=function(f,h){var a=this.raw_options[f],c=h||[];return typeof a=="object"?a!==null&&typeof a.concat=="function"&&(c=a.concat()):typeof a=="string"&&(c=a.split(/[^a-zA-Z0-9_\/\-]+/)),c},I.prototype._get_boolean=function(f,h){var a=this.raw_options[f],c=a===void 0?!!h:!!a;return c},I.prototype._get_characters=function(f,h){var a=this.raw_options[f],c=h||"";return typeof a=="string"&&(c=a.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),c},I.prototype._get_number=function(f,h){var a=this.raw_options[f];h=parseInt(h,10),isNaN(h)&&(h=0);var c=parseInt(a,10);return isNaN(c)&&(c=h),c},I.prototype._get_selection=function(f,h,a){var c=this._get_selection_list(f,h,a);if(c.length!==1)throw new Error("Invalid Option Value: The option '"+f+`' can only be one of the following values:
`+h+`
You passed in: '`+this.raw_options[f]+"'");return c[0]},I.prototype._get_selection_list=function(f,h,a){if(!h||h.length===0)throw new Error("Selection list cannot be empty.");if(a=a||[h[0]],!this._is_valid_selection(a,h))throw new Error("Invalid Default Value!");var c=this._get_array(f,a);if(!this._is_valid_selection(c,h))throw new Error("Invalid Option Value: The option '"+f+`' can contain only the following values:
`+h+`
You passed in: '`+this.raw_options[f]+"'");return c},I.prototype._is_valid_selection=function(f,h){return f.length&&h.length&&!f.some(function(a){return h.indexOf(a)===-1})};function g(f,h){var a={};f=p(f);var c;for(c in f)c!==h&&(a[c]=f[c]);if(h&&f[h])for(c in f[h])a[c]=f[h][c];return a}function p(f){var h={},a;for(a in f){var c=a.replace(/-/g,"_");h[c]=f[a]}return h}M.exports.Options=I,M.exports.normalizeOpts=p,M.exports.mergeOpts=g},,function(M){var I=RegExp.prototype.hasOwnProperty("sticky");function g(p){this.__input=p||"",this.__input_length=this.__input.length,this.__position=0}g.prototype.restart=function(){this.__position=0},g.prototype.back=function(){this.__position>0&&(this.__position-=1)},g.prototype.hasNext=function(){return this.__position<this.__input_length},g.prototype.next=function(){var p=null;return this.hasNext()&&(p=this.__input.charAt(this.__position),this.__position+=1),p},g.prototype.peek=function(p){var f=null;return p=p||0,p+=this.__position,p>=0&&p<this.__input_length&&(f=this.__input.charAt(p)),f},g.prototype.__match=function(p,f){p.lastIndex=f;var h=p.exec(this.__input);return h&&!(I&&p.sticky)&&(h.index!==f&&(h=null)),h},g.prototype.test=function(p,f){return f=f||0,f+=this.__position,f>=0&&f<this.__input_length?!!this.__match(p,f):!1},g.prototype.testChar=function(p,f){var h=this.peek(f);return p.lastIndex=0,h!==null&&p.test(h)},g.prototype.match=function(p){var f=this.__match(p,this.__position);return f?this.__position+=f[0].length:f=null,f},g.prototype.read=function(p,f,h){var a="",c;return p&&(c=this.match(p),c&&(a+=c[0])),f&&(c||!p)&&(a+=this.readUntil(f,h)),a},g.prototype.readUntil=function(p,f){var h="",a=this.__position;p.lastIndex=this.__position;var c=p.exec(this.__input);return c?(a=c.index,f&&(a+=c[0].length)):a=this.__input_length,h=this.__input.substring(this.__position,a),this.__position=a,h},g.prototype.readUntilAfter=function(p){return this.readUntil(p,!0)},g.prototype.get_regexp=function(p,f){var h=null,a="g";return f&&I&&(a="y"),typeof p=="string"&&p!==""?h=new RegExp(p,a):p&&(h=new RegExp(p.source,a)),h},g.prototype.get_literal_regexp=function(p){return RegExp(p.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},g.prototype.peekUntilAfter=function(p){var f=this.__position,h=this.readUntilAfter(p);return this.__position=f,h},g.prototype.lookBack=function(p){var f=this.__position-1;return f>=p.length&&this.__input.substring(f-p.length,f).toLowerCase()===p},M.exports.InputScanner=g},,,,,function(M){function I(g,p){g=typeof g=="string"?g:g.source,p=typeof p=="string"?p:p.source,this.__directives_block_pattern=new RegExp(g+/ beautify( \w+[:]\w+)+ /.source+p,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(g+/\sbeautify\signore:end\s/.source+p,"g")}I.prototype.get_directives=function(g){if(!g.match(this.__directives_block_pattern))return null;var p={};this.__directive_pattern.lastIndex=0;for(var f=this.__directive_pattern.exec(g);f;)p[f[1]]=f[2],f=this.__directive_pattern.exec(g);return p},I.prototype.readIgnored=function(g){return g.readUntilAfter(this.__directives_end_ignore_pattern)},M.exports.Directives=I},,function(M,I,g){var p=g(16).Beautifier,f=g(17).Options;function h(a,c){var o=new p(a,c);return o.beautify()}M.exports=h,M.exports.defaultOptions=function(){return new f}},function(M,I,g){var p=g(17).Options,f=g(2).Output,h=g(8).InputScanner,a=g(13).Directives,c=new a(/\/\*/,/\*\//),o=/\r\n|[\r\n]/,s=/\r\n|[\r\n]/g,l=/\s/,d=/(?:\s|\n)+/g,O=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,w=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function x(R,A){this._source_text=R||"",this._options=new p(A),this._ch=null,this._input=null,this.NESTED_AT_RULE={"@page":!0,"@font-face":!0,"@keyframes":!0,"@media":!0,"@supports":!0,"@document":!0},this.CONDITIONAL_GROUP_RULE={"@media":!0,"@supports":!0,"@document":!0},this.NON_SEMICOLON_NEWLINE_PROPERTY=["grid-template-areas","grid-template"]}x.prototype.eatString=function(R){var A="";for(this._ch=this._input.next();this._ch;){if(A+=this._ch,this._ch==="\\")A+=this._input.next();else if(R.indexOf(this._ch)!==-1||this._ch===`
`)break;this._ch=this._input.next()}return A},x.prototype.eatWhitespace=function(R){for(var A=l.test(this._input.peek()),T=0;l.test(this._input.peek());)this._ch=this._input.next(),R&&this._ch===`
`&&((T===0||T<this._options.max_preserve_newlines)&&(T++,this._output.add_new_line(!0)));return A},x.prototype.foundNestedPseudoClass=function(){for(var R=0,A=1,T=this._input.peek(A);T;){if(T==="{")return!0;if(T==="(")R+=1;else if(T===")"){if(R===0)return!1;R-=1}else if(T===";"||T==="}")return!1;A++,T=this._input.peek(A)}return!1},x.prototype.print_string=function(R){this._output.set_indent(this._indentLevel),this._output.non_breaking_space=!0,this._output.add_token(R)},x.prototype.preserveSingleSpace=function(R){R&&(this._output.space_before_token=!0)},x.prototype.indent=function(){this._indentLevel++},x.prototype.outdent=function(){this._indentLevel>0&&this._indentLevel--},x.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var R=this._source_text,A=this._options.eol;A==="auto"&&(A=`
`,R&&o.test(R||"")&&(A=R.match(o)[0])),R=R.replace(s,`
`);var T=R.match(/^[\t ]*/)[0];this._output=new f(this._options,T),this._input=new h(R),this._indentLevel=0,this._nestedLevel=0,this._ch=null;for(var E=0,y=!1,u=!1,_=!1,m=!1,b=!1,P=!1,N=this._ch,K=!1,X,B,S;X=this._input.read(d),B=X!=="",S=N,this._ch=this._input.next(),this._ch==="\\"&&this._input.hasNext()&&(this._ch+=this._input.next()),N=this._ch,this._ch;)if(this._ch==="/"&&this._input.peek()==="*"){this._output.add_new_line(),this._input.back();var Y=this._input.read(O),te=c.get_directives(Y);te&&te.ignore==="start"&&(Y+=c.readIgnored(this._input)),this.print_string(Y),this.eatWhitespace(!0),this._output.add_new_line()}else if(this._ch==="/"&&this._input.peek()==="/")this._output.space_before_token=!0,this._input.back(),this.print_string(this._input.read(w)),this.eatWhitespace(!0);else if(this._ch==="@"||this._ch==="$")if(this.preserveSingleSpace(B),this._input.peek()==="{")this.print_string(this._ch+this.eatString("}"));else{this.print_string(this._ch);var re=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);re.match(/[ :]$/)&&(re=this.eatString(": ").replace(/\s$/,""),this.print_string(re),this._output.space_before_token=!0),re=re.replace(/\s$/,""),re==="extend"?m=!0:re==="import"&&(b=!0),re in this.NESTED_AT_RULE?(this._nestedLevel+=1,re in this.CONDITIONAL_GROUP_RULE&&(_=!0)):!y&&E===0&&re.indexOf(":")!==-1&&(u=!0,this.indent())}else if(this._ch==="#"&&this._input.peek()==="{")this.preserveSingleSpace(B),this.print_string(this._ch+this.eatString("}"));else if(this._ch==="{")u&&(u=!1,this.outdent()),_?(_=!1,y=this._indentLevel>=this._nestedLevel):y=this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&y&&(this._output.previous_line&&this._output.previous_line.item(-1)!=="{"&&this._output.ensure_empty_line_above("/",",")),this._output.space_before_token=!0,this._options.brace_style==="expand"?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):(S==="("?this._output.space_before_token=!1:S!==","&&this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line();else if(this._ch==="}")this.outdent(),this._output.add_new_line(),S==="{"&&this._output.trim(!0),b=!1,m=!1,u&&(this.outdent(),u=!1),this.print_string(this._ch),y=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&(this._input.peek()!=="}"&&this._output.add_new_line(!0)),this._input.peek()===")"&&(this._output.trim(!0),this._options.brace_style==="expand"&&this._output.add_new_line(!0));else if(this._ch===":"){for(var ce=0;ce<this.NON_SEMICOLON_NEWLINE_PROPERTY.length;ce++)if(this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[ce])){K=!0;break}(y||_)&&!(this._input.lookBack("&")||this.foundNestedPseudoClass())&&!this._input.lookBack("(")&&!m&&E===0?(this.print_string(":"),u||(u=!0,this._output.space_before_token=!0,this.eatWhitespace(!0),this.indent())):(this._input.lookBack(" ")&&(this._output.space_before_token=!0),this._input.peek()===":"?(this._ch=this._input.next(),this.print_string("::")):this.print_string(":"))}else if(this._ch==='"'||this._ch==="'"){var Te=S==='"'||S==="'";this.preserveSingleSpace(Te||B),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)}else if(this._ch===";")K=!1,E===0?(u&&(this.outdent(),u=!1),m=!1,b=!1,this.print_string(this._ch),this.eatWhitespace(!0),this._input.peek()!=="/"&&this._output.add_new_line()):(this.print_string(this._ch),this.eatWhitespace(!0),this._output.space_before_token=!0);else if(this._ch==="(")if(this._input.lookBack("url"))this.print_string(this._ch),this.eatWhitespace(),E++,this.indent(),this._ch=this._input.next(),this._ch===")"||this._ch==='"'||this._ch==="'"?this._input.back():this._ch&&(this.print_string(this._ch+this.eatString(")")),E&&(E--,this.outdent()));else{var ye=!1;this._input.lookBack("with")&&(ye=!0),this.preserveSingleSpace(B||ye),this.print_string(this._ch),u&&S==="$"&&this._options.selector_separator_newline?(this._output.add_new_line(),P=!0):(this.eatWhitespace(),E++,this.indent())}else if(this._ch===")")E&&(E--,this.outdent()),P&&this._input.peek()===";"&&this._options.selector_separator_newline&&(P=!1,this.outdent(),this._output.add_new_line()),this.print_string(this._ch);else if(this._ch===",")this.print_string(this._ch),this.eatWhitespace(!0),this._options.selector_separator_newline&&(!u||P)&&E===0&&!b&&!m?this._output.add_new_line():this._output.space_before_token=!0;else if((this._ch===">"||this._ch==="+"||this._ch==="~")&&!u&&E===0)this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&l.test(this._ch)&&(this._ch=""));else if(this._ch==="]")this.print_string(this._ch);else if(this._ch==="[")this.preserveSingleSpace(B),this.print_string(this._ch);else if(this._ch==="=")this.eatWhitespace(),this.print_string("="),l.test(this._ch)&&(this._ch="");else if(this._ch==="!"&&!this._input.lookBack("\\"))this._output.space_before_token=!0,this.print_string(this._ch);else{var be=S==='"'||S==="'";this.preserveSingleSpace(be||B),this.print_string(this._ch),!this._output.just_added_newline()&&this._input.peek()===`
`&&K&&this._output.add_new_line()}var we=this._output.get_code(A);return we},M.exports.Beautifier=x},function(M,I,g){var p=g(6).Options;function f(h){p.call(this,h,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0);var a=this._get_boolean("space_around_selector_separator");this.space_around_combinator=this._get_boolean("space_around_combinator")||a;var c=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_style="collapse";for(var o=0;o<c.length;o++)c[o]!=="expand"?this.brace_style="collapse":this.brace_style=c[o]}f.prototype=new p,M.exports.Options=f}],D={};function G(M){var I=D[M];if(I!==void 0)return I.exports;var g=D[M]={exports:{}};return F[M](g,g.exports,G),g.exports}var j=G(15);k=j})();var V=k;!(ae=[],Z=function(){return{css_beautify:V}}.apply(lt,ae),Z!==void 0&&(_t.exports=Z))})()},UZu5:function(_t,lt,ne){},"VrN/":function(_t,lt,ne){(function(ae,Z){_t.exports=Z()})(this,function(){"use strict";var ae=navigator.userAgent,Z=navigator.platform,k=/gecko\/\d/i.test(ae),V=/MSIE \d/.test(ae),F=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ae),D=/Edge\/(\d+)/.exec(ae),G=V||F||D,j=G&&(V?document.documentMode||6:+(D||F)[1]),M=!D&&/WebKit\//.test(ae),I=M&&/Qt\/\d+\.\d+/.test(ae),g=!D&&/Chrome\//.test(ae),p=/Opera\//.test(ae),f=/Apple Computer/.test(navigator.vendor),h=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ae),a=/PhantomJS/.test(ae),c=!D&&/AppleWebKit/.test(ae)&&/Mobile\/\w+/.test(ae),o=/Android/.test(ae),s=c||o||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ae),l=c||/Mac/.test(Z),d=/\bCrOS\b/.test(ae),O=/win/i.test(Z),w=p&&ae.match(/Version\/(\d*\.\d*)/);w&&(w=Number(w[1])),w&&w>=15&&(p=!1,M=!0);var x=l&&(I||p&&(w==null||w<12.11)),R=k||G&&j>=9;function A(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var T=function(e,t){var n=e.className,i=A(t).exec(n);if(i){var r=n.slice(i.index+i[0].length);e.className=n.slice(0,i.index)+(r?i[1]+r:"")}};function E(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function y(e,t){return E(e).appendChild(t)}function u(e,t,n,i){var r=document.createElement(e);if(n&&(r.className=n),i&&(r.style.cssText=i),typeof t=="string")r.appendChild(document.createTextNode(t));else if(t)for(var L=0;L<t.length;++L)r.appendChild(t[L]);return r}function _(e,t,n,i){var r=u(e,t,n,i);return r.setAttribute("role","presentation"),r}var m;document.createRange?m=function(e,t,n,i){var r=document.createRange();return r.setEnd(i||e,n),r.setStart(e,t),r}:m=function(e,t,n){var i=document.body.createTextRange();try{i.moveToElementText(e.parentNode)}catch(r){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",t),i};function b(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function P(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function N(e,t){var n=e.className;A(t).test(n)||(e.className+=(n?" ":"")+t)}function K(e,t){for(var n=e.split(" "),i=0;i<n.length;i++)n[i]&&!A(n[i]).test(t)&&(t+=" "+n[i]);return t}var X=function(e){e.select()};c?X=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:G&&(X=function(e){try{e.select()}catch(t){}});function B(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function S(e,t,n){t||(t={});for(var i in e)e.hasOwnProperty(i)&&(n!==!1||!t.hasOwnProperty(i))&&(t[i]=e[i]);return t}function Y(e,t,n,i,r){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var L=i||0,H=r||0;;){var $=e.indexOf(" ",L);if($<0||$>=t)return H+(t-L);H+=$-L,H+=n-H%n,L=$+1}}var te=function(){this.id=null,this.f=null,this.time=0,this.handler=B(this.onTimeout,this)};te.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},te.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};function re(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}var ce=50,Te={toString:function(){return"CodeMirror.Pass"}},ye={scroll:!1},be={origin:"*mouse"},we={origin:"+move"};function xe(e,t,n){for(var i=0,r=0;;){var L=e.indexOf(" ",i);L==-1&&(L=e.length);var H=L-i;if(L==e.length||r+H>=t)return i+Math.min(H,t-r);if(r+=L-i,r+=n-r%n,i=L+1,r>=t)return i}}var ve=[""];function oe(e){for(;ve.length<=e;)ve.push(Re(ve)+" ");return ve[e]}function Re(e){return e[e.length-1]}function Ye(e,t){for(var n=[],i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function Ue(e,t,n){for(var i=0,r=n(t);i<e.length&&n(e[i])<=r;)i++;e.splice(i,0,t)}function rt(){}function ot(e,t){var n;return Object.create?n=Object.create(e):(rt.prototype=e,n=new rt),t&&S(t,n),n}var Oe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Me(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Oe.test(e))}function We(e,t){return t?t.source.indexOf("\\w")>-1&&Me(e)?!0:t.test(e):Me(e)}function qe(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Ve=/[\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 je(e){return e.charCodeAt(0)>=768&&Ve.test(e)}function Fe(e,t,n){for(;(n<0?t>0:t<e.length)&&je(e.charAt(t));)t+=n;return t}function ht(e,t,n){for(var i=t>n?-1:1;;){if(t==n)return t;var r=(t+n)/2,L=i<0?Math.ceil(r):Math.floor(r);if(L==t)return e(L)?t:n;e(L)?n=L:t=L+i}}function He(e,t,n,i){if(!e)return i(t,n,"ltr",0);for(var r=!1,L=0;L<e.length;++L){var H=e[L];(H.from<n&&H.to>t||t==n&&H.to==t)&&(i(Math.max(H.from,t),Math.min(H.to,n),H.level==1?"rtl":"ltr",L),r=!0)}r||i(t,n,"ltr")}var Pe=null;function Xe(e,t,n){var i;Pe=null;for(var r=0;r<e.length;++r){var L=e[r];if(L.from<t&&L.to>t)return r;L.to==t&&(L.from!=L.to&&n=="before"?i=r:Pe=r),L.from==t&&(L.from!=L.to&&n!="before"?i=r:Pe=r)}return i!=null?i:Pe}var tt=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(ee){return ee<=247?e.charAt(ee):1424<=ee&&ee<=1524?"R":1536<=ee&&ee<=1785?t.charAt(ee-1536):1774<=ee&&ee<=2220?"r":8192<=ee&&ee<=8203?"w":ee==8204?"b":"L"}var i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,r=/[stwN]/,L=/[LRr]/,H=/[Lb1n]/,$=/[1n]/;function Q(ee,le,fe){this.level=ee,this.from=le,this.to=fe}return function(ee,le){var fe=le=="ltr"?"L":"R";if(ee.length==0||le=="ltr"&&!i.test(ee))return!1;for(var Ee=ee.length,_e=[],Ie=0;Ie<Ee;++Ie)_e.push(n(ee.charCodeAt(Ie)));for(var Be=0,Ze=fe;Be<Ee;++Be){var at=_e[Be];at=="m"?_e[Be]=Ze:Ze=at}for(var dt=0,st=fe;dt<Ee;++dt){var mt=_e[dt];mt=="1"&&st=="r"?_e[dt]="n":L.test(mt)&&(st=mt,mt=="r"&&(_e[dt]="R"))}for(var St=1,Et=_e[0];St<Ee-1;++St){var Pt=_e[St];Pt=="+"&&Et=="1"&&_e[St+1]=="1"?_e[St]="1":Pt==","&&Et==_e[St+1]&&(Et=="1"||Et=="n")&&(_e[St]=Et),Et=Pt}for(var Jt=0;Jt<Ee;++Jt){var yi=_e[Jt];if(yi==",")_e[Jt]="N";else if(yi=="%"){var ni=void 0;for(ni=Jt+1;ni<Ee&&_e[ni]=="%";++ni);for(var Wi=Jt&&_e[Jt-1]=="!"||ni<Ee&&_e[ni]=="1"?"1":"N",Ni=Jt;Ni<ni;++Ni)_e[Ni]=Wi;Jt=ni-1}}for(var ui=0,Ui=fe;ui<Ee;++ui){var xi=_e[ui];Ui=="L"&&xi=="1"?_e[ui]="L":L.test(xi)&&(Ui=xi)}for(var fi=0;fi<Ee;++fi)if(r.test(_e[fi])){var hi=void 0;for(hi=fi+1;hi<Ee&&r.test(_e[hi]);++hi);for(var ai=(fi?_e[fi-1]:fe)=="L",Fi=(hi<Ee?_e[hi]:fe)=="L",ur=ai==Fi?ai?"L":"R":fe,In=fi;In<hi;++In)_e[In]=ur;fi=hi-1}for(var Ri=[],on,_i=0;_i<Ee;)if(H.test(_e[_i])){var Va=_i;for(++_i;_i<Ee&&H.test(_e[_i]);++_i);Ri.push(new Q(0,Va,_i))}else{var fn=_i,Gn=Ri.length,zn=le=="rtl"?1:0;for(++_i;_i<Ee&&_e[_i]!="L";++_i);for(var Ii=fn;Ii<_i;)if($.test(_e[Ii])){fn<Ii&&(Ri.splice(Gn,0,new Q(1,fn,Ii)),Gn+=zn);var hr=Ii;for(++Ii;Ii<_i&&$.test(_e[Ii]);++Ii);Ri.splice(Gn,0,new Q(2,hr,Ii)),Gn+=zn,fn=Ii}else++Ii;fn<_i&&Ri.splice(Gn,0,new Q(1,fn,_i))}return le=="ltr"&&(Ri[0].level==1&&(on=ee.match(/^\s+/))&&(Ri[0].from=on[0].length,Ri.unshift(new Q(0,0,on[0].length))),Re(Ri).level==1&&(on=ee.match(/\s+$/))&&(Re(Ri).to-=on[0].length,Ri.push(new Q(0,Ee-on[0].length,Ee)))),le=="rtl"?Ri.reverse():Ri}}();function Ke(e,t){var n=e.order;return n==null&&(n=e.order=tt(e.text,t)),n}var et=[],Ae=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var i=e._handlers||(e._handlers={});i[t]=(i[t]||et).concat(n)}};function nt(e,t){return e._handlers&&e._handlers[t]||et}function Je(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var i=e._handlers,r=i&&i[t];if(r){var L=re(r,n);L>-1&&(i[t]=r.slice(0,L).concat(r.slice(L+1)))}}}function Se(e,t){var n=nt(e,t);if(!n.length)return;for(var i=Array.prototype.slice.call(arguments,2),r=0;r<n.length;++r)n[r].apply(null,i)}function ke(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Se(e,n||t.type,e,t),se(t)||t.codemirrorIgnore}function me(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),i=0;i<t.length;++i)re(n,t[i])==-1&&n.push(t[i])}function he(e,t){return nt(e,t).length>0}function de(e){e.prototype.on=function(t,n){Ae(this,t,n)},e.prototype.off=function(t,n){Je(this,t,n)}}function ie(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function q(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){ie(e),q(e)}function ge(e){return e.target||e.srcElement}function Ce(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 Le=function(){if(G&&j<9)return!1;var e=u("div");return"draggable"in e||"dragDrop"in e}(),ze;function pt(e){if(ze==null){var t=u("span","\u200B");y(e,u("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(ze=t.offsetWidth<=1&&t.offsetHeight>2&&!(G&&j<8))}var n=ze?u("span","\u200B"):u("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var ct;function Ct(e){if(ct!=null)return ct;var t=y(e,document.createTextNode("A\u062EA")),n=m(t,0,1).getBoundingClientRect(),i=m(t,1,2).getBoundingClientRect();return E(e),!n||n.left==n.right?!1:ct=i.right-n.right<3}var xt=`
b`.split(/\n/).length!=3?function(e){for(var t=0,n=[],i=e.length;t<=i;){var r=e.indexOf(`
`,t);r==-1&&(r=e.length);var L=e.slice(t,e.charAt(r-1)=="\r"?r-1:r),H=L.indexOf("\r");H!=-1?(n.push(L.slice(0,H)),t+=H+1):(n.push(L),t=r+1)}return n}:function(e){return e.split(/\r\n?|\n/)},$e=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Rt=function(){var e=u("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),vt=null;function Nt(e){if(vt!=null)return vt;var t=y(e,u("span","x")),n=t.getBoundingClientRect(),i=m(t,0,1).getBoundingClientRect();return vt=Math.abs(n.left-i.left)>1}var It={},At={};function di(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),It[e]=t}function ri(e,t){At[e]=t}function Qe(e){if(typeof e=="string"&&At.hasOwnProperty(e))e=At[e];else if(e&&typeof e.name=="string"&&At.hasOwnProperty(e.name)){var t=At[e.name];typeof t=="string"&&(t={name:t}),e=ot(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Qe("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Qe("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function bt(e,t){t=Qe(t);var n=It[t.name];if(!n)return bt(e,"text/plain");var i=n(e,t);if(kt.hasOwnProperty(t.name)){var r=kt[t.name];for(var L in r){if(!r.hasOwnProperty(L))continue;i.hasOwnProperty(L)&&(i["_"+L]=i[L]),i[L]=r[L]}}if(i.name=t.name,t.helperType&&(i.helperType=t.helperType),t.modeProps)for(var H in t.modeProps)i[H]=t.modeProps[H];return i}var kt={};function Mt(e,t){var n=kt.hasOwnProperty(e)?kt[e]:kt[e]={};S(t,n)}function ei(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var i in t){var r=t[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function Gi(e,t){for(var n;e.innerMode&&!(n=e.innerMode(t),!n||n.mode==e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Xi(e,t,n){return e.startState?e.startState(t,n):!0}var ft=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};ft.prototype.eol=function(){return this.pos>=this.string.length},ft.prototype.sol=function(){return this.pos==this.lineStart},ft.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ft.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},ft.prototype.eat=function(e){var t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e.test?e.test(t):e(t)),n)return++this.pos,t},ft.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},ft.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},ft.prototype.skipToEnd=function(){this.pos=this.string.length},ft.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},ft.prototype.backUp=function(e){this.pos-=e},ft.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)},ft.prototype.indentation=function(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},ft.prototype.match=function(e,t,n){if(typeof e=="string"){var i=function(H){return n?H.toLowerCase():H},r=this.string.substr(this.pos,e.length);if(i(r)==i(e))return t!==!1&&(this.pos+=e.length),!0}else{var L=this.string.slice(this.pos).match(e);return L&&L.index>0?null:(L&&t!==!1&&(this.pos+=L[0].length),L)}},ft.prototype.current=function(){return this.string.slice(this.start,this.pos)},ft.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},ft.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},ft.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ut(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var i=0;;++i){var r=n.children[i],L=r.chunkSize();if(t<L){n=r;break}t-=L}return n.lines[t]}function ti(e,t,n){var i=[],r=t.line;return e.iter(t.line,n.line+1,function(L){var H=L.text;r==n.line&&(H=H.slice(0,n.ch)),r==t.line&&(H=H.slice(t.ch)),i.push(H),++r}),i}function Wt(e,t,n){var i=[];return e.iter(t,n,function(r){i.push(r.text)}),i}function Ut(e,t){var n=t-e.height;if(n)for(var i=e;i;i=i.parent)i.height+=n}function Dt(e){if(e.parent==null)return null;for(var t=e.parent,n=re(t.lines,e),i=t.parent;i;t=i,i=i.parent)for(var r=0;!(i.children[r]==t);++r)n+=i.children[r].chunkSize();return n+t.first}function Vt(e,t){var n=e.first;e:do{for(var i=0;i<e.children.length;++i){var r=e.children[i],L=r.height;if(t<L){e=r;continue e}t-=L,n+=r.chunkSize()}return n}while(!e.lines);for(var H=0;H<e.lines.length;++H){var $=e.lines[H],Q=$.height;if(t<Q)break;t-=Q}return n+H}function Ti(e,t){return t>=e.first&&t<e.first+e.size}function pn(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ge(e,t,n){if(n===void 0&&(n=null),!(this instanceof Ge))return new Ge(e,t,n);this.line=e,this.ch=t,this.sticky=n}function Ot(e,t){return e.line-t.line||e.ch-t.ch}function mn(e,t){return e.sticky==t.sticky&&Ot(e,t)==0}function gn(e){return Ge(e.line,e.ch)}function vn(e,t){return Ot(e,t)<0?t:e}function yn(e,t){return Ot(e,t)<0?e:t}function z(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function v(e,t){if(t.line<e.first)return Ge(e.first,0);var n=e.first+e.size-1;return t.line>n?Ge(n,ut(e,n).text.length):C(t,ut(e,t.line).text.length)}function C(e,t){var n=e.ch;return n==null||n>t?Ge(e.line,t):n<0?Ge(e.line,0):e}function U(e,t){for(var n=[],i=0;i<t.length;i++)n[i]=v(e,t[i]);return n}var J=function(e,t){this.state=e,this.lookAhead=t},W=function(e,t,n,i){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};W.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},W.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}},W.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},W.fromSaved=function(e,t,n){return t instanceof J?new W(e,ei(e.mode,t.state),n,t.lookAhead):new W(e,ei(e.mode,t),n)},W.prototype.save=function(e){var t=e!==!1?ei(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new J(t,this.maxLookAhead):t};function pe(e,t,n,i){var r=[e.state.modeGen],L={};wi(e,t.text,e.doc.mode,n,function(ee,le){return r.push(ee,le)},L,i);for(var H=n.state,$=function(ee){n.baseTokens=r;var le=e.state.overlays[ee],fe=1,Ee=0;n.state=!0,wi(e,t.text,le.mode,n,function(_e,Ie){for(var Be=fe;Ee<_e;){var Ze=r[fe];Ze>_e&&r.splice(fe,1,_e,r[fe+1],Ze),fe+=2,Ee=Math.min(_e,Ze)}if(!Ie)return;if(le.opaque)r.splice(Be,fe-Be,_e,"overlay "+Ie),fe=Be+2;else for(;Be<fe;Be+=2){var at=r[Be+1];r[Be+1]=(at?at+" ":"")+"overlay "+Ie}},L),n.state=H,n.baseTokens=null,n.baseTokenPos=1},Q=0;Q<e.state.overlays.length;++Q)$(Q);return{styles:r,classes:L.bgClass||L.textClass?L:null}}function De(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var i=it(e,Dt(t)),r=t.text.length>e.options.maxHighlightLength&&ei(e.doc.mode,i.state),L=pe(e,t,i);r&&(i.state=r),t.stateAfter=i.save(!r),t.styles=L.styles,L.classes?t.styleClasses=L.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function it(e,t,n){var i=e.doc,r=e.display;if(!i.mode.startState)return new W(i,!0,t);var L=Si(e,t,n),H=L>i.first&&ut(i,L-1).stateAfter,$=H?W.fromSaved(i,H,L):new W(i,Xi(i.mode),L);return i.iter(L,t,function(Q){gt(e,Q.text,$);var ee=$.line;Q.stateAfter=ee==t-1||ee%5==0||ee>=r.viewFrom&&ee<r.viewTo?$.save():null,$.nextLine()}),n&&(i.modeFrontier=$.line),$}function gt(e,t,n,i){var r=e.doc.mode,L=new ft(t,e.options.tabSize,n);for(L.start=L.pos=i||0,t==""&&Ne(r,n.state);!L.eol();)Tt(r,L,n.state),L.start=L.pos}function Ne(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=Gi(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function Tt(e,t,n,i){for(var r=0;r<10;r++){i&&(i[0]=Gi(e,n).mode);var L=e.token(t,n);if(t.pos>t.start)return L}throw new Error("Mode "+e.name+" failed to advance stream.")}var zt=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function qt(e,t,n,i){var r=e.doc,L=r.mode,H;t=v(r,t);var $=ut(r,t.line),Q=it(e,t.line,n),ee=new ft($.text,e.options.tabSize,Q),le;for(i&&(le=[]);(i||ee.pos<t.ch)&&!ee.eol();)ee.start=ee.pos,H=Tt(L,ee,Q.state),i&&le.push(new zt(ee,H,ei(r.mode,Q.state)));return i?le:new zt(ee,H,Q.state)}function Bi(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var i=n[1]?"bgClass":"textClass";t[i]==null?t[i]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[i])||(t[i]+=" "+n[2])}return e}function wi(e,t,n,i,r,L,H){var $=n.flattenSpans;$==null&&($=e.options.flattenSpans);var Q=0,ee=null,le=new ft(t,e.options.tabSize,i),fe,Ee=e.options.addModeClass&&[null];for(t==""&&Bi(Ne(n,i.state),L);!le.eol();){if(le.pos>e.options.maxHighlightLength?($=!1,H&&gt(e,t,i,le.pos),le.pos=t.length,fe=null):fe=Bi(Tt(n,le,i.state,Ee),L),Ee){var _e=Ee[0].name;_e&&(fe="m-"+(fe?_e+" "+fe:_e))}if(!$||ee!=fe){for(;Q<le.start;)Q=Math.min(le.start,Q+5e3),r(Q,ee);ee=fe}le.start=le.pos}for(;Q<le.pos;){var Ie=Math.min(le.pos,Q+5e3);r(Ie,ee),Q=Ie}}function Si(e,t,n){for(var i,r,L=e.doc,H=n?-1:t-(e.doc.mode.innerMode?1e3:100),$=t;$>H;--$){if($<=L.first)return L.first;var Q=ut(L,$-1),ee=Q.stateAfter;if(ee&&(!n||$+(ee instanceof J?ee.lookAhead:0)<=L.modeFrontier))return $;var le=Y(Q.text,null,e.options.tabSize);(r==null||i>le)&&(r=$-1,i=le)}return r}function Qi(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var n=e.first,i=t-1;i>n;i--){var r=ut(e,i).stateAfter;if(r&&(!(r instanceof J)||i+r.lookAhead<t)){n=i+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}var Dn=!1,pi=!1;function zi(){Dn=!0}function ln(){pi=!0}function un(e,t,n){this.marker=e,this.from=t,this.to=n}function ji(e,t){if(e)for(var n=0;n<e.length;++n){var i=e[n];if(i.marker==t)return i}}function kn(e,t){for(var n,i=0;i<e.length;++i)e[i]!=t&&(n||(n=[])).push(e[i]);return n}function _n(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Kn(e,t,n){var i;if(e)for(var r=0;r<e.length;++r){var L=e[r],H=L.marker,$=L.from==null||(H.inclusiveLeft?L.from<=t:L.from<t);if($||L.from==t&&H.type=="bookmark"&&(!n||!L.marker.insertLeft)){var Q=L.to==null||(H.inclusiveRight?L.to>=t:L.to>t);(i||(i=[])).push(new un(H,L.from,Q?null:L.to))}}return i}function Vn(e,t,n){var i;if(e)for(var r=0;r<e.length;++r){var L=e[r],H=L.marker,$=L.to==null||(H.inclusiveRight?L.to>=t:L.to>t);if($||L.from==t&&H.type=="bookmark"&&(!n||L.marker.insertLeft)){var Q=L.from==null||(H.inclusiveLeft?L.from<=t:L.from<t);(i||(i=[])).push(new un(H,Q?null:L.from-t,L.to==null?null:L.to-t))}}return i}function Zi(e,t){if(t.full)return null;var n=Ti(e,t.from.line)&&ut(e,t.from.line).markedSpans,i=Ti(e,t.to.line)&&ut(e,t.to.line).markedSpans;if(!n&&!i)return null;var r=t.from.ch,L=t.to.ch,H=Ot(t.from,t.to)==0,$=Kn(n,r,H),Q=Vn(i,L,H),ee=t.text.length==1,le=Re(t.text).length+(ee?r:0);if($)for(var fe=0;fe<$.length;++fe){var Ee=$[fe];if(Ee.to==null){var _e=ji(Q,Ee.marker);_e?ee&&(Ee.to=_e.to==null?null:_e.to+le):Ee.to=r}}if(Q)for(var Ie=0;Ie<Q.length;++Ie){var Be=Q[Ie];if(Be.to!=null&&(Be.to+=le),Be.from==null){var Ze=ji($,Be.marker);Ze||(Be.from=le,ee&&($||($=[])).push(Be))}else Be.from+=le,ee&&($||($=[])).push(Be)}$&&($=Yi($)),Q&&Q!=$&&(Q=Yi(Q));var at=[$];if(!ee){var dt=t.text.length-2,st;if(dt>0&&$)for(var mt=0;mt<$.length;++mt)$[mt].to==null&&(st||(st=[])).push(new un($[mt].marker,null,null));for(var St=0;St<dt;++St)at.push(st);at.push(Q)}return at}function Yi(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function bn(e,t,n){var i=null;if(e.iter(t.line,n.line+1,function(_e){if(_e.markedSpans)for(var Ie=0;Ie<_e.markedSpans.length;++Ie){var Be=_e.markedSpans[Ie].marker;Be.readOnly&&(!i||re(i,Be)==-1)&&(i||(i=[])).push(Be)}}),!i)return null;for(var r=[{from:t,to:n}],L=0;L<i.length;++L)for(var H=i[L],$=H.find(0),Q=0;Q<r.length;++Q){var ee=r[Q];if(Ot(ee.to,$.from)<0||Ot(ee.from,$.to)>0)continue;var le=[Q,1],fe=Ot(ee.from,$.from),Ee=Ot(ee.to,$.to);(fe<0||!H.inclusiveLeft&&!fe)&&le.push({from:ee.from,to:$.from}),(Ee>0||!H.inclusiveRight&&!Ee)&&le.push({from:$.to,to:ee.to}),r.splice.apply(r,le),Q+=le.length-3}return r}function dr(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function En(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function si(e){return e.inclusiveLeft?-1:0}function Kt(e){return e.inclusiveRight?1:0}function bi(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var i=e.find(),r=t.find(),L=Ot(i.from,r.from)||si(e)-si(t);if(L)return-L;var H=Ot(i.to,r.to)||Kt(e)-Kt(t);return H||t.id-e.id}function Bt(e,t){var n=pi&&e.markedSpans,i;if(n)for(var r=void 0,L=0;L<n.length;++L)r=n[L],r.marker.collapsed&&(t?r.from:r.to)==null&&(!i||bi(i,r.marker)<0)&&(i=r.marker);return i}function li(e){return Bt(e,!0)}function $t(e){return Bt(e,!1)}function nn(e,t){var n=pi&&e.markedSpans,i;if(n)for(var r=0;r<n.length;++r){var L=n[r];L.marker.collapsed&&(L.from==null||L.from<t)&&(L.to==null||L.to>t)&&(!i||bi(i,L.marker)<0)&&(i=L.marker)}return i}function mi(e,t,n,i,r){var L=ut(e,t),H=pi&&L.markedSpans;if(H)for(var $=0;$<H.length;++$){var Q=H[$];if(!Q.marker.collapsed)continue;var ee=Q.marker.find(0),le=Ot(ee.from,n)||si(Q.marker)-si(r),fe=Ot(ee.to,i)||Kt(Q.marker)-Kt(r);if(le>=0&&fe<=0||le<=0&&fe>=0)continue;if(le<=0&&(Q.marker.inclusiveRight&&r.inclusiveLeft?Ot(ee.to,n)>=0:Ot(ee.to,n)>0)||le>=0&&(Q.marker.inclusiveRight&&r.inclusiveLeft?Ot(ee.from,i)<=0:Ot(ee.from,i)<0))return!0}}function Oi(e){for(var t;t=li(e);)e=t.find(-1,!0).line;return e}function Xn(e){for(var t;t=$t(e);)e=t.find(1,!0).line;return e}function xn(e){for(var t,n;t=$t(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function cr(e,t){var n=ut(e,t),i=Oi(n);return n==i?t:Dt(i)}function Tn(e,t){if(t>e.lastLine())return t;var n=ut(e,t),i;if(!rn(e,n))return t;for(;i=$t(n);)n=i.find(1,!0).line;return Dt(n)+1}function rn(e,t){var n=pi&&t.markedSpans;if(n)for(var i=void 0,r=0;r<n.length;++r){if(i=n[r],!i.marker.collapsed)continue;if(i.from==null)return!0;if(i.marker.widgetNode)continue;if(i.from==0&&i.marker.inclusiveLeft&&fr(e,t,i))return!0}}function fr(e,t,n){if(n.to==null){var i=n.marker.find(1,!0);return fr(e,i.line,ji(i.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var r=void 0,L=0;L<t.markedSpans.length;++L)if(r=t.markedSpans[L],r.marker.collapsed&&!r.marker.widgetNode&&r.from==n.to&&(r.to==null||r.to!=n.from)&&(r.marker.inclusiveLeft||n.marker.inclusiveRight)&&fr(e,t,r))return!0}function Ji(e){e=Oi(e);for(var t=0,n=e.parent,i=0;i<n.lines.length;++i){var r=n.lines[i];if(r==e)break;t+=r.height}for(var L=n.parent;L;n=L,L=n.parent)for(var H=0;H<L.children.length;++H){var $=L.children[H];if($==n)break;t+=$.height}return t}function pr(e){if(e.height==0)return 0;for(var t=e.text.length,n,i=e;n=li(i);){var r=n.find(0,!0);i=r.from.line,t+=r.from.ch-r.to.ch}for(i=e;n=$t(i);){var L=n.find(0,!0);t-=i.text.length-L.from.ch,i=L.to.line,t+=i.text.length-L.to.ch}return t}function jr(e){var t=e.display,n=e.doc;t.maxLine=ut(n,n.first),t.maxLineLength=pr(t.maxLine),t.maxLineChanged=!0,n.iter(function(i){var r=pr(i);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=i)})}var Mn=function(e,t,n){this.text=e,En(this,t),this.height=n?n(this):1};Mn.prototype.lineNo=function(){return Dt(this)},de(Mn);function ua(e,t,n,i){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),dr(e),En(e,n);var r=i?i(e):1;r!=e.height&&Ut(e,r)}function yt(e){e.parent=null,dr(e)}var Lt={},wt={};function Ft(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?wt:Lt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Gt(e,t){var n=_("span",null,null,M?"padding-right: .1px":null),i={pre:_("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var r=0;r<=(t.rest?t.rest.length:0);r++){var L=r?t.rest[r-1]:t.line,H=void 0;i.pos=0,i.addToken=Ht,Ct(e.display.measure)&&(H=Ke(L,e.doc.direction))&&(i.addToken=Di(i.addToken,H)),i.map=[];var $=t!=e.display.externalMeasured&&Dt(L);hn(L,i,De(e,L,$)),L.styleClasses&&(L.styleClasses.bgClass&&(i.bgClass=K(L.styleClasses.bgClass,i.bgClass||"")),L.styleClasses.textClass&&(i.textClass=K(L.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(pt(e.display.measure))),r==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(M){var Q=i.content.lastChild;(/\bcm-tab\b/.test(Q.className)||Q.querySelector&&Q.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return Se(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=K(i.pre.className,i.textClass||"")),i}function Zt(e){var t=u("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Ht(e,t,n,i,r,L,H){if(!t)return;var $=e.splitSpaces?ci(t,e.trailingSpace):t,Q=e.cm.state.specialChars,ee=!1,le;if(!Q.test(t))e.col+=t.length,le=document.createTextNode($),e.map.push(e.pos,e.pos+t.length,le),G&&j<9&&(ee=!0),e.pos+=t.length;else{le=document.createDocumentFragment();for(var fe=0;;){Q.lastIndex=fe;var Ee=Q.exec(t),_e=Ee?Ee.index-fe:t.length-fe;if(_e){var Ie=document.createTextNode($.slice(fe,fe+_e));G&&j<9?le.appendChild(u("span",[Ie])):le.appendChild(Ie),e.map.push(e.pos,e.pos+_e,Ie),e.col+=_e,e.pos+=_e}if(!Ee)break;fe+=_e+1;var Be=void 0;if(Ee[0]==" "){var Ze=e.cm.options.tabSize,at=Ze-e.col%Ze;Be=le.appendChild(u("span",oe(at),"cm-tab")),Be.setAttribute("role","presentation"),Be.setAttribute("cm-text"," "),e.col+=at}else Ee[0]=="\r"||Ee[0]==`
`?(Be=le.appendChild(u("span",Ee[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Be.setAttribute("cm-text",Ee[0]),e.col+=1):(Be=e.cm.options.specialCharPlaceholder(Ee[0]),Be.setAttribute("cm-text",Ee[0]),G&&j<9?le.appendChild(u("span",[Be])):le.appendChild(Be),e.col+=1);e.map.push(e.pos,e.pos+1,Be),e.pos++}}if(e.trailingSpace=$.charCodeAt(t.length-1)==32,n||i||r||ee||L||H){var dt=n||"";i&&(dt+=i),r&&(dt+=r);var st=u("span",[le],dt,L);if(H)for(var mt in H)H.hasOwnProperty(mt)&&mt!="style"&&mt!="class"&&st.setAttribute(mt,H[mt]);return e.content.appendChild(st)}e.content.appendChild(le)}function ci(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,i="",r=0;r<e.length;r++){var L=e.charAt(r);L==" "&&n&&(r==e.length-1||e.charCodeAt(r+1)==32)&&(L="\xA0"),i+=L,n=L==" "}return i}function Di(e,t){return function(n,i,r,L,H,$,Q){r=r?r+" cm-force-border":"cm-force-border";for(var ee=n.pos,le=ee+i.length;;){for(var fe=void 0,Ee=0;Ee<t.length&&!(fe=t[Ee],fe.to>ee&&fe.from<=ee);Ee++);if(fe.to>=le)return e(n,i,r,L,H,$,Q);e(n,i.slice(0,fe.to-ee),r,L,null,$,Q),L=null,i=i.slice(fe.to-ee),ee=fe.to}}}function jt(e,t,n,i){var r=!i&&n.widgetNode;r&&e.map.push(e.pos,e.pos+t,r),!i&&e.cm.display.input.needsContentAttribute&&(r||(r=e.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(e.cm.display.input.setUneditable(r),e.content.appendChild(r)),e.pos+=t,e.trailingSpace=!1}function hn(e,t,n){var i=e.markedSpans,r=e.text,L=0;if(!i){for(var H=1;H<n.length;H+=2)t.addToken(t,r.slice(L,L=n[H]),Ft(n[H+1],t.cm.options));return}for(var $=r.length,Q=0,ee=1,le="",fe,Ee,_e=0,Ie,Be,Ze,at,dt;;){if(_e==Q){Ie=Be=Ze=Ee="",dt=null,at=null,_e=Infinity;for(var st=[],mt=void 0,St=0;St<i.length;++St){var Et=i[St],Pt=Et.marker;if(Pt.type=="bookmark"&&Et.from==Q&&Pt.widgetNode)st.push(Pt);else if(Et.from<=Q&&(Et.to==null||Et.to>Q||Pt.collapsed&&Et.to==Q&&Et.from==Q)){if(Et.to!=null&&Et.to!=Q&&_e>Et.to&&(_e=Et.to,Be=""),Pt.className&&(Ie+=" "+Pt.className),Pt.css&&(Ee=(Ee?Ee+";":"")+Pt.css),Pt.startStyle&&Et.from==Q&&(Ze+=" "+Pt.startStyle),Pt.endStyle&&Et.to==_e&&(mt||(mt=[])).push(Pt.endStyle,Et.to),Pt.title&&((dt||(dt={})).title=Pt.title),Pt.attributes)for(var Jt in Pt.attributes)(dt||(dt={}))[Jt]=Pt.attributes[Jt];Pt.collapsed&&(!at||bi(at.marker,Pt)<0)&&(at=Et)}else Et.from>Q&&_e>Et.from&&(_e=Et.from)}if(mt)for(var yi=0;yi<mt.length;yi+=2)mt[yi+1]==_e&&(Be+=" "+mt[yi]);if(!at||at.from==Q)for(var ni=0;ni<st.length;++ni)jt(t,0,st[ni]);if(at&&(at.from||0)==Q){if(jt(t,(at.to==null?$+1:at.to)-Q,at.marker,at.from==null),at.to==null)return;at.to==Q&&(at=!1)}}if(Q>=$)break;for(var Wi=Math.min($,_e);;){if(le){var Ni=Q+le.length;if(!at){var ui=Ni>Wi?le.slice(0,Wi-Q):le;t.addToken(t,ui,fe?fe+Ie:Ie,Ze,Q+ui.length==_e?Be:"",Ee,dt)}if(Ni>=Wi){le=le.slice(Wi-Q),Q=Wi;break}Q=Ni,Ze=""}le=r.slice(L,L=n[ee++]),fe=Ft(n[ee++],t.cm.options)}}}function Xt(e,t,n){this.line=t,this.rest=xn(t),this.size=this.rest?Dt(Re(this.rest))-n+1:1,this.node=this.text=null,this.hidden=rn(e,t)}function ki(e,t,n){for(var i=[],r,L=t;L<n;L=r){var H=new Xt(e.doc,ut(e.doc,L),L);r=L+H.size,i.push(H)}return i}var Ci=null;function $i(e){Ci?Ci.ops.push(e):e.ownsGroup=Ci={ops:[e],delayedCallbacks:[]}}function Lo(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var i=0;i<e.ops.length;i++){var r=e.ops[i];if(r.cursorActivityHandlers)for(;r.cursorActivityCalled<r.cursorActivityHandlers.length;)r.cursorActivityHandlers[r.cursorActivityCalled++].call(null,r.cm)}}while(n<t.length)}function Io(e,t){var n=e.ownsGroup;if(!n)return;try{Lo(n)}finally{Ci=null,t(n)}}var mr=null;function Ei(e,t){var n=nt(e,t);if(!n.length)return;var i=Array.prototype.slice.call(arguments,2),r;Ci?r=Ci.delayedCallbacks:mr?r=mr:(r=mr=[],setTimeout(Do,0));for(var L=function($){r.push(function(){return n[$].apply(null,i)})},H=0;H<n.length;++H)L(H)}function Do(){var e=mr;mr=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,n,i){for(var r=0;r<t.changes.length;r++){var L=t.changes[r];L=="text"?Mo(e,t):L=="gutter"?Qa(e,t,n,i):L=="class"?ha(e,t):L=="widget"&&Po(e,t,i)}t.changes=null}function gr(e){return e.node==e.text&&(e.node=u("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),G&&j<8&&(e.node.style.zIndex=2)),e.node}function ko(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var i=gr(t);t.background=i.insertBefore(u("div",null,n),i.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Gt(e,t)}function Mo(e,t){var n=t.text.className,i=$a(e,t);t.text==t.node&&(t.node=i.pre),t.text.parentNode.replaceChild(i.pre,t.text),t.text=i.pre,i.bgClass!=t.bgClass||i.textClass!=t.textClass?(t.bgClass=i.bgClass,t.textClass=i.textClass,ha(e,t)):n&&(t.text.className=n)}function ha(e,t){ko(e,t),t.line.wrapClass?gr(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function Qa(e,t,n,i){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 r=gr(t);t.gutterBackground=u("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),r.insertBefore(t.gutterBackground,t.text)}var L=t.line.gutterMarkers;if(e.options.lineNumbers||L){var H=gr(t),$=t.gutter=u("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(e.display.input.setUneditable($),H.insertBefore($,t.text),t.line.gutterClass&&($.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!L||!L["CodeMirror-linenumbers"])&&(t.lineNumber=$.appendChild(u("div",pn(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),L)for(var Q=0;Q<e.display.gutterSpecs.length;++Q){var ee=e.display.gutterSpecs[Q].className,le=L.hasOwnProperty(ee)&&L[ee];le&&$.appendChild(u("div",[le],"CodeMirror-gutter-elt","left: "+i.gutterLeft[ee]+"px; width: "+i.gutterWidth[ee]+"px"))}}}function Po(e,t,n){t.alignable&&(t.alignable=null);for(var i=A("CodeMirror-linewidget"),r=t.node.firstChild,L=void 0;r;r=L)L=r.nextSibling,i.test(r.className)&&t.node.removeChild(r);Za(e,t,n)}function No(e,t,n,i){var r=$a(e,t);return t.text=t.node=r.pre,r.bgClass&&(t.bgClass=r.bgClass),r.textClass&&(t.textClass=r.textClass),ha(e,t),Qa(e,t,n,i),Za(e,t,i),t.node}function Za(e,t,n){if(Ja(e,t.line,t,n,!0),t.rest)for(var i=0;i<t.rest.length;i++)Ja(e,t.rest[i],t,n,!1)}function Ja(e,t,n,i,r){if(!t.widgets)return;for(var L=gr(n),H=0,$=t.widgets;H<$.length;++H){var Q=$[H],ee=u("div",[Q.node],"CodeMirror-linewidget"+(Q.className?" "+Q.className:""));Q.handleMouseEvents||ee.setAttribute("cm-ignore-events","true"),Uo(Q,ee,n,i),e.display.input.setUneditable(ee),r&&Q.above?L.insertBefore(ee,n.gutter||n.text):L.appendChild(ee),Ei(Q,"redraw")}}function Uo(e,t,n,i){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var r=i.wrapperWidth;t.style.left=i.fixedPos+"px",e.coverGutter||(r-=i.gutterTotalWidth,t.style.paddingLeft=i.gutterTotalWidth+"px"),t.style.width=r+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-i.gutterTotalWidth+"px"))}function vr(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!b(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),y(t.display.measure,u("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function dn(e,t){for(var n=ge(t);n!=e.wrapper;n=n.parentNode)if(!n||n.nodeType==1&&n.getAttribute("cm-ignore-events")=="true"||n.parentNode==e.sizer&&n!=e.mover)return!0}function Hr(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=y(e.measure,u("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,i={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(i.left)&&!isNaN(i.right)&&(e.cachedPaddingH=i),i}function an(e){return ce-e.display.nativeBarWidth}function Pn(e){return e.display.scroller.clientWidth-an(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-an(e)-e.display.barHeight}function Fo(e,t,n){var i=e.options.lineWrapping,r=i&&Pn(e);if(!t.measure.heights||i&&t.measure.width!=r){var L=t.measure.heights=[];if(i){t.measure.width=r;for(var H=t.text.firstChild.getClientRects(),$=0;$<H.length-1;$++){var Q=H[$],ee=H[$+1];Math.abs(Q.bottom-ee.bottom)>2&&L.push((Q.bottom+ee.top)/2-n.top)}}L.push(n.bottom-n.top)}}function es(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var i=0;i<e.rest.length;i++)if(e.rest[i]==t)return{map:e.measure.maps[i],cache:e.measure.caches[i]};for(var r=0;r<e.rest.length;r++)if(Dt(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Bo(e,t){t=Oi(t);var n=Dt(t),i=e.display.externalMeasured=new Xt(e.doc,t,n);i.lineN=n;var r=i.built=Gt(e,i);return i.text=r.pre,y(e.display.lineMeasure,r.pre),i}function ts(e,t,n,i){return sn(e,Yn(e,t),n,i)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Fn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function Yn(e,t){var n=Dt(t),i=fa(e,n);i&&!i.text?i=null:i&&i.changes&&(Ya(e,i,n,_a(e)),e.curOp.forceUpdate=!0),i||(i=Bo(e,t));var r=es(i,t,n);return{line:t,view:i,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function sn(e,t,n,i,r){t.before&&(n=-1);var L=n+(i||""),H;return t.cache.hasOwnProperty(L)?H=t.cache[L]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fo(e,t.view,t.rect),t.hasHeights=!0),H=Ho(e,t,n,i),H.bogus||(t.cache[L]=H)),{left:H.left,right:H.right,top:r?H.rtop:H.top,bottom:r?H.rbottom:H.bottom}}var is={left:0,right:0,top:0,bottom:0};function ns(e,t,n){for(var i,r,L,H,$,Q,ee=0;ee<e.length;ee+=3)if($=e[ee],Q=e[ee+1],t<$?(r=0,L=1,H="left"):t<Q?(r=t-$,L=r+1):(ee==e.length-3||t==Q&&e[ee+3]>t)&&(L=Q-$,r=L-1,t>=Q&&(H="right")),r!=null){if(i=e[ee+2],$==Q&&n==(i.insertLeft?"left":"right")&&(H=n),n=="left"&&r==0)for(;ee&&e[ee-2]==e[ee-3]&&e[ee-1].insertLeft;)i=e[(ee-=3)+2],H="left";if(n=="right"&&r==Q-$)for(;ee<e.length-3&&e[ee+3]==e[ee+4]&&!e[ee+5].insertLeft;)i=e[(ee+=3)+2],H="right";break}return{node:i,start:r,end:L,collapse:H,coverStart:$,coverEnd:Q}}function jo(e,t){var n=is;if(t=="left")for(var i=0;i<e.length&&!((n=e[i]).left!=n.right);i++);else for(var r=e.length-1;r>=0&&!((n=e[r]).left!=n.right);r--);return n}function Ho(e,t,n,i){var r=ns(t.map,n,i),L=r.node,H=r.start,$=r.end,Q=r.collapse,ee;if(L.nodeType==3){for(var le=0;le<4;le++){for(;H&&je(t.line.text.charAt(r.coverStart+H));)--H;for(;r.coverStart+$<r.coverEnd&&je(t.line.text.charAt(r.coverStart+$));)++$;if(G&&j<9&&H==0&&$==r.coverEnd-r.coverStart?ee=L.parentNode.getBoundingClientRect():ee=jo(m(L,H,$).getClientRects(),i),ee.left||ee.right||H==0)break;$=H,H=H-1,Q="right"}G&&j<11&&(ee=Wo(e.display.measure,ee))}else{H>0&&(Q=i="right");var fe;e.options.lineWrapping&&(fe=L.getClientRects()).length>1?ee=fe[i=="right"?fe.length-1:0]:ee=L.getBoundingClientRect()}if(G&&j<9&&!H&&(!ee||!ee.left&&!ee.right)){var Ee=L.parentNode.getClientRects()[0];Ee?ee={left:Ee.left,right:Ee.left+Qn(e.display),top:Ee.top,bottom:Ee.bottom}:ee=is}for(var _e=ee.top-t.rect.top,Ie=ee.bottom-t.rect.top,Be=(_e+Ie)/2,Ze=t.view.measure.heights,at=0;at<Ze.length-1&&!(Be<Ze[at]);at++);var dt=at?Ze[at-1]:0,st=Ze[at],mt={left:(Q=="right"?ee.right:ee.left)-t.rect.left,right:(Q=="left"?ee.left:ee.right)-t.rect.left,top:dt,bottom:st};return!ee.left&&!ee.right&&(mt.bogus=!0),e.options.singleCursorHeightPerLine||(mt.rtop=_e,mt.rbottom=Ie),mt}function Wo(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Nt(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,i=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*i,bottom:t.bottom*i}}function rs(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 as(e){e.display.externalMeasure=null,E(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rs(e.display.view[t])}function yr(e){as(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ss(){return g&&o?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function os(){return g&&o?-(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 n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=vr(e.widgets[n]));return t}function Wr(e,t,n,i,r){if(!r){var L=pa(t);n.top+=L,n.bottom+=L}if(i=="line")return n;i||(i="local");var H=Ji(t);if(i=="local"?H+=Hr(e.display):H-=e.display.viewOffset,i=="page"||i=="window"){var $=e.display.lineSpace.getBoundingClientRect();H+=$.top+(i=="window"?0:os());var Q=$.left+(i=="window"?0:ss());n.left+=Q,n.right+=Q}return n.top+=H,n.bottom+=H,n}function ls(e,t,n){if(n=="div")return t;var i=t.left,r=t.top;if(n=="page")i-=ss(),r-=os();else if(n=="local"||!n){var L=e.display.sizer.getBoundingClientRect();i+=L.left,r+=L.top}var H=e.display.lineSpace.getBoundingClientRect();return{left:i-H.left,top:r-H.top}}function ma(e,t,n,i,r){return i||(i=ut(e.doc,t.line)),Wr(e,i,ts(e,i,t.ch,r),n)}function qi(e,t,n,i,r,L){i=i||ut(e.doc,t.line),r||(r=Yn(e,i));function H(Ie,Be){var Ze=sn(e,r,Ie,Be?"right":"left",L);return Be?Ze.left=Ze.right:Ze.right=Ze.left,Wr(e,i,Ze,n)}var $=Ke(i,e.doc.direction),Q=t.ch,ee=t.sticky;if(Q>=i.text.length?(Q=i.text.length,ee="before"):Q<=0&&(Q=0,ee="after"),!$)return H(ee=="before"?Q-1:Q,ee=="before");function le(Ie,Be,Ze){var at=$[Be],dt=at.level==1;return H(Ze?Ie-1:Ie,dt!=Ze)}var fe=Xe($,Q,ee),Ee=Pe,_e=le(Q,fe,ee=="before");return Ee!=null&&(_e.other=le(Q,Ee,ee!="before")),_e}function us(e,t){var n=0;t=v(e.doc,t),e.options.lineWrapping||(n=Qn(e.display)*t.ch);var i=ut(e.doc,t.line),r=Ji(i)+Hr(e.display);return{left:n,right:n,top:r,bottom:r+i.height}}function ga(e,t,n,i,r){var L=Ge(e,t,n);return L.xRel=r,i&&(L.outside=i),L}function va(e,t,n){var i=e.doc;if(n+=e.display.viewOffset,n<0)return ga(i.first,0,null,-1,-1);var r=Vt(i,n),L=i.first+i.size-1;if(r>L)return ga(i.first+i.size-1,ut(i,L).text.length,null,1,1);t<0&&(t=0);for(var H=ut(i,r);;){var $=Go(e,H,r,t,n),Q=nn(H,$.ch+($.xRel>0||$.outside>0?1:0));if(!Q)return $;var ee=Q.find(1);if(ee.line==r)return ee;H=ut(i,r=ee.line)}}function hs(e,t,n,i){i-=pa(t);var r=t.text.length,L=ht(function(H){return sn(e,n,H-1).bottom<=i},r,0);return r=ht(function(H){return sn(e,n,H).top>i},L,r),{begin:L,end:r}}function ds(e,t,n,i){n||(n=Yn(e,t));var r=Wr(e,t,sn(e,n,i),"line").top;return hs(e,t,n,r)}function ya(e,t,n,i){return e.bottom<=n?!1:e.top>n?!0:(i?e.left:e.right)>t}function Go(e,t,n,i,r){r-=Ji(t);var L=Yn(e,t),H=pa(t),$=0,Q=t.text.length,ee=!0,le=Ke(t,e.doc.direction);if(le){var fe=(e.options.lineWrapping?Ko:zo)(e,t,n,L,le,i,r);ee=fe.level!=1,$=ee?fe.from:fe.to-1,Q=ee?fe.to:fe.from-1}var Ee=null,_e=null,Ie=ht(function(St){var Et=sn(e,L,St);return Et.top+=H,Et.bottom+=H,ya(Et,i,r,!1)?(Et.top<=r&&Et.left<=i&&(Ee=St,_e=Et),!0):!1},$,Q),Be,Ze,at=!1;if(_e){var dt=i-_e.left<_e.right-i,st=dt==ee;Ie=Ee+(st?0:1),Ze=st?"after":"before",Be=dt?_e.left:_e.right}else{!ee&&(Ie==Q||Ie==$)&&Ie++,Ze=Ie==0?"after":Ie==t.text.length?"before":sn(e,L,Ie-(ee?1:0)).bottom+H<=r==ee?"after":"before";var mt=qi(e,Ge(n,Ie,Ze),"line",t,L);Be=mt.left,at=r<mt.top?-1:r>=mt.bottom?1:0}return Ie=Fe(t.text,Ie,1),ga(n,Ie,Ze,at,i-Be)}function zo(e,t,n,i,r,L,H){var $=ht(function(fe){var Ee=r[fe],_e=Ee.level!=1;return ya(qi(e,Ge(n,_e?Ee.to:Ee.from,_e?"before":"after"),"line",t,i),L,H,!0)},0,r.length-1),Q=r[$];if($>0){var ee=Q.level!=1,le=qi(e,Ge(n,ee?Q.from:Q.to,ee?"after":"before"),"line",t,i);ya(le,L,H,!0)&&le.top>H&&(Q=r[$-1])}return Q}function Ko(e,t,n,i,r,L,H){var $=hs(e,t,i,H),Q=$.begin,ee=$.end;/\s/.test(t.text.charAt(ee-1))&&ee--;for(var le=null,fe=null,Ee=0;Ee<r.length;Ee++){var _e=r[Ee];if(_e.from>=ee||_e.to<=Q)continue;var Ie=_e.level!=1,Be=sn(e,i,Ie?Math.min(ee,_e.to)-1:Math.max(Q,_e.from)).right,Ze=Be<L?L-Be+1e9:Be-L;(!le||fe>Ze)&&(le=_e,fe=Ze)}return le||(le=r[r.length-1]),le.from<Q&&(le={from:Q,to:le.to,level:le.level}),le.to>ee&&(le={from:le.from,to:ee,level:le.level}),le}var Nn;function $n(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Nn==null){Nn=u("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Nn.appendChild(document.createTextNode("x")),Nn.appendChild(u("br"));Nn.appendChild(document.createTextNode("x"))}y(e.measure,Nn);var n=Nn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),E(e.measure),n||1}function Qn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=u("span","xxxxxxxxxx"),n=u("pre",[t],"CodeMirror-line-like");y(e.measure,n);var i=t.getBoundingClientRect(),r=(i.right-i.left)/10;return r>2&&(e.cachedCharWidth=r),r||10}function _a(e){for(var t=e.display,n={},i={},r=t.gutters.clientLeft,L=t.gutters.firstChild,H=0;L;L=L.nextSibling,++H){var $=e.display.gutterSpecs[H].className;n[$]=L.offsetLeft+L.clientLeft+r,i[$]=L.clientWidth}return{fixedPos:ba(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:t.wrapper.clientWidth}}function ba(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function cs(e){var t=$n(e.display),n=e.options.lineWrapping,i=n&&Math.max(5,e.display.scroller.clientWidth/Qn(e.display)-3);return function(r){if(rn(e.doc,r))return 0;var L=0;if(r.widgets)for(var H=0;H<r.widgets.length;H++)r.widgets[H].height&&(L+=r.widgets[H].height);return n?L+(Math.ceil(r.text.length/i)||1)*t:L+t}}function Ea(e){var t=e.doc,n=cs(e);t.iter(function(i){var r=n(i);r!=i.height&&Ut(i,r)})}function Un(e,t,n,i){var r=e.display;if(!n&&ge(t).getAttribute("cm-not-content")=="true")return null;var L,H,$=r.lineSpace.getBoundingClientRect();try{L=t.clientX-$.left,H=t.clientY-$.top}catch(fe){return null}var Q=va(e,L,H),ee;if(i&&Q.xRel>0&&(ee=ut(e.doc,Q.line).text).length==Q.ch){var le=Y(ee,ee.length,e.options.tabSize)-ee.length;Q=Ge(Q.line,Math.max(0,Math.round((L-qa(e.display).left)/Qn(e.display))-le))}return Q}function Fn(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var n=e.display.view,i=0;i<n.length;i++)if(t-=n[i].size,t<0)return i}function Mi(e,t,n,i){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),i||(i=0);var r=e.display;if(i&&n<r.viewTo&&(r.updateLineNumbers==null||r.updateLineNumbers>t)&&(r.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=r.viewTo)pi&&cr(e.doc,t)<r.viewTo&&Sn(e);else if(n<=r.viewFrom)pi&&Tn(e.doc,n+i)>r.viewFrom?Sn(e):(r.viewFrom+=i,r.viewTo+=i);else if(t<=r.viewFrom&&n>=r.viewTo)Sn(e);else if(t<=r.viewFrom){var L=Gr(e,n,n+i,1);L?(r.view=r.view.slice(L.index),r.viewFrom=L.lineN,r.viewTo+=i):Sn(e)}else if(n>=r.viewTo){var H=Gr(e,t,t,-1);H?(r.view=r.view.slice(0,H.index),r.viewTo=H.lineN):Sn(e)}else{var $=Gr(e,t,t,-1),Q=Gr(e,n,n+i,1);$&&Q?(r.view=r.view.slice(0,$.index).concat(ki(e,$.lineN,Q.lineN)).concat(r.view.slice(Q.index)),r.viewTo+=i):Sn(e)}var ee=r.externalMeasured;ee&&(n<ee.lineN?ee.lineN+=i:t<ee.lineN+ee.size&&(r.externalMeasured=null))}function wn(e,t,n){e.curOp.viewChanged=!0;var i=e.display,r=e.display.externalMeasured;if(r&&t>=r.lineN&&t<r.lineN+r.size&&(i.externalMeasured=null),t<i.viewFrom||t>=i.viewTo)return;var L=i.view[Fn(e,t)];if(L.node==null)return;var H=L.changes||(L.changes=[]);re(H,n)==-1&&H.push(n)}function Sn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gr(e,t,n,i){var r=Fn(e,t),L,H=e.display.view;if(!pi||n==e.doc.first+e.doc.size)return{index:r,lineN:n};for(var $=e.display.viewFrom,Q=0;Q<r;Q++)$+=H[Q].size;if($!=t){if(i>0){if(r==H.length-1)return null;L=$+H[r].size-t,r++}else L=$-t;t+=L,n+=L}for(;cr(e.doc,n)!=n;){if(r==(i<0?0:H.length-1))return null;n+=i*H[r-(i<0?1:0)].size,r+=i}return{index:r,lineN:n}}function Vo(e,t,n){var i=e.display,r=i.view;r.length==0||t>=i.viewTo||n<=i.viewFrom?(i.view=ki(e,t,n),i.viewFrom=t):(i.viewFrom>t?i.view=ki(e,t,i.viewFrom).concat(i.view):i.viewFrom<t&&(i.view=i.view.slice(Fn(e,t))),i.viewFrom=t,i.viewTo<n?i.view=i.view.concat(ki(e,i.viewTo,n)):i.viewTo>n&&(i.view=i.view.slice(0,Fn(e,n)))),i.viewTo=n}function fs(e){for(var t=e.display.view,n=0,i=0;i<t.length;i++){var r=t[i];!r.hidden&&(!r.node||r.changes)&&++n}return n}function _r(e){e.display.input.showSelection(e.display.input.prepareSelection())}function ps(e,t){t===void 0&&(t=!0);for(var n=e.doc,i={},r=i.cursors=document.createDocumentFragment(),L=i.selection=document.createDocumentFragment(),H=0;H<n.sel.ranges.length;H++){if(!t&&H==n.sel.primIndex)continue;var $=n.sel.ranges[H];if($.from().line>=e.display.viewTo||$.to().line<e.display.viewFrom)continue;var Q=$.empty();(Q||e.options.showCursorWhenSelecting)&&ms(e,$.head,r),Q||Xo(e,$,L)}return i}function ms(e,t,n){var i=qi(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),r=n.appendChild(u("div","\xA0","CodeMirror-cursor"));if(r.style.left=i.left+"px",r.style.top=i.top+"px",r.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other){var L=n.appendChild(u("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));L.style.display="",L.style.left=i.other.left+"px",L.style.top=i.other.top+"px",L.style.height=(i.other.bottom-i.other.top)*.85+"px"}}function zr(e,t){return e.top-t.top||e.left-t.left}function Xo(e,t,n){var i=e.display,r=e.doc,L=document.createDocumentFragment(),H=qa(e.display),$=H.left,Q=Math.max(i.sizerWidth,Pn(e)-i.sizer.offsetLeft)-H.right,ee=r.direction=="ltr";function le(st,mt,St,Et){mt<0&&(mt=0),mt=Math.round(mt),Et=Math.round(Et),L.appendChild(u("div",null,"CodeMirror-selected","position: absolute; left: "+st+`px;
top: `+mt+"px; width: "+(St==null?Q-st:St)+`px;
height: `+(Et-mt)+"px"))}function fe(st,mt,St){var Et=ut(r,st),Pt=Et.text.length,Jt,yi;function ni(ui,Ui){return ma(e,Ge(st,ui),"div",Et,Ui)}function Wi(ui,Ui,xi){var fi=ds(e,Et,null,ui),hi=Ui=="ltr"==(xi=="after")?"left":"right",ai=xi=="after"?fi.begin:fi.end-(/\s/.test(Et.text.charAt(fi.end-1))?2:1);return ni(ai,hi)[hi]}var Ni=Ke(Et,r.direction);return He(Ni,mt||0,St==null?Pt:St,function(ui,Ui,xi,fi){var hi=xi=="ltr",ai=ni(ui,hi?"left":"right"),Fi=ni(Ui-1,hi?"right":"left"),ur=mt==null&&ui==0,In=St==null&&Ui==Pt,Ri=fi==0,on=!Ni||fi==Ni.length-1;if(Fi.top-ai.top<=3){var _i=(ee?ur:In)&&Ri,Va=(ee?In:ur)&&on,fn=_i?$:(hi?ai:Fi).left,Gn=Va?Q:(hi?Fi:ai).right;le(fn,ai.top,Gn-fn,ai.bottom)}else{var zn,Ii,hr,Xa;hi?(zn=ee&&ur&&Ri?$:ai.left,Ii=ee?Q:Wi(ui,xi,"before"),hr=ee?$:Wi(Ui,xi,"after"),Xa=ee&&In&&on?Q:Fi.right):(zn=ee?Wi(ui,xi,"before"):$,Ii=!ee&&ur&&Ri?Q:ai.right,hr=!ee&&In&&on?$:Fi.left,Xa=ee?Wi(Ui,xi,"after"):Q),le(zn,ai.top,Ii-zn,ai.bottom),ai.bottom<Fi.top&&le($,ai.bottom,null,Fi.top),le(hr,Fi.top,Xa-hr,Fi.bottom)}(!Jt||zr(ai,Jt)<0)&&(Jt=ai),zr(Fi,Jt)<0&&(Jt=Fi),(!yi||zr(ai,yi)<0)&&(yi=ai),zr(Fi,yi)<0&&(yi=Fi)}),{start:Jt,end:yi}}var Ee=t.from(),_e=t.to();if(Ee.line==_e.line)fe(Ee.line,Ee.ch,_e.ch);else{var Ie=ut(r,Ee.line),Be=ut(r,_e.line),Ze=Oi(Ie)==Oi(Be),at=fe(Ee.line,Ee.ch,Ze?Ie.text.length+1:null).end,dt=fe(_e.line,Ze?0:null,_e.ch).start;Ze&&(at.top<dt.top-2?(le(at.right,at.top,null,at.bottom),le($,dt.top,dt.left,dt.bottom)):le(at.right,at.top,dt.left-at.right,at.bottom)),at.bottom<dt.top&&le($,at.bottom,null,dt.top)}n.appendChild(L)}function xa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zn(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function gs(e){e.state.focused||(e.display.input.focus(),Ta(e))}function vs(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zn(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Se(e,"focus",e,t),e.state.focused=!0,N(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),M&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),xa(e)}function Zn(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Se(e,"blur",e,t),e.state.focused=!1,T(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kr(e){for(var t=e.display,n=t.lineDiv.offsetTop,i=0;i<t.view.length;i++){var r=t.view[i],L=e.options.lineWrapping,H=void 0,$=0;if(r.hidden)continue;if(G&&j<8){var Q=r.node.offsetTop+r.node.offsetHeight;H=Q-n,n=Q}else{var ee=r.node.getBoundingClientRect();H=ee.bottom-ee.top,!L&&r.text.firstChild&&($=r.text.firstChild.getBoundingClientRect().right-ee.left-1)}var le=r.line.height-H;if((le>.005||le<-.005)&&(Ut(r.line,H),ys(r.line),r.rest))for(var fe=0;fe<r.rest.length;fe++)ys(r.rest[fe]);if($>e.display.sizerWidth){var Ee=Math.ceil($/Qn(e.display));Ee>e.display.maxLineLength&&(e.display.maxLineLength=Ee,e.display.maxLine=r.line,e.display.maxLineChanged=!0)}}}function ys(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],i=n.node.parentNode;i&&(n.height=i.offsetHeight)}}function Vr(e,t,n){var i=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;i=Math.floor(i-Hr(e));var r=n&&n.bottom!=null?n.bottom:i+e.wrapper.clientHeight,L=Vt(t,i),H=Vt(t,r);if(n&&n.ensure){var $=n.ensure.from.line,Q=n.ensure.to.line;$<L?(L=$,H=Vt(t,Ji(ut(t,$))+e.wrapper.clientHeight)):Math.min(Q,t.lastLine())>=H&&(L=Vt(t,Ji(ut(t,Q))-e.wrapper.clientHeight),H=Q)}return{from:L,to:Math.max(H,L+1)}}function Yo(e,t){if(ke(e,"scrollCursorIntoView"))return;var n=e.display,i=n.sizer.getBoundingClientRect(),r=null;if(t.top+i.top<0?r=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1),r!=null&&!a){var L=u("div","\u200B",null,`position: absolute;
top: `+(t.top-n.viewOffset-Hr(e.display))+`px;
height: `+(t.bottom-t.top+an(e)+n.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(L),L.scrollIntoView(r),e.display.lineSpace.removeChild(L)}}function $o(e,t,n,i){i==null&&(i=0);var r;!e.options.lineWrapping&&t==n&&(t=t.ch?Ge(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,n=t.sticky=="before"?Ge(t.line,t.ch+1,"before"):t);for(var L=0;L<5;L++){var H=!1,$=qi(e,t),Q=!n||n==t?$:qi(e,n);r={left:Math.min($.left,Q.left),top:Math.min($.top,Q.top)-i,right:Math.max($.left,Q.left),bottom:Math.max($.bottom,Q.bottom)+i};var ee=wa(e,r),le=e.doc.scrollTop,fe=e.doc.scrollLeft;if(ee.scrollTop!=null&&(Er(e,ee.scrollTop),Math.abs(e.doc.scrollTop-le)>1&&(H=!0)),ee.scrollLeft!=null&&(Bn(e,ee.scrollLeft),Math.abs(e.doc.scrollLeft-fe)>1&&(H=!0)),!H)break}return r}function Qo(e,t){var n=wa(e,t);n.scrollTop!=null&&Er(e,n.scrollTop),n.scrollLeft!=null&&Bn(e,n.scrollLeft)}function wa(e,t){var n=e.display,i=$n(e.display);t.top<0&&(t.top=0);var r=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:n.scroller.scrollTop,L=ca(e),H={};t.bottom-t.top>L&&(t.bottom=t.top+L);var $=e.doc.height+da(n),Q=t.top<i,ee=t.bottom>$-i;if(t.top<r)H.scrollTop=Q?0:t.top;else if(t.bottom>r+L){var le=Math.min(t.top,(ee?$:t.bottom)-L);le!=r&&(H.scrollTop=le)}var fe=e.options.fixedGutter?0:n.gutters.offsetWidth,Ee=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:n.scroller.scrollLeft-fe,_e=Pn(e)-n.gutters.offsetWidth,Ie=t.right-t.left>_e;return Ie&&(t.right=t.left+_e),t.left<10?H.scrollLeft=0:t.left<Ee?H.scrollLeft=Math.max(0,t.left+fe-(Ie?0:10)):t.right>_e+Ee-3&&(H.scrollLeft=t.right+(Ie?0:10)-_e),H}function Sa(e,t){if(t==null)return;Xr(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Jn(e){Xr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function br(e,t,n){(t!=null||n!=null)&&Xr(e),t!=null&&(e.curOp.scrollLeft=t),n!=null&&(e.curOp.scrollTop=n)}function Zo(e,t){Xr(e),e.curOp.scrollToPos=t}function Xr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=us(e,t.from),i=us(e,t.to);_s(e,n,i,t.margin)}}function _s(e,t,n,i){var r=wa(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-i,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+i});br(e,r.scrollLeft,r.scrollTop)}function Er(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;k||Aa(e,{top:t}),bs(e,t,!0),k&&Aa(e),wr(e,100)}function bs(e,t,n){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Bn(e,t,n,i){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!i)return;e.doc.scrollLeft=t,Ss(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function xr(e){var t=e.display,n=t.gutters.offsetWidth,i=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?n:0,docHeight:i,scrollHeight:i+an(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var jn=function(e,t,n){this.cm=n;var i=this.vert=u("div",[u("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r=this.horiz=u("div",[u("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");i.tabIndex=r.tabIndex=-1,e(i),e(r),Ae(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Ae(r,"scroll",function(){r.clientWidth&&t(r.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,G&&j<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};jn.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,i=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?i+"px":"0";var r=e.viewHeight-(t?i:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+r)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?i+"px":"0",this.horiz.style.left=e.barLeft+"px";var L=e.viewWidth-e.barLeft-(n?i:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+L)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(i==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?i:0,bottom:t?i:0}},jn.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},jn.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},jn.prototype.zeroWidthHack=function(){var e=l&&!h?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new te,this.disableVert=new te},jn.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto";function i(){var r=e.getBoundingClientRect(),L=n=="vert"?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1);L!=e?e.style.pointerEvents="none":t.set(1e3,i)}t.set(1e3,i)},jn.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Tr=function(){};Tr.prototype.update=function(){return{bottom:0,right:0}},Tr.prototype.setScrollLeft=function(){},Tr.prototype.setScrollTop=function(){},Tr.prototype.clear=function(){};function qn(e,t){t||(t=xr(e));var n=e.display.barWidth,i=e.display.barHeight;Es(e,t);for(var r=0;r<4&&n!=e.display.barWidth||i!=e.display.barHeight;r++)n!=e.display.barWidth&&e.options.lineWrapping&&Kr(e),Es(e,xr(e)),n=e.display.barWidth,i=e.display.barHeight}function Es(e,t){var n=e.display,i=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px",n.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=i.bottom+"px",n.scrollbarFiller.style.width=i.right+"px"):n.scrollbarFiller.style.display="",i.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}var xs={native:jn,null:Tr};function Ts(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&T(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new xs[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ae(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){n=="horizontal"?Bn(e,t):Er(e,t)},e),e.display.scrollbars.addClass&&N(e.display.wrapper,e.display.scrollbars.addClass)}var Jo=0;function Hn(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:++Jo},$i(e.curOp)}function Wn(e){var t=e.curOp;t&&Io(t,function(n){for(var i=0;i<n.ops.length;i++)n.ops[i].cm.curOp=null;qo(n)})}function qo(e){for(var t=e.ops,n=0;n<t.length;n++)el(t[n]);for(var i=0;i<t.length;i++)tl(t[i]);for(var r=0;r<t.length;r++)il(t[r]);for(var L=0;L<t.length;L++)nl(t[L]);for(var H=0;H<t.length;H++)rl(t[H])}function el(e){var t=e.cm,n=t.display;sl(t),e.updateMaxLine&&jr(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Ca(e.cm,e.update)}function il(e){var t=e.cm,n=t.display;e.updatedDisplay&&Kr(t),e.barMeasure=xr(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=ts(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+an(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Pn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function nl(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Bn(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==P();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&qn(t,e.barMeasure),e.updatedDisplay&&Oa(t,e.barMeasure),e.selectionChanged&&xa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&gs(e.cm)}function rl(e){var t=e.cm,n=t.display,i=t.doc;if(e.updatedDisplay&&ws(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null),e.scrollTop!=null&&bs(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Bn(t,e.scrollLeft,!0,!0),e.scrollToPos){var r=$o(t,v(i,e.scrollToPos.from),v(i,e.scrollToPos.to),e.scrollToPos.margin);Yo(t,r)}var L=e.maybeHiddenMarkers,H=e.maybeUnhiddenMarkers;if(L)for(var $=0;$<L.length;++$)L[$].lines.length||Se(L[$],"hide");if(H)for(var Q=0;Q<H.length;++Q)H[Q].lines.length&&Se(H[Q],"unhide");n.wrapper.offsetHeight&&(i.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Se(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Hi(e,t){if(e.curOp)return t();Hn(e);try{return t()}finally{Wn(e)}}function gi(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Hn(e);try{return t.apply(e,arguments)}finally{Wn(e)}}}function Li(e){return function(){if(this.curOp)return e.apply(this,arguments);Hn(this);try{return e.apply(this,arguments)}finally{Wn(this)}}}function vi(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Hn(t);try{return e.apply(this,arguments)}finally{Wn(t)}}}function wr(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,B(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var n=+new Date+e.options.workTime,i=it(e,t.highlightFrontier),r=[];t.iter(i.line,Math.min(t.first+t.size,e.display.viewTo+500),function(L){if(i.line>=e.display.viewFrom){var H=L.styles,$=L.text.length>e.options.maxHighlightLength?ei(t.mode,i.state):null,Q=pe(e,L,i,!0);$&&(i.state=$),L.styles=Q.styles;var ee=L.styleClasses,le=Q.classes;le?L.styleClasses=le:ee&&(L.styleClasses=null);for(var fe=!H||H.length!=L.styles.length||ee!=le&&(!ee||!le||ee.bgClass!=le.bgClass||ee.textClass!=le.textClass),Ee=0;!fe&&Ee<H.length;++Ee)fe=H[Ee]!=L.styles[Ee];fe&&r.push(i.line),L.stateAfter=i.save(),i.nextLine()}else L.text.length<=e.options.maxHighlightLength&&gt(e,L.text,i),L.stateAfter=i.line%5==0?i.save():null,i.nextLine();if(+new Date>n)return wr(e,e.options.workDelay),!0}),t.highlightFrontier=i.line,t.modeFrontier=Math.max(t.modeFrontier,i.line),r.length&&Hi(e,function(){for(var L=0;L<r.length;L++)wn(e,r[L],"text")})}var Yr=function(e,t,n){var i=e.display;this.viewport=t,this.visible=Vr(i,e.doc,t),this.editorIsHidden=!i.wrapper.offsetWidth,this.wrapperHeight=i.wrapper.clientHeight,this.wrapperWidth=i.wrapper.clientWidth,this.oldDisplayWidth=Pn(e),this.force=n,this.dims=_a(e),this.events=[]};Yr.prototype.signal=function(e,t){he(e,t)&&this.events.push(arguments)},Yr.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Se.apply(null,this.events[e])};function sl(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=an(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=an(e)+"px",t.scrollbarsClipped=!0)}function ol(e){if(e.hasFocus())return null;var t=P();if(!t||!b(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var i=window.getSelection();i.anchorNode&&i.extend&&b(e.display.lineDiv,i.anchorNode)&&(n.anchorNode=i.anchorNode,n.anchorOffset=i.anchorOffset,n.focusNode=i.focusNode,n.focusOffset=i.focusOffset)}return n}function ll(e){if(!e||!e.activeElt||e.activeElt==P())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&b(document.body,e.anchorNode)&&b(document.body,e.focusNode)){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}function Ca(e,t){var n=e.display,i=e.doc;if(t.editorIsHidden)return Sn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&fs(e)==0)return!1;Cs(e)&&(Sn(e),t.dims=_a(e));var r=i.first+i.size,L=Math.max(t.visible.from-e.options.viewportMargin,i.first),H=Math.min(r,t.visible.to+e.options.viewportMargin);n.viewFrom<L&&L-n.viewFrom<20&&(L=Math.max(i.first,n.viewFrom)),n.viewTo>H&&n.viewTo-H<20&&(H=Math.min(r,n.viewTo)),pi&&(L=cr(e.doc,L),H=Tn(e.doc,H));var $=L!=n.viewFrom||H!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Vo(e,L,H),n.viewOffset=Ji(ut(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var Q=fs(e);if(!$&&Q==0&&!t.force&&n.renderedView==n.view&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var ee=ol(e);return Q>4&&(n.lineDiv.style.display="none"),ul(e,n.updateLineNumbers,t.dims),Q>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,ll(ee),E(n.cursorDiv),E(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,$&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,wr(e,400)),n.updateLineNumbers=null,!0}function ws(e,t){for(var n=t.viewport,i=!0;;i=!1){if(!i||!e.options.lineWrapping||t.oldDisplayWidth==Pn(e)){if(n&&n.top!=null&&(n={top:Math.min(e.doc.height+da(e.display)-ca(e),n.top)}),t.visible=Vr(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else i&&(t.visible=Vr(e.display,e.doc,n));if(!Ca(e,t))break;Kr(e);var r=xr(e);_r(e),qn(e,r),Oa(e,r),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Aa(e,t){var n=new Yr(e,t);if(Ca(e,n)){Kr(e),ws(e,n);var i=xr(e);_r(e),qn(e,i),Oa(e,i),n.finish()}}function ul(e,t,n){var i=e.display,r=e.options.lineNumbers,L=i.lineDiv,H=L.firstChild;function $(Ie){var Be=Ie.nextSibling;return M&&l&&e.display.currentWheelTarget==Ie?Ie.style.display="none":Ie.parentNode.removeChild(Ie),Be}for(var Q=i.view,ee=i.viewFrom,le=0;le<Q.length;le++){var fe=Q[le];if(!fe.hidden)if(!fe.node||fe.node.parentNode!=L){var Ee=No(e,fe,ee,n);L.insertBefore(Ee,H)}else{for(;H!=fe.node;)H=$(H);var _e=r&&t!=null&&t<=ee&&fe.lineNumber;fe.changes&&(re(fe.changes,"gutter")>-1&&(_e=!1),Ya(e,fe,ee,n)),_e&&(E(fe.lineNumber),fe.lineNumber.appendChild(document.createTextNode(pn(e.options,ee)))),H=fe.node.nextSibling}ee+=fe.size}for(;H;)H=$(H)}function Ra(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Oa(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+an(e)+"px"}function Ss(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var i=ba(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,L=i+"px",H=0;H<n.length;H++)if(!n[H].hidden){e.options.fixedGutter&&(n[H].gutter&&(n[H].gutter.style.left=L),n[H].gutterBackground&&(n[H].gutterBackground.style.left=L));var $=n[H].alignable;if($)for(var Q=0;Q<$.length;Q++)$[Q].style.left=L}e.options.fixedGutter&&(t.gutters.style.left=i+r+"px")}function Cs(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=pn(e.options,t.first+t.size-1),i=e.display;if(n.length!=i.lineNumChars){var r=i.measure.appendChild(u("div",[u("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),L=r.firstChild.offsetWidth,H=r.offsetWidth-L;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(L,i.lineGutter.offsetWidth-H)+1,i.lineNumWidth=i.lineNumInnerWidth+H,i.lineNumChars=i.lineNumInnerWidth?n.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",Ra(e.display),!0}return!1}function La(e,t){for(var n=[],i=!1,r=0;r<e.length;r++){var L=e[r],H=null;if(typeof L!="string"&&(H=L.style,L=L.className),L=="CodeMirror-linenumbers")if(t)i=!0;else continue;n.push({className:L,style:H})}return t&&!i&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function As(e){var t=e.gutters,n=e.gutterSpecs;E(t),e.lineGutter=null;for(var i=0;i<n.length;++i){var r=n[i],L=r.className,H=r.style,$=t.appendChild(u("div",null,"CodeMirror-gutter "+L));H&&($.style.cssText=H),L=="CodeMirror-linenumbers"&&(e.lineGutter=$,$.style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",Ra(e)}function Sr(e){As(e.display),Mi(e),Ss(e)}function hl(e,t,n,i){var r=this;this.input=n,r.scrollbarFiller=u("div",null,"CodeMirror-scrollbar-filler"),r.scrollbarFiller.setAttribute("cm-not-content","true"),r.gutterFiller=u("div",null,"CodeMirror-gutter-filler"),r.gutterFiller.setAttribute("cm-not-content","true"),r.lineDiv=_("div",null,"CodeMirror-code"),r.selectionDiv=u("div",null,null,"position: relative; z-index: 1"),r.cursorDiv=u("div",null,"CodeMirror-cursors"),r.measure=u("div",null,"CodeMirror-measure"),r.lineMeasure=u("div",null,"CodeMirror-measure"),r.lineSpace=_("div",[r.measure,r.lineMeasure,r.selectionDiv,r.cursorDiv,r.lineDiv],null,"position: relative; outline: none");var L=_("div",[r.lineSpace],"CodeMirror-lines");r.mover=u("div",[L],null,"position: relative"),r.sizer=u("div",[r.mover],"CodeMirror-sizer"),r.sizerWidth=null,r.heightForcer=u("div",null,null,"position: absolute; height: "+ce+"px; width: 1px;"),r.gutters=u("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=u("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=u("div",[r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),G&&j<8&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),!M&&!(k&&s)&&(r.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(r.wrapper):e(r.wrapper)),r.viewFrom=r.viewTo=t.first,r.reportedViewFrom=r.reportedViewTo=t.first,r.view=[],r.renderedView=null,r.externalMeasured=null,r.viewOffset=0,r.lastWrapHeight=r.lastWrapWidth=0,r.updateLineNumbers=null,r.nativeBarWidth=r.barHeight=r.barWidth=0,r.scrollbarsClipped=!1,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.alignWidgets=!1,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1,r.selForContextMenu=null,r.activeTouch=null,r.gutterSpecs=La(i.gutters,i.lineNumbers),As(r),n.init(r)}var $r=0,Ki=null;G?Ki=-.53:k?Ki=15:g?Ki=-.7:f&&(Ki=-1/3);function Rs(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),n==null&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:n==null&&(n=e.wheelDelta),{x:t,y:n}}function dl(e){var t=Rs(e);return t.x*=Ki,t.y*=Ki,t}function Os(e,t){var n=Rs(t),i=n.x,r=n.y,L=e.display,H=L.scroller,$=H.scrollWidth>H.clientWidth,Q=H.scrollHeight>H.clientHeight;if(!(i&&$||r&&Q))return;if(r&&l&&M){e:for(var ee=t.target,le=L.view;ee!=H;ee=ee.parentNode)for(var fe=0;fe<le.length;fe++)if(le[fe].node==ee){e.display.currentWheelTarget=ee;break e}}if(i&&!k&&!p&&Ki!=null){r&&Q&&Er(e,Math.max(0,H.scrollTop+r*Ki)),Bn(e,Math.max(0,H.scrollLeft+i*Ki)),(!r||r&&Q)&&ie(t),L.wheelStartX=null;return}if(r&&Ki!=null){var Ee=r*Ki,_e=e.doc.scrollTop,Ie=_e+L.wrapper.clientHeight;Ee<0?_e=Math.max(0,_e+Ee-50):Ie=Math.min(e.doc.height,Ie+Ee+50),Aa(e,{top:_e,bottom:Ie})}$r<20&&(L.wheelStartX==null?(L.wheelStartX=H.scrollLeft,L.wheelStartY=H.scrollTop,L.wheelDX=i,L.wheelDY=r,setTimeout(function(){if(L.wheelStartX==null)return;var Be=H.scrollLeft-L.wheelStartX,Ze=H.scrollTop-L.wheelStartY,at=Ze&&L.wheelDY&&Ze/L.wheelDY||Be&&L.wheelDX&&Be/L.wheelDX;if(L.wheelStartX=L.wheelStartY=null,!at)return;Ki=(Ki*$r+at)/($r+1),++$r},200)):(L.wheelDX+=i,L.wheelDY+=r))}var Vi=function(e,t){this.ranges=e,this.primIndex=t};Vi.prototype.primary=function(){return this.ranges[this.primIndex]},Vi.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],i=e.ranges[t];if(!mn(n.anchor,i.anchor)||!mn(n.head,i.head))return!1}return!0},Vi.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Yt(gn(this.ranges[t].anchor),gn(this.ranges[t].head));return new Vi(e,this.primIndex)},Vi.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Vi.prototype.contains=function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var i=this.ranges[n];if(Ot(t,i.from())>=0&&Ot(e,i.to())<=0)return n}return-1};var Yt=function(e,t){this.anchor=e,this.head=t};Yt.prototype.from=function(){return yn(this.anchor,this.head)},Yt.prototype.to=function(){return vn(this.anchor,this.head)},Yt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function en(e,t,n){var i=e&&e.options.selectionsMayTouch,r=t[n];t.sort(function(Ee,_e){return Ot(Ee.from(),_e.from())}),n=re(t,r);for(var L=1;L<t.length;L++){var H=t[L],$=t[L-1],Q=Ot($.to(),H.from());if(i&&!H.empty()?Q>0:Q>=0){var ee=yn($.from(),H.from()),le=vn($.to(),H.to()),fe=$.empty()?H.from()==H.head:$.from()==$.head;L<=n&&--n,t.splice(--L,2,new Yt(fe?le:ee,fe?ee:le))}}return new Vi(t,n)}function Cn(e,t){return new Vi([new Yt(e,t||e)],0)}function An(e){return e.text?Ge(e.from.line+e.text.length-1,Re(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ls(e,t){if(Ot(e,t.from)<0)return e;if(Ot(e,t.to)<=0)return An(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,i=e.ch;return e.line==t.to.line&&(i+=An(t).ch-t.to.ch),Ge(n,i)}function Ia(e,t){for(var n=[],i=0;i<e.sel.ranges.length;i++){var r=e.sel.ranges[i];n.push(new Yt(Ls(r.anchor,t),Ls(r.head,t)))}return en(e.cm,n,e.sel.primIndex)}function Is(e,t,n){return e.line==t.line?Ge(n.line,e.ch-t.ch+n.ch):Ge(n.line+(e.line-t.line),e.ch)}function cl(e,t,n){for(var i=[],r=Ge(e.first,0),L=r,H=0;H<t.length;H++){var $=t[H],Q=Is($.from,r,L),ee=Is(An($),r,L);if(r=$.to,L=ee,n=="around"){var le=e.sel.ranges[H],fe=Ot(le.head,le.anchor)<0;i[H]=new Yt(fe?ee:Q,fe?Q:ee)}else i[H]=new Yt(Q,Q)}return new Vi(i,e.sel.primIndex)}function Da(e){e.doc.mode=bt(e.options,e.doc.modeOption),Cr(e)}function Cr(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,wr(e,100),e.state.modeGen++,e.curOp&&Mi(e)}function Ds(e,t){return t.from.ch==0&&t.to.ch==0&&Re(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function ka(e,t,n,i){function r(dt){return n?n[dt]:null}function L(dt,st,mt){ua(dt,st,mt,i),Ei(dt,"change",dt,t)}function H(dt,st){for(var mt=[],St=dt;St<st;++St)mt.push(new Mn(ee[St],r(St),i));return mt}var $=t.from,Q=t.to,ee=t.text,le=ut(e,$.line),fe=ut(e,Q.line),Ee=Re(ee),_e=r(ee.length-1),Ie=Q.line-$.line;if(t.full)e.insert(0,H(0,ee.length)),e.remove(ee.length,e.size-ee.length);else if(Ds(e,t)){var Be=H(0,ee.length-1);L(fe,fe.text,_e),Ie&&e.remove($.line,Ie),Be.length&&e.insert($.line,Be)}else if(le==fe)if(ee.length==1)L(le,le.text.slice(0,$.ch)+Ee+le.text.slice(Q.ch),_e);else{var Ze=H(1,ee.length-1);Ze.push(new Mn(Ee+le.text.slice(Q.ch),_e,i)),L(le,le.text.slice(0,$.ch)+ee[0],r(0)),e.insert($.line+1,Ze)}else if(ee.length==1)L(le,le.text.slice(0,$.ch)+ee[0]+fe.text.slice(Q.ch),r(0)),e.remove($.line+1,Ie);else{L(le,le.text.slice(0,$.ch)+ee[0],r(0)),L(fe,Ee+fe.text.slice(Q.ch),_e);var at=H(1,ee.length-1);Ie>1&&e.remove($.line+1,Ie-1),e.insert($.line+1,at)}Ei(e,"change",e,t)}function Rn(e,t,n){function i(r,L,H){if(r.linked)for(var $=0;$<r.linked.length;++$){var Q=r.linked[$];if(Q.doc==L)continue;var ee=H&&Q.sharedHist;if(n&&!ee)continue;t(Q.doc,ee),i(Q.doc,r,ee)}}i(e,null,!0)}function ks(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Da(e),Ms(e),e.options.lineWrapping||jr(e),e.options.mode=t.modeOption,Mi(e)}function Ms(e){(e.doc.direction=="rtl"?N:T)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Hi(e,function(){Ms(e),Mi(e)})}function Qr(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var n={from:gn(t.from),to:An(t),text:ti(e,t.from,t.to)};return Us(e,n,t.from.line,t.to.line+1),Rn(e,function(i){return Us(i,n,t.from.line,t.to.line+1)},!0),n}function Ps(e){for(;e.length;){var t=Re(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return Ps(e.done),Re(e.done);if(e.done.length&&!Re(e.done).ranges)return Re(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Re(e.done)}function Ns(e,t,n,i){var r=e.history;r.undone.length=0;var L=+new Date,H,$;if((r.lastOp==i||r.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&r.lastModTime>L-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(H=pl(r,r.lastOp==i)))$=Re(H.changes),Ot(t.from,t.to)==0&&Ot(t.from,$.to)==0?$.to=An(t):H.changes.push(Ma(e,t));else{var Q=Re(r.done);for((!Q||!Q.ranges)&&Zr(e.sel,r.done),H={changes:[Ma(e,t)],generation:r.generation},r.done.push(H);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=L,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=t.origin,$||Se(e,"historyAdded")}function ml(e,t,n,i){var r=t.charAt(0);return r=="*"||r=="+"&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,n,i){var r=e.history,L=i&&i.origin;n==r.lastSelOp||L&&r.lastSelOrigin==L&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==L||ml(e,L,Re(r.done),t))?r.done[r.done.length-1]=t:Zr(t,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=L,r.lastSelOp=n,i&&i.clearRedo!==!1&&Ps(r.undone)}function Zr(e,t){var n=Re(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Us(e,t,n,i){var r=t["spans_"+e.id],L=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,i),function(H){H.markedSpans&&((r||(r=t["spans_"+e.id]={}))[L]=H.markedSpans),++L})}function vl(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function yl(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var i=[],r=0;r<t.text.length;++r)i.push(vl(n[r]));return i}function Fs(e,t){var n=yl(e,t),i=Zi(e,t);if(!n)return i;if(!i)return n;for(var r=0;r<n.length;++r){var L=n[r],H=i[r];if(L&&H){e:for(var $=0;$<H.length;++$){for(var Q=H[$],ee=0;ee<L.length;++ee)if(L[ee].marker==Q.marker)continue e;L.push(Q)}}else H&&(n[r]=H)}return n}function er(e,t,n){for(var i=[],r=0;r<e.length;++r){var L=e[r];if(L.ranges){i.push(n?Vi.prototype.deepCopy.call(L):L);continue}var H=L.changes,$=[];i.push({changes:$});for(var Q=0;Q<H.length;++Q){var ee=H[Q],le=void 0;if($.push({from:ee.from,to:ee.to,text:ee.text}),t)for(var fe in ee)(le=fe.match(/^spans_(\d+)$/))&&(re(t,Number(le[1]))>-1&&(Re($)[fe]=ee[fe],delete ee[fe]))}}return i}function Pa(e,t,n,i){if(i){var r=e.anchor;if(n){var L=Ot(t,r)<0;L!=Ot(n,r)<0?(r=t,t=n):L!=Ot(t,n)<0&&(t=n)}return new Yt(r,t)}else return new Yt(n||t,t)}function Jr(e,t,n,i,r){r==null&&(r=e.cm&&(e.cm.display.shift||e.extend)),Ai(e,new Vi([Pa(e.sel.primary(),t,n,r)],0),i)}function Bs(e,t,n){for(var i=[],r=e.cm&&(e.cm.display.shift||e.extend),L=0;L<e.sel.ranges.length;L++)i[L]=Pa(e.sel.ranges[L],t[L],null,r);var H=en(e.cm,i,e.sel.primIndex);Ai(e,H,n)}function Na(e,t,n,i){var r=e.sel.ranges.slice(0);r[t]=n,Ai(e,en(e.cm,r,e.sel.primIndex),i)}function js(e,t,n,i){Ai(e,Cn(t,n),i)}function _l(e,t,n){var i={ranges:t.ranges,update:function(r){this.ranges=[];for(var L=0;L<r.length;L++)this.ranges[L]=new Yt(v(e,r[L].anchor),v(e,r[L].head))},origin:n&&n.origin};return Se(e,"beforeSelectionChange",e,i),e.cm&&Se(e.cm,"beforeSelectionChange",e.cm,i),i.ranges!=t.ranges?en(e.cm,i.ranges,i.ranges.length-1):t}function Hs(e,t,n){var i=e.history.done,r=Re(i);r&&r.ranges?(i[i.length-1]=t,qr(e,t,n)):Ai(e,t,n)}function Ai(e,t,n){qr(e,t,n),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function qr(e,t,n){(he(e,"beforeSelectionChange")||e.cm&&he(e.cm,"beforeSelectionChange"))&&(t=_l(e,t,n));var i=n&&n.bias||(Ot(t.primary().head,e.sel.primary().head)<0?-1:1);Ws(e,zs(e,t,i,!0)),!(n&&n.scroll===!1)&&e.cm&&Jn(e.cm)}function Ws(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,me(e.cm)),Ei(e,"cursorActivity",e)}function Gs(e){Ws(e,zs(e,e.sel,null,!1))}function zs(e,t,n,i){for(var r,L=0;L<t.ranges.length;L++){var H=t.ranges[L],$=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[L],Q=ea(e,H.anchor,$&&$.anchor,n,i),ee=ea(e,H.head,$&&$.head,n,i);(r||Q!=H.anchor||ee!=H.head)&&(r||(r=t.ranges.slice(0,L)),r[L]=new Yt(Q,ee))}return r?en(e.cm,r,t.primIndex):t}function tr(e,t,n,i,r){var L=ut(e,t.line);if(L.markedSpans)for(var H=0;H<L.markedSpans.length;++H){var $=L.markedSpans[H],Q=$.marker,ee="selectLeft"in Q?!Q.selectLeft:Q.inclusiveLeft,le="selectRight"in Q?!Q.selectRight:Q.inclusiveRight;if(($.from==null||(ee?$.from<=t.ch:$.from<t.ch))&&($.to==null||(le?$.to>=t.ch:$.to>t.ch))){if(r&&(Se(Q,"beforeCursorEnter"),Q.explicitlyCleared))if(L.markedSpans){--H;continue}else break;if(!Q.atomic)continue;if(n){var fe=Q.find(i<0?1:-1),Ee=void 0;if((i<0?le:ee)&&(fe=Ks(e,fe,-i,fe&&fe.line==t.line?L:null)),fe&&fe.line==t.line&&(Ee=Ot(fe,n))&&(i<0?Ee<0:Ee>0))return tr(e,fe,t,i,r)}var _e=Q.find(i<0?-1:1);return(i<0?ee:le)&&(_e=Ks(e,_e,i,_e.line==t.line?L:null)),_e?tr(e,_e,t,i,r):null}}return t}function ea(e,t,n,i,r){var L=i||1,H=tr(e,t,n,L,r)||!r&&tr(e,t,n,L,!0)||tr(e,t,n,-L,r)||!r&&tr(e,t,n,-L,!0);return H||(e.cantEdit=!0,Ge(e.first,0))}function Ks(e,t,n,i){return n<0&&t.ch==0?t.line>e.first?v(e,Ge(t.line-1)):null:n>0&&t.ch==(i||ut(e,t.line)).text.length?t.line<e.first+e.size-1?Ge(t.line+1,0):null:new Ge(t.line,t.ch+n)}function Vs(e){e.setSelection(Ge(e.firstLine(),0),Ge(e.lastLine()),ye)}function Xs(e,t,n){var i={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return i.canceled=!0}};return n&&(i.update=function(r,L,H,$){r&&(i.from=v(e,r)),L&&(i.to=v(e,L)),H&&(i.text=H),$!==void 0&&(i.origin=$)}),Se(e,"beforeChange",e,i),e.cm&&Se(e.cm,"beforeChange",e.cm,i),i.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:i.from,to:i.to,text:i.text,origin:i.origin}}function ir(e,t,n){if(e.cm){if(!e.cm.curOp)return gi(e.cm,ir)(e,t,n);if(e.cm.state.suppressEdits)return}if((he(e,"beforeChange")||e.cm&&he(e.cm,"beforeChange"))&&(t=Xs(e,t,!0),!t))return;var i=Dn&&!n&&bn(e,t.from,t.to);if(i)for(var r=i.length-1;r>=0;--r)Ys(e,{from:i[r].from,to:i[r].to,text:r?[""]:t.text,origin:t.origin});else Ys(e,t)}function Ys(e,t){if(t.text.length==1&&t.text[0]==""&&Ot(t.from,t.to)==0)return;var n=Ia(e,t);Ns(e,t,n,e.cm?e.cm.curOp.id:NaN),Ar(e,t,n,Zi(e,t));var i=[];Rn(e,function(r,L){!L&&re(i,r.history)==-1&&(Js(r.history,t),i.push(r.history)),Ar(r,t,null,Zi(r,t))})}function ta(e,t,n){var i=e.cm&&e.cm.state.suppressEdits;if(i&&!n)return;for(var r=e.history,L,H=e.sel,$=t=="undo"?r.done:r.undone,Q=t=="undo"?r.undone:r.done,ee=0;ee<$.length&&!(L=$[ee],n?L.ranges&&!L.equals(e.sel):!L.ranges);ee++);if(ee==$.length)return;for(r.lastOrigin=r.lastSelOrigin=null;;)if(L=$.pop(),L.ranges){if(Zr(L,Q),n&&!L.equals(e.sel)){Ai(e,L,{clearRedo:!1});return}H=L}else if(i){$.push(L);return}else break;var le=[];Zr(H,Q),Q.push({changes:le,generation:r.generation}),r.generation=L.generation||++r.maxGeneration;for(var fe=he(e,"beforeChange")||e.cm&&he(e.cm,"beforeChange"),Ee=function(Be){var Ze=L.changes[Be];if(Ze.origin=t,fe&&!Xs(e,Ze,!1))return $.length=0,{};le.push(Ma(e,Ze));var at=Be?Ia(e,Ze):Re($);Ar(e,Ze,at,Fs(e,Ze)),!Be&&e.cm&&e.cm.scrollIntoView({from:Ze.from,to:An(Ze)});var dt=[];Rn(e,function(st,mt){!mt&&re(dt,st.history)==-1&&(Js(st.history,Ze),dt.push(st.history)),Ar(st,Ze,null,Fs(st,Ze))})},_e=L.changes.length-1;_e>=0;--_e){var Ie=Ee(_e);if(Ie)return Ie.v}}function $s(e,t){if(t==0)return;if(e.first+=t,e.sel=new Vi(Ye(e.sel.ranges,function(r){return new Yt(Ge(r.anchor.line+t,r.anchor.ch),Ge(r.head.line+t,r.head.ch))}),e.sel.primIndex),e.cm){Mi(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,i=n.viewFrom;i<n.viewTo;i++)wn(e.cm,i,"gutter")}}function Ar(e,t,n,i){if(e.cm&&!e.cm.curOp)return gi(e.cm,Ar)(e,t,n,i);if(t.to.line<e.first){$s(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 r=t.text.length-1-(e.first-t.from.line);$s(e,r),t={from:Ge(e.first,0),to:Ge(t.to.line+r,t.to.ch),text:[Re(t.text)],origin:t.origin}}var L=e.lastLine();t.to.line>L&&(t={from:t.from,to:Ge(L,ut(e,L).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ti(e,t.from,t.to),n||(n=Ia(e,t)),e.cm?bl(e.cm,t,i):ka(e,t,i),qr(e,n,ye),e.cantEdit&&ea(e,Ge(e.firstLine(),0))&&(e.cantEdit=!1)}function bl(e,t,n){var i=e.doc,r=e.display,L=t.from,H=t.to,$=!1,Q=L.line;e.options.lineWrapping||(Q=Dt(Oi(ut(i,L.line))),i.iter(Q,H.line+1,function(_e){if(_e==r.maxLine)return $=!0,!0})),i.sel.contains(t.from,t.to)>-1&&me(e),ka(i,t,n,cs(e)),e.options.lineWrapping||(i.iter(Q,L.line+t.text.length,function(_e){var Ie=pr(_e);Ie>r.maxLineLength&&(r.maxLine=_e,r.maxLineLength=Ie,r.maxLineChanged=!0,$=!1)}),$&&(e.curOp.updateMaxLine=!0)),Qi(i,L.line),wr(e,400);var ee=t.text.length-(H.line-L.line)-1;t.full?Mi(e):L.line==H.line&&t.text.length==1&&!Ds(e.doc,t)?wn(e,L.line,"text"):Mi(e,L.line,H.line+1,ee);var le=he(e,"changes"),fe=he(e,"change");if(fe||le){var Ee={from:L,to:H,text:t.text,removed:t.removed,origin:t.origin};fe&&Ei(e,"change",e,Ee),le&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Ee)}e.display.selForContextMenu=null}function nr(e,t,n,i,r){var L;i||(i=n),Ot(i,n)<0&&(L=[i,n],n=L[0],i=L[1]),typeof t=="string"&&(t=e.splitLines(t)),ir(e,{from:n,to:i,text:t,origin:r})}function Qs(e,t,n,i){n<e.line?e.line+=i:t<e.line&&(e.line=t,e.ch=0)}function Zs(e,t,n,i){for(var r=0;r<e.length;++r){var L=e[r],H=!0;if(L.ranges){L.copied||(L=e[r]=L.deepCopy(),L.copied=!0);for(var $=0;$<L.ranges.length;$++)Qs(L.ranges[$].anchor,t,n,i),Qs(L.ranges[$].head,t,n,i);continue}for(var Q=0;Q<L.changes.length;++Q){var ee=L.changes[Q];if(n<ee.from.line)ee.from=Ge(ee.from.line+i,ee.from.ch),ee.to=Ge(ee.to.line+i,ee.to.ch);else if(t<=ee.to.line){H=!1;break}}H||(e.splice(0,r+1),r=0)}}function Js(e,t){var n=t.from.line,i=t.to.line,r=t.text.length-(i-n)-1;Zs(e.done,n,i,r),Zs(e.undone,n,i,r)}function Rr(e,t,n,i){var r=t,L=t;return typeof t=="number"?L=ut(e,z(e,t)):r=Dt(t),r==null?null:(i(L,r)&&e.cm&&wn(e.cm,r,n),L)}function Or(e){this.lines=e,this.parent=null;for(var t=0,n=0;n<e.length;++n)e[n].parent=this,t+=e[n].height;this.height=t}Or.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,i=e+t;n<i;++n){var r=this.lines[n];this.height-=r.height,yt(r),Ei(r,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var i=0;i<t.length;++i)t[i].parent=this},iterN:function(e,t,n){for(var i=e+t;e<i;++e)if(n(this.lines[e]))return!0}};function Lr(e){this.children=e;for(var t=0,n=0,i=0;i<e.length;++i){var r=e[i];t+=r.chunkSize(),n+=r.height,r.parent=this}this.size=t,this.height=n,this.parent=null}Lr.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var i=this.children[n],r=i.chunkSize();if(e<r){var L=Math.min(t,r-e),H=i.height;if(i.removeInner(e,L),this.height-=H-i.height,r==L&&(this.children.splice(n--,1),i.parent=null),(t-=L)==0)break;e=0}else e-=r}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Or))){var $=[];this.collapse($),this.children=[new Or($)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var i=0;i<this.children.length;++i){var r=this.children[i],L=r.chunkSize();if(e<=L){if(r.insertInner(e,t,n),r.lines&&r.lines.length>50){for(var H=r.lines.length%25+25,$=H;$<r.lines.length;){var Q=new Or(r.lines.slice($,$+=25));r.height-=Q.height,this.children.splice(++i,0,Q),Q.parent=this}r.lines=r.lines.slice(0,H),this.maybeSpill()}break}e-=L}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Lr(t);if(e.parent){e.size-=n.size,e.height-=n.height;var r=re(e.parent.children,e);e.parent.children.splice(r+1,0,n)}else{var i=new Lr(e.children);i.parent=e,e.children=[i,n],e=i}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var i=0;i<this.children.length;++i){var r=this.children[i],L=r.chunkSize();if(e<L){var H=Math.min(t,L-e);if(r.iterN(e,H,n))return!0;if((t-=H)==0)break;e=0}else e-=L}}};var Ir=function(e,t,n){if(n)for(var i in n)n.hasOwnProperty(i)&&(this[i]=n[i]);this.doc=e,this.node=t};Ir.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,i=Dt(n);if(i==null||!t)return;for(var r=0;r<t.length;++r)t[r]==this&&t.splice(r--,1);t.length||(n.widgets=null);var L=vr(this);Ut(n,Math.max(0,n.height-L)),e&&(Hi(e,function(){qs(e,n,-L),wn(e,i,"widget")}),Ei(e,"lineWidgetCleared",e,this,i))},Ir.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,i=this.line;this.height=null;var r=vr(this)-t;if(!r)return;rn(this.doc,i)||Ut(i,i.height+r),n&&Hi(n,function(){n.curOp.forceUpdate=!0,qs(n,i,r),Ei(n,"lineWidgetChanged",n,e,Dt(i))})},de(Ir);function qs(e,t,n){Ji(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Sa(e,n)}function El(e,t,n,i){var r=new Ir(e,n,i),L=e.cm;return L&&r.noHScroll&&(L.display.alignWidgets=!0),Rr(e,t,"widget",function(H){var $=H.widgets||(H.widgets=[]);if(r.insertAt==null?$.push(r):$.splice(Math.min($.length-1,Math.max(0,r.insertAt)),0,r),r.line=H,L&&!rn(e,H)){var Q=Ji(H)<e.scrollTop;Ut(H,H.height+vr(r)),Q&&Sa(L,r.height),L.curOp.forceUpdate=!0}return!0}),L&&Ei(L,"lineWidgetAdded",L,r,typeof t=="number"?t:Dt(t)),r}var eo=0,On=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++eo};On.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Hn(e),he(this,"clear")){var n=this.find();n&&Ei(this,"clear",n.from,n.to)}for(var i=null,r=null,L=0;L<this.lines.length;++L){var H=this.lines[L],$=ji(H.markedSpans,this);e&&!this.collapsed?wn(e,Dt(H),"text"):e&&($.to!=null&&(r=Dt(H)),$.from!=null&&(i=Dt(H))),H.markedSpans=kn(H.markedSpans,$),$.from==null&&this.collapsed&&!rn(this.doc,H)&&e&&Ut(H,$n(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Q=0;Q<this.lines.length;++Q){var ee=Oi(this.lines[Q]),le=pr(ee);le>e.display.maxLineLength&&(e.display.maxLine=ee,e.display.maxLineLength=le,e.display.maxLineChanged=!0)}i!=null&&e&&this.collapsed&&Mi(e,i,r+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Gs(e.doc)),e&&Ei(e,"markerCleared",e,this,i,r),t&&Wn(e),this.parent&&this.parent.clear()},On.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var n,i,r=0;r<this.lines.length;++r){var L=this.lines[r],H=ji(L.markedSpans,this);if(H.from!=null&&(n=Ge(t?L:Dt(L),H.from),e==-1))return n;if(H.to!=null&&(i=Ge(t?L:Dt(L),H.to),e==1))return i}return n&&{from:n,to:i}},On.prototype.changed=function(){var e=this,t=this.find(-1,!0),n=this,i=this.doc.cm;if(!t||!i)return;Hi(i,function(){var r=t.line,L=Dt(t.line),H=fa(i,L);if(H&&(rs(H),i.curOp.selectionChanged=i.curOp.forceUpdate=!0),i.curOp.updateMaxLine=!0,!rn(n.doc,r)&&n.height!=null){var $=n.height;n.height=null;var Q=vr(n)-$;Q&&Ut(r,r.height+Q)}Ei(i,"markerChanged",i,e)})},On.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||re(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},On.prototype.detachLine=function(e){if(this.lines.splice(re(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},de(On);function rr(e,t,n,i,r){if(i&&i.shared)return xl(e,t,n,i,r);if(e.cm&&!e.cm.curOp)return gi(e.cm,rr)(e,t,n,i,r);var L=new On(e,r),H=Ot(t,n);if(i&&S(i,L,!1),H>0||H==0&&L.clearWhenEmpty!==!1)return L;if(L.replacedWith&&(L.collapsed=!0,L.widgetNode=_("span",[L.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||L.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(L.widgetNode.insertLeft=!0)),L.collapsed){if(mi(e,t.line,t,n,L)||t.line!=n.line&&mi(e,n.line,t,n,L))throw new Error("Inserting collapsed marker partially overlapping an existing one");ln()}L.addToHistory&&Ns(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var $=t.line,Q=e.cm,ee;if(e.iter($,n.line+1,function(fe){Q&&L.collapsed&&!Q.options.lineWrapping&&Oi(fe)==Q.display.maxLine&&(ee=!0),L.collapsed&&$!=t.line&&Ut(fe,0),_n(fe,new un(L,$==t.line?t.ch:null,$==n.line?n.ch:null)),++$}),L.collapsed&&e.iter(t.line,n.line+1,function(fe){rn(e,fe)&&Ut(fe,0)}),L.clearOnEnter&&Ae(L,"beforeCursorEnter",function(){return L.clear()}),L.readOnly&&(zi(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),L.collapsed&&(L.id=++eo,L.atomic=!0),Q){if(ee&&(Q.curOp.updateMaxLine=!0),L.collapsed)Mi(Q,t.line,n.line+1);else if(L.className||L.startStyle||L.endStyle||L.css||L.attributes||L.title)for(var le=t.line;le<=n.line;le++)wn(Q,le,"text");L.atomic&&Gs(Q.doc),Ei(Q,"markerAdded",Q,L)}return L}var Dr=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};Dr.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Ei(this,"clear")},Dr.prototype.find=function(e,t){return this.primary.find(e,t)},de(Dr);function xl(e,t,n,i,r){i=S(i),i.shared=!1;var L=[rr(e,t,n,i,r)],H=L[0],$=i.widgetNode;return Rn(e,function(Q){$&&(i.widgetNode=$.cloneNode(!0)),L.push(rr(Q,v(Q,t),v(Q,n),i,r));for(var ee=0;ee<Q.linked.length;++ee)if(Q.linked[ee].isParent)return;H=Re(L)}),new Dr(L,H)}function to(e){return e.findMarks(Ge(e.first,0),e.clipPos(Ge(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var n=0;n<t.length;n++){var i=t[n],r=i.find(),L=e.clipPos(r.from),H=e.clipPos(r.to);if(Ot(L,H)){var $=rr(e,L,H,i.primary,i.primary.type);i.markers.push($),$.parent=i}}}function wl(e){for(var t=function(i){var r=e[i],L=[r.primary.doc];Rn(r.primary.doc,function(Q){return L.push(Q)});for(var H=0;H<r.markers.length;H++){var $=r.markers[H];re(L,$.doc)==-1&&($.parent=null,r.markers.splice(H--,1))}},n=0;n<e.length;n++)t(n)}var Sl=0,Pi=function(e,t,n,i,r){if(!(this instanceof Pi))return new Pi(e,t,n,i,r);n==null&&(n=0),Lr.call(this,[new Or([new Mn("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var L=Ge(n,0);this.sel=Cn(L),this.history=new Qr(null),this.id=++Sl,this.modeOption=t,this.lineSep=i,this.direction=r=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),ka(this,{from:L,to:L,text:e}),Ai(this,Cn(L),ye)};Pi.prototype=ot(Lr.prototype,{constructor:Pi,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,i=0;i<t.length;++i)n+=t[i].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Wt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:vi(function(e){var t=Ge(this.first,0),n=this.first+this.size-1;ir(this,{from:t,to:Ge(n,ut(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&br(this.cm,0,0),Ai(this,Cn(t),ye)}),replaceRange:function(e,t,n,i){t=v(this,t),n=n?v(this,n):t,nr(this,e,t,n,i)},getRange:function(e,t,n){var i=ti(this,v(this,e),v(this,t));return n===!1?i:i.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Ti(this,e))return ut(this,e)},getLineNumber:function(e){return Dt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ut(this,e)),Oi(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return v(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:vi(function(e,t,n){js(this,v(this,typeof e=="number"?Ge(e,t||0):e),null,n)}),setSelection:vi(function(e,t,n){js(this,v(this,e),v(this,t||e),n)}),extendSelection:vi(function(e,t,n){Jr(this,v(this,e),t&&v(this,t),n)}),extendSelections:vi(function(e,t){Bs(this,U(this,e),t)}),extendSelectionsBy:vi(function(e,t){var n=Ye(this.sel.ranges,e);Bs(this,U(this,n),t)}),setSelections:vi(function(e,t,n){if(!e.length)return;for(var i=[],r=0;r<e.length;r++)i[r]=new Yt(v(this,e[r].anchor),v(this,e[r].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Ai(this,en(this.cm,i,t),n)}),addSelection:vi(function(e,t,n){var i=this.sel.ranges.slice(0);i.push(new Yt(v(this,e),v(this,t||e))),Ai(this,en(this.cm,i,i.length-1),n)}),getSelection:function(e){for(var t=this.sel.ranges,n,i=0;i<t.length;i++){var r=ti(this,t[i].from(),t[i].to());n=n?n.concat(r):r}return e===!1?n:n.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,i=0;i<n.length;i++){var r=ti(this,n[i].from(),n[i].to());e!==!1&&(r=r.join(e||this.lineSeparator())),t[i]=r}return t},replaceSelection:function(e,t,n){for(var i=[],r=0;r<this.sel.ranges.length;r++)i[r]=e;this.replaceSelections(i,t,n||"+input")},replaceSelections:vi(function(e,t,n){for(var i=[],r=this.sel,L=0;L<r.ranges.length;L++){var H=r.ranges[L];i[L]={from:H.from(),to:H.to(),text:this.splitLines(e[L]),origin:n}}for(var $=t&&t!="end"&&cl(this,i,t),Q=i.length-1;Q>=0;Q--)ir(this,i[Q]);$?Hs(this,$):this.cm&&Jn(this.cm)}),undo:vi(function(){ta(this,"undo")}),redo:vi(function(){ta(this,"redo")}),undoSelection:vi(function(){ta(this,"undo",!0)}),redoSelection:vi(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,n=0,i=0;i<e.done.length;i++)e.done[i].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){var e=this;this.history=new Qr(this.history.maxGeneration),Rn(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:er(this.history.done),undone:er(this.history.undone)}},setHistory:function(e){var t=this.history=new Qr(this.history.maxGeneration);t.done=er(e.done.slice(0),null,!0),t.undone=er(e.undone.slice(0),null,!0)},setGutterMarker:vi(function(e,t,n){return Rr(this,e,"gutter",function(i){var r=i.gutterMarkers||(i.gutterMarkers={});return r[t]=n,!n&&qe(r)&&(i.gutterMarkers=null),!0})}),clearGutter:vi(function(e){var t=this;this.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&Rr(t,n,"gutter",function(){return n.gutterMarkers[e]=null,qe(n.gutterMarkers)&&(n.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Ti(this,e))return null;if(t=e,e=ut(this,e),!e)return null}else if(t=Dt(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:vi(function(e,t,n){return Rr(this,e,t=="gutter"?"gutter":"class",function(i){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!i[r])i[r]=n;else{if(A(n).test(i[r]))return!1;i[r]+=" "+n}return!0})}),removeLineClass:vi(function(e,t,n){return Rr(this,e,t=="gutter"?"gutter":"class",function(i){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",L=i[r];if(L)if(n==null)i[r]=null;else{var H=L.match(A(n));if(!H)return!1;var $=H.index+H[0].length;i[r]=L.slice(0,H.index)+(!H.index||$==L.length?"":" ")+L.slice($)||null}else return!1;return!0})}),addLineWidget:vi(function(e,t,n){return El(this,e,t,n)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return rr(this,v(this,e),v(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=v(this,e),rr(this,e,e,n,"bookmark")},findMarksAt:function(e){e=v(this,e);var t=[],n=ut(this,e.line).markedSpans;if(n)for(var i=0;i<n.length;++i){var r=n[i];(r.from==null||r.from<=e.ch)&&(r.to==null||r.to>=e.ch)&&t.push(r.marker.parent||r.marker)}return t},findMarks:function(e,t,n){e=v(this,e),t=v(this,t);var i=[],r=e.line;return this.iter(e.line,t.line+1,function(L){var H=L.markedSpans;if(H)for(var $=0;$<H.length;$++){var Q=H[$];!(Q.to!=null&&r==e.line&&e.ch>=Q.to||Q.from==null&&r!=e.line||Q.from!=null&&r==t.line&&Q.from>=t.ch)&&(!n||n(Q.marker))&&i.push(Q.marker.parent||Q.marker)}++r}),i},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var i=0;i<n.length;++i)n[i].from!=null&&e.push(n[i].marker)}),e},posFromIndex:function(e){var t,n=this.first,i=this.lineSeparator().length;return this.iter(function(r){var L=r.text.length+i;if(L>e)return t=e,!0;e-=L,++n}),v(this,Ge(n,t))},indexFromPos:function(e){e=v(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,function(i){t+=i.text.length+n}),t},copy:function(e){var t=new Pi(Wt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var i=new Pi(Wt(this,t,n),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(i.history=this.history),(this.linked||(this.linked=[])).push({doc:i,sharedHist:e.sharedHist}),i.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Tl(i,to(this)),i},unlinkDoc:function(e){if(e instanceof ii&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),wl(to(this));break}if(e.history==this.history){var i=[e.id];Rn(e,function(r){return i.push(r.id)},!0),e.history=new Qr(null),e.history.done=er(this.history.done,i),e.history.undone=er(this.history.undone,i)}},iterLinkedDocs:function(e){Rn(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):xt(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:vi(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)})}),Pi.prototype.eachLine=Pi.prototype.iter;var io=0;function Cl(e){var t=this;if(no(t),ke(t,e)||dn(t.display,e))return;ie(e),G&&(io=+new Date);var n=Un(t,e,!0),i=e.dataTransfer.files;if(!n||t.isReadOnly())return;if(i&&i.length&&window.FileReader&&window.File)for(var r=i.length,L=Array(r),H=0,$=function(){++H==r&&gi(t,function(){n=v(t.doc,n);var _e={from:n,to:n,text:t.doc.splitLines(L.filter(function(Ie){return Ie!=null}).join(t.doc.lineSeparator())),origin:"paste"};ir(t.doc,_e),Hs(t.doc,Cn(v(t.doc,n),v(t.doc,An(_e))))})()},Q=function(_e,Ie){if(t.options.allowDropFileTypes&&re(t.options.allowDropFileTypes,_e.type)==-1){$();return}var Be=new FileReader;Be.onerror=function(){return $()},Be.onload=function(){var Ze=Be.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ze)){$();return}L[Ie]=Ze,$()},Be.readAsText(_e)},ee=0;ee<i.length;ee++)Q(i[ee],ee);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var le=e.dataTransfer.getData("Text");if(le){var fe;if(t.state.draggingText&&!t.state.draggingText.copy&&(fe=t.listSelections()),qr(t.doc,Cn(n,n)),fe)for(var Ee=0;Ee<fe.length;++Ee)nr(t.doc,"",fe[Ee].anchor,fe[Ee].head,"drag");t.replaceSelection(le,"around","paste"),t.display.input.focus()}}catch(_e){}}}function Al(e,t){if(G&&(!e.state.draggingText||+new Date-io<100)){ue(t);return}if(ke(e,t)||dn(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!f){var n=u("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",p&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),p&&n.parentNode.removeChild(n)}}function Rl(e,t){var n=Un(e,t);if(!n)return;var i=document.createDocumentFragment();ms(e,n,i),e.display.dragCursor||(e.display.dragCursor=u("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),y(e.display.dragCursor,i)}function no(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ro(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),n=[],i=0;i<t.length;i++){var r=t[i].CodeMirror;r&&n.push(r)}n.length&&n[0].operation(function(){for(var L=0;L<n.length;L++)e(n[L])})}var ao=!1;function Ol(){if(ao)return;Ll(),ao=!0}function Ll(){var e;Ae(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,ro(Il)},100))}),Ae(window,"blur",function(){return ro(Zn)})}function Il(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Ln={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"},kr=0;kr<10;kr++)Ln[kr+48]=Ln[kr+96]=String(kr);for(var ia=65;ia<=90;ia++)Ln[ia]=String.fromCharCode(ia);for(var Mr=1;Mr<=12;Mr++)Ln[Mr+111]=Ln[Mr+63235]="F"+Mr;var cn={};cn.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"},cn.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"},cn.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"},cn.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"]},cn.default=l?cn.macDefault:cn.pcDefault;function Dl(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,i,r,L,H=0;H<t.length-1;H++){var $=t[H];if(/^(cmd|meta|m)$/i.test($))L=!0;else if(/^a(lt)?$/i.test($))n=!0;else if(/^(c|ctrl|control)$/i.test($))i=!0;else if(/^s(hift)?$/i.test($))r=!0;else throw new Error("Unrecognized modifier name: "+$)}return n&&(e="Alt-"+e),i&&(e="Ctrl-"+e),L&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function kl(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(i=="..."){delete e[n];continue}for(var r=Ye(n.split(" "),Dl),L=0;L<r.length;L++){var H=void 0,$=void 0;L==r.length-1?($=r.join(" "),H=i):($=r.slice(0,L+1).join(" "),H="...");var Q=t[$];if(!Q)t[$]=H;else if(Q!=H)throw new Error("Inconsistent bindings for "+$)}delete e[n]}for(var ee in t)e[ee]=t[ee];return e}function ar(e,t,n,i){t=na(t);var r=t.call?t.call(e,i):t[e];if(r===!1)return"nothing";if(r==="...")return"multi";if(r!=null&&n(r))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return ar(e,t.fallthrough,n,i);for(var L=0;L<t.fallthrough.length;L++){var H=ar(e,t.fallthrough[L],n,i);if(H)return H}}}function so(e){var t=typeof e=="string"?e:Ln[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function oo(e,t,n){var i=e;return t.altKey&&i!="Alt"&&(e="Alt-"+e),(x?t.metaKey:t.ctrlKey)&&i!="Ctrl"&&(e="Ctrl-"+e),(x?t.ctrlKey:t.metaKey)&&i!="Mod"&&(e="Cmd-"+e),!n&&t.shiftKey&&i!="Shift"&&(e="Shift-"+e),e}function lo(e,t){if(p&&e.keyCode==34&&e.char)return!1;var n=Ln[e.keyCode];return n==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(n=e.code),oo(n,e,t))}function na(e){return typeof e=="string"?cn[e]:e}function sr(e,t){for(var n=e.doc.sel.ranges,i=[],r=0;r<n.length;r++){for(var L=t(n[r]);i.length&&Ot(L.from,Re(i).to)<=0;){var H=i.pop();if(Ot(H.from,L.from)<0){L.from=H.from;break}}i.push(L)}Hi(e,function(){for(var $=i.length-1;$>=0;$--)nr(e.doc,"",i[$].from,i[$].to,"+delete");Jn(e)})}function Ua(e,t,n){var i=Fe(e.text,t+n,n);return i<0||i>e.text.length?null:i}function Fa(e,t,n){var i=Ua(e,t.ch,n);return i==null?null:new Ge(t.line,i,n<0?"after":"before")}function Ba(e,t,n,i,r){if(e){t.doc.direction=="rtl"&&(r=-r);var L=Ke(n,t.doc.direction);if(L){var H=r<0?Re(L):L[0],$=r<0==(H.level==1),Q=$?"after":"before",ee;if(H.level>0||t.doc.direction=="rtl"){var le=Yn(t,n);ee=r<0?n.text.length-1:0;var fe=sn(t,le,ee).top;ee=ht(function(Ee){return sn(t,le,Ee).top==fe},r<0==(H.level==1)?H.from:H.to-1,ee),Q=="before"&&(ee=Ua(n,ee,1))}else ee=r<0?H.to:H.from;return new Ge(i,ee,Q)}}return new Ge(i,r<0?n.text.length:0,r<0?"before":"after")}function Ml(e,t,n,i){var r=Ke(t,e.doc.direction);if(!r)return Fa(t,n,i);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var L=Xe(r,n.ch,n.sticky),H=r[L];if(e.doc.direction=="ltr"&&H.level%2==0&&(i>0?H.to>n.ch:H.from<n.ch))return Fa(t,n,i);var $=function(at,dt){return Ua(t,at instanceof Ge?at.ch:at,dt)},Q,ee=function(at){return e.options.lineWrapping?(Q=Q||Yn(e,t),ds(e,t,Q,at)):{begin:0,end:t.text.length}},le=ee(n.sticky=="before"?$(n,-1):n.ch);if(e.doc.direction=="rtl"||H.level==1){var fe=H.level==1==i<0,Ee=$(n,fe?1:-1);if(Ee!=null&&(fe?Ee<=H.to&&Ee<=le.end:Ee>=H.from&&Ee>=le.begin)){var _e=fe?"before":"after";return new Ge(n.line,Ee,_e)}}var Ie=function(at,dt,st){for(var mt=function(Jt,yi){return yi?new Ge(n.line,$(Jt,1),"before"):new Ge(n.line,Jt,"after")};at>=0&&at<r.length;at+=dt){var St=r[at],Et=dt>0==(St.level!=1),Pt=Et?st.begin:$(st.end,-1);if(St.from<=Pt&&Pt<St.to)return mt(Pt,Et);if(Pt=Et?St.from:$(St.to,-1),st.begin<=Pt&&Pt<st.end)return mt(Pt,Et)}},Be=Ie(L+i,i,le);if(Be)return Be;var Ze=i>0?le.end:$(le.begin,-1);return Ze!=null&&!(i>0&&Ze==t.text.length)&&(Be=Ie(i>0?0:r.length-1,i,ee(Ze)),Be)?Be:null}var Pr={selectAll:Vs,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ye)},killLine:function(e){return sr(e,function(t){if(t.empty()){var n=ut(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Ge(t.head.line+1,0)}:{from:t.head,to:Ge(t.head.line,n)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return sr(e,function(t){return{from:Ge(t.from().line,0),to:v(e.doc,Ge(t.to().line+1,0))}})},delLineLeft:function(e){return sr(e,function(t){return{from:Ge(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return sr(e,function(t){var n=e.charCoords(t.head,"div").top+5,i=e.coordsChar({left:0,top:n},"div");return{from:i,to:t.from()}})},delWrappedLineRight:function(e){return sr(e,function(t){var n=e.charCoords(t.head,"div").top+5,i=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:i}})},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(Ge(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ge(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return uo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ho(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Pl(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},we)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},we)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5,i=e.coordsChar({left:0,top:n},"div");return i.ch<e.getLine(i.line).search(/\S/)?ho(e,t.head):i},we)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),i=e.options.tabSize,r=0;r<n.length;r++){var L=n[r].from(),H=Y(e.getLine(L.line),L.ch,i);t.push(oe(i-H%i))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Hi(e,function(){for(var t=e.listSelections(),n=[],i=0;i<t.length;i++){if(!t[i].empty())continue;var r=t[i].head,L=ut(e.doc,r.line).text;if(L){if(r.ch==L.length&&(r=new Ge(r.line,r.ch-1)),r.ch>0)r=new Ge(r.line,r.ch+1),e.replaceRange(L.charAt(r.ch-1)+L.charAt(r.ch-2),Ge(r.line,r.ch-2),r,"+transpose");else if(r.line>e.doc.first){var H=ut(e.doc,r.line-1).text;H&&(r=new Ge(r.line,1),e.replaceRange(L.charAt(0)+e.doc.lineSeparator()+H.charAt(H.length-1),Ge(r.line-1,H.length-1),r,"+transpose"))}}n.push(new Yt(r,r))}e.setSelections(n)})},newlineAndIndent:function(e){return Hi(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var i=0;i<t.length;i++)e.indentLine(t[i].from().line,null,!0);Jn(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function uo(e,t){var n=ut(e.doc,t),i=Oi(n);return i!=n&&(t=Dt(i)),Ba(!0,e,i,t,1)}function Pl(e,t){var n=ut(e.doc,t),i=Xn(n);return i!=n&&(t=Dt(i)),Ba(!0,e,n,t,-1)}function ho(e,t){var n=uo(e,t.line),i=ut(e.doc,n.line),r=Ke(i,e.doc.direction);if(!r||r[0].level==0){var L=Math.max(n.ch,i.text.search(/\S/)),H=t.line==n.line&&t.ch<=L&&t.ch;return Ge(n.line,H?0:L,n.sticky)}return n}function ra(e,t,n){if(typeof t=="string"&&(t=Pr[t],!t))return!1;e.display.input.ensurePolled();var i=e.display.shift,r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),r=t(e)!=Te}finally{e.display.shift=i,e.state.suppressEdits=!1}return r}function Nl(e,t,n){for(var i=0;i<e.state.keyMaps.length;i++){var r=ar(t,e.state.keyMaps[i],n,e);if(r)return r}return e.options.extraKeys&&ar(t,e.options.extraKeys,n,e)||ar(t,e.options.keyMap,n,e)}var Ul=new te;function Nr(e,t,n,i){var r=e.state.keySeq;if(r){if(so(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Ul.set(50,function(){e.state.keySeq==r&&(e.state.keySeq=null,e.display.input.reset())}),co(e,r+" "+t,n,i))return!0}return co(e,t,n,i)}function co(e,t,n,i){var r=Nl(e,t,i);return r=="multi"&&(e.state.keySeq=t),r=="handled"&&Ei(e,"keyHandled",e,t,n),(r=="handled"||r=="multi")&&(ie(n),xa(e)),!!r}function fo(e,t){var n=lo(t,!0);return n?t.shiftKey&&!e.state.keySeq?Nr(e,"Shift-"+n,t,function(i){return ra(e,i,!0)})||Nr(e,n,t,function(i){if(typeof i=="string"?/^go[A-Z]/.test(i):i.motion)return ra(e,i)}):Nr(e,n,t,function(i){return ra(e,i)}):!1}function Fl(e,t,n){return Nr(e,"'"+n+"'",t,function(i){return ra(e,i,!0)})}var ja=null;function po(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=P(),ke(t,e))return;G&&j<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var i=fo(t,e);p&&(ja=i?n:null,!i&&n==88&&!Rt&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),k&&!l&&!i&&n==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Bl(t)}function Bl(e){var t=e.display.lineDiv;N(t,"CodeMirror-crosshair");function n(i){(i.keyCode==18||!i.altKey)&&(T(t,"CodeMirror-crosshair"),Je(document,"keyup",n),Je(document,"mouseover",n))}Ae(document,"keyup",n),Ae(document,"mouseover",n)}function mo(e){e.keyCode==16&&(this.doc.sel.shift=!1),ke(this,e)}function go(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(dn(t.display,e)||ke(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var n=e.keyCode,i=e.charCode;if(p&&n==ja){ja=null,ie(e);return}if(p&&(!e.which||e.which<10)&&fo(t,e))return;var r=String.fromCharCode(i==null?n:i);if(r=="\b")return;if(Fl(t,e,r))return;t.display.input.onKeyPress(e)}var jl=400,Ha=function(e,t,n){this.time=e,this.pos=t,this.button=n};Ha.prototype.compare=function(e,t,n){return this.time+jl>e&&Ot(t,this.pos)==0&&n==this.button};var Ur,Fr;function Hl(e,t){var n=+new Date;return Fr&&Fr.compare(n,e,t)?(Ur=Fr=null,"triple"):Ur&&Ur.compare(n,e,t)?(Fr=new Ha(n,e,t),Ur=null,"double"):(Ur=new Ha(n,e,t),Fr=null,"single")}function vo(e){var t=this,n=t.display;if(ke(t,e)||n.activeTouch&&n.input.supportsTouch())return;if(n.input.ensurePolled(),n.shift=e.shiftKey,dn(n,e)){M||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100));return}if(Wa(t,e))return;var i=Un(t,e),r=Ce(e),L=i?Hl(i,r):"single";if(window.focus(),r==1&&t.state.selectingText&&t.state.selectingText(e),i&&Wl(t,r,i,L,e))return;r==1?i?zl(t,i,L,e):ge(e)==n.scroller&&ie(e):r==2?(i&&Jr(t.doc,i),setTimeout(function(){return n.input.focus()},20)):r==3&&(R?t.display.input.onContextMenu(e):vs(t))}function Wl(e,t,n,i,r){var L="Click";return i=="double"?L="Double"+L:i=="triple"&&(L="Triple"+L),L=(t==1?"Left":t==2?"Middle":"Right")+L,Nr(e,oo(L,r),r,function(H){if(typeof H=="string"&&(H=Pr[H]),!H)return!1;var $=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),$=H(e,n)!=Te}finally{e.state.suppressEdits=!1}return $})}function Gl(e,t,n){var i=e.getOption("configureMouse"),r=i?i(e,t,n):{};if(r.unit==null){var L=d?n.shiftKey&&n.metaKey:n.altKey;r.unit=L?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(r.extend==null||e.doc.extend)&&(r.extend=e.doc.extend||n.shiftKey),r.addNew==null&&(r.addNew=l?n.metaKey:n.ctrlKey),r.moveOnDrag==null&&(r.moveOnDrag=!(l?n.altKey:n.ctrlKey)),r}function zl(e,t,n,i){G?setTimeout(B(gs,e),0):e.curOp.focus=P();var r=Gl(e,n,i),L=e.doc.sel,H;e.options.dragDrop&&Le&&!e.isReadOnly()&&n=="single"&&(H=L.contains(t))>-1&&(Ot((H=L.ranges[H]).from(),t)<0||t.xRel>0)&&(Ot(H.to(),t)>0||t.xRel<0)?Kl(e,i,t,r):Vl(e,i,t,r)}function Kl(e,t,n,i){var r=e.display,L=!1,H=gi(e,function(ee){M&&(r.scroller.draggable=!1),e.state.draggingText=!1,Je(r.wrapper.ownerDocument,"mouseup",H),Je(r.wrapper.ownerDocument,"mousemove",$),Je(r.scroller,"dragstart",Q),Je(r.scroller,"drop",H),L||(ie(ee),i.addNew||Jr(e.doc,n,null,null,i.extend),M&&!f||G&&j==9?setTimeout(function(){r.wrapper.ownerDocument.body.focus({preventScroll:!0}),r.input.focus()},20):r.input.focus())}),$=function(ee){L=L||Math.abs(t.clientX-ee.clientX)+Math.abs(t.clientY-ee.clientY)>=10},Q=function(){return L=!0};M&&(r.scroller.draggable=!0),e.state.draggingText=H,H.copy=!i.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),Ae(r.wrapper.ownerDocument,"mouseup",H),Ae(r.wrapper.ownerDocument,"mousemove",$),Ae(r.scroller,"dragstart",Q),Ae(r.scroller,"drop",H),vs(e),setTimeout(function(){return r.input.focus()},20)}function yo(e,t,n){if(n=="char")return new Yt(t,t);if(n=="word")return e.findWordAt(t);if(n=="line")return new Yt(Ge(t.line,0),v(e.doc,Ge(t.line+1,0)));var i=n(e,t);return new Yt(i.from,i.to)}function Vl(e,t,n,i){var r=e.display,L=e.doc;ie(t);var H,$,Q=L.sel,ee=Q.ranges;if(i.addNew&&!i.extend?($=L.sel.contains(n),$>-1?H=ee[$]:H=new Yt(n,n)):(H=L.sel.primary(),$=L.sel.primIndex),i.unit=="rectangle")i.addNew||(H=new Yt(n,n)),n=Un(e,t,!0,!0),$=-1;else{var le=yo(e,n,i.unit);i.extend?H=Pa(H,le.anchor,le.head,i.extend):H=le}i.addNew?$==-1?($=ee.length,Ai(L,en(e,ee.concat([H]),$),{scroll:!1,origin:"*mouse"})):ee.length>1&&ee[$].empty()&&i.unit=="char"&&!i.extend?(Ai(L,en(e,ee.slice(0,$).concat(ee.slice($+1)),0),{scroll:!1,origin:"*mouse"}),Q=L.sel):Na(L,$,H,be):($=0,Ai(L,new Vi([H],0),be),Q=L.sel);var fe=n;function Ee(st){if(Ot(fe,st)==0)return;if(fe=st,i.unit=="rectangle"){for(var mt=[],St=e.options.tabSize,Et=Y(ut(L,n.line).text,n.ch,St),Pt=Y(ut(L,st.line).text,st.ch,St),Jt=Math.min(Et,Pt),yi=Math.max(Et,Pt),ni=Math.min(n.line,st.line),Wi=Math.min(e.lastLine(),Math.max(n.line,st.line));ni<=Wi;ni++){var Ni=ut(L,ni).text,ui=xe(Ni,Jt,St);Jt==yi?mt.push(new Yt(Ge(ni,ui),Ge(ni,ui))):Ni.length>ui&&mt.push(new Yt(Ge(ni,ui),Ge(ni,xe(Ni,yi,St))))}mt.length||mt.push(new Yt(n,n)),Ai(L,en(e,Q.ranges.slice(0,$).concat(mt),$),{origin:"*mouse",scroll:!1}),e.scrollIntoView(st)}else{var Ui=H,xi=yo(e,st,i.unit),fi=Ui.anchor,hi;Ot(xi.anchor,fi)>0?(hi=xi.head,fi=yn(Ui.from(),xi.anchor)):(hi=xi.anchor,fi=vn(Ui.to(),xi.head));var ai=Q.ranges.slice(0);ai[$]=Xl(e,new Yt(v(L,fi),hi)),Ai(L,en(e,ai,$),be)}}var _e=r.wrapper.getBoundingClientRect(),Ie=0;function Be(st){var mt=++Ie,St=Un(e,st,!0,i.unit=="rectangle");if(!St)return;if(Ot(St,fe)!=0){e.curOp.focus=P(),Ee(St);var Et=Vr(r,L);(St.line>=Et.to||St.line<Et.from)&&setTimeout(gi(e,function(){Ie==mt&&Be(st)}),150)}else{var Pt=st.clientY<_e.top?-20:st.clientY>_e.bottom?20:0;Pt&&setTimeout(gi(e,function(){if(Ie!=mt)return;r.scroller.scrollTop+=Pt,Be(st)}),50)}}function Ze(st){e.state.selectingText=!1,Ie=Infinity,st&&(ie(st),r.input.focus()),Je(r.wrapper.ownerDocument,"mousemove",at),Je(r.wrapper.ownerDocument,"mouseup",dt),L.history.lastSelOrigin=null}var at=gi(e,function(st){st.buttons===0||!Ce(st)?Ze(st):Be(st)}),dt=gi(e,Ze);e.state.selectingText=dt,Ae(r.wrapper.ownerDocument,"mousemove",at),Ae(r.wrapper.ownerDocument,"mouseup",dt)}function Xl(e,t){var n=t.anchor,i=t.head,r=ut(e.doc,n.line);if(Ot(n,i)==0&&n.sticky==i.sticky)return t;var L=Ke(r);if(!L)return t;var H=Xe(L,n.ch,n.sticky),$=L[H];if($.from!=n.ch&&$.to!=n.ch)return t;var Q=H+($.from==n.ch==($.level!=1)?0:1);if(Q==0||Q==L.length)return t;var ee;if(i.line!=n.line)ee=(i.line-n.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var le=Xe(L,i.ch,i.sticky),fe=le-H||(i.ch-n.ch)*($.level==1?-1:1);le==Q-1||le==Q?ee=fe<0:ee=fe>0}var Ee=L[Q+(ee?-1:0)],_e=ee==(Ee.level==1),Ie=_e?Ee.from:Ee.to,Be=_e?"after":"before";return n.ch==Ie&&n.sticky==Be?t:new Yt(new Ge(n.line,Ie,Be),i)}function _o(e,t,n,i){var r,L;if(t.touches)r=t.touches[0].clientX,L=t.touches[0].clientY;else try{r=t.clientX,L=t.clientY}catch(Ee){return!1}if(r>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;i&&ie(t);var H=e.display,$=H.lineDiv.getBoundingClientRect();if(L>$.bottom||!he(e,n))return se(t);L-=$.top-H.viewOffset;for(var Q=0;Q<e.display.gutterSpecs.length;++Q){var ee=H.gutters.childNodes[Q];if(ee&&ee.getBoundingClientRect().right>=r){var le=Vt(e.doc,L),fe=e.display.gutterSpecs[Q];return Se(e,n,e,le,fe.className,t),se(t)}}}function Wa(e,t){return _o(e,t,"gutterClick",!0)}function bo(e,t){if(dn(e.display,t)||Yl(e,t))return;if(ke(e,t,"contextmenu"))return;R||e.display.input.onContextMenu(t)}function Yl(e,t){return he(e,"gutterContextMenu")?_o(e,t,"gutterContextMenu",!1):!1}function Eo(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yr(e)}var or={toString:function(){return"CodeMirror.Init"}},xo={},aa={};function $l(e){var t=e.optionHandlers;function n(i,r,L,H){e.defaults[i]=r,L&&(t[i]=H?function($,Q,ee){ee!=or&&L($,Q,ee)}:L)}e.defineOption=n,e.Init=or,n("value","",function(i,r){return i.setValue(r)},!0),n("mode",null,function(i,r){i.doc.modeOption=r,Da(i)},!0),n("indentUnit",2,Da,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,function(i){Cr(i),yr(i),Mi(i)},!0),n("lineSeparator",null,function(i,r){if(i.doc.lineSep=r,!r)return;var L=[],H=i.doc.first;i.doc.iter(function(Q){for(var ee=0;;){var le=Q.text.indexOf(r,ee);if(le==-1)break;ee=le+r.length,L.push(Ge(H,le))}H++});for(var $=L.length-1;$>=0;$--)nr(i.doc,r,L[$],Ge(L[$].line,L[$].ch+r.length))}),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(i,r,L){i.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),L!=or&&i.refresh()}),n("specialCharPlaceholder",Zt,function(i){return i.refresh()},!0),n("electricChars",!0),n("inputStyle",s?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),n("spellcheck",!1,function(i,r){return i.getInputField().spellcheck=r},!0),n("autocorrect",!1,function(i,r){return i.getInputField().autocorrect=r},!0),n("autocapitalize",!1,function(i,r){return i.getInputField().autocapitalize=r},!0),n("rtlMoveVisually",!O),n("wholeLineUpdateBefore",!0),n("theme","default",function(i){Eo(i),Sr(i)},!0),n("keyMap","default",function(i,r,L){var H=na(r),$=L!=or&&na(L);$&&$.detach&&$.detach(i,H),H.attach&&H.attach(i,$||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Zl,!0),n("gutters",[],function(i,r){i.display.gutterSpecs=La(r,i.options.lineNumbers),Sr(i)},!0),n("fixedGutter",!0,function(i,r){i.display.gutters.style.left=r?ba(i.display)+"px":"0",i.refresh()},!0),n("coverGutterNextToScrollbar",!1,function(i){return qn(i)},!0),n("scrollbarStyle","native",function(i){Ts(i),qn(i),i.display.scrollbars.setScrollTop(i.doc.scrollTop),i.display.scrollbars.setScrollLeft(i.doc.scrollLeft)},!0),n("lineNumbers",!1,function(i,r){i.display.gutterSpecs=La(i.options.gutters,r),Sr(i)},!0),n("firstLineNumber",1,Sr,!0),n("lineNumberFormatter",function(i){return i},Sr,!0),n("showCursorWhenSelecting",!1,_r,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,function(i,r){r=="nocursor"&&(Zn(i),i.display.input.blur()),i.display.input.readOnlyChanged(r)}),n("screenReaderLabel",null,function(i,r){r=r===""?null:r,i.display.input.screenReaderLabelChanged(r)}),n("disableInput",!1,function(i,r){r||i.display.input.reset()},!0),n("dragDrop",!0,Ql),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,_r,!0),n("singleCursorHeightPerLine",!0,_r,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,Cr,!0),n("addModeClass",!1,Cr,!0),n("pollInterval",100),n("undoDepth",200,function(i,r){return i.doc.history.undoDepth=r}),n("historyEventDelay",1250),n("viewportMargin",10,function(i){return i.refresh()},!0),n("maxHighlightLength",1e4,Cr,!0),n("moveInputWithCursor",!0,function(i,r){r||i.display.input.resetPosition()}),n("tabindex",null,function(i,r){return i.display.input.getField().tabIndex=r||""}),n("autofocus",null),n("direction","ltr",function(i,r){return i.doc.setDirection(r)},!0),n("phrases",null)}function Ql(e,t,n){var i=n&&n!=or;if(!t!=!i){var r=e.display.dragFunctions,L=t?Ae:Je;L(e.display.scroller,"dragstart",r.start),L(e.display.scroller,"dragenter",r.enter),L(e.display.scroller,"dragover",r.over),L(e.display.scroller,"dragleave",r.leave),L(e.display.scroller,"drop",r.drop)}}function Zl(e){e.options.lineWrapping?(N(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),jr(e)),Ea(e),Mi(e),yr(e),setTimeout(function(){return qn(e)},100)}function ii(e,t){var n=this;if(!(this instanceof ii))return new ii(e,t);this.options=t=t?S(t):{},S(xo,t,!1);var i=t.value;typeof i=="string"?i=new Pi(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode),this.doc=i;var r=new ii.inputStyles[t.inputStyle](this),L=this.display=new hl(e,i,r,t);L.wrapper.CodeMirror=this,Eo(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ts(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new te,keySeq:null,specialChars:null},t.autofocus&&!s&&L.input.focus(),G&&j<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Jl(this),Ol(),Hn(this),this.curOp.forceUpdate=!0,ks(this,i),t.autofocus&&!s||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&Ta(n)},20):Zn(this);for(var H in aa)aa.hasOwnProperty(H)&&aa[H](this,t[H],or);Cs(this),t.finishInit&&t.finishInit(this);for(var $=0;$<Ga.length;++$)Ga[$](this);Wn(this),M&&t.lineWrapping&&getComputedStyle(L.lineDiv).textRendering=="optimizelegibility"&&(L.lineDiv.style.textRendering="auto")}ii.defaults=xo,ii.optionHandlers=aa;function Jl(e){var t=e.display;Ae(t.scroller,"mousedown",gi(e,vo)),G&&j<11?Ae(t.scroller,"dblclick",gi(e,function(Q){if(ke(e,Q))return;var ee=Un(e,Q);if(!ee||Wa(e,Q)||dn(e.display,Q))return;ie(Q);var le=e.findWordAt(ee);Jr(e.doc,le.anchor,le.head)})):Ae(t.scroller,"dblclick",function(Q){return ke(e,Q)||ie(Q)}),Ae(t.scroller,"contextmenu",function(Q){return bo(e,Q)}),Ae(t.input.getField(),"contextmenu",function(Q){t.scroller.contains(Q.target)||bo(e,Q)});var n,i={end:0};function r(){t.activeTouch&&(n=setTimeout(function(){return t.activeTouch=null},1e3),i=t.activeTouch,i.end=+new Date)}function L(Q){if(Q.touches.length!=1)return!1;var ee=Q.touches[0];return ee.radiusX<=1&&ee.radiusY<=1}function H(Q,ee){if(ee.left==null)return!0;var le=ee.left-Q.left,fe=ee.top-Q.top;return le*le+fe*fe>20*20}Ae(t.scroller,"touchstart",function(Q){if(!ke(e,Q)&&!L(Q)&&!Wa(e,Q)){t.input.ensurePolled(),clearTimeout(n);var ee=+new Date;t.activeTouch={start:ee,moved:!1,prev:ee-i.end<=300?i:null},Q.touches.length==1&&(t.activeTouch.left=Q.touches[0].pageX,t.activeTouch.top=Q.touches[0].pageY)}}),Ae(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ae(t.scroller,"touchend",function(Q){var ee=t.activeTouch;if(ee&&!dn(t,Q)&&ee.left!=null&&!ee.moved&&new Date-ee.start<300){var le=e.coordsChar(t.activeTouch,"page"),fe;!ee.prev||H(ee,ee.prev)?fe=new Yt(le,le):!ee.prev.prev||H(ee,ee.prev.prev)?fe=e.findWordAt(le):fe=new Yt(Ge(le.line,0),v(e.doc,Ge(le.line+1,0))),e.setSelection(fe.anchor,fe.head),e.focus(),ie(Q)}r()}),Ae(t.scroller,"touchcancel",r),Ae(t.scroller,"scroll",function(){t.scroller.clientHeight&&(Er(e,t.scroller.scrollTop),Bn(e,t.scroller.scrollLeft,!0),Se(e,"scroll",e))}),Ae(t.scroller,"mousewheel",function(Q){return Os(e,Q)}),Ae(t.scroller,"DOMMouseScroll",function(Q){return Os(e,Q)}),Ae(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Q){ke(e,Q)||ue(Q)},over:function(Q){ke(e,Q)||(Rl(e,Q),ue(Q))},start:function(Q){return Al(e,Q)},drop:gi(e,Cl),leave:function(Q){ke(e,Q)||no(e)}};var $=t.input.getField();Ae($,"keyup",function(Q){return mo.call(e,Q)}),Ae($,"keydown",gi(e,po)),Ae($,"keypress",gi(e,go)),Ae($,"focus",function(Q){return Ta(e,Q)}),Ae($,"blur",function(Q){return Zn(e,Q)})}var Ga=[];ii.defineInitHook=function(e){return Ga.push(e)};function Br(e,t,n,i){var r=e.doc,L;n==null&&(n="add"),n=="smart"&&(r.mode.indent?L=it(e,t).state:n="prev");var H=e.options.tabSize,$=ut(r,t),Q=Y($.text,null,H);$.stateAfter&&($.stateAfter=null);var ee=$.text.match(/^\s*/)[0],le;if(!i&&!/\S/.test($.text))le=0,n="not";else if(n=="smart"&&(le=r.mode.indent(L,$.text.slice(ee.length),$.text),le==Te||le>150)){if(!i)return;n="prev"}n=="prev"?t>r.first?le=Y(ut(r,t-1).text,null,H):le=0:n=="add"?le=Q+e.options.indentUnit:n=="subtract"?le=Q-e.options.indentUnit:typeof n=="number"&&(le=Q+n),le=Math.max(0,le);var fe="",Ee=0;if(e.options.indentWithTabs)for(var _e=Math.floor(le/H);_e;--_e)Ee+=H,fe+=" ";if(Ee<le&&(fe+=oe(le-Ee)),fe!=ee)return nr(r,fe,Ge(t,0),Ge(t,ee.length),"+input"),$.stateAfter=null,!0;for(var Ie=0;Ie<r.sel.ranges.length;Ie++){var Be=r.sel.ranges[Ie];if(Be.head.line==t&&Be.head.ch<ee.length){var Ze=Ge(t,ee.length);Na(r,Ie,new Yt(Ze,Ze));break}}}var tn=null;function sa(e){tn=e}function za(e,t,n,i,r){var L=e.doc;e.display.shift=!1,i||(i=L.sel);var H=+new Date-200,$=r=="paste"||e.state.pasteIncoming>H,Q=xt(t),ee=null;if($&&i.ranges.length>1)if(tn&&tn.text.join(`
`)==t){if(i.ranges.length%tn.text.length==0){ee=[];for(var le=0;le<tn.text.length;le++)ee.push(L.splitLines(tn.text[le]))}}else Q.length==i.ranges.length&&e.options.pasteLinesPerSelection&&(ee=Ye(Q,function(at){return[at]}));for(var fe=e.curOp.updateInput,Ee=i.ranges.length-1;Ee>=0;Ee--){var _e=i.ranges[Ee],Ie=_e.from(),Be=_e.to();_e.empty()&&(n&&n>0?Ie=Ge(Ie.line,Ie.ch-n):e.state.overwrite&&!$?Be=Ge(Be.line,Math.min(ut(L,Be.line).text.length,Be.ch+Re(Q).length)):$&&tn&&tn.lineWise&&tn.text.join(`
`)==Q.join(`
`)&&(Ie=Be=Ge(Ie.line,0)));var Ze={from:Ie,to:Be,text:ee?ee[Ee%ee.length]:Q,origin:r||($?"paste":e.state.cutIncoming>H?"cut":"+input")};ir(e.doc,Ze),Ei(e,"inputRead",e,Ze)}t&&!$&&wo(e,t),Jn(e),e.curOp.updateInput<2&&(e.curOp.updateInput=fe),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function To(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Hi(t,function(){return za(t,n,0,null,"paste")}),!0}function wo(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var n=e.doc.sel,i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)continue;var L=e.getModeAt(r.head),H=!1;if(L.electricChars){for(var $=0;$<L.electricChars.length;$++)if(t.indexOf(L.electricChars.charAt($))>-1){H=Br(e,r.head.line,"smart");break}}else L.electricInput&&(L.electricInput.test(ut(e.doc,r.head.line).text.slice(0,r.head.ch))&&(H=Br(e,r.head.line,"smart")));H&&Ei(e,"electricInput",e,r.head.line)}}function So(e){for(var t=[],n=[],i=0;i<e.doc.sel.ranges.length;i++){var r=e.doc.sel.ranges[i].head.line,L={anchor:Ge(r,0),head:Ge(r+1,0)};n.push(L),t.push(e.getRange(L.anchor,L.head))}return{text:t,ranges:n}}function Co(e,t,n,i){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",i?"":"off"),e.setAttribute("spellcheck",!!t)}function Ao(){var e=u("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=u("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),c&&(e.style.border="1px solid black"),Co(e),t}function ql(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(i,r){var L=this.options,H=L[i];if(L[i]==r&&i!="mode")return;L[i]=r,t.hasOwnProperty(i)&&gi(this,t[i])(this,r,H),Se(this,"optionChange",this,i)},getOption:function(i){return this.options[i]},getDoc:function(){return this.doc},addKeyMap:function(i,r){this.state.keyMaps[r?"push":"unshift"](na(i))},removeKeyMap:function(i){for(var r=this.state.keyMaps,L=0;L<r.length;++L)if(r[L]==i||r[L].name==i)return r.splice(L,1),!0},addOverlay:Li(function(i,r){var L=i.token?i:e.getMode(this.options,i);if(L.startState)throw new Error("Overlays may not be stateful.");Ue(this.state.overlays,{mode:L,modeSpec:i,opaque:r&&r.opaque,priority:r&&r.priority||0},function(H){return H.priority}),this.state.modeGen++,Mi(this)}),removeOverlay:Li(function(i){for(var r=this.state.overlays,L=0;L<r.length;++L){var H=r[L].modeSpec;if(H==i||typeof i=="string"&&H.name==i){r.splice(L,1),this.state.modeGen++,Mi(this);return}}}),indentLine:Li(function(i,r,L){typeof r!="string"&&typeof r!="number"&&(r==null?r=this.options.smartIndent?"smart":"prev":r=r?"add":"subtract"),Ti(this.doc,i)&&Br(this,i,r,L)}),indentSelection:Li(function(i){for(var r=this.doc.sel.ranges,L=-1,H=0;H<r.length;H++){var $=r[H];if($.empty())$.head.line>L&&(Br(this,$.head.line,i,!0),L=$.head.line,H==this.doc.sel.primIndex&&Jn(this));else{var Q=$.from(),ee=$.to(),le=Math.max(L,Q.line);L=Math.min(this.lastLine(),ee.line-(ee.ch?0:1))+1;for(var fe=le;fe<L;++fe)Br(this,fe,i);var Ee=this.doc.sel.ranges;Q.ch==0&&r.length==Ee.length&&Ee[H].from().ch>0&&Na(this.doc,H,new Yt(Q,Ee[H].to()),ye)}}}),getTokenAt:function(i,r){return qt(this,i,r)},getLineTokens:function(i,r){return qt(this,Ge(i),r,!0)},getTokenTypeAt:function(i){i=v(this.doc,i);var r=De(this,ut(this.doc,i.line)),L=0,H=(r.length-1)/2,$=i.ch,Q;if($==0)Q=r[2];else for(;;){var ee=L+H>>1;if((ee?r[ee*2-1]:0)>=$)H=ee;else if(r[ee*2+1]<$)L=ee+1;else{Q=r[ee*2+2];break}}var le=Q?Q.indexOf("overlay "):-1;return le<0?Q:le==0?null:Q.slice(0,le-1)},getModeAt:function(i){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(i).state).mode:r},getHelper:function(i,r){return this.getHelpers(i,r)[0]},getHelpers:function(i,r){var L=[];if(!n.hasOwnProperty(r))return L;var H=n[r],$=this.getModeAt(i);if(typeof $[r]=="string")H[$[r]]&&L.push(H[$[r]]);else if($[r])for(var Q=0;Q<$[r].length;Q++){var ee=H[$[r][Q]];ee&&L.push(ee)}else $.helperType&&H[$.helperType]?L.push(H[$.helperType]):H[$.name]&&L.push(H[$.name]);for(var le=0;le<H._global.length;le++){var fe=H._global[le];fe.pred($,this)&&re(L,fe.val)==-1&&L.push(fe.val)}return L},getStateAfter:function(i,r){var L=this.doc;return i=z(L,i==null?L.first+L.size-1:i),it(this,i+1,r).state},cursorCoords:function(i,r){var L,H=this.doc.sel.primary();return i==null?L=H.head:typeof i=="object"?L=v(this.doc,i):L=i?H.from():H.to(),qi(this,L,r||"page")},charCoords:function(i,r){return ma(this,v(this.doc,i),r||"page")},coordsChar:function(i,r){return i=ls(this,i,r||"page"),va(this,i.left,i.top)},lineAtHeight:function(i,r){return i=ls(this,{top:i,left:0},r||"page").top,Vt(this.doc,i+this.display.viewOffset)},heightAtLine:function(i,r,L){var H=!1,$;if(typeof i=="number"){var Q=this.doc.first+this.doc.size-1;i<this.doc.first?i=this.doc.first:i>Q&&(i=Q,H=!0),$=ut(this.doc,i)}else $=i;return Wr(this,$,{top:0,left:0},r||"page",L||H).top+(H?this.doc.height-Ji($):0)},defaultTextHeight:function(){return $n(this.display)},defaultCharWidth:function(){return Qn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(i,r,L,H,$){var Q=this.display;i=qi(this,v(this.doc,i));var ee=i.bottom,le=i.left;if(r.style.position="absolute",r.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(r),Q.sizer.appendChild(r),H=="over")ee=i.top;else if(H=="above"||H=="near"){var fe=Math.max(Q.wrapper.clientHeight,this.doc.height),Ee=Math.max(Q.sizer.clientWidth,Q.lineSpace.clientWidth);(H=="above"||i.bottom+r.offsetHeight>fe)&&i.top>r.offsetHeight?ee=i.top-r.offsetHeight:i.bottom+r.offsetHeight<=fe&&(ee=i.bottom),le+r.offsetWidth>Ee&&(le=Ee-r.offsetWidth)}r.style.top=ee+"px",r.style.left=r.style.right="",$=="right"?(le=Q.sizer.clientWidth-r.offsetWidth,r.style.right="0px"):($=="left"?le=0:$=="middle"&&(le=(Q.sizer.clientWidth-r.offsetWidth)/2),r.style.left=le+"px"),L&&Qo(this,{left:le,top:ee,right:le+r.offsetWidth,bottom:ee+r.offsetHeight})},triggerOnKeyDown:Li(po),triggerOnKeyPress:Li(go),triggerOnKeyUp:mo,triggerOnMouseDown:Li(vo),execCommand:function(i){if(Pr.hasOwnProperty(i))return Pr[i].call(null,this)},triggerElectric:Li(function(i){wo(this,i)}),findPosH:function(i,r,L,H){var $=1;r<0&&($=-1,r=-r);for(var Q=v(this.doc,i),ee=0;ee<r&&!(Q=Ka(this.doc,Q,$,L,H),Q.hitSide);++ee);return Q},moveH:Li(function(i,r){var L=this;this.extendSelectionsBy(function(H){return L.display.shift||L.doc.extend||H.empty()?Ka(L.doc,H.head,i,r,L.options.rtlMoveVisually):i<0?H.from():H.to()},we)}),deleteH:Li(function(i,r){var L=this.doc.sel,H=this.doc;L.somethingSelected()?H.replaceSelection("",null,"+delete"):sr(this,function($){var Q=Ka(H,$.head,i,r,!1);return i<0?{from:Q,to:$.head}:{from:$.head,to:Q}})}),findPosV:function(i,r,L,H){var $=1,Q=H;r<0&&($=-1,r=-r);for(var ee=v(this.doc,i),le=0;le<r;++le){var fe=qi(this,ee,"div");if(Q==null?Q=fe.left:fe.left=Q,ee=Ro(this,fe,$,L),ee.hitSide)break}return ee},moveV:Li(function(i,r){var L=this,H=this.doc,$=[],Q=!this.display.shift&&!H.extend&&H.sel.somethingSelected();if(H.extendSelectionsBy(function(le){if(Q)return i<0?le.from():le.to();var fe=qi(L,le.head,"div");le.goalColumn!=null&&(fe.left=le.goalColumn),$.push(fe.left);var Ee=Ro(L,fe,i,r);return r=="page"&&le==H.sel.primary()&&Sa(L,ma(L,Ee,"div").top-fe.top),Ee},we),$.length)for(var ee=0;ee<H.sel.ranges.length;ee++)H.sel.ranges[ee].goalColumn=$[ee]}),findWordAt:function(i){var r=this.doc,L=ut(r,i.line).text,H=i.ch,$=i.ch;if(L){var Q=this.getHelper(i,"wordChars");(i.sticky=="before"||$==L.length)&&H?--H:++$;for(var ee=L.charAt(H),le=We(ee,Q)?function(fe){return We(fe,Q)}:/\s/.test(ee)?function(fe){return/\s/.test(fe)}:function(fe){return!/\s/.test(fe)&&!We(fe)};H>0&&le(L.charAt(H-1));)--H;for(;$<L.length&&le(L.charAt($));)++$}return new Yt(Ge(i.line,H),Ge(i.line,$))},toggleOverwrite:function(i){if(i!=null&&i==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?N(this.display.cursorDiv,"CodeMirror-overwrite"):T(this.display.cursorDiv,"CodeMirror-overwrite"),Se(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==P()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Li(function(i,r){br(this,i,r)}),getScrollInfo:function(){var i=this.display.scroller;return{left:i.scrollLeft,top:i.scrollTop,height:i.scrollHeight-an(this)-this.display.barHeight,width:i.scrollWidth-an(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Pn(this)}},scrollIntoView:Li(function(i,r){i==null?(i={from:this.doc.sel.primary().head,to:null},r==null&&(r=this.options.cursorScrollMargin)):typeof i=="number"?i={from:Ge(i,0),to:null}:i.from==null&&(i={from:i,to:null}),i.to||(i.to=i.from),i.margin=r||0,i.from.line!=null?Zo(this,i):_s(this,i.from,i.to,i.margin)}),setSize:Li(function(i,r){var L=this,H=function(Q){return typeof Q=="number"||/^\d+$/.test(String(Q))?Q+"px":Q};i!=null&&(this.display.wrapper.style.width=H(i)),r!=null&&(this.display.wrapper.style.height=H(r)),this.options.lineWrapping&&as(this);var $=this.display.viewFrom;this.doc.iter($,this.display.viewTo,function(Q){if(Q.widgets){for(var ee=0;ee<Q.widgets.length;ee++)if(Q.widgets[ee].noHScroll){wn(L,$,"widget");break}}++$}),this.curOp.forceUpdate=!0,Se(this,"refresh",this)}),operation:function(i){return Hi(this,i)},startOperation:function(){return Hn(this)},endOperation:function(){return Wn(this)},refresh:Li(function(){var i=this.display.cachedTextHeight;Mi(this),this.curOp.forceUpdate=!0,yr(this),br(this,this.doc.scrollLeft,this.doc.scrollTop),Ra(this.display),(i==null||Math.abs(i-$n(this.display))>.5||this.options.lineWrapping)&&Ea(this),Se(this,"refresh",this)}),swapDoc:Li(function(i){var r=this.doc;return r.cm=null,this.state.selectingText&&this.state.selectingText(),ks(this,i),yr(this),this.display.input.reset(),br(this,i.scrollLeft,i.scrollTop),this.curOp.forceScroll=!0,Ei(this,"swapDoc",this,r),r}),phrase:function(i){var r=this.options.phrases;return r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:i},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}},de(e),e.registerHelper=function(i,r,L){n.hasOwnProperty(i)||(n[i]=e[i]={_global:[]}),n[i][r]=L},e.registerGlobalHelper=function(i,r,L,H){e.registerHelper(i,r,H),n[i]._global.push({pred:L,val:H})}}function Ka(e,t,n,i,r){var L=t,H=n,$=ut(e,t.line),Q=r&&e.direction=="rtl"?-n:n;function ee(){var dt=t.line+Q;return dt<e.first||dt>=e.first+e.size?!1:(t=new Ge(dt,t.ch,t.sticky),$=ut(e,dt))}function le(dt){var st;if(i=="codepoint"){var mt=$.text.charCodeAt(t.ch+(i>0?0:-1));isNaN(mt)?st=null:st=new Ge(t.line,Math.max(0,Math.min($.text.length,t.ch+n*(mt>=55296&&mt<56320?2:1))),-n)}else r?st=Ml(e.cm,$,t,n):st=Fa($,t,n);if(st==null)if(!dt&&ee())t=Ba(r,e.cm,$,t.line,Q);else return!1;else t=st;return!0}if(i=="char"||i=="codepoint")le();else if(i=="column")le(!0);else if(i=="word"||i=="group")for(var fe=null,Ee=i=="group",_e=e.cm&&e.cm.getHelper(t,"wordChars"),Ie=!0;!(n<0&&!le(!Ie));Ie=!1){var Be=$.text.charAt(t.ch)||`
`,Ze=We(Be,_e)?"w":Ee&&Be==`
`?"n":!Ee||/\s/.test(Be)?null:"p";if(Ee&&!Ie&&!Ze&&(Ze="s"),fe&&fe!=Ze){n<0&&(n=1,le(),t.sticky="after");break}if(Ze&&(fe=Ze),n>0&&!le(!Ie))break}var at=ea(e,t,L,H,!0);return mn(L,at)&&(at.hitSide=!0),at}function Ro(e,t,n,i){var r=e.doc,L=t.left,H;if(i=="page"){var $=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Q=Math.max($-.5*$n(e.display),3);H=(n>0?t.bottom:t.top)+n*Q}else i=="line"&&(H=n>0?t.bottom+3:t.top-3);for(var ee;!(ee=va(e,L,H),!ee.outside);){if(n<0?H<=0:H>=r.height){ee.hitSide=!0;break}H+=n*5}return ee}var Qt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new te,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Qt.prototype.init=function(e){var t=this,n=this,i=n.cm,r=n.div=e.lineDiv;Co(r,i.options.spellcheck,i.options.autocorrect,i.options.autocapitalize);function L($){for(var Q=$.target;Q;Q=Q.parentNode){if(Q==r)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Q.className))break}return!1}Ae(r,"paste",function($){if(!L($)||ke(i,$)||To($,i))return;j<=11&&setTimeout(gi(i,function(){return t.updateFromDOM()}),20)}),Ae(r,"compositionstart",function($){t.composing={data:$.data,done:!1}}),Ae(r,"compositionupdate",function($){t.composing||(t.composing={data:$.data,done:!1})}),Ae(r,"compositionend",function($){t.composing&&($.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ae(r,"touchstart",function(){return n.forceCompositionEnd()}),Ae(r,"input",function(){t.composing||t.readFromDOMSoon()});function H($){if(!L($)||ke(i,$))return;if(i.somethingSelected())sa({lineWise:!1,text:i.getSelections()}),$.type=="cut"&&i.replaceSelection("",null,"cut");else if(i.options.lineWiseCopyCut){var Q=So(i);sa({lineWise:!0,text:Q.text}),$.type=="cut"&&i.operation(function(){i.setSelections(Q.ranges,0,ye),i.replaceSelection("",null,"cut")})}else return;if($.clipboardData){$.clipboardData.clearData();var ee=tn.text.join(`
`);if($.clipboardData.setData("Text",ee),$.clipboardData.getData("Text")==ee){$.preventDefault();return}}var le=Ao(),fe=le.firstChild;i.display.lineSpace.insertBefore(le,i.display.lineSpace.firstChild),fe.value=tn.text.join(`
`);var Ee=document.activeElement;X(fe),setTimeout(function(){i.display.lineSpace.removeChild(le),Ee.focus(),Ee==r&&n.showPrimarySelection()},50)}Ae(r,"copy",H),Ae(r,"cut",H)},Qt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Qt.prototype.prepareSelection=function(){var e=ps(this.cm,!1);return e.focus=document.activeElement==this.div,e},Qt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Qt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Qt.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),i=n.from(),r=n.to();if(t.display.viewTo==t.display.viewFrom||i.line>=t.display.viewTo||r.line<t.display.viewFrom){e.removeAllRanges();return}var L=oa(t,e.anchorNode,e.anchorOffset),H=oa(t,e.focusNode,e.focusOffset);if(L&&!L.bad&&H&&!H.bad&&Ot(yn(L,H),i)==0&&Ot(vn(L,H),r)==0)return;var $=t.display.view,Q=i.line>=t.display.viewFrom&&Oo(t,i)||{node:$[0].measure.map[2],offset:0},ee=r.line<t.display.viewTo&&Oo(t,r);if(!ee){var le=$[$.length-1].measure,fe=le.maps?le.maps[le.maps.length-1]:le.map;ee={node:fe[fe.length-1],offset:fe[fe.length-2]-fe[fe.length-3]}}if(!Q||!ee){e.removeAllRanges();return}var Ee=e.rangeCount&&e.getRangeAt(0),_e;try{_e=m(Q.node,Q.offset,ee.offset,ee.node)}catch(Ie){}_e&&(!k&&t.state.focused?(e.collapse(Q.node,Q.offset),_e.collapsed||(e.removeAllRanges(),e.addRange(_e))):(e.removeAllRanges(),e.addRange(_e)),Ee&&e.anchorNode==null?e.addRange(Ee):k&&this.startGracePeriod()),this.rememberSelection()},Qt.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)},Qt.prototype.showMultipleSelections=function(e){y(this.cm.display.cursorDiv,e.cursors),y(this.cm.display.selectionDiv,e.selection)},Qt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Qt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return b(this.div,t)},Qt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Qt.prototype.blur=function(){this.div.blur()},Qt.prototype.getField=function(){return this.div},Qt.prototype.supportsTouch=function(){return!0},Qt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Hi(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)},Qt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Qt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(o&&g&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var n=oa(t,e.anchorNode,e.anchorOffset),i=oa(t,e.focusNode,e.focusOffset);n&&i&&Hi(t,function(){Ai(t.doc,Cn(n,i),ye),(n.bad||i.bad)&&(t.curOp.selectionChanged=!0)})},Qt.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,n=e.doc.sel.primary(),i=n.from(),r=n.to();if(i.ch==0&&i.line>e.firstLine()&&(i=Ge(i.line-1,ut(e.doc,i.line-1).length)),r.ch==ut(e.doc,r.line).text.length&&r.line<e.lastLine()&&(r=Ge(r.line+1,0)),i.line<t.viewFrom||r.line>t.viewTo-1)return!1;var L,H,$;i.line==t.viewFrom||(L=Fn(e,i.line))==0?(H=Dt(t.view[0].line),$=t.view[0].node):(H=Dt(t.view[L].line),$=t.view[L-1].node.nextSibling);var Q=Fn(e,r.line),ee,le;if(Q==t.view.length-1?(ee=t.viewTo-1,le=t.lineDiv.lastChild):(ee=Dt(t.view[Q+1].line)-1,le=t.view[Q+1].node.previousSibling),!$)return!1;for(var fe=e.doc.splitLines(tu(e,$,le,H,ee)),Ee=ti(e.doc,Ge(H,0),Ge(ee,ut(e.doc,ee).text.length));fe.length>1&&Ee.length>1;)if(Re(fe)==Re(Ee))fe.pop(),Ee.pop(),ee--;else if(fe[0]==Ee[0])fe.shift(),Ee.shift(),H++;else break;for(var _e=0,Ie=0,Be=fe[0],Ze=Ee[0],at=Math.min(Be.length,Ze.length);_e<at&&Be.charCodeAt(_e)==Ze.charCodeAt(_e);)++_e;for(var dt=Re(fe),st=Re(Ee),mt=Math.min(dt.length-(fe.length==1?_e:0),st.length-(Ee.length==1?_e:0));Ie<mt&&dt.charCodeAt(dt.length-Ie-1)==st.charCodeAt(st.length-Ie-1);)++Ie;if(fe.length==1&&Ee.length==1&&H==i.line)for(;_e&&_e>i.ch&&dt.charCodeAt(dt.length-Ie-1)==st.charCodeAt(st.length-Ie-1);)_e--,Ie++;fe[fe.length-1]=dt.slice(0,dt.length-Ie).replace(/^\u200b+/,""),fe[0]=fe[0].slice(_e).replace(/\u200b+$/,"");var St=Ge(H,_e),Et=Ge(ee,Ee.length?Re(Ee).length-Ie:0);if(fe.length>1||fe[0]||Ot(St,Et))return nr(e.doc,fe,St,Et,"+input"),!0},Qt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Qt.prototype.reset=function(){this.forceCompositionEnd()},Qt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Qt.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)},Qt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Hi(this.cm,function(){return Mi(e.cm)})},Qt.prototype.setUneditable=function(e){e.contentEditable="false"},Qt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||gi(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Qt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Qt.prototype.onContextMenu=function(){},Qt.prototype.resetPosition=function(){},Qt.prototype.needsContentAttribute=!0;function Oo(e,t){var n=fa(e,t.line);if(!n||n.hidden)return null;var i=ut(e.doc,t.line),r=es(n,i,t.line),L=Ke(i,e.doc.direction),H="left";if(L){var $=Xe(L,t.ch);H=$%2?"right":"left"}var Q=ns(r.map,t.ch,H);return Q.offset=Q.collapse=="right"?Q.end:Q.start,Q}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function lr(e,t){return t&&(e.bad=!0),e}function tu(e,t,n,i,r){var L="",H=!1,$=e.doc.lineSeparator(),Q=!1;function ee(_e){return function(Ie){return Ie.id==_e}}function le(){H&&(L+=$,Q&&(L+=$),H=Q=!1)}function fe(_e){_e&&(le(),L+=_e)}function Ee(_e){if(_e.nodeType==1){var Ie=_e.getAttribute("cm-text");if(Ie){fe(Ie);return}var Be=_e.getAttribute("cm-marker"),Ze;if(Be){var at=e.findMarks(Ge(i,0),Ge(r+1,0),ee(+Be));at.length&&(Ze=at[0].find(0))&&fe(ti(e.doc,Ze.from,Ze.to).join($));return}if(_e.getAttribute("contenteditable")=="false")return;var dt=/^(pre|div|p|li|table|br)$/i.test(_e.nodeName);if(!/^br$/i.test(_e.nodeName)&&_e.textContent.length==0)return;dt&&le();for(var st=0;st<_e.childNodes.length;st++)Ee(_e.childNodes[st]);/^(pre|p)$/i.test(_e.nodeName)&&(Q=!0),dt&&(H=!0)}else _e.nodeType==3&&fe(_e.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Ee(t),t==n);)t=t.nextSibling,Q=!1;return L}function oa(e,t,n){var i;if(t==e.display.lineDiv){if(i=e.display.lineDiv.childNodes[n],!i)return lr(e.clipPos(Ge(e.display.viewTo-1)),!0);t=null,n=0}else for(i=t;;i=i.parentNode){if(!i||i==e.display.lineDiv)return null;if(i.parentNode&&i.parentNode==e.display.lineDiv)break}for(var r=0;r<e.display.view.length;r++){var L=e.display.view[r];if(L.node==i)return iu(L,t,n)}}function iu(e,t,n){var i=e.text.firstChild,r=!1;if(!t||!b(i,t))return lr(Ge(Dt(e.line),0),!0);if(t==i&&(r=!0,t=i.childNodes[n],n=0,!t)){var L=e.rest?Re(e.rest):e.line;return lr(Ge(Dt(L),L.text.length),r)}var H=t.nodeType==3?t:null,$=t;for(!H&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(H=t.firstChild,n&&(n=H.nodeValue.length));$.parentNode!=i;)$=$.parentNode;var Q=e.measure,ee=Q.maps;function le(Ze,at,dt){for(var st=-1;st<(ee?ee.length:0);st++)for(var mt=st<0?Q.map:ee[st],St=0;St<mt.length;St+=3){var Et=mt[St+2];if(Et==Ze||Et==at){var Pt=Dt(st<0?e.line:e.rest[st]),Jt=mt[St]+dt;return(dt<0||Et!=Ze)&&(Jt=mt[St+(dt?1:0)]),Ge(Pt,Jt)}}}var fe=le(H,$,n);if(fe)return lr(fe,r);for(var Ee=$.nextSibling,_e=H?H.nodeValue.length-n:0;Ee;Ee=Ee.nextSibling){if(fe=le(Ee,Ee.firstChild,0),fe)return lr(Ge(fe.line,fe.ch-_e),r);_e+=Ee.textContent.length}for(var Ie=$.previousSibling,Be=n;Ie;Ie=Ie.previousSibling){if(fe=le(Ie,Ie.firstChild,-1),fe)return lr(Ge(fe.line,fe.ch+Be),r);Be+=Ie.textContent.length}}var oi=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new te,this.hasSelection=!1,this.composing=null};oi.prototype.init=function(e){var t=this,n=this,i=this.cm;this.createField(e);var r=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),c&&(r.style.width="0px"),Ae(r,"input",function(){G&&j>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),Ae(r,"paste",function(H){if(ke(i,H)||To(H,i))return;i.state.pasteIncoming=+new Date,n.fastPoll()});function L(H){if(ke(i,H))return;if(i.somethingSelected())sa({lineWise:!1,text:i.getSelections()});else if(i.options.lineWiseCopyCut){var $=So(i);sa({lineWise:!0,text:$.text}),H.type=="cut"?i.setSelections($.ranges,null,ye):(n.prevInput="",r.value=$.text.join(`
`),X(r))}else return;H.type=="cut"&&(i.state.cutIncoming=+new Date)}Ae(r,"cut",L),Ae(r,"copy",L),Ae(e.scroller,"paste",function(H){if(dn(e,H)||ke(i,H))return;if(!r.dispatchEvent){i.state.pasteIncoming=+new Date,n.focus();return}var $=new Event("paste");$.clipboardData=H.clipboardData,r.dispatchEvent($)}),Ae(e.lineSpace,"selectstart",function(H){dn(e,H)||ie(H)}),Ae(r,"compositionstart",function(){var H=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:H,range:i.markText(H,i.getCursor("to"),{className:"CodeMirror-composing"})}}),Ae(r,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},oi.prototype.createField=function(e){this.wrapper=Ao(),this.textarea=this.wrapper.firstChild},oi.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},oi.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,i=ps(e);if(e.options.moveInputWithCursor){var r=qi(e,n.sel.primary().head,"div"),L=t.wrapper.getBoundingClientRect(),H=t.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+H.top-L.top)),i.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+H.left-L.left))}return i},oi.prototype.showSelection=function(e){var t=this.cm,n=t.display;y(n.cursorDiv,e.cursors),y(n.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},oi.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&X(this.textarea),G&&j>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",G&&j>=9&&(this.hasSelection=null))},oi.prototype.getField=function(){return this.textarea},oi.prototype.supportsTouch=function(){return!1},oi.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!s||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},oi.prototype.blur=function(){this.textarea.blur()},oi.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},oi.prototype.receivedFocus=function(){this.slowPoll()},oi.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()})},oi.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function n(){var i=t.poll();!i&&!e?(e=!0,t.polling.set(60,n)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,n)},oi.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,i=this.prevInput;if(this.contextMenuPending||!t.state.focused||$e(n)&&!i&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var r=n.value;if(r==i&&!t.somethingSelected())return!1;if(G&&j>=9&&this.hasSelection===r||l&&/[\uf700-\uf7ff]/.test(r))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var L=r.charCodeAt(0);if(L==8203&&!i&&(i="\u200B"),L==8666)return this.reset(),this.cm.execCommand("undo")}for(var H=0,$=Math.min(i.length,r.length);H<$&&i.charCodeAt(H)==r.charCodeAt(H);)++H;return Hi(t,function(){za(t,r.slice(H),i.length-H,null,e.composing?"*compose":null),r.length>1e3||r.indexOf(`
`)>-1?n.value=e.prevInput="":e.prevInput=r,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},oi.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},oi.prototype.onKeyPress=function(){G&&j>=9&&(this.hasSelection=null),this.fastPoll()},oi.prototype.onContextMenu=function(e){var t=this,n=t.cm,i=n.display,r=t.textarea;t.contextMenuPending&&t.contextMenuPending();var L=Un(n,e),H=i.scroller.scrollTop;if(!L||p)return;var $=n.options.resetSelectionOnContextMenu;$&&n.doc.sel.contains(L)==-1&&gi(n,Ai)(n.doc,Cn(L),ye);var Q=r.style.cssText,ee=t.wrapper.style.cssText,le=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",r.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-le.top-5)+"px; left: "+(e.clientX-le.left-5)+`px;
z-index: 1000; background: `+(G?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var fe;M&&(fe=window.scrollY),i.input.focus(),M&&window.scrollTo(null,fe),i.input.reset(),n.somethingSelected()||(r.value=t.prevInput=" "),t.contextMenuPending=_e,i.selForContextMenu=n.doc.sel,clearTimeout(i.detectingSelectAll);function Ee(){if(r.selectionStart!=null){var Be=n.somethingSelected(),Ze="\u200B"+(Be?r.value:"");r.value="\u21DA",r.value=Ze,t.prevInput=Be?"":"\u200B",r.selectionStart=1,r.selectionEnd=Ze.length,i.selForContextMenu=n.doc.sel}}function _e(){if(t.contextMenuPending!=_e)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=ee,r.style.cssText=Q,G&&j<9&&i.scrollbars.setScrollTop(i.scroller.scrollTop=H),r.selectionStart!=null){(!G||G&&j<9)&&Ee();var Be=0,Ze=function(){i.selForContextMenu==n.doc.sel&&r.selectionStart==0&&r.selectionEnd>0&&t.prevInput=="\u200B"?gi(n,Vs)(n):Be++<10?i.detectingSelectAll=setTimeout(Ze,500):(i.selForContextMenu=null,i.input.reset())};i.detectingSelectAll=setTimeout(Ze,200)}}if(G&&j>=9&&Ee(),R){ue(e);var Ie=function(){Je(window,"mouseup",Ie),setTimeout(_e,20)};Ae(window,"mouseup",Ie)}else setTimeout(_e,50)},oi.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},oi.prototype.setUneditable=function(){},oi.prototype.needsContentAttribute=!1;function nu(e,t){if(t=t?S(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var n=P();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function i(){e.value=$.getValue()}var r;if(e.form&&(Ae(e.form,"submit",i),!t.leaveSubmitMethodAlone)){var L=e.form;r=L.submit;try{var H=L.submit=function(){i(),L.submit=r,L.submit(),L.submit=H}}catch(Q){}}t.finishInit=function(Q){Q.save=i,Q.getTextArea=function(){return e},Q.toTextArea=function(){Q.toTextArea=isNaN,i(),e.parentNode.removeChild(Q.getWrapperElement()),e.style.display="",e.form&&(Je(e.form,"submit",i),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=r))}},e.style.display="none";var $=ii(function(Q){return e.parentNode.insertBefore(Q,e.nextSibling)},t);return $}function ru(e){e.off=Je,e.on=Ae,e.wheelEventPixels=dl,e.Doc=Pi,e.splitLines=xt,e.countColumn=Y,e.findColumn=xe,e.isWordChar=Me,e.Pass=Te,e.signal=Se,e.Line=Mn,e.changeEnd=An,e.scrollbarModel=xs,e.Pos=Ge,e.cmpPos=Ot,e.modes=It,e.mimeModes=At,e.resolveMode=Qe,e.getMode=bt,e.modeExtensions=kt,e.extendMode=Mt,e.copyState=ei,e.startState=Xi,e.innerMode=Gi,e.commands=Pr,e.keyMap=cn,e.keyName=lo,e.isModifierKey=so,e.lookupKey=ar,e.normalizeKeyMap=kl,e.StringStream=ft,e.SharedTextMarker=Dr,e.TextMarker=On,e.LineWidget=Ir,e.e_preventDefault=ie,e.e_stopPropagation=q,e.e_stop=ue,e.addClass=N,e.contains=b,e.rmClass=T,e.keyNames=Ln}$l(ii),ql(ii);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Pi.prototype)Pi.prototype.hasOwnProperty(la)&&re(au,la)<0&&(ii.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Pi.prototype[la]));return de(Pi),ii.inputStyles={textarea:oi,contenteditable:Qt},ii.defineMode=function(e){!ii.defaults.mode&&e!="null"&&(ii.defaults.mode=e),di.apply(this,arguments)},ii.defineMIME=ri,ii.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),ii.defineMIME("text/plain","null"),ii.defineExtension=function(e,t){ii.prototype[e]=t},ii.defineDocExtension=function(e,t){Pi.prototype[e]=t},ii.fromTextArea=nu,ru(ii),ii.version="5.58.2",ii})},Y1PL:function(_t,lt,ne){"use strict";ne.r(lt),ne.d(lt,"ResizableTextArea",function(){return re});var ae=ne("wx14"),Z=ne("1OyB"),k=ne("vuIU"),V=ne("Ji7U"),F=ne("LK+K"),D=ne("q1tI"),G=ne("VTBJ"),j=ne("rePB"),M=ne("Zm9Q"),I=ne("Kwbf"),g=ne("c+Xe"),p=ne("m+aA"),f=ne("bdgK"),h=new Map;function a(ye){ye.forEach(function(be){var we,xe=be.target;(we=h.get(xe))===null||we===void 0||we.forEach(function(ve){return ve(xe)})})}var c=new f.default(a),o=null,s=null;function l(ye,be){h.has(ye)||(h.set(ye,new Set),c.observe(ye)),h.get(ye).add(be)}function d(ye,be){h.has(ye)&&(h.get(ye).delete(be),h.get(ye).size||(c.unobserve(ye),h.delete(ye)))}var O=function(ye){Object(V.a)(we,ye);var be=Object(F.a)(we);function we(){return Object(Z.a)(this,we),be.apply(this,arguments)}return Object(k.a)(we,[{key:"render",value:function(){return this.props.children}}]),we}(D.Component),w=D.createContext(null);function x(ye){var be=ye.children,we=ye.onBatchResize,xe=D.useRef(0),ve=D.useRef([]),oe=D.useContext(w),Re=D.useCallback(function(Ye,Ue,rt){xe.current+=1;var ot=xe.current;ve.current.push({size:Ye,element:Ue,data:rt}),Promise.resolve().then(function(){ot===xe.current&&(we==null||we(ve.current),ve.current=[])}),oe==null||oe(Ye,Ue,rt)},[we,oe]);return D.createElement(w.Provider,{value:Re},be)}function R(ye){var be=ye.children,we=ye.disabled,xe=D.useRef(null),ve=D.useRef(null),oe=D.useContext(w),Re=D.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ye=D.isValidElement(be)&&Object(g.c)(be),Ue=Ye?be.ref:null,rt=D.useMemo(function(){return Object(g.a)(Ue,xe)},[Ue,xe]),ot=D.useRef(ye);ot.current=ye;var Oe=D.useCallback(function(Me){var We=ot.current,qe=We.onResize,Ve=We.data,je=Me.getBoundingClientRect(),Fe=je.width,ht=je.height,He=Me.offsetWidth,Pe=Me.offsetHeight,Xe=Math.floor(Fe),tt=Math.floor(ht);if(Re.current.width!==Xe||Re.current.height!==tt||Re.current.offsetWidth!==He||Re.current.offsetHeight!==Pe){var Ke={width:Xe,height:tt,offsetWidth:He,offsetHeight:Pe};Re.current=Ke;var et=He===Math.round(Fe)?Fe:He,Ae=Pe===Math.round(ht)?ht:Pe,nt=Object(G.a)(Object(G.a)({},Ke),{},{offsetWidth:et,offsetHeight:Ae});oe==null||oe(nt,Me,Ve),qe&&Promise.resolve().then(function(){qe(nt,Me)})}},[]);return D.useEffect(function(){var Me=Object(p.a)(xe.current)||Object(p.a)(ve.current);return Me&&!we&&l(Me,Oe),function(){return d(Me,Oe)}},[xe.current,we]),D.createElement(O,{ref:ve},Ye?D.cloneElement(be,{ref:rt}):be)}var A="rc-observer-key";function T(ye){var be=ye.children,we=Object(M.a)(be);return we.map(function(xe,ve){var oe=(xe==null?void 0:xe.key)||"".concat(A,"-").concat(ve);return D.createElement(R,Object(ae.a)({},ye,{key:oe}),xe)})}T.Collection=x;var E=T,y=ne("bT9E"),u=ne("TSYQ"),_=ne.n(u),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
`,b=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],P={},N;function K(ye){var be=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=ye.getAttribute("id")||ye.getAttribute("data-reactid")||ye.getAttribute("name");if(be&&P[we])return P[we];var xe=window.getComputedStyle(ye),ve=xe.getPropertyValue("box-sizing")||xe.getPropertyValue("-moz-box-sizing")||xe.getPropertyValue("-webkit-box-sizing"),oe=parseFloat(xe.getPropertyValue("padding-bottom"))+parseFloat(xe.getPropertyValue("padding-top")),Re=parseFloat(xe.getPropertyValue("border-bottom-width"))+parseFloat(xe.getPropertyValue("border-top-width")),Ye=b.map(function(rt){return"".concat(rt,":").concat(xe.getPropertyValue(rt))}).join(";"),Ue={sizingStyle:Ye,paddingSize:oe,borderSize:Re,boxSizing:ve};return be&&we&&(P[we]=Ue),Ue}function X(ye){var be=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,xe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;N||(N=document.createElement("textarea"),N.setAttribute("tab-index","-1"),N.setAttribute("aria-hidden","true"),document.body.appendChild(N)),ye.getAttribute("wrap")?N.setAttribute("wrap",ye.getAttribute("wrap")):N.removeAttribute("wrap");var ve=K(ye,be),oe=ve.paddingSize,Re=ve.borderSize,Ye=ve.boxSizing,Ue=ve.sizingStyle;N.setAttribute("style","".concat(Ue,";").concat(m)),N.value=ye.value||ye.placeholder||"";var rt=Number.MIN_SAFE_INTEGER,ot=Number.MAX_SAFE_INTEGER,Oe=N.scrollHeight,Me;if(Ye==="border-box"?Oe+=Re:Ye==="content-box"&&(Oe-=oe),we!==null||xe!==null){N.value=" ";var We=N.scrollHeight-oe;we!==null&&(rt=We*we,Ye==="border-box"&&(rt=rt+oe+Re),Oe=Math.max(rt,Oe)),xe!==null&&(ot=We*xe,Ye==="border-box"&&(ot=ot+oe+Re),Me=Oe>ot?"":"hidden",Oe=Math.min(ot,Oe))}return{height:Oe,minHeight:rt,maxHeight:ot,overflowY:Me,resize:"none"}}var B=ne("Gytx"),S=ne.n(B),Y;(function(ye){ye[ye.NONE=0]="NONE",ye[ye.RESIZING=1]="RESIZING",ye[ye.RESIZED=2]="RESIZED"})(Y||(Y={}));var te=function(ye){Object(V.a)(we,ye);var be=Object(F.a)(we);function we(xe){var ve;return Object(Z.a)(this,we),ve=be.call(this,xe),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(oe){ve.textArea=oe},ve.handleResize=function(oe){var Re=ve.state.resizeStatus,Ye=ve.props,Ue=Ye.autoSize,rt=Ye.onResize;if(Re!==Y.NONE)return;typeof rt=="function"&&rt(oe),Ue&&ve.resizeOnNextFrame()},ve.resizeOnNextFrame=function(){cancelAnimationFrame(ve.nextFrameActionId),ve.nextFrameActionId=requestAnimationFrame(ve.resizeTextarea)},ve.resizeTextarea=function(){var oe=ve.props.autoSize;if(!oe||!ve.textArea)return;var Re=oe.minRows,Ye=oe.maxRows,Ue=X(ve.textArea,!1,Re,Ye);ve.setState({textareaStyles:Ue,resizeStatus:Y.RESIZING},function(){cancelAnimationFrame(ve.resizeFrameId),ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:Y.RESIZED},function(){ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:Y.NONE}),ve.fixFirefoxAutoScroll()})})})})},ve.renderTextArea=function(){var oe=ve.props,Re=oe.prefixCls,Ye=Re===void 0?"rc-textarea":Re,Ue=oe.autoSize,rt=oe.onResize,ot=oe.className,Oe=oe.disabled,Me=ve.state,We=Me.textareaStyles,qe=Me.resizeStatus,Ve=Object(y.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),je=_()(Ye,ot,Object(j.a)({},"".concat(Ye,"-disabled"),Oe));"value"in Ve&&(Ve.value=Ve.value||"");var Fe=Object(G.a)(Object(G.a)(Object(G.a)({},ve.props.style),We),qe===Y.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return D.createElement(E,{onResize:ve.handleResize,disabled:!(Ue||rt)},D.createElement("textarea",Object(ae.a)({},Ve,{className:je,style:Fe,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:Y.NONE},ve}return Object(k.a)(we,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!S()(ve.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ve=this.textArea.selectionStart,oe=this.textArea.selectionEnd;this.textArea.setSelectionRange(ve,oe)}}catch(Re){}}},{key:"render",value:function(){return this.renderTextArea()}}]),we}(D.Component),re=te,ce=function(ye){Object(V.a)(we,ye);var be=Object(F.a)(we);function we(xe){var ve;Object(Z.a)(this,we),ve=be.call(this,xe),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(Re){ve.resizableTextArea=Re},ve.handleChange=function(Re){var Ye=ve.props.onChange;ve.setValue(Re.target.value,function(){ve.resizableTextArea.resizeTextarea()}),Ye&&Ye(Re)},ve.handleKeyDown=function(Re){var Ye=ve.props,Ue=Ye.onPressEnter,rt=Ye.onKeyDown;Re.keyCode===13&&Ue&&Ue(Re),rt&&rt(Re)};var oe=typeof xe.value=="undefined"||xe.value===null?xe.defaultValue:xe.value;return ve.state={value:oe},ve}return Object(k.a)(we,[{key:"setValue",value:function(ve,oe){"value"in this.props||this.setState({value:ve},oe)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return D.createElement(re,Object(ae.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ve){return"value"in ve?{value:ve.value}:null}}]),we}(D.Component),Te=lt.default=ce},ZW9T:function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return X});var ae=ne("k1fw"),Z=ne("miYZ"),k=ne("tsqr"),V=ne("rAM+"),F=ne("tJVT"),D=ne("PpiC"),G=ne("q1tI"),j=ne.n(G),M=ne("bdgK"),I=ne("oBTY"),g=ne("9og8"),p=ne("WmNS"),f=ne.n(p),h={keywords:["print","auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while"]},a={quickKey:[{label:"main",content:["public static void main(String[] args) {"," $0","}"].join(`
`)},{label:"System.out.println",content:["System.out.println($0)"].join(`
`)},{label:"System.out.print",content:["System.out.print($0)"].join(`
`)}],keywords:["abstract","continue","for","new","switch","assert","default","goto","package","synchronized","boolean","do","if","private","this","break","double","implements","protected","throw","byte","else","import","public","throws","case","enum","instanceof","return","transient","catch","extends","int","short","try","char","final","interface","static","void","class","finally","long","strictfp","volatile","const","float","native","super","while","true","false"]},c={keywords:["abstract","amp","array","auto","bool","break","case","catch","char","class","const","constexpr","const_cast","continue","cpu","decltype","default","delegate","delete","do","double","dynamic_cast","each","else","enum","event","explicit","export","extern","false","final","finally","float","for","friend","gcnew","generic","goto","if","in","initonly","inline","int","interface","interior_ptr","internal","literal","long","mutable","namespace","new","noexcept","nullptr","__nullptr","operator","override","partial","pascal","pin_ptr","private","property","protected","public","ref","register","reinterpret_cast","restrict","return","safe_cast","sealed","short","signed","sizeof","static","static_assert","static_cast","struct","switch","template","this","thread_local","throw","tile_static","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","where","while","_asm","_based","_cdecl","_declspec","_fastcall","_if_exists","_if_not_exists","_inline","_multiple_inheritance","_pascal","_single_inheritance","_stdcall","_virtual_inheritance","_w64","__abstract","__alignof","__asm","__assume","__based","__box","__builtin_alignof","__cdecl","__clrcall","__declspec","__delegate","__event","__except","__fastcall","__finally","__forceinline","__gc","__hook","__identifier","__if_exists","__if_not_exists","__inline","__int128","__int16","__int32","__int64","__int8","__interface","__leave","__m128","__m128d","__m128i","__m256","__m256d","__m256i","__m64","__multiple_inheritance","__newslot","__nogc","__noop","__nounwind","__novtordisp","__pascal","__pin","__pragma","__property","__ptr32","__ptr64","__raise","__restrict","__resume","__sealed","__single_inheritance","__stdcall","__super","__thiscall","__try","__try_cast","__typeof","__unaligned","__unhook","__uuidof","__value","__virtual_inheritance","__w64","__wchar_t"],operators:["=",">","<","!","~","?",":","==","<=",">=","!=","&&","||","++","--","+","-","*","/","&","|","^","%","<<",">>",">>>","+=","-=","*=","/=","&=","|=","^=","%=","<<=",">>=",">>>="],quickKey:[{label:"ifelse",content:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
`)},{label:"#include",content:'include "$0"'},{label:"printf",content:"printf($0)"},{label:"main",content:["int main () {"," $0","}"].join(`
`)},{label:"for",content:["for( ; ; ){"," $0","}"].join(`
`)},{label:"trycatch",content:["try{"," $0","}catch(ExceptionName e){","}"].join(`
`)},{label:"using namespace std;",content:["using namespace std;"].join(`
`)},{label:"#include <iostream>",content:["#include <iostream>"].join(`
`)},{label:"#include <vector>",content:["#include <vector>"].join(`
`)},{label:"#include <sstream>",content:["#include <sstream>"].join(`
`)},{label:"#include <string>",content:["#include <string>"].join(`
`)},{label:"#include <cmath>",content:["#include <cmath>"].join(`
`)}]},o={keywords:["and","as","assert","break","class","continue","def","del","elif","else","except","exec","finally","for","from","global","if","import","in","is","lambda","None","not","or","pass","raise","return","self","try","while","with","yield","int","float","long","complex","hex","abs","all","any","apply","basestring","bin","bool","buffer","bytearray","callable","chr","classmethod","cmp","coerce","compile","complex","delattr","dict","dir","divmod","enumerate","eval","execfile","file","filter","format","frozenset","getattr","globals","hasattr","hash","help","id","input","intern","isinstance","issubclass","iter","len","locals","list","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","reversed","range","raw_input","reduce","reload","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","unichr","unicode","vars","xrange","zip","True","False","__dict__","__methods__","__members__","__class__","__bases__","__name__","__mro__","__subclasses__","__init__","__import__"],quickKey:[{label:"print",content:["print($0)"].join(`
`)}]},s=ne("5VLF"),l=ne.n(s),d={languages:["c","abap","apex","azcli","bat","cameligo","clojure","coffee","cpp","csharp","csp","css","dockerfile","fsharp","go","graphql","handlebars","html","ini","java","javascript","json","kotlin","less","lua","markdown","mips","msdax","mysql","objective-c","pascal","pascaligo","perl","pgsql","php","postiats","powerquery","powershell","pug","python","r","razor","redis","redshift","restructuredtext","ruby","rust","sb","scheme","scss","shell","solidity","sophia","sql","st","swift","tcl","twig","vb","xml","yaml'"],tables:{users:["name","id","email","phone","password"],roles:["id","name","order","created_at","updated_at","deleted_at"]}},O=function(S,Y){return Y.map(function(te){return{label:te,kind:S.languages.CompletionItemKind.Keyword,insertText:te}})},w=function(S){return Object.keys(d.tables).map(function(Y){return{label:Y,kind:S.languages.CompletionItemKind.Variable,insertText:Y}})},x=function(S,Y){var te=d.tables[S];return te?te.map(function(re){return{label:re,kind:Y.languages.CompletionItemKind.Field,insertText:re}}):[]};function R(B,S,Y,te,re){var ce=S.getWordUntilPosition(Y),Te={startLineNumber:Y.lineNumber,endLineNumber:Y.lineNumber,startColumn:ce.startColumn,endColumn:ce.endColumn},ye=te.map(function(be){return{label:be,kind:B.languages.CompletionItemKind.Keyword,insertText:be,insertTextRules:B.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:Te}});return re.map(function(be){ye.push(Object(ae.a)(Object(ae.a)({},be),{},{range:Te}))}),ye}var A=function(B){d.languages.map(function(re){return B.languages.registerDocumentFormattingEditProvider(re,{provideDocumentFormattingEdits:function(Te,ye,be){return Object(g.a)(f.a.mark(function we(){var xe;return f.a.wrap(function(oe){for(;;)switch(oe.prev=oe.next){case 0:return xe=l()(Te.getValue(),{indent_size:"2",indent_char:" ",max_preserve_newlines:"2",preserve_newlines:!0,keep_array_indentation:!0,break_chained_methods:!1,indent_scripts:"normal",brace_style:"collapse",space_before_conditional:!0,unescape_strings:!1,jslint_happy:!1,end_with_newline:!0,wrap_line_length:"0",indent_inner_html:!1,comma_first:!1,e4x:!1,indent_empty_lines:!1}),oe.abrupt("return",[{range:Te.getFullModelRange(),text:xe}]);case 2:case"end":return oe.stop()}},we)}))()}}),re});var S=c.quickKey.map(function(re){return{label:re.label,kind:B.languages.CompletionItemKind.Method,insertText:re.content,insertTextRules:B.languages.CompletionItemInsertTextRule.InsertAsSnippet}}),Y=o.quickKey.map(function(re){return{label:re.label,kind:B.languages.CompletionItemKind.Method,insertText:re.content,insertTextRules:B.languages.CompletionItemInsertTextRule.InsertAsSnippet}}),te=a.quickKey.map(function(re){return{label:re.label,kind:B.languages.CompletionItemKind.Method,insertText:re.content,insertTextRules:B.languages.CompletionItemInsertTextRule.InsertAsSnippet}});B.languages.registerCompletionItemProvider("cpp",{triggerCharacters:["."," ","#"].concat(Object(I.a)(c.keywords),Object(I.a)(c.quickKey.map(function(re){return re.label}))),provideCompletionItems:function(ce,Te){var ye=ce.getValueInRange({startLineNumber:Te.lineNumber,startColumn:1,endLineNumber:Te.lineNumber,endColumn:Te.column}),be=ye.match(/cu/gim);console.log("match:",be,Te,ye,ce);var we=[],xe=Te.lineNumber,ve=Te.column,oe=ce.getValueInRange({startLineNumber:xe,startColumn:0,endLineNumber:xe,endColumn:ve}),Re=oe.trim().split(/\s+/),Ye=Re[Re.length-1];if(Ye.endsWith(".")){var Ue=Ye.slice(0,Ye.length-1);Object.keys(d.tables).includes(Ue)&&(we=Object(I.a)(x(Ue,B)))}else Ye==="."?we=[]:we=[].concat(Object(I.a)(w(B)),Object(I.a)(O(B,c.keywords)),Object(I.a)(S));return{suggestions:we}}}),B.languages.registerCompletionItemProvider("c",{triggerCharacters:["."," ","#"].concat(Object(I.a)(h.keywords)),provideCompletionItems:function(ce,Te){var ye=ce.getValueInRange({startLineNumber:Te.lineNumber,startColumn:1,endLineNumber:Te.lineNumber,endColumn:Te.column}),be=ye.match(/cu/gim);console.log("match:",be,Te,ye,ce);var we=[],xe=Te.lineNumber,ve=Te.column,oe=ce.getValueInRange({startLineNumber:xe,startColumn:0,endLineNumber:xe,endColumn:ve}),Re=oe.trim().split(/\s+/),Ye=Re[Re.length-1];if(Ye.endsWith(".")){var Ue=Ye.slice(0,Ye.length-1);Object.keys(d.tables).includes(Ue)&&(we=Object(I.a)(x(Ue,B)))}else Ye==="."?we=[]:we=[].concat(Object(I.a)(w(B)),Object(I.a)(O(B,h.keywords)));return{suggestions:we}}}),B.languages.registerCompletionItemProvider("java",{triggerCharacters:["."," "].concat(Object(I.a)(a.keywords)),provideCompletionItems:function(ce,Te){var ye=[],be=Te.lineNumber,we=Te.column,xe=ce.getValueInRange({startLineNumber:be,startColumn:0,endLineNumber:be,endColumn:we}),ve=xe.trim().split(/\s+/),oe=ve[ve.length-1];if(oe.endsWith(".")){var Re=oe.slice(0,oe.length-1);Object.keys(d.tables).includes(Re)&&(ye=Object(I.a)(x(Re,B)))}else oe==="."?ye=[]:ye=[].concat(Object(I.a)(w(B)),Object(I.a)(O(B,a.keywords)),Object(I.a)(te));return{suggestions:ye}}}),B.languages.registerCompletionItemProvider("python",{triggerCharacters:["."," "].concat(Object(I.a)(o.keywords)),provideCompletionItems:function(ce,Te){var ye=[],be=Te.lineNumber,we=Te.column,xe=ce.getValueInRange({startLineNumber:be,startColumn:0,endLineNumber:be,endColumn:we}),ve=xe.trim().split(/\s+/),oe=ve[ve.length-1];if(oe.endsWith(".")){var Re=oe.slice(0,oe.length-1);Object.keys(d.tables).includes(Re)&&(ye=Object(I.a)(x(Re,B)))}else oe==="."?ye=[]:ye=[].concat(Object(I.a)(w(B)),Object(I.a)(O(B,o.keywords)),Object(I.a)(Y));return{suggestions:ye}}})},T="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",E=ne("LvDl"),y=ne("+ua5");function u(B){return/^\d+$/.test(B)?"".concat(B,"px"):B}function _(){}var m=!1,b={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function P(){var B=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],S=B;if(Array.isArray(B)){for(var Y=0;Y<B.length;Y++){var te=b[B[Y]];if(te)return te}return S[0]}return b[S]||S}var N=null,K=lt.b=function(B){var S=B.width,Y=S===void 0?"100%":S,te=B.height,re=te===void 0?"100%":te,ce=B.value,Te=B.language,ye=Te===void 0?"javascript":Te,be=B.style,we=be===void 0?{}:be,xe=B.options,ve=xe===void 0?{}:xe,oe=B.overrideServices,Re=oe===void 0?{}:oe,Ye=B.theme,Ue=Ye===void 0?"vs-dark":Ye,rt=B.onEditBlur,ot=B.onSave,Oe=B.autoHeight,Me=Oe===void 0?!1:Oe,We=B.forbidCopy,qe=We===void 0?!1:We,Ve=B.onChange,je=Ve===void 0?_:Ve,Fe=B.editorDidMount,ht=Fe===void 0?_:Fe,He=B.onFocus,Pe=He===void 0?_:He,Xe=B.filename,tt=Xe===void 0?"educoder.txt":Xe,Ke=B.errorLine,et=B.errorContent,Ae=et===void 0?"":et,nt=Object(D.a)(B,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename","errorLine","errorContent"]),Je=Object(G.useRef)(),Se=Object(G.useRef)({}),ke=Object(G.useRef)(),me=Object(G.useRef)(!1),he=Object(G.useRef)(),de=Object(G.useState)(!1),ie=Object(F.a)(de,2),q=ie[0],se=ie[1];function ue(){var Qe;return Je.current&&(Qe=new M.default(function(bt){var kt=Object(V.a)(bt),Mt;try{for(kt.s();!(Mt=kt.n()).done;){var ei=Mt.value;(ei.target.offsetHeight>0||ei.target.offsetWidth>0)&&Se.current.instance.layout()}}catch(Gi){kt.e(Gi)}finally{kt.f()}}),Qe.observe(Je.current)),Qe}function ge(){k.b.warn(decodeURIComponent(T))}var Ce=function(){var bt=Se.current.instance;if(ce!=null&&bt&&q){var kt=bt.getModel();kt&&ce!==kt.getValue()&&(m=!0,kt.setValue(ce),bt.layout(),m=!1)}};Object(G.useEffect)(function(){ke.current&&clearTimeout(ke.current),ke.current=setTimeout(function(){Ce()},500)},[ce,q,Se.current]),Object(G.useEffect)(function(){if(Ke&&Se.current&&Se.current.instance){var Qe=Se.current.instance;Qe.changeViewZones(function(kt){var Mt=document.createElement("div");Mt.style.padding="10px 20px",Mt.style.width="calc(100% - 20px)",Mt.className="my-error-line-wrp",Mt.innerHTML=Ae,kt.addZone({afterLineNumber:Ke||11,heightInLines:3,domNode:Mt})});var bt={domNode:null,getId:function(){return"my.overlay.widget"},getDomNode:function(){return this.domNode||(this.domNode=document.createElement("div"),this.domNode.innerHTML="",this.domNode.style.width="100%",this.domNode.style.padding="20px 100px",this.domNode.style.right="0px",this.domNode.style.top="50px",this.domNode.style.position="relative",this.domNode.style.color="#333"),this.domNode},getPosition:function(){return null}};Qe.addOverlayWidget(bt),Qe.revealPositionInCenter({lineNumber:20,column:1})}},[Ke,Se.current,q]);function Le(){var Qe=Se.current.instance;if(Qe){var bt=Qe.getSelection(),kt=Se.current.pastePos||{},Mt=new N.Range(kt.startLineNumber||bt.endLineNumber,kt.startColumn||bt.endColumn,kt.endLineNumber||bt.endLineNumber,kt.endColumn||bt.endColumn);setTimeout(function(){Qe.executeEdits("",[{range:Mt,text:""}])},300)}}function ze(Qe){(window.navigator.platform.match("Mac")?Qe.metaKey:Qe.ctrlKey)&&Qe.keyCode==83&&(Qe.preventDefault(),ot())}var pt=function(){if(Me&&Se.current.instance){var bt=Se.current.instance.getContentHeight();di(bt<re?re:bt)}else di(re)};function ct(Qe){var bt=document.createEvent("MouseEvents");bt.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),Qe.dispatchEvent(bt)}function Ct(Qe,bt){var kt=window.URL||window.webkitURL||window,Mt=new Blob([bt]),ei=document.createElementNS("http://www.w3.org/1999/xhtml","a");ei.href=kt.createObjectURL(Mt),ei.download=Qe,ct(ei)}Object(G.useEffect)(function(){pt()},[pt]),Object(G.useEffect)(function(){Je.current&&!q&&ne.e(27).then(ne.t.bind(null,"M/lh",7)).then(function(Qe){try{N=Qe,Se.current.instance=N.editor.create(Je.current,{value:ce,language:P(ye),theme:Ue,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},Re);var bt=Se.current.instance;if(ht(bt,N),setTimeout(function(){pt(),Se.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Ct(tt||"educoder.txt",bt.getValue())}})},500),Se.current.subscription=bt.onDidChangeModelContent(function(Mt){me.current?clearTimeout(he.current):(pt(),je(bt.getValue(),Mt)),he.current=setTimeout(function(){me.current=!1},500)}),window.Monaco||A(N),qe&&(bt.addCommand(N.KeyMod.CtrlCmd|N.KeyMod.Shift|N.KeyCode.KEY_V,function(){return ge(),null}),bt.addCommand(N.KeyMod.CtrlCmd|N.KeyCode.KEY_C,function(){return ge(),null})),window.Monaco=N,rt&&bt.onDidBlurEditorWidget(function(){rt(bt.getValue())}),Pe&&bt.onDidFocusEditorText(function(){Pe(bt.getValue())}),qe){bt.addCommand(N.KeyMod.CtrlCmd|N.KeyCode.KEY_V,function(){return ge(),null}),bt.onDidPaste(function(Mt){Se.current.pastePos=Mt});try{window.addEventListener("paste",Le)}catch(Mt){}}var kt=ue();return se(!0),function(){var Mt=Se.current.instance;Mt.dispose();var ei=Mt.getModel();ei&&ei.dispose(),Se.current.subscription&&Se.current.subscription.dispose(),qe&&window.removeEventListener("paste",Le),kt.unobserve(Je.current)}}catch(Mt){}})},[]),Object(G.useEffect)(function(){var Qe=Se.current.instance;if(Qe&&q)return document.addEventListener("keydown",ze,!1),function(){document.removeEventListener("keydown",ze)}},[ot,q]),Object(G.useEffect)(function(){var Qe=Se.current.instance;if(Qe&&q){var bt=P(ye);N.editor.setModelLanguage(Qe.getModel(),bt),console.log("language:",ye,Qe.getModel(),bt)}},[ye,q]),Object(G.useEffect)(function(){var Qe=Se.current.instance;Qe&&q&&N.editor.setTheme(Ue)},[Ue,q]),Object(G.useEffect)(function(){var Qe=Se.current.instance;Qe&&q&&(Qe.updateOptions(Object(ae.a)({},ve)),setTimeout(function(){Qe.getModel().updateOptions(Object(ae.a)({},ve))},200))},[JSON.stringify(ve),q]),Object(G.useEffect)(function(){var Qe=Se.current.instance;Qe&&q&&Qe.layout()},[Y,re,q]);var xt=Object(G.useState)(u(Y)),$e=Object(F.a)(xt,2),Rt=$e[0],vt=$e[1],Nt=Object(G.useState)(u(re)),It=Object(F.a)(Nt,2),At=It[0],di=It[1],ri=Object(ae.a)(Object(ae.a)({},we),{},{width:Rt,height:At});return j.a.createElement("div",{className:"my-monaco-editor",ref:Je,style:ri})};function X(B){var S=B.width,Y=S===void 0?"100%":S,te=B.height,re=te===void 0?"100%":te,ce=B.original,Te=B.modified,ye=B.language,be=B.options,we=be===void 0?{}:be,xe=Object(G.useRef)(),ve=Object(G.useState)(null),oe=Object(F.a)(ve,2),Re=oe[0],Ye=oe[1];function Ue(Me){var We;return xe.current&&(We=new M.default(function(qe){var Ve=Object(V.a)(qe),je;try{for(Ve.s();!(je=Ve.n()).done;){var Fe=je.value;(Fe.target.offsetHeight>0||Fe.target.offsetWidth>0)&&Me.layout()}}catch(ht){Ve.e(ht)}finally{Ve.f()}}),We.observe(xe.current)),We}Object(G.useEffect)(function(){xe.current&&ne.e(27).then(ne.t.bind(null,"M/lh",7)).then(function(Me){N=Me;var We=N.editor.createDiffEditor(xe.current,Object(ae.a)(Object(ae.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},we),{},{wordWrap:!0}));Ye(We);var qe=Ue(We);return function(){We.dispose();var Ve=We.getModel();Ve&&Ve.dispose(),qe.unobserve(xe.current)}})},[]),Object(G.useEffect)(function(){Re&&Re.setModel({original:N.editor.createModel(ce,ye),modified:N.editor.createModel(Te,ye)})},[ce,Te,ye,Re]);var rt=u(Y),ot=u(re),Oe={width:rt,height:ot};return j.a.createElement("div",{className:"my-diff-editor",ref:xe,style:Oe})}},ZpRC:function(_t,lt,ne){"use strict";function ae(g){return typeof g=="object"&&g!=null&&g.nodeType===1}function Z(g,p){return(!p||g!=="hidden")&&g!=="visible"&&g!=="clip"}function k(g,p){if(g.clientHeight<g.scrollHeight||g.clientWidth<g.scrollWidth){var f=getComputedStyle(g,null);return Z(f.overflowY,p)||Z(f.overflowX,p)||function(h){var a=function(c){if(!c.ownerDocument||!c.ownerDocument.defaultView)return null;try{return c.ownerDocument.defaultView.frameElement}catch(o){return null}}(h);return!!a&&(a.clientHeight<h.scrollHeight||a.clientWidth<h.scrollWidth)}(g)}return!1}function V(g,p,f,h,a,c,o,s){return c<g&&o>p||c>g&&o<p?0:c<=g&&s<=f||o>=p&&s>=f?c-g-h:o>p&&s<f||c<g&&s>f?o-p+a:0}var F=function(g,p){var f=window,h=p.scrollMode,a=p.block,c=p.inline,o=p.boundary,s=p.skipOverflowHiddenElements,l=typeof o=="function"?o:function(We){return We!==o};if(!ae(g))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,O=[],w=g;ae(w)&&l(w);){if((w=w.parentElement)===d){O.push(w);break}w!=null&&w===document.body&&k(w)&&!k(document.documentElement)||w!=null&&k(w,s)&&O.push(w)}for(var x=f.visualViewport?f.visualViewport.width:innerWidth,R=f.visualViewport?f.visualViewport.height:innerHeight,A=window.scrollX||pageXOffset,T=window.scrollY||pageYOffset,E=g.getBoundingClientRect(),y=E.height,u=E.width,_=E.top,m=E.right,b=E.bottom,P=E.left,N=a==="start"||a==="nearest"?_:a==="end"?b:_+y/2,K=c==="center"?P+u/2:c==="end"?m:P,X=[],B=0;B<O.length;B++){var S=O[B],Y=S.getBoundingClientRect(),te=Y.height,re=Y.width,ce=Y.top,Te=Y.right,ye=Y.bottom,be=Y.left;if(h==="if-needed"&&_>=0&&P>=0&&b<=R&&m<=x&&_>=ce&&b<=ye&&P>=be&&m<=Te)return X;var we=getComputedStyle(S),xe=parseInt(we.borderLeftWidth,10),ve=parseInt(we.borderTopWidth,10),oe=parseInt(we.borderRightWidth,10),Re=parseInt(we.borderBottomWidth,10),Ye=0,Ue=0,rt="offsetWidth"in S?S.offsetWidth-S.clientWidth-xe-oe:0,ot="offsetHeight"in S?S.offsetHeight-S.clientHeight-ve-Re:0;if(d===S)Ye=a==="start"?N:a==="end"?N-R:a==="nearest"?V(T,T+R,R,ve,Re,T+N,T+N+y,y):N-R/2,Ue=c==="start"?K:c==="center"?K-x/2:c==="end"?K-x:V(A,A+x,x,xe,oe,A+K,A+K+u,u),Ye=Math.max(0,Ye+T),Ue=Math.max(0,Ue+A);else{Ye=a==="start"?N-ce-ve:a==="end"?N-ye+Re+ot:a==="nearest"?V(ce,ye,te,ve,Re+ot,N,N+y,y):N-(ce+te/2)+ot/2,Ue=c==="start"?K-be-xe:c==="center"?K-(be+re/2)+rt/2:c==="end"?K-Te+oe+rt:V(be,Te,re,xe,oe+rt,K,K+u,u);var Oe=S.scrollLeft,Me=S.scrollTop;N+=Me-(Ye=Math.max(0,Math.min(Me+Ye,S.scrollHeight-te+ot))),K+=Oe-(Ue=Math.max(0,Math.min(Oe+Ue,S.scrollWidth-re+rt)))}X.push({el:S,top:Ye,left:Ue})}return X};function D(g){return g===Object(g)&&Object.keys(g).length!==0}function G(g,p){p===void 0&&(p="auto");var f="scrollBehavior"in document.body.style;g.forEach(function(h){var a=h.el,c=h.top,o=h.left;a.scroll&&f?a.scroll({top:c,left:o,behavior:p}):(a.scrollTop=c,a.scrollLeft=o)})}function j(g){return g===!1?{block:"end",inline:"nearest"}:D(g)?g:{block:"start",inline:"nearest"}}function M(g,p){var f=!g.ownerDocument.documentElement.contains(g);if(D(p)&&typeof p.behavior=="function")return p.behavior(f?[]:F(g,p));if(f)return;var h=j(p);return G(F(g,h),h.behavior)}var I=lt.a=M},bT9E:function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return Z});var ae=ne("VTBJ");function Z(k,V){var F=Object(ae.a)({},k);return Array.isArray(V)&&V.forEach(function(D){delete F[D]}),F}},c5Ni:function(_t,lt,ne){},dejd:function(_t,lt,ne){},dmUQ:function(_t,lt,ne){"use strict";var ae=ne("Ff2n"),Z=ne("rePB"),k=ne("1OyB"),V=ne("vuIU"),F=ne("Ji7U"),D=ne("md7G"),G=ne("foSv"),j=ne("q1tI"),M=ne.n(j),I=ne("TSYQ"),g=ne.n(I),p=ne("4IlW");function f(y,u){var _=Object.keys(y);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(y);u&&(m=m.filter(function(b){return Object.getOwnPropertyDescriptor(y,b).enumerable})),_.push.apply(_,m)}return _}function h(y){for(var u=1;u<arguments.length;u++){var _=arguments[u]!=null?arguments[u]:{};u%2?f(Object(_),!0).forEach(function(m){Object(Z.a)(y,m,_[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(_)):f(Object(_)).forEach(function(m){Object.defineProperty(y,m,Object.getOwnPropertyDescriptor(_,m))})}return y}function a(y){var u=c();return function(){var m=Object(G.a)(y),b;if(u){var P=Object(G.a)(this).constructor;b=Reflect.construct(m,arguments,P)}else b=m.apply(this,arguments);return Object(D.a)(this,b)}}function c(){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(y){return!1}}function o(){}function s(y){y.preventDefault()}var l=function(u){return u.replace(/[^\w.-]+/g,"")},d=200,O=600,w=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,x=function(u){return u!=null},R=function(u,_){return _===u||typeof _=="number"&&typeof u=="number"&&isNaN(_)&&isNaN(u)},A=function(y){Object(F.a)(_,y);var u=a(_);function _(m){var b;Object(k.a)(this,_),b=u.call(this,m),b.onKeyDown=function(K){var X=b.props,B=X.onKeyDown,S=X.onPressEnter;if(K.keyCode===p.a.UP){var Y=b.getRatio(K);b.up(K,Y,null),b.stop()}else if(K.keyCode===p.a.DOWN){var te=b.getRatio(K);b.down(K,te,null),b.stop()}else K.keyCode===p.a.ENTER&&S&&S(K);if(b.recordCursorPosition(),b.lastKeyCode=K.keyCode,B){for(var re=arguments.length,ce=new Array(re>1?re-1:0),Te=1;Te<re;Te++)ce[Te-1]=arguments[Te];B.apply(void 0,[K].concat(ce))}},b.onKeyUp=function(K){var X=b.props.onKeyUp;if(b.stop(),b.recordCursorPosition(),X){for(var B=arguments.length,S=new Array(B>1?B-1:0),Y=1;Y<B;Y++)S[Y-1]=arguments[Y];X.apply(void 0,[K].concat(S))}},b.onChange=function(K){var X=b.props.onChange;b.state.focused&&(b.inputting=!0),b.rawInput=b.props.parser(b.getValueFromEvent(K)),b.setState({inputValue:b.rawInput}),X(b.toNumber(b.rawInput))},b.onMouseUp=function(){var K=b.props.onMouseUp;b.recordCursorPosition(),K&&K.apply(void 0,arguments)},b.onFocus=function(){var K;b.setState({focused:!0}),(K=b.props).onFocus.apply(K,arguments)},b.onBlur=function(){var K=b.props.onBlur;b.inputting=!1,b.setState({focused:!1});var X=b.getCurrentValidValue(b.state.inputValue),B=b.setValue(X,o);if(K){var S=b.input.value,Y=b.getInputDisplayValue({focus:!1,value:B});b.input.value=Y&&Number(Y),K.apply(void 0,arguments),b.input.value=S}},b.getRatio=function(K){var X=1;return K.metaKey||K.ctrlKey?X=.1:K.shiftKey&&(X=10),X},b.getFullNum=function(K){return isNaN(K)?K:/e/i.test(String(K))?Number(K).toFixed(18).replace(/\.?0+$/,""):K},b.getPrecision=function(K){if(x(b.props.precision))return b.props.precision;var X=String(K);if(X.indexOf("e-")>=0)return parseInt(X.slice(X.indexOf("e-")+2),10);var B=0;return X.indexOf(".")>=0&&(B=X.length-X.indexOf(".")-1),B},b.getInputDisplayValue=function(K){var X=K||b.state,B=X.focused,S=X.inputValue,Y=X.value,te;B?te=S:te=b.toPrecisionAsStep(Y),te==null&&(te="");var re=b.formatWrapper(te);return x(b.props.decimalSeparator)&&(re=re.toString().replace(".",b.props.decimalSeparator)),re},b.recordCursorPosition=function(){try{b.cursorStart=b.input.selectionStart,b.cursorEnd=b.input.selectionEnd,b.currentValue=b.input.value,b.cursorBefore=b.input.value.substring(0,b.cursorStart),b.cursorAfter=b.input.value.substring(b.cursorEnd)}catch(K){}},b.restoreByAfter=function(K){if(K===void 0)return!1;var X=b.input.value,B=X.lastIndexOf(K);if(B===-1)return!1;var S=b.cursorBefore.length;return b.lastKeyCode===p.a.DELETE&&b.cursorBefore.charAt(S-1)===K[0]?(b.fixCaret(S,S),!0):B+K.length===X.length?(b.fixCaret(B,B),!0):!1},b.partRestoreByAfter=function(K){return K===void 0?!1:Array.prototype.some.call(K,function(X,B){var S=K.substring(B);return b.restoreByAfter(S)})},b.isNotCompleteNumber=function(K){return isNaN(K)||K===""||K===null||K&&K.toString().indexOf(".")===K.toString().length-1},b.stop=function(){b.autoStepTimer&&clearTimeout(b.autoStepTimer)},b.down=function(K,X,B){b.pressingUpOrDown=!0,b.step("down",K,X,B)},b.up=function(K,X,B){b.pressingUpOrDown=!0,b.step("up",K,X,B)},b.saveInput=function(K){b.input=K};var P=m.value;P===void 0&&(P=m.defaultValue),b.state={focused:m.autoFocus};var N=b.getValidValue(b.toNumber(P));return b.state=h(h({},b.state),{},{inputValue:b.toPrecisionAsStep(N),value:N}),b}return Object(V.a)(_,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(b){var P=this.props,N=P.value,K=P.onChange,X=P.max,B=P.min,S=this.state.focused;if(b){if(!R(b.value,N)||!R(b.max,X)||!R(b.min,B)){var Y=S?N:this.getValidValue(N),te;this.pressingUpOrDown?te=Y:this.inputting?te=this.rawInput:te=this.toPrecisionAsStep(Y),this.setState({value:Y,inputValue:te})}var re="value"in this.props?N:this.state.value;"max"in this.props&&b.max!==X&&typeof re=="number"&&re>X&&K&&K(X),"min"in this.props&&b.min!==B&&typeof re=="number"&&re<B&&K&&K(B)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ce=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===p.a.BACKSPACE?ce=this.cursorStart-1:this.lastKeyCode===p.a.DELETE&&(ce=this.cursorStart):ce=this.input.value.length,this.fixCaret(ce,ce)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case p.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case p.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Te){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(b){var P=b;return P===""?P="":this.isNotCompleteNumber(parseFloat(P))?P=this.state.value:P=this.getValidValue(P),this.toNumber(P)}},{key:"getValueFromEvent",value:function(b){var P=b.target.value.trim().replace(/。/g,".");return x(this.props.decimalSeparator)&&(P=P.replace(this.props.decimalSeparator,".")),P}},{key:"getValidValue",value:function(b){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,K=parseFloat(b);return isNaN(K)?b:(K<P&&(K=P),K>N&&(K=N),K)}},{key:"setValue",value:function(b,P){var N=this.props.precision,K=this.isNotCompleteNumber(parseFloat(b))?null:parseFloat(b),X=this.state.value,B=X===void 0?null:X,S=this.state.inputValue,Y=S===void 0?null:S,te=typeof K=="number"?K.toFixed(N):"".concat(K),re=K!==B||te!=="".concat(Y);return"value"in this.props?(Y=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:Y},P)):this.setState({value:K,inputValue:this.toPrecisionAsStep(b)},P),re&&this.props.onChange(K),K}},{key:"getMaxPrecision",value:function(b){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,N=this.props,K=N.precision,X=N.step;if(x(K))return K;var B=this.getPrecision(P),S=this.getPrecision(X),Y=this.getPrecision(b);return b?Math.max(Y,B+S):B+S}},{key:"getPrecisionFactor",value:function(b){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,N=this.getMaxPrecision(b,P);return Math.pow(10,N)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(b){return this.props.formatter?this.props.formatter(b):b}},{key:"toPrecisionAsStep",value:function(b){if(this.isNotCompleteNumber(b)||b==="")return b;var P=Math.abs(this.getMaxPrecision(b));return isNaN(P)?b.toString():Number(b).toFixed(P)}},{key:"toNumber",value:function(b){var P=this.props.precision,N=this.state.focused,K=b&&b.length>16&&N;return this.isNotCompleteNumber(b)||K?b:x(P)?Math.round(b*Math.pow(10,P))/Math.pow(10,P):Number(b)}},{key:"upStep",value:function(b,P){var N=this.props.step,K=this.getPrecisionFactor(b,P),X=Math.abs(this.getMaxPrecision(b,P)),B=((K*b+K*N*P)/K).toFixed(X);return this.toNumber(B)}},{key:"downStep",value:function(b,P){var N=this.props.step,K=this.getPrecisionFactor(b,P),X=Math.abs(this.getMaxPrecision(b,P)),B=((K*b-K*N*P)/K).toFixed(X);return this.toNumber(B)}},{key:"step",value:function(b,P){var N=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,X=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var B=this.props;if(B.disabled)return;var S=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(S))return;var Y=this["".concat(b,"Step")](S,K),te=Y>B.max||Y<B.min;if(Y>B.max?Y=B.max:Y<B.min&&(Y=B.min),this.setValue(Y,null),this.setState({focused:!0},function(){N.pressingUpOrDown=!1}),te)return;this.autoStepTimer=setTimeout(function(){N[b](P,K,!0)},X?d:O)}},{key:"fixCaret",value:function(b,P){if(b===void 0||P===void 0||!this.input||!this.input.value)return;try{var N=this.input.selectionStart,K=this.input.selectionEnd;(b!==N||P!==K)&&this.input.setSelectionRange(b,P)}catch(X){}}},{key:"render",value:function(){var b,P=this.props,N=P.prefixCls,K=P.disabled,X=P.readOnly,B=P.useTouch,S=P.autoComplete,Y=P.upHandler,te=P.downHandler,re=P.className,ce=P.max,Te=P.min,ye=P.style,be=P.title,we=P.onMouseEnter,xe=P.onMouseLeave,ve=P.onMouseOver,oe=P.onMouseOut,Re=P.required,Ye=P.onClick,Ue=P.tabIndex,rt=P.type,ot=P.placeholder,Oe=P.id,Me=P.inputMode,We=P.pattern,qe=P.step,Ve=P.maxLength,je=P.autoFocus,Fe=P.name,ht=P.onPaste,He=P.onInput,Pe=Object(ae.a)(P,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),Xe=this.state,tt=Xe.value,Ke=Xe.focused,et=g()(N,(b={},Object(Z.a)(b,re,!!re),Object(Z.a)(b,"".concat(N,"-disabled"),K),Object(Z.a)(b,"".concat(N,"-focused"),Ke),b)),Ae={};Object.keys(Pe).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(Ae[ue]=Pe[ue])});var nt=!X&&!K,Je=this.getInputDisplayValue(null),Se=(tt||tt===0)&&(isNaN(tt)||Number(tt)>=ce),ke=(tt||tt===0)&&(isNaN(tt)||Number(tt)<=Te),me=Se||K||X,he=ke||K||X,de=g()("".concat(N,"-handler"),"".concat(N,"-handler-up"),Object(Z.a)({},"".concat(N,"-handler-up-disabled"),me)),ie=g()("".concat(N,"-handler"),"".concat(N,"-handler-down"),Object(Z.a)({},"".concat(N,"-handler-down-disabled"),he)),q=B?{onTouchStart:me?o:this.up,onTouchEnd:this.stop}:{onMouseDown:me?o:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=B?{onTouchStart:he?o:this.down,onTouchEnd:this.stop}:{onMouseDown:he?o:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:et,style:ye,title:be,onMouseEnter:we,onMouseLeave:xe,onMouseOver:ve,onMouseOut:oe,onFocus:function(){return null},onBlur:function(){return null}},M.a.createElement("div",{className:"".concat(N,"-handler-wrap")},M.a.createElement("span",Object.assign({unselectable:"on"},q,{role:"button","aria-label":"Increase Value","aria-disabled":me,className:de}),Y||M.a.createElement("span",{unselectable:"on",className:"".concat(N,"-handler-up-inner"),onClick:s})),M.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":he,className:ie}),te||M.a.createElement("span",{unselectable:"on",className:"".concat(N,"-handler-down-inner"),onClick:s}))),M.a.createElement("div",{className:"".concat(N,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Te,"aria-valuemax":ce,"aria-valuenow":tt,required:Re,type:rt,placeholder:ot,onPaste:ht,onClick:Ye,onMouseUp:this.onMouseUp,className:"".concat(N,"-input"),tabIndex:Ue,autoComplete:S,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:nt?this.onKeyDown:o,onKeyUp:nt?this.onKeyUp:o,autoFocus:je,maxLength:Ve,readOnly:X,disabled:K,max:ce,min:Te,step:qe,name:Fe,title:be,id:Oe,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(Je),pattern:We,inputMode:Me,onInput:He},Ae))))}}]),_}(M.a.Component);A.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:w,min:-w,step:1,style:{},onChange:o,onKeyDown:o,onPressEnter:o,onFocus:o,onBlur:o,parser:l,required:!1,autoComplete:"off"};var T=A,E=lt.a=T},kSUc:function(_t,lt,ne){},"kaH+":function(_t,lt,ne){"use strict";var ae=ne("+L6B"),Z=ne("2/Rp"),k=ne("tJVT"),V=ne("q1tI"),F=ne.n(V),D=ne("UZu5"),G=ne.n(D),j=ne("dhSg"),M=ne("rLCj"),I=ne("dF/Y"),g=ne("4i/N");lt.a=function(){var p=Object(V.useState)(""),f=Object(k.a)(p,2),h=f[0],a=f[1],c=Object(V.useState)(0),o=Object(k.a)(c,2),s=o[0],l=o[1],d=Object(V.useRef)("");Object(V.useEffect)(function(){var E=j.a.subscribe("preview-image",function(y){a(y),document.body.style.overflow="hidden"});return E},[]),Object(V.useEffect)(function(){return document.addEventListener("keydown",O),function(){document.removeEventListener("keydown",O)}},[]),Object(V.useEffect)(function(){d.current=h},[h]);function O(E){E.keyCode==27&&d.current&&w()}function w(){document.body.style.overflow="auto",a("")}function x(){l(s+90)}var R=Object(V.useRef)(),A=Object(V.useRef)(),T=function(y){(y.nativeEvent.target===R.current||y.nativeEvent.target===A.current)&&w()};return F.a.createElement(V.Fragment,null,h?F.a.createElement("div",{className:"image-preview-container",ref:R,onClick:T},F.a.createElement("div",{className:"button-group"},F.a.createElement(Z.a,{onClick:x},"\u65CB\u8F6C",F.a.createElement(M.a,null)),F.a.createElement(Z.a,{href:h},"\u4E0B\u8F7D",F.a.createElement(I.a,null)),F.a.createElement(Z.a,{onClick:w},"\u5173\u95ED",F.a.createElement(g.a,null))),F.a.createElement("div",{className:"preview-wrp-group",ref:A},F.a.createElement("img",{className:"image-preview",src:h,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(s,"deg)")}}))):null)}},lZu9:function(_t,lt,ne){(function(ae){ae(ne("VrN/"),ne("1eCo"),ne("8EBN"))})(function(ae){"use strict";ae.defineMode("markdown",function(Z,k){var V=ae.getMode(Z,"text/html"),F=V.name=="null";function D(B){if(ae.findModeByName){var S=ae.findModeByName(B);S&&(B=S.mime||S.mimes[0])}var Y=ae.getMode(Z,B);return Y.name=="null"?null:Y}k.highlightFormatting===void 0&&(k.highlightFormatting=!1),k.maxBlockquoteDepth===void 0&&(k.maxBlockquoteDepth=0),k.taskLists===void 0&&(k.taskLists=!1),k.strikethrough===void 0&&(k.strikethrough=!1),k.emoji===void 0&&(k.emoji=!1),k.fencedCodeBlockHighlighting===void 0&&(k.fencedCodeBlockHighlighting=!0),k.fencedCodeBlockDefaultMode===void 0&&(k.fencedCodeBlockDefaultMode="text/plain"),k.xml===void 0&&(k.xml=!0),k.tokenTypeOverrides===void 0&&(k.tokenTypeOverrides={});var G={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 j in G)G.hasOwnProperty(j)&&k.tokenTypeOverrides[j]&&(G[j]=k.tokenTypeOverrides[j]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,I=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,g=/^\[(x| )\](?=\s)/i,p=k.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,f=/^ {0,3}(?:\={1,}|-{2,})\s*$/,h=/^[^#!\[\]*_\\<>` "'(~:]+/,a=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,c=/^\s*\[[^\]]+?\]:.*$/,o=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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]/,s=" ";function l(B,S,Y){return S.f=S.inline=Y,Y(B,S)}function d(B,S,Y){return S.f=S.block=Y,Y(B,S)}function O(B){return!B||!/\S/.test(B.string)}function w(B){if(B.linkTitle=!1,B.linkHref=!1,B.linkText=!1,B.em=!1,B.strong=!1,B.strikethrough=!1,B.quote=0,B.indentedCode=!1,B.f==R){var S=F;if(!S){var Y=ae.innerMode(V,B.htmlState);S=Y.mode.name=="xml"&&Y.state.tagStart===null&&!Y.state.context&&Y.state.tokenize.isInText}S&&(B.f=y,B.block=x,B.htmlState=null)}return B.trailingSpace=0,B.trailingSpaceNewLine=!1,B.prevLine=B.thisLine,B.thisLine={stream:null},null}function x(B,S){var Y=B.column()===S.indentation,te=O(S.prevLine.stream),re=S.indentedCode,ce=S.prevLine.hr,Te=S.list!==!1,ye=(S.listStack[S.listStack.length-1]||0)+3;S.indentedCode=!1;var be=S.indentation;if(S.indentationDiff===null&&(S.indentationDiff=S.indentation,Te)){for(S.list=null;be<S.listStack[S.listStack.length-1];)S.listStack.pop(),S.listStack.length?S.indentation=S.listStack[S.listStack.length-1]:S.list=!1;S.list!==!1&&(S.indentationDiff=be-S.listStack[S.listStack.length-1])}var we=!te&&!ce&&!S.prevLine.header&&(!Te||!re)&&!S.prevLine.fencedCodeEnd,xe=(S.list===!1||ce||te)&&S.indentation<=ye&&B.match(M),ve=null;if(S.indentationDiff>=4&&(re||S.prevLine.fencedCodeEnd||S.prevLine.header||te))return B.skipToEnd(),S.indentedCode=!0,G.code;if(B.eatSpace())return null;if(Y&&S.indentation<=ye&&(ve=B.match(p))&&ve[1].length<=6)return S.quote=0,S.header=ve[1].length,S.thisLine.header=!0,k.highlightFormatting&&(S.formatting="header"),S.f=S.inline,T(S);if(S.indentation<=ye&&B.eat(">"))return S.quote=Y?1:S.quote+1,k.highlightFormatting&&(S.formatting="quote"),B.eatSpace(),T(S);if(!xe&&!S.setext&&Y&&S.indentation<=ye&&(ve=B.match(I))){var oe=ve[1]?"ol":"ul";return S.indentation=be+B.current().length,S.list=!0,S.quote=0,S.listStack.push(S.indentation),S.em=!1,S.strong=!1,S.code=!1,S.strikethrough=!1,k.taskLists&&B.match(g,!1)&&(S.taskList=!0),S.f=S.inline,k.highlightFormatting&&(S.formatting=["list","list-"+oe]),T(S)}else{if(Y&&S.indentation<=ye&&(ve=B.match(a,!0)))return S.quote=0,S.fencedEndRE=new RegExp(ve[1]+"+ *$"),S.localMode=k.fencedCodeBlockHighlighting&&D(ve[2]||k.fencedCodeBlockDefaultMode),S.localMode&&(S.localState=ae.startState(S.localMode)),S.f=S.block=A,k.highlightFormatting&&(S.formatting="code-block"),S.code=-1,T(S);if(S.setext||(!we||!Te)&&!S.quote&&S.list===!1&&!S.code&&!xe&&!c.test(B.string)&&(ve=B.lookAhead(1))&&(ve=ve.match(f)))return S.setext?(S.header=S.setext,S.setext=0,B.skipToEnd(),k.highlightFormatting&&(S.formatting="header")):(S.header=ve[0].charAt(0)=="="?1:2,S.setext=S.header),S.thisLine.header=!0,S.f=S.inline,T(S);if(xe)return B.skipToEnd(),S.hr=!0,S.thisLine.hr=!0,G.hr;if(B.peek()==="[")return l(B,S,P)}return l(B,S,S.inline)}function R(B,S){var Y=V.token(B,S.htmlState);if(!F){var te=ae.innerMode(V,S.htmlState);(te.mode.name=="xml"&&te.state.tagStart===null&&!te.state.context&&te.state.tokenize.isInText||S.md_inside&&B.current().indexOf(">")>-1)&&(S.f=y,S.block=x,S.htmlState=null)}return Y}function A(B,S){var Y=S.listStack[S.listStack.length-1]||0,te=S.indentation<Y,re=Y+3;if(S.fencedEndRE&&S.indentation<=re&&(te||B.match(S.fencedEndRE))){k.highlightFormatting&&(S.formatting="code-block");var ce;return te||(ce=T(S)),S.localMode=S.localState=null,S.block=x,S.f=y,S.fencedEndRE=null,S.code=0,S.thisLine.fencedCodeEnd=!0,te?d(B,S,S.block):ce}else return S.localMode?S.localMode.token(B,S.localState):(B.skipToEnd(),G.code)}function T(B){var S=[];if(B.formatting){S.push(G.formatting),typeof B.formatting=="string"&&(B.formatting=[B.formatting]);for(var Y=0;Y<B.formatting.length;Y++)S.push(G.formatting+"-"+B.formatting[Y]),B.formatting[Y]==="header"&&S.push(G.formatting+"-"+B.formatting[Y]+"-"+B.header),B.formatting[Y]==="quote"&&(!k.maxBlockquoteDepth||k.maxBlockquoteDepth>=B.quote?S.push(G.formatting+"-"+B.formatting[Y]+"-"+B.quote):S.push("error"))}if(B.taskOpen)return S.push("meta"),S.length?S.join(" "):null;if(B.taskClosed)return S.push("property"),S.length?S.join(" "):null;if(B.linkHref?S.push(G.linkHref,"url"):(B.strong&&S.push(G.strong),B.em&&S.push(G.em),B.strikethrough&&S.push(G.strikethrough),B.emoji&&S.push(G.emoji),B.linkText&&S.push(G.linkText),B.code&&S.push(G.code),B.image&&S.push(G.image),B.imageAltText&&S.push(G.imageAltText,"link"),B.imageMarker&&S.push(G.imageMarker)),B.header&&S.push(G.header,G.header+"-"+B.header),B.quote&&(S.push(G.quote),!k.maxBlockquoteDepth||k.maxBlockquoteDepth>=B.quote?S.push(G.quote+"-"+B.quote):S.push(G.quote+"-"+k.maxBlockquoteDepth)),B.list!==!1){var te=(B.listStack.length-1)%3;te?te===1?S.push(G.list2):S.push(G.list3):S.push(G.list1)}return B.trailingSpaceNewLine?S.push("trailing-space-new-line"):B.trailingSpace&&S.push("trailing-space-"+(B.trailingSpace%2?"a":"b")),S.length?S.join(" "):null}function E(B,S){return B.match(h,!0)?T(S):void 0}function y(B,S){var Y=S.text(B,S);if(typeof Y!="undefined")return Y;if(S.list)return S.list=null,T(S);if(S.taskList){var te=B.match(g,!0)[1]===" ";return te?S.taskOpen=!0:S.taskClosed=!0,k.highlightFormatting&&(S.formatting="task"),S.taskList=!1,T(S)}if(S.taskOpen=!1,S.taskClosed=!1,S.header&&B.match(/^#+$/,!0))return k.highlightFormatting&&(S.formatting="header"),T(S);var re=B.next();if(S.linkTitle){S.linkTitle=!1;var ce=re;re==="("&&(ce=")"),ce=(ce+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Te="^\\s*(?:[^"+ce+"\\\\]+|\\\\\\\\|\\\\.)"+ce;if(B.match(new RegExp(Te),!0))return G.linkHref}if(re==="`"){var ye=S.formatting;k.highlightFormatting&&(S.formatting="code"),B.eatWhile("`");var be=B.current().length;if(S.code==0&&(!S.quote||be==1))return S.code=be,T(S);if(be==S.code){var we=T(S);return S.code=0,we}else return S.formatting=ye,T(S)}else if(S.code)return T(S);if(re==="\\"&&(B.next(),k.highlightFormatting)){var xe=T(S),ve=G.formatting+"-escape";return xe?xe+" "+ve:ve}if(re==="!"&&B.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return S.imageMarker=!0,S.image=!0,k.highlightFormatting&&(S.formatting="image"),T(S);if(re==="["&&S.imageMarker&&B.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return S.imageMarker=!1,S.imageAltText=!0,k.highlightFormatting&&(S.formatting="image"),T(S);if(re==="]"&&S.imageAltText){k.highlightFormatting&&(S.formatting="image");var xe=T(S);return S.imageAltText=!1,S.image=!1,S.inline=S.f=_,xe}if(re==="["&&!S.image)return S.linkText&&B.match(/^.*?\]/)||(S.linkText=!0,k.highlightFormatting&&(S.formatting="link")),T(S);if(re==="]"&&S.linkText){k.highlightFormatting&&(S.formatting="link");var xe=T(S);return S.linkText=!1,S.inline=S.f=B.match(/\(.*?\)| ?\[.*?\]/,!1)?_:y,xe}if(re==="<"&&B.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){S.f=S.inline=u,k.highlightFormatting&&(S.formatting="link");var xe=T(S);return xe?xe+=" ":xe="",xe+G.linkInline}if(re==="<"&&B.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){S.f=S.inline=u,k.highlightFormatting&&(S.formatting="link");var xe=T(S);return xe?xe+=" ":xe="",xe+G.linkEmail}if(k.xml&&re==="<"&&B.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var oe=B.string.indexOf(">",B.pos);if(oe!=-1){var Re=B.string.substring(B.start,oe);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Re)&&(S.md_inside=!0)}return B.backUp(1),S.htmlState=ae.startState(V),d(B,S,R)}if(k.xml&&re==="<"&&B.match(/^\/\w*?>/))return S.md_inside=!1,"tag";if(re==="*"||re==="_"){for(var Ye=1,Ue=B.pos==1?" ":B.string.charAt(B.pos-2);Ye<3&&B.eat(re);)Ye++;var rt=B.peek()||" ",ot=!/\s/.test(rt)&&(!o.test(rt)||/\s/.test(Ue)||o.test(Ue)),Oe=!/\s/.test(Ue)&&(!o.test(Ue)||/\s/.test(rt)||o.test(rt)),Me=null,We=null;if(Ye%2&&(!S.em&&ot&&(re==="*"||!Oe||o.test(Ue))?Me=!0:S.em==re&&Oe&&(re==="*"||!ot||o.test(rt))&&(Me=!1)),Ye>1&&(!S.strong&&ot&&(re==="*"||!Oe||o.test(Ue))?We=!0:S.strong==re&&Oe&&(re==="*"||!ot||o.test(rt))&&(We=!1)),We!=null||Me!=null){k.highlightFormatting&&(S.formatting=Me==null?"strong":We==null?"em":"strong em"),Me===!0&&(S.em=re),We===!0&&(S.strong=re);var we=T(S);return Me===!1&&(S.em=!1),We===!1&&(S.strong=!1),we}}else if(re===" "&&(B.eat("*")||B.eat("_"))){if(B.peek()===" ")return T(S);B.backUp(1)}if(k.strikethrough){if(re==="~"&&B.eatWhile(re)){if(S.strikethrough){k.highlightFormatting&&(S.formatting="strikethrough");var we=T(S);return S.strikethrough=!1,we}else if(B.match(/^[^\s]/,!1))return S.strikethrough=!0,k.highlightFormatting&&(S.formatting="strikethrough"),T(S)}else if(re===" "&&B.match(/^~~/,!0)){if(B.peek()===" ")return T(S);B.backUp(2)}}if(k.emoji&&re===":"&&B.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){S.emoji=!0,k.highlightFormatting&&(S.formatting="emoji");var qe=T(S);return S.emoji=!1,qe}return re===" "&&(B.match(/^ +$/,!1)?S.trailingSpace++:S.trailingSpace&&(S.trailingSpaceNewLine=!0)),T(S)}function u(B,S){var Y=B.next();if(Y===">"){S.f=S.inline=y,k.highlightFormatting&&(S.formatting="link");var te=T(S);return te?te+=" ":te="",te+G.linkInline}return B.match(/^[^>]+/,!0),G.linkInline}function _(B,S){if(B.eatSpace())return null;var Y=B.next();return Y==="("||Y==="["?(S.f=S.inline=b(Y==="("?")":"]"),k.highlightFormatting&&(S.formatting="link-string"),S.linkHref=!0,T(S)):"error"}var m={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function b(B){return function(S,Y){var te=S.next();if(te===B){Y.f=Y.inline=y,k.highlightFormatting&&(Y.formatting="link-string");var re=T(Y);return Y.linkHref=!1,re}return S.match(m[B]),Y.linkHref=!0,T(Y)}}function P(B,S){return B.match(/^([^\]\\]|\\.)*\]:/,!1)?(S.f=N,B.next(),k.highlightFormatting&&(S.formatting="link"),S.linkText=!0,T(S)):l(B,S,y)}function N(B,S){if(B.match(/^\]:/,!0)){S.f=S.inline=K,k.highlightFormatting&&(S.formatting="link");var Y=T(S);return S.linkText=!1,Y}return B.match(/^([^\]\\]|\\.)+/,!0),G.linkText}function K(B,S){return B.eatSpace()?null:(B.match(/^[^\s]+/,!0),B.peek()===void 0?S.linkTitle=!0:B.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),S.f=S.inline=y,G.linkHref+" url")}var X={startState:function(){return{f:x,prevLine:{stream:null},thisLine:{stream:null},block:x,htmlState:null,indentation:0,inline:y,text:E,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(B){return{f:B.f,prevLine:B.prevLine,thisLine:B.thisLine,block:B.block,htmlState:B.htmlState&&ae.copyState(V,B.htmlState),indentation:B.indentation,localMode:B.localMode,localState:B.localMode?ae.copyState(B.localMode,B.localState):null,inline:B.inline,text:B.text,formatting:!1,linkText:B.linkText,linkTitle:B.linkTitle,linkHref:B.linkHref,code:B.code,em:B.em,strong:B.strong,strikethrough:B.strikethrough,emoji:B.emoji,header:B.header,setext:B.setext,hr:B.hr,taskList:B.taskList,list:B.list,listStack:B.listStack.slice(0),quote:B.quote,indentedCode:B.indentedCode,trailingSpace:B.trailingSpace,trailingSpaceNewLine:B.trailingSpaceNewLine,md_inside:B.md_inside,fencedEndRE:B.fencedEndRE}},token:function(B,S){if(S.formatting=!1,B!=S.thisLine.stream){if(S.header=0,S.hr=!1,B.match(/^\s*$/,!0))return w(S),null;if(S.prevLine=S.thisLine,S.thisLine={stream:B},S.taskList=!1,S.trailingSpace=0,S.trailingSpaceNewLine=!1,!S.localState&&(S.f=S.block,S.f!=R)){var Y=B.match(/^\s*/,!0)[0].replace(/\t/g,s).length;if(S.indentation=Y,S.indentationDiff=null,Y>0)return null}}return S.f(B,S)},innerMode:function(B){return B.block==R?{state:B.htmlState,mode:V}:B.localState?{state:B.localState,mode:B.localMode}:{state:B,mode:X}},indent:function(B,S,Y){return B.block==R&&V.indent?V.indent(B.htmlState,S,Y):B.localState&&B.localMode.indent?B.localMode.indent(B.localState,S,Y):ae.Pass},blankLine:w,getType:T,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return X},"xml"),ae.defineMIME("text/markdown","markdown"),ae.defineMIME("text/x-markdown","markdown")})},osHv:function(_t,lt,ne){(function(ae){ae(ne("VrN/"))})(function(ae){"use strict";var Z=ae.Pos;function k(o,s){return o.line-s.line||o.ch-s.ch}var V="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",F=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",D=new RegExp("<(/?)(["+V+"]["+F+"]*)","g");function G(o,s,l,d){this.line=s,this.ch=l,this.cm=o,this.text=o.getLine(s),this.min=d?Math.max(d.from,o.firstLine()):o.firstLine(),this.max=d?Math.min(d.to-1,o.lastLine()):o.lastLine()}function j(o,s){var l=o.cm.getTokenTypeAt(Z(o.line,s));return l&&/\btag\b/.test(l)}function M(o){return o.line>=o.max?void 0:(o.ch=0,o.text=o.cm.getLine(++o.line),!0)}function I(o){return o.line<=o.min?void 0:(o.text=o.cm.getLine(--o.line),o.ch=o.text.length,!0)}function g(o){for(;;){var s=o.text.indexOf(">",o.ch);if(s==-1){if(M(o))continue;return}if(!j(o,s+1)){o.ch=s+1;continue}var l=o.text.lastIndexOf("/",s),d=l>-1&&!/\S/.test(o.text.slice(l+1,s));return o.ch=s+1,d?"selfClose":"regular"}}function p(o){for(;;){var s=o.ch?o.text.lastIndexOf("<",o.ch-1):-1;if(s==-1){if(I(o))continue;return}if(!j(o,s+1)){o.ch=s;continue}D.lastIndex=s,o.ch=s;var l=D.exec(o.text);if(l&&l.index==s)return l}}function f(o){for(;;){D.lastIndex=o.ch;var s=D.exec(o.text);if(!s){if(M(o))continue;return}if(!j(o,s.index+1)){o.ch=s.index+1;continue}return o.ch=s.index+s[0].length,s}}function h(o){for(;;){var s=o.ch?o.text.lastIndexOf(">",o.ch-1):-1;if(s==-1){if(I(o))continue;return}if(!j(o,s+1)){o.ch=s;continue}var l=o.text.lastIndexOf("/",s),d=l>-1&&!/\S/.test(o.text.slice(l+1,s));return o.ch=s+1,d?"selfClose":"regular"}}function a(o,s){for(var l=[];;){var d=f(o),O,w=o.line,x=o.ch-(d?d[0].length:0);if(!d||!(O=g(o)))return;if(O=="selfClose")continue;if(d[1]){for(var R=l.length-1;R>=0;--R)if(l[R]==d[2]){l.length=R;break}if(R<0&&(!s||s==d[2]))return{tag:d[2],from:Z(w,x),to:Z(o.line,o.ch)}}else l.push(d[2])}}function c(o,s){for(var l=[];;){var d=h(o);if(!d)return;if(d=="selfClose"){p(o);continue}var O=o.line,w=o.ch,x=p(o);if(!x)return;if(x[1])l.push(x[2]);else{for(var R=l.length-1;R>=0;--R)if(l[R]==x[2]){l.length=R;break}if(R<0&&(!s||s==x[2]))return{tag:x[2],from:Z(o.line,o.ch),to:Z(O,w)}}}}ae.registerHelper("fold","xml",function(o,s){for(var l=new G(o,s.line,0);;){var d=f(l);if(!d||l.line!=s.line)return;var O=g(l);if(!O)return;if(!d[1]&&O!="selfClose"){var w=Z(l.line,l.ch),x=a(l,d[2]);return x&&k(x.from,w)>0?{from:w,to:x.from}:null}}}),ae.findMatchingTag=function(o,s,l){var d=new G(o,s.line,s.ch,l);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var O=g(d),w=O&&Z(d.line,d.ch),x=O&&p(d);if(!O||!x||k(d,s)>0)return;var R={from:Z(d.line,d.ch),to:w,tag:x[2]};return O=="selfClose"?{open:R,close:null,at:"open"}:x[1]?{open:c(d,x[2]),close:R,at:"close"}:(d=new G(o,w.line,w.ch,l),{open:R,close:a(d,x[2]),at:"open"})},ae.findEnclosingTag=function(o,s,l,d){for(var O=new G(o,s.line,s.ch,l);;){var w=c(O,d);if(!w)break;var x=new G(o,s.line,s.ch,l),R=a(x,w.tag);if(R)return{open:w,close:R}}},ae.scanForClosingTag=function(o,s,l,d){var O=new G(o,s.line,s.ch,d?{from:0,to:d}:null);return a(O,l)}})},p5ED:function(_t,lt,ne){"use strict";var ae=ne("+L6B"),Z=ne("2/Rp"),k=ne("5Dmo"),V=ne("3S7+"),F=ne("k1fw"),D=ne("tJVT"),G=ne("q1tI"),j=ne.n(G),M=ne("vHTk"),I=ne.n(M),g=ne("yEEn"),p=ne("ZW9T"),f=ne("1vsH");lt.a=function(h){var a=h.name,c=h.data,o=h.theme,s=h.type,l=h.filename,d=h.monacoEditor,O=h.className,w=h.style,x=h.close,R=h.onClose,A=h.hasMask,T=Object(G.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),E=Object(D.a)(T,2),y=E[0],u=E[1],_=Object(G.useState)(""),m=Object(D.a)(_,2),b=m[0],P=m[1],N,K=1024*1024,X=10*K,B=Object(G.useRef)();s==="office"&&(N=Object(f.T)(c).filesize,N>X&&(s="other")),l&&(d.filename=l),Object(G.useEffect)(function(){var te,re,ce=(te=document.cookie)===null||te===void 0||((re=te.replace(/\s/g,""))===null||re===void 0)?void 0:re.split(";");ce==null||ce.map(function(Te){var ye=Te.split("=");ye[0]==="_educoder_session"&&P(ye[1])})},[]);var S=function(){if(c.startsWith("http")||c.startsWith("/")){Y();return}Object(f.z)(l||"educoder",c,l)},Y=function(){Object(f.x)(l||a,c)};return console.log("data:",c,"fileanme:",l," name:",a),j.a.createElement("div",{style:Object(F.a)({},w||{}),className:"".concat(A&&I.a.bgBlack," ").concat(s?I.a.wrp:"hide")},x&&j.a.createElement("div",{className:I.a.close,ref:B},j.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return B.current}},j.a.createElement("span",{onClick:Y},j.a.createElement("i",{className:"icon-quxiaozhiding"}))),j.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return B.current}},j.a.createElement("span",{className:"",onClick:R},j.a.createElement("i",{className:"icon-guanbi1"})))),j.a.createElement("div",{className:"".concat(I.a[O]," ").concat(O," ").concat(I.a.monaco," ").concat(s==="txt"?"show":"hide")},s==="txt"&&j.a.createElement(p.b,d)),s==="audio"&&j.a.createElement("audio",{src:"".concat(c!=null&&c.startsWith("/")||(c==null?void 0:c.indexOf("https://"))>-1?c:"data:audio/mp3;base64,").concat(c),autoPlay:!0}),s==="video"&&j.a.createElement(j.a.Fragment,null,c!=null&&c.startsWith("/")?j.a.createElement("video",{controls:!0,src:"".concat(c),autoPlay:!0}):j.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(c),autoPlay:!0})),s==="html"&&j.a.createElement("iframe",{src:c+"&disposition=inline"}),s==="pdf"&&j.a.createElement("embed",{className:I.a.embed,src:c}),s==="image"&&j.a.createElement(j.a.Fragment,null,j.a.createElement("img",{src:"".concat(c!=null&&c.startsWith("/")||(c==null?void 0:c.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(c)})),s==="other"&&j.a.createElement("div",null,j.a.createElement(Z.a,{type:"primary",size:"large",onClick:S},j.a.createElement(g.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(s==="download"||s==="office")&&j.a.createElement(Z.a,{type:"primary",size:"large",onClick:S},j.a.createElement(g.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(_t,lt,ne){},psGv:function(_t,lt,ne){var ae,Z;(function(){var k;(function(){"use strict";var G=[,,function(g){function p(a){this.__parent=a,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}p.prototype.clone_empty=function(){var a=new p(this.__parent);return a.set_indent(this.__indent_count,this.__alignment_count),a},p.prototype.item=function(a){return a<0?this.__items[this.__items.length+a]:this.__items[a]},p.prototype.has_match=function(a){for(var c=this.__items.length-1;c>=0;c--)if(this.__items[c].match(a))return!0;return!1},p.prototype.set_indent=function(a,c){this.is_empty()&&(this.__indent_count=a||0,this.__alignment_count=c||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},p.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},p.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},p.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var a=this.__parent.current_line;return a.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),a.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),a.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,a.__items[0]===" "&&(a.__items.splice(0,1),a.__character_count-=1),!0}return!1},p.prototype.is_empty=function(){return this.__items.length===0},p.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},p.prototype.push=function(a){this.__items.push(a);var c=a.lastIndexOf(`
`);c!==-1?this.__character_count=a.length-c:this.__character_count+=a.length},p.prototype.pop=function(){var a=null;return this.is_empty()||(a=this.__items.pop(),this.__character_count-=a.length),a},p.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},p.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},p.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},p.prototype.toString=function(){var a="";return this.is_empty()?this.__parent.indent_empty_lines&&(a=this.__parent.get_indent_string(this.__indent_count)):(a=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),a+=this.__items.join("")),a};function f(a,c){this.__cache=[""],this.__indent_size=a.indent_size,this.__indent_string=a.indent_char,a.indent_with_tabs||(this.__indent_string=new Array(a.indent_size+1).join(a.indent_char)),c=c||"",a.indent_level>0&&(c=new Array(a.indent_level+1).join(this.__indent_string)),this.__base_string=c,this.__base_string_length=c.length}f.prototype.get_indent_size=function(a,c){var o=this.__base_string_length;return c=c||0,a<0&&(o=0),o+=a*this.__indent_size,o+=c,o},f.prototype.get_indent_string=function(a,c){var o=this.__base_string;return c=c||0,a<0&&(a=0,o=""),c+=a*this.__indent_size,this.__ensure_cache(c),o+=this.__cache[c],o},f.prototype.__ensure_cache=function(a){for(;a>=this.__cache.length;)this.__add_column()},f.prototype.__add_column=function(){var a=this.__cache.length,c=0,o="";this.__indent_size&&a>=this.__indent_size&&(c=Math.floor(a/this.__indent_size),a-=c*this.__indent_size,o=new Array(c+1).join(this.__indent_string)),a&&(o+=new Array(a+1).join(" ")),this.__cache.push(o)};function h(a,c){this.__indent_cache=new f(a,c),this.raw=!1,this._end_with_newline=a.end_with_newline,this.indent_size=a.indent_size,this.wrap_line_length=a.wrap_line_length,this.indent_empty_lines=a.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new p(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}h.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},h.prototype.get_line_number=function(){return this.__lines.length},h.prototype.get_indent_string=function(a,c){return this.__indent_cache.get_indent_string(a,c)},h.prototype.get_indent_size=function(a,c){return this.__indent_cache.get_indent_size(a,c)},h.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},h.prototype.add_new_line=function(a){return this.is_empty()||!a&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},h.prototype.get_code=function(a){this.trim(!0);var c=this.current_line.pop();c&&(c[c.length-1]===`
`&&(c=c.replace(/\n+$/g,"")),this.current_line.push(c)),this._end_with_newline&&this.__add_outputline();var o=this.__lines.join(`
`);return a!==`
`&&(o=o.replace(/[\n]/g,a)),o},h.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},h.prototype.set_indent=function(a,c){return a=a||0,c=c||0,this.next_line.set_indent(a,c),this.__lines.length>1?(this.current_line.set_indent(a,c),!0):(this.current_line.set_indent(),!1)},h.prototype.add_raw_token=function(a){for(var c=0;c<a.newlines;c++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(a.whitespace_before),this.current_line.push(a.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},h.prototype.add_token=function(a){this.__add_space_before_token(),this.current_line.push(a),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},h.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},h.prototype.remove_indent=function(a){for(var c=this.__lines.length;a<c;)this.__lines[a]._remove_indent(),a++;this.current_line._remove_wrap_indent()},h.prototype.trim=function(a){for(a=a===void 0?!1:a,this.current_line.trim();a&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},h.prototype.just_added_newline=function(){return this.current_line.is_empty()},h.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},h.prototype.ensure_empty_line_above=function(a,c){for(var o=this.__lines.length-2;o>=0;){var s=this.__lines[o];if(s.is_empty())break;if(s.item(0).indexOf(a)!==0&&s.item(-1)!==c){this.__lines.splice(o+1,0,new p(this)),this.previous_line=this.__lines[this.__lines.length-2];break}o--}},g.exports.Output=h},function(g){function p(f,h,a,c){this.type=f,this.text=h,this.comments_before=null,this.newlines=a||0,this.whitespace_before=c||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}g.exports.Token=p},,,function(g){function p(a,c){this.raw_options=f(a,c),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}p.prototype._get_array=function(a,c){var o=this.raw_options[a],s=c||[];return typeof o=="object"?o!==null&&typeof o.concat=="function"&&(s=o.concat()):typeof o=="string"&&(s=o.split(/[^a-zA-Z0-9_\/\-]+/)),s},p.prototype._get_boolean=function(a,c){var o=this.raw_options[a],s=o===void 0?!!c:!!o;return s},p.prototype._get_characters=function(a,c){var o=this.raw_options[a],s=c||"";return typeof o=="string"&&(s=o.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),s},p.prototype._get_number=function(a,c){var o=this.raw_options[a];c=parseInt(c,10),isNaN(c)&&(c=0);var s=parseInt(o,10);return isNaN(s)&&(s=c),s},p.prototype._get_selection=function(a,c,o){var s=this._get_selection_list(a,c,o);if(s.length!==1)throw new Error("Invalid Option Value: The option '"+a+`' can only be one of the following values:
`+c+`
You passed in: '`+this.raw_options[a]+"'");return s[0]},p.prototype._get_selection_list=function(a,c,o){if(!c||c.length===0)throw new Error("Selection list cannot be empty.");if(o=o||[c[0]],!this._is_valid_selection(o,c))throw new Error("Invalid Default Value!");var s=this._get_array(a,o);if(!this._is_valid_selection(s,c))throw new Error("Invalid Option Value: The option '"+a+`' can contain only the following values:
`+c+`
You passed in: '`+this.raw_options[a]+"'");return s},p.prototype._is_valid_selection=function(a,c){return a.length&&c.length&&!a.some(function(o){return c.indexOf(o)===-1})};function f(a,c){var o={};a=h(a);var s;for(s in a)s!==c&&(o[s]=a[s]);if(c&&a[c])for(s in a[c])o[s]=a[c][s];return o}function h(a){var c={},o;for(o in a){var s=o.replace(/-/g,"_");c[s]=a[o]}return c}g.exports.Options=p,g.exports.normalizeOpts=h,g.exports.mergeOpts=f},,function(g){var p=RegExp.prototype.hasOwnProperty("sticky");function f(h){this.__input=h||"",this.__input_length=this.__input.length,this.__position=0}f.prototype.restart=function(){this.__position=0},f.prototype.back=function(){this.__position>0&&(this.__position-=1)},f.prototype.hasNext=function(){return this.__position<this.__input_length},f.prototype.next=function(){var h=null;return this.hasNext()&&(h=this.__input.charAt(this.__position),this.__position+=1),h},f.prototype.peek=function(h){var a=null;return h=h||0,h+=this.__position,h>=0&&h<this.__input_length&&(a=this.__input.charAt(h)),a},f.prototype.__match=function(h,a){h.lastIndex=a;var c=h.exec(this.__input);return c&&!(p&&h.sticky)&&(c.index!==a&&(c=null)),c},f.prototype.test=function(h,a){return a=a||0,a+=this.__position,a>=0&&a<this.__input_length?!!this.__match(h,a):!1},f.prototype.testChar=function(h,a){var c=this.peek(a);return h.lastIndex=0,c!==null&&h.test(c)},f.prototype.match=function(h){var a=this.__match(h,this.__position);return a?this.__position+=a[0].length:a=null,a},f.prototype.read=function(h,a,c){var o="",s;return h&&(s=this.match(h),s&&(o+=s[0])),a&&(s||!h)&&(o+=this.readUntil(a,c)),o},f.prototype.readUntil=function(h,a){var c="",o=this.__position;h.lastIndex=this.__position;var s=h.exec(this.__input);return s?(o=s.index,a&&(o+=s[0].length)):o=this.__input_length,c=this.__input.substring(this.__position,o),this.__position=o,c},f.prototype.readUntilAfter=function(h){return this.readUntil(h,!0)},f.prototype.get_regexp=function(h,a){var c=null,o="g";return a&&p&&(o="y"),typeof h=="string"&&h!==""?c=new RegExp(h,o):h&&(c=new RegExp(h.source,o)),c},f.prototype.get_literal_regexp=function(h){return RegExp(h.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},f.prototype.peekUntilAfter=function(h){var a=this.__position,c=this.readUntilAfter(h);return this.__position=a,c},f.prototype.lookBack=function(h){var a=this.__position-1;return a>=h.length&&this.__input.substring(a-h.length,a).toLowerCase()===h},g.exports.InputScanner=f},function(g,p,f){var h=f(8).InputScanner,a=f(3).Token,c=f(10).TokenStream,o=f(11).WhitespacePattern,s={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},l=function(d,O){this._input=new h(d),this._options=O||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new o(this._input)};l.prototype.tokenize=function(){this._input.restart(),this.__tokens=new c,this._reset();for(var d,O=new a(s.START,""),w=null,x=[],R=new c;O.type!==s.EOF;){for(d=this._get_next_token(O,w);this._is_comment(d);)R.add(d),d=this._get_next_token(O,w);R.isEmpty()||(d.comments_before=R,R=new c),d.parent=w,this._is_opening(d)?(x.push(w),w=d):w&&this._is_closing(d,w)&&(d.opened=w,w.closed=d,w=x.pop(),d.parent=w),d.previous=O,O.next=d,this.__tokens.add(d),O=d}return this.__tokens},l.prototype._is_first_token=function(){return this.__tokens.isEmpty()},l.prototype._reset=function(){},l.prototype._get_next_token=function(d,O){this._readWhitespace();var w=this._input.read(/.+/g);return w?this._create_token(s.RAW,w):this._create_token(s.EOF,"")},l.prototype._is_comment=function(d){return!1},l.prototype._is_opening=function(d){return!1},l.prototype._is_closing=function(d,O){return!1},l.prototype._create_token=function(d,O){var w=new a(d,O,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return w},l.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},g.exports.Tokenizer=l,g.exports.TOKEN=s},function(g){function p(f){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=f}p.prototype.restart=function(){this.__position=0},p.prototype.isEmpty=function(){return this.__tokens_length===0},p.prototype.hasNext=function(){return this.__position<this.__tokens_length},p.prototype.next=function(){var f=null;return this.hasNext()&&(f=this.__tokens[this.__position],this.__position+=1),f},p.prototype.peek=function(f){var h=null;return f=f||0,f+=this.__position,f>=0&&f<this.__tokens_length&&(h=this.__tokens[f]),h},p.prototype.add=function(f){this.__parent_token&&(f.parent=this.__parent_token),this.__tokens.push(f),this.__tokens_length+=1},g.exports.TokenStream=p},function(g,p,f){var h=f(12).Pattern;function a(c,o){h.call(this,c,o),o?this._line_regexp=this._input.get_regexp(o._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}a.prototype=new h,a.prototype.__set_whitespace_patterns=function(c,o){c+="\\t ",o+="\\n\\r",this._match_pattern=this._input.get_regexp("["+c+o+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+o+"]")},a.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var c=this._input.read(this._match_pattern);if(c===" ")this.whitespace_before_token=" ";else if(c){var o=this.__split(this._newline_regexp,c);this.newline_count=o.length-1,this.whitespace_before_token=o[this.newline_count]}return c},a.prototype.matching=function(c,o){var s=this._create();return s.__set_whitespace_patterns(c,o),s._update(),s},a.prototype._create=function(){return new a(this._input,this)},a.prototype.__split=function(c,o){c.lastIndex=0;for(var s=0,l=[],d=c.exec(o);d;)l.push(o.substring(s,d.index)),s=d.index+d[0].length,d=c.exec(o);return s<o.length?l.push(o.substring(s,o.length)):l.push(""),l},g.exports.WhitespacePattern=a},function(g){function p(f,h){this._input=f,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,h&&(this._starting_pattern=this._input.get_regexp(h._starting_pattern,!0),this._match_pattern=this._input.get_regexp(h._match_pattern,!0),this._until_pattern=this._input.get_regexp(h._until_pattern),this._until_after=h._until_after)}p.prototype.read=function(){var f=this._input.read(this._starting_pattern);return(!this._starting_pattern||f)&&(f+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),f},p.prototype.read_match=function(){return this._input.match(this._match_pattern)},p.prototype.until_after=function(f){var h=this._create();return h._until_after=!0,h._until_pattern=this._input.get_regexp(f),h._update(),h},p.prototype.until=function(f){var h=this._create();return h._until_after=!1,h._until_pattern=this._input.get_regexp(f),h._update(),h},p.prototype.starting_with=function(f){var h=this._create();return h._starting_pattern=this._input.get_regexp(f,!0),h._update(),h},p.prototype.matching=function(f){var h=this._create();return h._match_pattern=this._input.get_regexp(f,!0),h._update(),h},p.prototype._create=function(){return new p(this._input,this)},p.prototype._update=function(){},g.exports.Pattern=p},function(g){function p(f,h){f=typeof f=="string"?f:f.source,h=typeof h=="string"?h:h.source,this.__directives_block_pattern=new RegExp(f+/ beautify( \w+[:]\w+)+ /.source+h,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(f+/\sbeautify\signore:end\s/.source+h,"g")}p.prototype.get_directives=function(f){if(!f.match(this.__directives_block_pattern))return null;var h={};this.__directive_pattern.lastIndex=0;for(var a=this.__directive_pattern.exec(f);a;)h[a[1]]=a[2],a=this.__directive_pattern.exec(f);return h},p.prototype.readIgnored=function(f){return f.readUntilAfter(this.__directives_end_ignore_pattern)},g.exports.Directives=p},function(g,p,f){var h=f(12).Pattern,a={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1};function c(o,s){h.call(this,o,s),this.__template_pattern=null,this._disabled=Object.assign({},a),this._excluded=Object.assign({},a),s&&(this.__template_pattern=this._input.get_regexp(s.__template_pattern),this._excluded=Object.assign(this._excluded,s._excluded),this._disabled=Object.assign(this._disabled,s._disabled));var l=new h(o);this.__patterns={handlebars_comment:l.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:l.starting_with(/{{{/).until_after(/}}}/),handlebars:l.starting_with(/{{/).until_after(/}}/),php:l.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:l.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:l.starting_with(/{%/).until_after(/%}/),django_value:l.starting_with(/{{/).until_after(/}}/),django_comment:l.starting_with(/{#/).until_after(/#}/),smarty:l.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:l.starting_with(/{\*/).until_after(/\*}/),smarty_literal:l.starting_with(/{literal}/).until_after(/{\/literal}/)}}c.prototype=new h,c.prototype._create=function(){return new c(this._input,this)},c.prototype._update=function(){this.__set_templated_pattern()},c.prototype.disable=function(o){var s=this._create();return s._disabled[o]=!0,s._update(),s},c.prototype.read_options=function(o){var s=this._create();for(var l in a)s._disabled[l]=o.templating.indexOf(l)===-1;return s._update(),s},c.prototype.exclude=function(o){var s=this._create();return s._excluded[o]=!0,s._update(),s},c.prototype.read=function(){var o="";this._match_pattern?o=this._input.read(this._starting_pattern):o=this._input.read(this._starting_pattern,this.__template_pattern);for(var s=this._read_template();s;)this._match_pattern?s+=this._input.read(this._match_pattern):s+=this._input.readUntil(this.__template_pattern),o+=s,s=this._read_template();return this._until_after&&(o+=this._input.readUntilAfter(this._until_pattern)),o},c.prototype.__set_templated_pattern=function(){var o=[];this._disabled.php||o.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||o.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||o.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(o.push(this.__patterns.django._starting_pattern.source),o.push(this.__patterns.django_value._starting_pattern.source),o.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||o.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&o.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+o.join("|")+")")},c.prototype._read_template=function(){var o="",s=this._input.peek();if(s==="<"){var l=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&l==="?"&&(o=o||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&l==="%"&&(o=o||this.__patterns.erb.read())}else s==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(o=o||this.__patterns.handlebars_comment.read(),o=o||this.__patterns.handlebars_unescaped.read(),o=o||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(o=o||this.__patterns.django_value.read()),this._excluded.django||(o=o||this.__patterns.django_comment.read(),o=o||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(o=o||this.__patterns.smarty_comment.read(),o=o||this.__patterns.smarty_literal.read(),o=o||this.__patterns.smarty.read()));return o},g.exports.TemplatablePattern=c},,,,function(g,p,f){var h=f(19).Beautifier,a=f(20).Options;function c(o,s,l,d){var O=new h(o,s,l,d);return O.beautify()}g.exports=c,g.exports.defaultOptions=function(){return new a}},function(g,p,f){var h=f(20).Options,a=f(2).Output,c=f(21).Tokenizer,o=f(21).TOKEN,s=/\r\n|[\r\n]/,l=/\r\n|[\r\n]/g,d=function(_,m){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=_.max_preserve_newlines,this.preserve_newlines=_.preserve_newlines,this._output=new a(_,m)};d.prototype.current_line_has_match=function(_){return this._output.current_line.has_match(_)},d.prototype.set_space_before_token=function(_,m){this._output.space_before_token=_,this._output.non_breaking_space=m},d.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},d.prototype.add_raw_token=function(_){this._output.add_raw_token(_)},d.prototype.print_preserved_newlines=function(_){var m=0;_.type!==o.TEXT&&_.previous.type!==o.TEXT&&(m=_.newlines?1:0),this.preserve_newlines&&(m=_.newlines<this.max_preserve_newlines+1?_.newlines:this.max_preserve_newlines+1);for(var b=0;b<m;b++)this.print_newline(b>0);return m!==0},d.prototype.traverse_whitespace=function(_){return _.whitespace_before||_.newlines?(this.print_preserved_newlines(_)||(this._output.space_before_token=!0),!0):!1},d.prototype.previous_token_wrapped=function(){return this._output.previous_token_wrapped},d.prototype.print_newline=function(_){this._output.add_new_line(_)},d.prototype.print_token=function(_){_.text&&(this._output.set_indent(this.indent_level,this.alignment_size),this._output.add_token(_.text))},d.prototype.indent=function(){this.indent_level++},d.prototype.get_full_indent=function(_){return _=this.indent_level+(_||0),_<1?"":this._output.get_indent_string(_)};var O=function(_){for(var m=null,b=_.next;b.type!==o.EOF&&_.closed!==b;){if(b.type===o.ATTRIBUTE&&b.text==="type"){b.next&&b.next.type===o.EQUALS&&b.next.next&&b.next.next.type===o.VALUE&&(m=b.next.next.text);break}b=b.next}return m},w=function(_,m){var b=null,P=null;return m.closed?(_==="script"?b="text/javascript":_==="style"&&(b="text/css"),b=O(m)||b,b.search("text/css")>-1?P="css":b.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/)>-1?P="javascript":b.search(/(text|application|dojo)\/(x-)?(html)/)>-1?P="html":b.search(/test\/null/)>-1&&(P="null"),P):null};function x(_,m){return m.indexOf(_)!==-1}function R(_,m,b){this.parent=_||null,this.tag=m?m.tag_name:"",this.indent_level=b||0,this.parser_token=m||null}function A(_){this._printer=_,this._current_frame=null}A.prototype.get_parser_token=function(){return this._current_frame?this._current_frame.parser_token:null},A.prototype.record_tag=function(_){var m=new R(this._current_frame,_,this._printer.indent_level);this._current_frame=m},A.prototype._try_pop_frame=function(_){var m=null;return _&&(m=_.parser_token,this._printer.indent_level=_.indent_level,this._current_frame=_.parent),m},A.prototype._get_frame=function(_,m){for(var b=this._current_frame;b&&!(_.indexOf(b.tag)!==-1);){if(m&&m.indexOf(b.tag)!==-1){b=null;break}b=b.parent}return b},A.prototype.try_pop=function(_,m){var b=this._get_frame([_],m);return this._try_pop_frame(b)},A.prototype.indent_to_tag=function(_){var m=this._get_frame(_);m&&(this._printer.indent_level=m.indent_level)};function T(_,m,b,P){this._source_text=_||"",m=m||{},this._js_beautify=b,this._css_beautify=P,this._tag_stack=null;var N=new h(m,"html");this._options=N,this._is_wrap_attributes_force=this._options.wrap_attributes.substr(0,"force".length)==="force",this._is_wrap_attributes_force_expand_multiline=this._options.wrap_attributes==="force-expand-multiline",this._is_wrap_attributes_force_aligned=this._options.wrap_attributes==="force-aligned",this._is_wrap_attributes_aligned_multiple=this._options.wrap_attributes==="aligned-multiple",this._is_wrap_attributes_preserve=this._options.wrap_attributes.substr(0,"preserve".length)==="preserve",this._is_wrap_attributes_preserve_aligned=this._options.wrap_attributes==="preserve-aligned"}T.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var _=this._source_text,m=this._options.eol;this._options.eol==="auto"&&(m=`
`,_&&s.test(_)&&(m=_.match(s)[0])),_=_.replace(l,`
`);var b=_.match(/^[\t ]*/)[0],P={text:"",type:""},N=new E,K=new d(this._options,b),X=new c(_,this._options).tokenize();this._tag_stack=new A(K);for(var B=null,S=X.next();S.type!==o.EOF;)S.type===o.TAG_OPEN||S.type===o.COMMENT?(B=this._handle_tag_open(K,S,N,P),N=B):S.type===o.ATTRIBUTE||S.type===o.EQUALS||S.type===o.VALUE||S.type===o.TEXT&&!N.tag_complete?B=this._handle_inside_tag(K,S,N,X):S.type===o.TAG_CLOSE?B=this._handle_tag_close(K,S,N):S.type===o.TEXT?B=this._handle_text(K,S,N):K.add_raw_token(S),P=B,S=X.next();var Y=K._output.get_code(m);return Y},T.prototype._handle_tag_close=function(_,m,b){var P={text:m.text,type:m.type};return _.alignment_size=0,b.tag_complete=!0,_.set_space_before_token(m.newlines||m.whitespace_before!=="",!0),b.is_unformatted?_.add_raw_token(m):(b.tag_start_char==="<"&&(_.set_space_before_token(m.text[0]==="/",!0),this._is_wrap_attributes_force_expand_multiline&&b.has_wrapped_attrs&&_.print_newline(!1)),_.print_token(m)),b.indent_content&&!(b.is_unformatted||b.is_content_unformatted)&&(_.indent(),b.indent_content=!1),!b.is_inline_element&&!(b.is_unformatted||b.is_content_unformatted)&&_.set_wrap_point(),P},T.prototype._handle_inside_tag=function(_,m,b,P){var N=b.has_wrapped_attrs,K={text:m.text,type:m.type};if(_.set_space_before_token(m.newlines||m.whitespace_before!=="",!0),b.is_unformatted)_.add_raw_token(m);else if(b.tag_start_char==="{"&&m.type===o.TEXT)_.print_preserved_newlines(m)?(m.newlines=0,_.add_raw_token(m)):_.print_token(m);else{if(m.type===o.ATTRIBUTE?(_.set_space_before_token(!0),b.attr_count+=1):(m.type===o.EQUALS||m.type===o.VALUE&&m.previous.type===o.EQUALS)&&_.set_space_before_token(!1),m.type===o.ATTRIBUTE&&b.tag_start_char==="<"&&((this._is_wrap_attributes_preserve||this._is_wrap_attributes_preserve_aligned)&&(_.traverse_whitespace(m),N=N||m.newlines!==0),this._is_wrap_attributes_force)){var X=b.attr_count>1;if(this._is_wrap_attributes_force_expand_multiline&&b.attr_count===1){var B=!0,S=0,Y;do{if(Y=P.peek(S),Y.type===o.ATTRIBUTE){B=!1;break}S+=1}while(S<4&&Y.type!==o.EOF&&Y.type!==o.TAG_CLOSE);X=!B}X&&(_.print_newline(!1),N=!0)}_.print_token(m),N=N||_.previous_token_wrapped(),b.has_wrapped_attrs=N}return K},T.prototype._handle_text=function(_,m,b){var P={text:m.text,type:"TK_CONTENT"};return b.custom_beautifier_name?this._print_custom_beatifier_text(_,m,b):b.is_unformatted||b.is_content_unformatted?_.add_raw_token(m):(_.traverse_whitespace(m),_.print_token(m)),P},T.prototype._print_custom_beatifier_text=function(_,m,b){var P=this;if(m.text!==""){var N=m.text,K,X=1,B="",S="";b.custom_beautifier_name==="javascript"&&typeof this._js_beautify=="function"?K=this._js_beautify:b.custom_beautifier_name==="css"&&typeof this._css_beautify=="function"?K=this._css_beautify:b.custom_beautifier_name==="html"&&(K=function(ye,be){var we=new T(ye,be,P._js_beautify,P._css_beautify);return we.beautify()}),this._options.indent_scripts==="keep"?X=0:this._options.indent_scripts==="separate"&&(X=-_.indent_level);var Y=_.get_full_indent(X);if(N=N.replace(/\n[ \t]*$/,""),b.custom_beautifier_name!=="html"&&N[0]==="<"&&N.match(/^(<!--|<!\[CDATA\[)/)){var te=/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(N);if(!te){_.add_raw_token(m);return}B=Y+te[1]+`
`,N=te[4],te[5]&&(S=Y+te[5]),N=N.replace(/\n[ \t]*$/,""),(te[2]||te[3].indexOf(`
`)!==-1)&&(te=te[3].match(/[ \t]+$/),te&&(m.whitespace_before=te[0]))}if(N)if(K){var re=function(){this.eol=`
`};re.prototype=this._options.raw_options;var ce=new re;N=K(Y+N,ce)}else{var Te=m.whitespace_before;Te&&(N=N.replace(new RegExp(`
(`+Te+")?","g"),`
`)),N=Y+N.replace(/\n/g,`
`+Y)}B&&(N?N=B+N+`
`+S:N=B+S),_.print_newline(!1),N&&(m.text=N,m.whitespace_before="",m.newlines=0,_.add_raw_token(m),_.print_newline(!0))}},T.prototype._handle_tag_open=function(_,m,b,P){var N=this._get_tag_open_token(m);return(b.is_unformatted||b.is_content_unformatted)&&!b.is_empty_element&&m.type===o.TAG_OPEN&&m.text.indexOf("</")===0?(_.add_raw_token(m),N.start_tag_token=this._tag_stack.try_pop(N.tag_name)):(_.traverse_whitespace(m),this._set_tag_position(_,m,N,b,P),N.is_inline_element||_.set_wrap_point(),_.print_token(m)),(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(N.alignment_size=m.text.length+1),!N.tag_complete&&!N.is_unformatted&&(_.alignment_size=N.alignment_size),N};var E=function(_,m){if(this.parent=_||null,this.text="",this.type="TK_TAG_OPEN",this.tag_name="",this.is_inline_element=!1,this.is_unformatted=!1,this.is_content_unformatted=!1,this.is_empty_element=!1,this.is_start_tag=!1,this.is_end_tag=!1,this.indent_content=!1,this.multiline_content=!1,this.custom_beautifier_name=null,this.start_tag_token=null,this.attr_count=0,this.has_wrapped_attrs=!1,this.alignment_size=0,this.tag_complete=!1,this.tag_start_char="",this.tag_check="",!m)this.tag_complete=!0;else{var b;this.tag_start_char=m.text[0],this.text=m.text,this.tag_start_char==="<"?(b=m.text.match(/^<([^\s>]*)/),this.tag_check=b?b[1]:""):(b=m.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=b?b[1]:"",(m.text.startsWith("{{#>")||m.text.startsWith("{{~#>"))&&this.tag_check[0]===">"&&(this.tag_check===">"&&m.next!==null?this.tag_check=m.next.text.split(" ")[0]:this.tag_check=m.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),m.type===o.COMMENT&&(this.tag_complete=!0),this.is_start_tag=this.tag_check.charAt(0)!=="/",this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||m.closed&&m.closed.text==="/>";var P=2;this.tag_start_char==="{"&&this.text.length>=3&&(this.text.charAt(2)==="~"&&(P=3)),this.is_end_tag=this.is_end_tag||this.tag_start_char==="{"&&(this.text.length<3||/[^#\^]/.test(this.text.charAt(P)))}};T.prototype._get_tag_open_token=function(_){var m=new E(this._tag_stack.get_parser_token(),_);return m.alignment_size=this._options.wrap_attributes_indent_size,m.is_end_tag=m.is_end_tag||x(m.tag_check,this._options.void_elements),m.is_empty_element=m.tag_complete||m.is_start_tag&&m.is_end_tag,m.is_unformatted=!m.tag_complete&&x(m.tag_check,this._options.unformatted),m.is_content_unformatted=!m.is_empty_element&&x(m.tag_check,this._options.content_unformatted),m.is_inline_element=x(m.tag_name,this._options.inline)||m.tag_name.includes("-")||m.tag_start_char==="{",m},T.prototype._set_tag_position=function(_,m,b,P,N){if(b.is_empty_element||(b.is_end_tag?b.start_tag_token=this._tag_stack.try_pop(b.tag_name):(this._do_optional_end_element(b)&&(b.is_inline_element||_.print_newline(!1)),this._tag_stack.record_tag(b),(b.tag_name==="script"||b.tag_name==="style")&&!(b.is_unformatted||b.is_content_unformatted)&&(b.custom_beautifier_name=w(b.tag_check,m)))),x(b.tag_check,this._options.extra_liners)&&(_.print_newline(!1),_._output.just_added_blankline()||_.print_newline(!0)),b.is_empty_element){if(b.tag_start_char==="{"&&b.tag_check==="else"){this._tag_stack.indent_to_tag(["if","unless","each"]),b.indent_content=!0;var K=_.current_line_has_match(/{{#if/);K||_.print_newline(!1)}b.tag_name==="!--"&&N.type===o.TAG_CLOSE&&P.is_end_tag&&b.text.indexOf(`
`)===-1||(b.is_inline_element||b.is_unformatted||_.print_newline(!1),this._calcluate_parent_multiline(_,b))}else if(b.is_end_tag){var X=!1;X=b.start_tag_token&&b.start_tag_token.multiline_content,X=X||!b.is_inline_element&&!(P.is_inline_element||P.is_unformatted)&&!(N.type===o.TAG_CLOSE&&b.start_tag_token===P)&&N.type!=="TK_CONTENT",(b.is_content_unformatted||b.is_unformatted)&&(X=!1),X&&_.print_newline(!1)}else b.indent_content=!b.custom_beautifier_name,b.tag_start_char==="<"&&(b.tag_name==="html"?b.indent_content=this._options.indent_inner_html:b.tag_name==="head"?b.indent_content=this._options.indent_head_inner_html:b.tag_name==="body"&&(b.indent_content=this._options.indent_body_inner_html)),!(b.is_inline_element||b.is_unformatted)&&(N.type!=="TK_CONTENT"||b.is_content_unformatted)&&_.print_newline(!1),this._calcluate_parent_multiline(_,b)},T.prototype._calcluate_parent_multiline=function(_,m){m.parent&&_._output.just_added_newline()&&!((m.is_inline_element||m.is_unformatted)&&m.parent.is_inline_element)&&(m.parent.multiline_content=!0)};var y=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"],u=["a","audio","del","ins","map","noscript","video"];T.prototype._do_optional_end_element=function(_){var m=null;if(_.is_empty_element||!_.is_start_tag||!_.parent)return;if(_.tag_name==="body")m=m||this._tag_stack.try_pop("head");else if(_.tag_name==="li")m=m||this._tag_stack.try_pop("li",["ol","ul"]);else if(_.tag_name==="dd"||_.tag_name==="dt")m=m||this._tag_stack.try_pop("dt",["dl"]),m=m||this._tag_stack.try_pop("dd",["dl"]);else if(_.parent.tag_name==="p"&&y.indexOf(_.tag_name)!==-1){var b=_.parent.parent;(!b||u.indexOf(b.tag_name)===-1)&&(m=m||this._tag_stack.try_pop("p"))}else _.tag_name==="rp"||_.tag_name==="rt"?(m=m||this._tag_stack.try_pop("rt",["ruby","rtc"]),m=m||this._tag_stack.try_pop("rp",["ruby","rtc"])):_.tag_name==="optgroup"?m=m||this._tag_stack.try_pop("optgroup",["select"]):_.tag_name==="option"?m=m||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):_.tag_name==="colgroup"?m=m||this._tag_stack.try_pop("caption",["table"]):_.tag_name==="thead"?(m=m||this._tag_stack.try_pop("caption",["table"]),m=m||this._tag_stack.try_pop("colgroup",["table"])):_.tag_name==="tbody"||_.tag_name==="tfoot"?(m=m||this._tag_stack.try_pop("caption",["table"]),m=m||this._tag_stack.try_pop("colgroup",["table"]),m=m||this._tag_stack.try_pop("thead",["table"]),m=m||this._tag_stack.try_pop("tbody",["table"])):_.tag_name==="tr"?(m=m||this._tag_stack.try_pop("caption",["table"]),m=m||this._tag_stack.try_pop("colgroup",["table"]),m=m||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"])):(_.tag_name==="th"||_.tag_name==="td")&&(m=m||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]),m=m||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return _.parent=this._tag_stack.get_parser_token(),m},g.exports.Beautifier=T},function(g,p,f){var h=f(6).Options;function a(c){h.call(this,c,"html"),this.templating.length===1&&this.templating[0]==="auto"&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}a.prototype=new h,g.exports.Options=a},function(g,p,f){var h=f(9).Tokenizer,a=f(9).TOKEN,c=f(13).Directives,o=f(14).TemplatablePattern,s=f(12).Pattern,l={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:a.START,RAW:a.RAW,EOF:a.EOF},d=new c(/<\!--/,/-->/),O=function(w,x){h.call(this,w,x),this._current_tag_name="";var R=new o(this._input).read_options(this._options),A=new s(this._input);if(this.__patterns={word:R.until(/[\n\r\t <]/),single_quote:R.until_after(/'/),double_quote:R.until_after(/"/),attribute:R.until(/[\n\r\t =>]|\/>/),element_name:R.until(/[\n\r\t >\/]/),handlebars_comment:A.starting_with(/{{!--/).until_after(/--}}/),handlebars:A.starting_with(/{{/).until_after(/}}/),handlebars_open:A.until(/[\n\r\t }]/),handlebars_raw_close:A.until(/}}/),comment:A.starting_with(/<!--/).until_after(/-->/),cdata:A.starting_with(/<!\[CDATA\[/).until_after(/]]>/),conditional_comment:A.starting_with(/<!\[/).until_after(/]>/),processing:A.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter){var T=this._input.get_literal_regexp(this._options.unformatted_content_delimiter);this.__patterns.unformatted_content_delimiter=A.matching(T).until_after(T)}};O.prototype=new h,O.prototype._is_comment=function(w){return!1},O.prototype._is_opening=function(w){return w.type===l.TAG_OPEN},O.prototype._is_closing=function(w,x){return w.type===l.TAG_CLOSE&&x&&((w.text===">"||w.text==="/>")&&x.text[0]==="<"||w.text==="}}"&&x.text[0]==="{"&&x.text[1]==="{")},O.prototype._reset=function(){this._current_tag_name=""},O.prototype._get_next_token=function(w,x){var R=null;this._readWhitespace();var A=this._input.peek();return A===null?this._create_token(l.EOF,""):(R=R||this._read_open_handlebars(A,x),R=R||this._read_attribute(A,w,x),R=R||this._read_close(A,x),R=R||this._read_raw_content(A,w,x),R=R||this._read_content_word(A),R=R||this._read_comment_or_cdata(A),R=R||this._read_processing(A),R=R||this._read_open(A,x),R=R||this._create_token(l.UNKNOWN,this._input.next()),R)},O.prototype._read_comment_or_cdata=function(w){var x=null,R=null,A=null;if(w==="<"){var T=this._input.peek(1);T==="!"&&(R=this.__patterns.comment.read(),R?(A=d.get_directives(R),A&&A.ignore==="start"&&(R+=d.readIgnored(this._input))):R=this.__patterns.cdata.read()),R&&(x=this._create_token(l.COMMENT,R),x.directives=A)}return x},O.prototype._read_processing=function(w){var x=null,R=null,A=null;if(w==="<"){var T=this._input.peek(1);(T==="!"||T==="?")&&(R=this.__patterns.conditional_comment.read(),R=R||this.__patterns.processing.read()),R&&(x=this._create_token(l.COMMENT,R),x.directives=A)}return x},O.prototype._read_open=function(w,x){var R=null,A=null;return x||w==="<"&&(R=this._input.next(),this._input.peek()==="/"&&(R+=this._input.next()),R+=this.__patterns.element_name.read(),A=this._create_token(l.TAG_OPEN,R)),A},O.prototype._read_open_handlebars=function(w,x){var R=null,A=null;return x||this._options.indent_handlebars&&w==="{"&&this._input.peek(1)==="{"&&(this._input.peek(2)==="!"?(R=this.__patterns.handlebars_comment.read(),R=R||this.__patterns.handlebars.read(),A=this._create_token(l.COMMENT,R)):(R=this.__patterns.handlebars_open.read(),A=this._create_token(l.TAG_OPEN,R))),A},O.prototype._read_close=function(w,x){var R=null,A=null;return x&&(x.text[0]==="<"&&(w===">"||w==="/"&&this._input.peek(1)===">")?(R=this._input.next(),w==="/"&&(R+=this._input.next()),A=this._create_token(l.TAG_CLOSE,R)):x.text[0]==="{"&&w==="}"&&this._input.peek(1)==="}"&&(this._input.next(),this._input.next(),A=this._create_token(l.TAG_CLOSE,"}}"))),A},O.prototype._read_attribute=function(w,x,R){var A=null,T="";if(R&&R.text[0]==="<")if(w==="=")A=this._create_token(l.EQUALS,this._input.next());else if(w==='"'||w==="'"){var E=this._input.next();w==='"'?E+=this.__patterns.double_quote.read():E+=this.__patterns.single_quote.read(),A=this._create_token(l.VALUE,E)}else T=this.__patterns.attribute.read(),T&&(x.type===l.EQUALS?A=this._create_token(l.VALUE,T):A=this._create_token(l.ATTRIBUTE,T));return A},O.prototype._is_content_unformatted=function(w){return this._options.void_elements.indexOf(w)===-1&&(this._options.content_unformatted.indexOf(w)!==-1||this._options.unformatted.indexOf(w)!==-1)},O.prototype._read_raw_content=function(w,x,R){var A="";if(R&&R.text[0]==="{")A=this.__patterns.handlebars_raw_close.read();else if(x.type===l.TAG_CLOSE&&x.opened.text[0]==="<"&&x.text[0]!=="/"){var T=x.opened.text.substr(1).toLowerCase();if(T==="script"||T==="style"){var E=this._read_comment_or_cdata(w);if(E)return E.type=l.TEXT,E;A=this._input.readUntil(new RegExp("</"+T+"[\\n\\r\\t ]*?>","ig"))}else this._is_content_unformatted(T)&&(A=this._input.readUntil(new RegExp("</"+T+"[\\n\\r\\t ]*?>","ig")))}return A?this._create_token(l.TEXT,A):null},O.prototype._read_content_word=function(w){var x="";if(this._options.unformatted_content_delimiter&&(w===this._options.unformatted_content_delimiter[0]&&(x=this.__patterns.unformatted_content_delimiter.read())),x||(x=this.__patterns.word.read()),x)return this._create_token(l.TEXT,x)},g.exports.Tokenizer=O,g.exports.TOKEN=l}],j={};function M(g){var p=j[g];if(p!==void 0)return p.exports;var f=j[g]={exports:{}};return G[g](f,f.exports,M),f.exports}var I=M(18);k=I})();var V=k;if(!0)!(ae=[ne,ne("6UM0"),ne("TXwP")],Z=function(G){var j=ne("6UM0"),M=ne("TXwP");return{html_beautify:function(I,g){return V(I,g,j.js_beautify,M.css_beautify)}}}.apply(lt,ae),Z!==void 0&&(_t.exports=Z));else var F,D})()},"rAM+":function(_t,lt,ne){"use strict";ne.d(lt,"a",function(){return Z});var ae=ne("Qw5x");function Z(k,V){var F;if(typeof Symbol=="undefined"||k[Symbol.iterator]==null){if(Array.isArray(k)||(F=Object(ae.a)(k))||V&&k&&typeof k.length=="number"){F&&(k=F);var D=0,G=function(){};return{s:G,n:function(){return D>=k.length?{done:!0}:{done:!1,value:k[D++]}},e:function(p){throw p},f:G}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var j=!0,M=!1,I;return{s:function(){F=k[Symbol.iterator]()},n:function(){var p=F.next();return j=p.done,p},e:function(p){M=!0,I=p},f:function(){try{!j&&F.return!=null&&F.return()}finally{if(M)throw I}}}}},rUJ1:function(_t,lt){const ne=/[&<>"']/,ae=/[&<>"']/g,Z=/[<>"']|&(?!#?\w+;)/,k=/[<>"']|&(?!#?\w+;)/g,V={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},F=A=>V[A];function D(A,T){if(T){if(ne.test(A))return A.replace(ae,F)}else if(Z.test(A))return A.replace(k,F);return A}const G=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function j(A){return A.replace(G,(T,E)=>(E=E.toLowerCase(),E==="colon"?":":E.charAt(0)==="#"?E.charAt(1)==="x"?String.fromCharCode(parseInt(E.substring(2),16)):String.fromCharCode(+E.substring(1)):""))}const M=/(^|[^\[])\^/g;function I(A,T){A=A.source||A,T=T||"";const E={replace:(y,u)=>(u=u.source||u,u=u.replace(M,"$1"),A=A.replace(y,u),E),getRegex:()=>new RegExp(A,T)};return E}const g=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function f(A,T,E){if(A){let y;try{y=decodeURIComponent(j(E)).replace(g,"").toLowerCase()}catch(u){return null}if(y.indexOf("javascript:")===0||y.indexOf("vbscript:")===0||y.indexOf("data:")===0)return null}T&&!p.test(E)&&(E=s(T,E));try{E=encodeURI(E).replace(/%25/g,"%")}catch(y){return null}return E}const h={},a=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,o=/^([^:]+:\/*[^/]*)[\s\S]*$/;function s(A,T){h[" "+A]||(a.test(A)?h[" "+A]=A+"/":h[" "+A]=w(A,"/",!0)),A=h[" "+A];const E=A.indexOf(":")===-1;return T.substring(0,2)==="//"?E?T:A.replace(c,"$1")+T:T.charAt(0)==="/"?E?T:A.replace(o,"$1")+T:A+T}const l={exec:function(){}};function d(A){let T=1,E,y;for(;T<arguments.length;T++){E=arguments[T];for(y in E)Object.prototype.hasOwnProperty.call(E,y)&&(A[y]=E[y])}return A}function O(A,T){const E=A.replace(/\|/g,(_,m,b)=>{let P=!1,N=m;for(;--N>=0&&b[N]==="\\";)P=!P;return P?"|":" |"}),y=E.split(/ \|/);let u=0;if(y.length>T)y.splice(T);else for(;y.length<T;)y.push("");for(;u<y.length;u++)y[u]=y[u].trim().replace(/\\\|/g,"|");return y}function w(A,T,E){const y=A.length;if(y===0)return"";let u=0;for(;u<y;){const _=A.charAt(y-u-1);if(_===T&&!E)u++;else if(_!==T&&E)u++;else break}return A.substr(0,y-u)}function x(A,T){if(A.indexOf(T[1])===-1)return-1;const E=A.length;let y=0,u=0;for(;u<E;u++)if(A[u]==="\\")u++;else if(A[u]===T[0])y++;else if(A[u]===T[1]&&(y--,y<0))return u;return-1}function R(A){A&&A.sanitize&&!A.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")}_t.exports={escape:D,unescape:j,edit:I,cleanUrl:f,resolveUrl:s,noopTest:l,merge:d,splitCells:O,rtrim:w,findClosingBracket:x,checkSanitizeDeprecation:R}},smFo:function(_t,lt,ne){_t.exports={wrap:"wrap___1xSvp",header:"header___1niV1",title:"title____shwY",menu:"menu___2Y-rd",top:"top___1_d5Y",line:"line___1kciD",flexCenter:"flexCenter___3bP7s",like:"like___3lXjz",canLike:"canLike___AuDmL",attachmentName:"attachmentName___2SteY"}},ulZh:function(_t,lt,ne){typeof window!="undefined"&&function(Z,k){_t.exports=k()}(this,function(){return function(ae){var Z={};function k(V){if(Z[V])return Z[V].exports;var F=Z[V]={i:V,l:!1,exports:{}};return ae[V].call(F.exports,F,F.exports,k),F.l=!0,F.exports}return k.m=ae,k.c=Z,k.d=function(V,F,D){k.o(V,F)||Object.defineProperty(V,F,{enumerable:!0,get:D})},k.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},k.t=function(V,F){if(F&1&&(V=k(V)),F&8)return V;if(F&4&&typeof V=="object"&&V&&V.__esModule)return V;var D=Object.create(null);if(k.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:V}),F&2&&typeof V!="string")for(var G in V)k.d(D,G,function(j){return V[j]}.bind(null,G));return D},k.n=function(V){var F=V&&V.__esModule?function(){return V.default}:function(){return V};return k.d(F,"a",F),F},k.o=function(V,F){return Object.prototype.hasOwnProperty.call(V,F)},k.p="/dist/",k(k.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ae,Z,k){"use strict";var V=Object.prototype.hasOwnProperty,F="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(F=!1));function G(g,p,f){this.fn=g,this.context=p,this.once=f||!1}function j(g,p,f,h,a){if(typeof f!="function")throw new TypeError("The listener must be a function");var c=new G(f,h||g,a),o=F?F+p:p;return g._events[o]?g._events[o].fn?g._events[o]=[g._events[o],c]:g._events[o].push(c):(g._events[o]=c,g._eventsCount++),g}function M(g,p){--g._eventsCount===0?g._events=new D:delete g._events[p]}function I(){this._events=new D,this._eventsCount=0}I.prototype.eventNames=function(){var p=[],f,h;if(this._eventsCount===0)return p;for(h in f=this._events)V.call(f,h)&&p.push(F?h.slice(1):h);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(f)):p},I.prototype.listeners=function(p){var f=F?F+p:p,h=this._events[f];if(!h)return[];if(h.fn)return[h.fn];for(var a=0,c=h.length,o=new Array(c);a<c;a++)o[a]=h[a].fn;return o},I.prototype.listenerCount=function(p){var f=F?F+p:p,h=this._events[f];return h?h.fn?1:h.length:0},I.prototype.emit=function(p,f,h,a,c,o){var s=F?F+p:p;if(!this._events[s])return!1;var l=this._events[s],d=arguments.length,O,w;if(l.fn){l.once&&this.removeListener(p,l.fn,void 0,!0);switch(d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,f),!0;case 3:return l.fn.call(l.context,f,h),!0;case 4:return l.fn.call(l.context,f,h,a),!0;case 5:return l.fn.call(l.context,f,h,a,c),!0;case 6:return l.fn.call(l.context,f,h,a,c,o),!0}for(w=1,O=new Array(d-1);w<d;w++)O[w-1]=arguments[w];l.fn.apply(l.context,O)}else{var x=l.length,R;for(w=0;w<x;w++){l[w].once&&this.removeListener(p,l[w].fn,void 0,!0);switch(d){case 1:l[w].fn.call(l[w].context);break;case 2:l[w].fn.call(l[w].context,f);break;case 3:l[w].fn.call(l[w].context,f,h);break;case 4:l[w].fn.call(l[w].context,f,h,a);break;default:if(!O)for(R=1,O=new Array(d-1);R<d;R++)O[R-1]=arguments[R];l[w].fn.apply(l[w].context,O)}}}return!0},I.prototype.on=function(p,f,h){return j(this,p,f,h,!1)},I.prototype.once=function(p,f,h){return j(this,p,f,h,!0)},I.prototype.removeListener=function(p,f,h,a){var c=F?F+p:p;if(!this._events[c])return this;if(!f)return M(this,c),this;var o=this._events[c];if(o.fn)o.fn===f&&(!a||o.once)&&(!h||o.context===h)&&M(this,c);else{for(var s=0,l=[],d=o.length;s<d;s++)(o[s].fn!==f||a&&!o[s].once||h&&o[s].context!==h)&&l.push(o[s]);l.length?this._events[c]=l.length===1?l[0]:l:M(this,c)}return this},I.prototype.removeAllListeners=function(p){var f;return p?(f=F?F+p:p,this._events[f]&&M(this,f)):(this._events=new D,this._eventsCount=0),this},I.prototype.off=I.prototype.removeListener,I.prototype.addListener=I.prototype.on,I.prefixed=F,I.EventEmitter=I,ae.exports=I},"./node_modules/url-toolkit/src/url-toolkit.js":function(ae,Z,k){(function(V){var F=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,D=/^([^\/?#]*)([^]*)$/,G=/(?:\/|^)\.(?=\/)/g,j=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(I,g,p){if(p=p||{},I=I.trim(),g=g.trim(),!g){if(!p.alwaysNormalize)return I;var f=M.parseURL(I);if(!f)throw new Error("Error trying to parse base URL.");return f.path=M.normalizePath(f.path),M.buildURLFromParts(f)}var h=M.parseURL(g);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return p.alwaysNormalize?(h.path=M.normalizePath(h.path),M.buildURLFromParts(h)):g;var a=M.parseURL(I);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&a.path[0]!=="/"){var c=D.exec(a.path);a.netLoc=c[1],a.path=c[2]}a.netLoc&&!a.path&&(a.path="/");var o={scheme:a.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(o.netLoc=a.netLoc,h.path[0]!=="/"))if(!h.path)o.path=a.path,h.params||(o.params=a.params,h.query||(o.query=a.query));else{var s=a.path,l=s.substring(0,s.lastIndexOf("/")+1)+h.path;o.path=M.normalizePath(l)}return o.path===null&&(o.path=p.alwaysNormalize?M.normalizePath(h.path):h.path),M.buildURLFromParts(o)},parseURL:function(I){var g=F.exec(I);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(I){for(I=I.split("").reverse().join("").replace(G,"");I.length!==(I=I.replace(j,"")).length;);return I.split("").reverse().join("")},buildURLFromParts:function(I){return I.scheme+I.netLoc+I.path+I.params+I.query+I.fragment}};ae.exports=M})(this)},"./node_modules/webworkify-webpack/index.js":function(ae,Z,k){function V(p){var f={};function h(c){if(f[c])return f[c].exports;var o=f[c]={i:c,l:!1,exports:{}};return p[c].call(o.exports,o,o.exports,h),o.l=!0,o.exports}h.m=p,h.c=f,h.i=function(c){return c},h.d=function(c,o,s){h.o(c,o)||Object.defineProperty(c,o,{configurable:!1,enumerable:!0,get:s})},h.r=function(c){Object.defineProperty(c,"__esModule",{value:!0})},h.n=function(c){var o=c&&c.__esModule?function(){return c.default}:function(){return c};return h.d(o,"a",o),o},h.o=function(c,o){return Object.prototype.hasOwnProperty.call(c,o)},h.p="/",h.oe=function(c){throw console.error(c),c};var a=h(h.s=ENTRY_MODULE);return a.default||a}var F="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+F+").*?\\)";function G(p){return(p+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function j(p){return!isNaN(1*p)}function M(p,f,h){var a={};a[h]=[];var c=f.toString(),o=c.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return a;for(var s=o[1],l=new RegExp("(\\\\n|\\W)"+G(s)+D,"g"),d;d=l.exec(c);){if(d[3]==="dll-reference")continue;a[h].push(d[3])}for(l=new RegExp("\\("+G(s)+'\\("(dll-reference\\s('+F+'))"\\)\\)'+D,"g");d=l.exec(c);)p[d[2]]||(a[h].push(d[1]),p[d[2]]=k(d[1]).m),a[d[2]]=a[d[2]]||[],a[d[2]].push(d[4]);for(var O=Object.keys(a),w=0;w<O.length;w++)for(var x=0;x<a[O[w]].length;x++)j(a[O[w]][x])&&(a[O[w]][x]=1*a[O[w]][x]);return a}function I(p){var f=Object.keys(p);return f.reduce(function(h,a){return h||p[a].length>0},!1)}function g(p,f){for(var h={main:[f]},a={main:[]},c={main:{}};I(h);)for(var o=Object.keys(h),s=0;s<o.length;s++){var l=o[s],d=h[l],O=d.pop();if(c[l]=c[l]||{},c[l][O]||!p[l][O])continue;c[l][O]=!0,a[l]=a[l]||[],a[l].push(O);for(var w=M(p,p[l][O],l),x=Object.keys(w),R=0;R<x.length;R++)h[x[R]]=h[x[R]]||[],h[x[R]]=h[x[R]].concat(w[x[R]])}return a}ae.exports=function(p,f){f=f||{};var h={main:k.m},a=f.all?{main:Object.keys(h.main)}:g(h,p),c="";Object.keys(a).filter(function(O){return O!=="main"}).forEach(function(O){for(var w=0;a[O][w];)w++;a[O].push(w),h[O][w]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",c=c+"var "+O+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(w))+")({"+a[O].map(function(x){return""+JSON.stringify(x)+": "+h[O][x].toString()}).join(",")+`});
`}),c=c+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(p))+")({"+a.main.map(function(O){return""+JSON.stringify(O)+": "+h.main[O].toString()}).join(",")+"}))(self);";var o=new window.Blob([c],{type:"text/javascript"});if(f.bare)return o;var s=window.URL||window.webkitURL||window.mozURL||window.msURL,l=s.createObjectURL(o),d=new window.Worker(l);return d.objectURL=l,d}},"./src/config.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"hlsDefaultConfig",function(){return R}),k.d(Z,"mergeConfig",function(){return T}),k.d(Z,"enableStreamingMode",function(){return E});var V=k("./src/controller/abr-controller.ts"),F=k("./src/controller/audio-stream-controller.ts"),D=k("./src/controller/audio-track-controller.ts"),G=k("./src/controller/subtitle-stream-controller.ts"),j=k("./src/controller/subtitle-track-controller.ts"),M=k("./src/controller/buffer-controller.ts"),I=k("./src/controller/timeline-controller.ts"),g=k("./src/controller/cap-level-controller.ts"),p=k("./src/controller/fps-controller.ts"),f=k("./src/controller/eme-controller.ts"),h=k("./src/controller/cmcd-controller.ts"),a=k("./src/utils/xhr-loader.ts"),c=k("./src/utils/fetch-loader.ts"),o=k("./src/utils/cues.ts"),s=k("./src/utils/mediakeys-helper.ts"),l=k("./src/utils/logger.ts");function d(){return d=Object.assign||function(y){for(var u=1;u<arguments.length;u++){var _=arguments[u];for(var m in _)Object.prototype.hasOwnProperty.call(_,m)&&(y[m]=_[m])}return y},d.apply(this,arguments)}function O(y,u){var _=Object.keys(y);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(y);u&&(m=m.filter(function(b){return Object.getOwnPropertyDescriptor(y,b).enumerable})),_.push.apply(_,m)}return _}function w(y){for(var u=1;u<arguments.length;u++){var _=arguments[u]!=null?arguments[u]:{};u%2?O(Object(_),!0).forEach(function(m){x(y,m,_[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(_)):O(Object(_)).forEach(function(m){Object.defineProperty(y,m,Object.getOwnPropertyDescriptor(_,m))})}return y}function x(y,u,_){return u in y?Object.defineProperty(y,u,{value:_,enumerable:!0,configurable:!0,writable:!0}):y[u]=_,y}var R=w(w({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:a.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:M.default,capLevelController:g.default,fpsController:p.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:s.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},A()),{},{subtitleStreamController:G.SubtitleStreamController,subtitleTrackController:j.default,timelineController:I.TimelineController,audioStreamController:F.default,audioTrackController:D.default,emeController:f.default,cmcdController:h.default});function A(){return{cueHandler:o.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 T(y,u){if((u.liveSyncDurationCount||u.liveMaxLatencyDurationCount)&&(u.liveSyncDuration||u.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(u.liveMaxLatencyDurationCount!==void 0&&(u.liveSyncDurationCount===void 0||u.liveMaxLatencyDurationCount<=u.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(u.liveMaxLatencyDuration!==void 0&&(u.liveSyncDuration===void 0||u.liveMaxLatencyDuration<=u.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return d({},y,u)}function E(y){var u=y.loader;if(u!==c.default&&u!==a.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),y.progressive=!1;else{var _=Object(c.fetchSupported)();_&&(y.loader=c.default,y.progressive=!0,y.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/polyfills/number.ts"),F=k("./src/utils/ewma-bandwidth-estimator.ts"),D=k("./src/events.ts"),G=k("./src/utils/buffer-helper.ts"),j=k("./src/errors.ts"),M=k("./src/types/loader.ts"),I=k("./src/utils/logger.ts");function g(h,a){for(var c=0;c<a.length;c++){var o=a[c];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(h,o.key,o)}}function p(h,a,c){return a&&g(h.prototype,a),c&&g(h,c),h}var f=function(){function h(c){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=c;var o=c.config;this.bwEstimator=new F.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var a=h.prototype;return a.registerListeners=function(){var o=this.hls;o.on(D.Events.FRAG_LOADING,this.onFragLoading,this),o.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(D.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var o=this.hls;o.off(D.Events.FRAG_LOADING,this.onFragLoading,this),o.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(D.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},a.onFragLoading=function(o,s){var l=s.frag;if(l.type===M.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=l,this.partCurrent=(d=s.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},a.onLevelLoaded=function(o,s){var l=this.hls.config;s.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},a._abandonRulesCheck=function(){var o=this.fragCurrent,s=this.partCurrent,l=this.hls,d=l.autoLevelEnabled,O=l.config,w=l.media;if(!o||!w)return;var x=s?s.stats:o.stats,R=s?s.duration:o.duration;if(x.aborted){I.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||w.paused||!w.playbackRate||!w.readyState)return;var A=performance.now()-x.loading.start,T=Math.abs(w.playbackRate);if(A<=500*R/T)return;var E=l.levels,y=l.minAutoLevel,u=E[o.level],_=x.total||Math.max(x.loaded,Math.round(R*u.maxBitrate/8)),m=Math.max(1,x.bwEstimate?x.bwEstimate/8:x.loaded*1e3/A),b=(_-x.loaded)/m,P=w.currentTime,N=(G.BufferHelper.bufferInfo(w,P,O.maxBufferHole).end-P)/T;if(N>=2*R/T||b<=N)return;var K=Number.POSITIVE_INFINITY,X;for(X=o.level-1;X>y;X--){var B=E[X].maxBitrate;if(K=R*B/(8*.8*m),K<N)break}if(K>=b)return;var S=this.bwEstimator.getEstimate();I.logger.warn("Fragment "+o.sn+(s?" part "+s.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+X+`
Current BW estimate: `+(Object(V.isFiniteNumber)(S)?(S/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+b.toFixed(3)+` s
Estimated load time for the next fragment: `+K.toFixed(3)+` s
Time to underbuffer: `+N.toFixed(3)+" s"),l.nextLoadLevel=X,this.bwEstimator.sample(A,x.loaded),this.clearTimer(),o.loader&&(this.fragCurrent=this.partCurrent=null,o.loader.abort()),l.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o,part:s,stats:x})},a.onFragLoaded=function(o,s){var l=s.frag,d=s.part;if(l.type===M.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(l.sn)){var O=d?d.stats:l.stats,w=d?d.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var x=this.hls.levels[l.level],R=(x.loaded?x.loaded.bytes:0)+O.loaded,A=(x.loaded?x.loaded.duration:0)+w;x.loaded={bytes:R,duration:A},x.realBitrate=Math.round(8*R/A)}if(l.bitrateTest){var T={stats:O,frag:l,part:d,id:l.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,T),l.bitrateTest=!1}}},a.onFragBuffered=function(o,s){var l=s.frag,d=s.part,O=d?d.stats:l.stats;if(O.aborted)return;if(l.type!==M.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var w=O.parsing.end-O.loading.start;this.bwEstimator.sample(w,O.loaded),O.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=w/1e3:this.bitrateTestDelay=0},a.onError=function(o,s){switch(s.details){case j.ErrorDetails.FRAG_LOAD_ERROR:case j.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},a.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},a.getNextABRAutoLevel=function(){var o=this.fragCurrent,s=this.partCurrent,l=this.hls,d=l.maxAutoLevel,O=l.config,w=l.minAutoLevel,x=l.media,R=s?s.duration:o?o.duration:0,A=x?x.currentTime:0,T=x&&x.playbackRate!==0?Math.abs(x.playbackRate):1,E=this.bwEstimator?this.bwEstimator.getEstimate():O.abrEwmaDefaultEstimate,y=(G.BufferHelper.bufferInfo(x,A,O.maxBufferHole).end-A)/T,u=this.findBestLevel(E,w,d,y,O.abrBandWidthFactor,O.abrBandWidthUpFactor);if(u>=0)return u;I.logger.trace((y?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var _=R?Math.min(R,O.maxStarvationDelay):O.maxStarvationDelay,m=O.abrBandWidthFactor,b=O.abrBandWidthUpFactor;if(!y){var P=this.bitrateTestDelay;if(P){var N=R?Math.min(R,O.maxLoadingDelay):O.maxLoadingDelay;_=N-P,I.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*_)+" ms"),m=b=1}}return u=this.findBestLevel(E,w,d,y+_,m,b),Math.max(u,0)},a.findBestLevel=function(o,s,l,d,O,w){for(var x,R=this.fragCurrent,A=this.partCurrent,T=this.lastLoadedFragLevel,E=this.hls.levels,y=E[T],u=!!(y!=null&&(x=y.details)!==null&&x!==void 0&&x.live),_=y==null?void 0:y.codecSet,m=A?A.duration:R?R.duration:0,b=l;b>=s;b--){var P=E[b];if(!P||_&&P.codecSet!==_)continue;var N=P.details,K=(A?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||m,X=void 0;b<=T?X=O*o:X=w*o;var B=E[b].maxBitrate,S=B*K/X;if(I.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+b+"/"+Math.round(X)+"/"+B+"/"+K+"/"+d+"/"+S),X>B&&(!S||u&&!this.bitrateTestDelay||S<d))return b}return-1},p(h,[{key:"nextAutoLevel",get:function(){var o=this._nextAutoLevel,s=this.bwEstimator;if(o!==-1&&(!s||!s.canEstimate()))return o;var l=this.getNextABRAutoLevel();return o!==-1&&(l=Math.min(o,l)),l},set:function(o){this._nextAutoLevel=o}}]),h}();Z.default=f},"./src/controller/audio-stream-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/polyfills/number.ts"),F=k("./src/controller/base-stream-controller.ts"),D=k("./src/events.ts"),G=k("./src/utils/buffer-helper.ts"),j=k("./src/controller/fragment-tracker.ts"),M=k("./src/types/level.ts"),I=k("./src/types/loader.ts"),g=k("./src/loader/fragment.ts"),p=k("./src/demux/chunk-cache.ts"),f=k("./src/demux/transmuxer-interface.ts"),h=k("./src/types/transmuxer.ts"),a=k("./src/controller/fragment-finders.ts"),c=k("./src/utils/discontinuities.ts"),o=k("./src/errors.ts"),s=k("./src/utils/logger.ts");function l(){return l=Object.assign||function(R){for(var A=1;A<arguments.length;A++){var T=arguments[A];for(var E in T)Object.prototype.hasOwnProperty.call(T,E)&&(R[E]=T[E])}return R},l.apply(this,arguments)}function d(R,A){R.prototype=Object.create(A.prototype),R.prototype.constructor=R,O(R,A)}function O(R,A){return O=Object.setPrototypeOf||function(E,y){return E.__proto__=y,E},O(R,A)}var w=100,x=function(R){d(A,R);function A(E,y){var u;return u=R.call(this,E,y,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u._registerListeners(),u}var T=A.prototype;return T.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},T._registerListeners=function(){var y=this.hls;y.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),y.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),y.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),y.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),y.on(D.Events.ERROR,this.onError,this),y.on(D.Events.BUFFER_RESET,this.onBufferReset,this),y.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),y.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),y.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),y.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T._unregisterListeners=function(){var y=this.hls;y.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),y.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),y.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),y.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),y.off(D.Events.ERROR,this.onError,this),y.off(D.Events.BUFFER_RESET,this.onBufferReset,this),y.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),y.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),y.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),y.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T.onInitPtsFound=function(y,u){var _=u.frag,m=u.id,b=u.initPTS;if(m==="main"){var P=_.cc;this.initPTS[_.cc]=b,this.log("InitPTS for cc: "+P+" found from main: "+b),this.videoTrackCC=P,this.state===F.State.WAITING_INIT_PTS&&this.tick()}},T.startLoad=function(y){if(!this.levels){this.startPosition=y,this.state=F.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(w),this.fragLoadError=0,u>0&&y===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),this.state=F.State.IDLE):(this.loadedmetadata=!1,this.state=F.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=y,this.tick()},T.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_TRACK:{var y,u=this.levels,_=this.trackId,m=u==null||((y=u[_])===null||y===void 0)?void 0:y.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=F.State.WAITING_INIT_PTS}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var b,P=performance.now(),N=this.retryDate;(!N||P>=N||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=F.State.IDLE);break}case F.State.WAITING_INIT_PTS:{var K=this.waitingData;if(K){var X=K.frag,B=K.part,S=K.cache,Y=K.complete;if(this.initPTS[X.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=F.State.FRAG_LOADING;var te=S.flush(),re={frag:X,part:B,payload:te,networkDetails:null};this._handleFragmentLoadProgress(re),Y&&R.prototype._handleFragmentLoadComplete.call(this,re)}else if(this.videoTrackCC!==this.waitingVideoCC)s.logger.log("Waiting fragment cc ("+X.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ce=this.getLoadPosition(),Te=G.BufferHelper.bufferInfo(this.mediaBuffer,ce,this.config.maxBufferHole),ye=Object(a.fragmentWithinToleranceTest)(Te.end,this.config.maxFragLookUpTolerance,X);ye<0&&(s.logger.log("Waiting fragment cc ("+X.cc+") @ "+X.start+" cancelled because another fragment at "+Te.end+" is needed"),this.clearWaitingFragment())}}else this.state=F.State.IDLE}}this.onTickEnd()},T.clearWaitingFragment=function(){var y=this.waitingData;y&&(this.fragmentTracker.removeFragment(y.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=F.State.IDLE)},T.onTickEnd=function(){var y=this.media;if(!y||!y.readyState)return;var u=this.mediaBuffer?this.mediaBuffer:y,_=u.buffered;!this.loadedmetadata&&_.length&&(this.loadedmetadata=!0),this.lastCurrentTime=y.currentTime},T.doTickIdle=function(){var y,u,_=this.hls,m=this.levels,b=this.media,P=this.trackId,N=_.config;if(!m||!m[P])return;if(!b&&(this.startFragRequested||!N.startFragPrefetch))return;var K=m[P],X=K.details;if(!X||X.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(X)){this.state=F.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,I.PlaylistLevelType.AUDIO));var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,I.PlaylistLevelType.AUDIO);if(B===null)return;var S=B.len,Y=this.getMaxBufferLength(),te=this.audioSwitch;if(S>=Y&&!te)return;if(!te&&this._streamEnded(B,X)){_.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=F.State.ENDED;return}var re=X.fragments,ce=re[0].start,Te=B.end;if(te){var ye=this.getLoadPosition();Te=ye,X.PTSKnown&&ye<ce&&((B.end>ce||B.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=ce+.05))}var be=this.getNextFragment(Te,X);if(!be){this.bufferFlushed=!0;return}((y=be.decryptdata)===null||y===void 0?void 0:y.keyFormat)==="identity"&&!((u=be.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(be,X):this.loadFragment(be,X,Te)},T.getMaxBufferLength=function(){var y=R.prototype.getMaxBufferLength.call(this),u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,I.PlaylistLevelType.MAIN);return u===null?y:Math.max(y,u.len)},T.onMediaDetaching=function(){this.videoBuffer=null,R.prototype.onMediaDetaching.call(this)},T.onAudioTracksUpdated=function(y,u){var _=u.audioTracks;this.resetTransmuxer(),this.levels=_.map(function(m){return new M.Level(m)})},T.onAudioTrackSwitching=function(y,u){var _=!!u.url;this.trackId=u.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),_?this.setInterval(w):this.resetTransmuxer(),_?(this.audioSwitch=!0,this.state=F.State.IDLE):this.state=F.State.STOPPED,this.tick()},T.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},T.onLevelLoaded=function(y,u){this.mainDetails=u.details},T.onAudioTrackLoaded=function(y,u){var _,m=this.levels,b=u.details,P=u.id;if(!m){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var N=m[P],K=0;if(b.live||(_=N.details)!==null&&_!==void 0&&_.live){var X=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!X)return;!N.details&&b.hasProgramDateTime&&X.hasProgramDateTime?(Object(c.alignMediaPlaylistByPDT)(b,X),K=b.fragments[0].start):K=this.alignPlaylists(b,N.details)}N.details=b,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!b.live)&&this.setStartPosition(N.details,K),this.state===F.State.WAITING_TRACK&&!this.waitForCdnTuneIn(b)&&(this.state=F.State.IDLE),this.tick()},T._handleFragmentLoadProgress=function(y){var u,_=y.frag,m=y.part,b=y.payload,P=this.config,N=this.trackId,K=this.levels;if(!K){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+_.sn+" of level "+_.level+" will not be buffered");return}var X=K[N];console.assert(X,"Audio track is defined on fragment load progress");var B=X.details;console.assert(B,"Audio track details are defined on fragment load progress");var S=P.defaultAudioCodec||X.audioCodec||"mp4a.40.2",Y=this.transmuxer;Y||(Y=this.transmuxer=new f.default(this.hls,I.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var te=this.initPTS[_.cc],re=(u=_.initSegment)===null||u===void 0?void 0:u.data;if(te!==void 0){var ce=!1,Te=m?m.index:-1,ye=Te!==-1,be=new h.ChunkMetadata(_.level,_.sn,_.stats.chunkCount,b.byteLength,Te,ye);Y.push(b,re,S,"",_,m,B.totalduration,ce,be,te)}else{s.logger.log("Unknown video PTS for cc "+_.cc+", waiting for video PTS before demuxing audio frag "+_.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+N);var we=this.waitingData=this.waitingData||{frag:_,part:m,cache:new p.default,complete:!1},xe=we.cache;xe.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=F.State.WAITING_INIT_PTS}},T._handleFragmentLoadComplete=function(y){if(this.waitingData){this.waitingData.complete=!0;return}R.prototype._handleFragmentLoadComplete.call(this,y)},T.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},T.onBufferCreated=function(y,u){var _=u.tracks.audio;_&&(this.mediaBuffer=_.buffer),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer)},T.onFragBuffered=function(y,u){var _=u.frag,m=u.part;if(_.type!==I.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(_)){this.warn("Fragment "+_.sn+(m?" p: "+m.index:"")+" of level "+_.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}_.sn!=="initSegment"&&(this.fragPrevious=_,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(_,m)},T.onError=function(y,u){switch(u.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(I.PlaylistLevelType.AUDIO,u);break;case o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==F.State.ERROR&&this.state!==F.State.STOPPED&&(this.state=u.fatal?F.State.ERROR:F.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case o.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===F.State.PARSING||this.state===F.State.PARSED)){var _=!0,m=this.getFwdBufferInfo(this.mediaBuffer,I.PlaylistLevelType.AUDIO);m&&m.len>.5&&(_=!this.reduceMaxBufferLength(m.len)),_&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,R.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},T.onBufferFlushed=function(y,u){var _=u.type;_===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},T._handleTransmuxComplete=function(y){var u,_="audio",m=this.hls,b=y.remuxResult,P=y.chunkMeta,N=this.getCurrentContext(P);if(!N){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var K=N.frag,X=N.part,B=b.audio,S=b.text,Y=b.id3,te=b.initSegment;if(this.fragContextChanged(K))return;if(this.state=F.State.PARSING,this.audioSwitch&&B&&this.completeAudioSwitch(),te!=null&&te.tracks&&(this._bufferInitSegment(te.tracks,K,P),m.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:K,id:_,tracks:te.tracks})),B){var re=B.startPTS,ce=B.endPTS,Te=B.startDTS,ye=B.endDTS;X&&(X.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:ce,startDTS:Te,endDTS:ye}),K.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,re,ce,Te,ye),this.bufferFragmentData(B,K,X,P)}if(Y!=null&&(u=Y.samples)!==null&&u!==void 0&&u.length){var be=l({frag:K,id:_},Y);m.trigger(D.Events.FRAG_PARSING_METADATA,be)}if(S){var we=l({frag:K,id:_},S);m.trigger(D.Events.FRAG_PARSING_USERDATA,we)}},T._bufferInitSegment=function(y,u,_){if(this.state!==F.State.PARSING)return;y.video&&delete y.video;var m=y.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(D.Events.BUFFER_CODECS,y);var b=m.initSegment;if(b!=null&&b.byteLength){var P={type:"audio",frag:u,part:null,chunkMeta:_,parent:u.type,data:b};this.hls.trigger(D.Events.BUFFER_APPENDING,P)}this.tick()},T.loadFragment=function(y,u,_){var m=this.fragmentTracker.getState(y);this.fragCurrent=y,(this.audioSwitch||m===j.FragmentState.NOT_LOADED||m===j.FragmentState.PARTIAL)&&(y.sn==="initSegment"?this._loadInitSegment(y):u.live&&!Object(V.isFiniteNumber)(this.initPTS[y.cc])?(this.log("Waiting for video PTS in continuity counter "+y.cc+" of live stream before loading audio fragment "+y.sn+" of level "+this.trackId),this.state=F.State.WAITING_INIT_PTS):(this.startFragRequested=!0,R.prototype.loadFragment.call(this,y,u,_)))},T.completeAudioSwitch=function(){var y=this.hls,u=this.media,_=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),R.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,y.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:_})},A}(F.default);Z.default=x},"./src/controller/audio-track-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts"),F=k("./src/errors.ts"),D=k("./src/controller/base-playlist-controller.ts"),G=k("./src/types/loader.ts");function j(f,h){for(var a=0;a<h.length;a++){var c=h[a];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(f,c.key,c)}}function M(f,h,a){return h&&j(f.prototype,h),a&&j(f,a),f}function I(f,h){f.prototype=Object.create(h.prototype),f.prototype.constructor=f,g(f,h)}function g(f,h){return g=Object.setPrototypeOf||function(c,o){return c.__proto__=o,c},g(f,h)}var p=function(f){I(h,f);function h(c){var o;return o=f.call(this,c,"[audio-track-controller]")||this,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.trackName="",o.selectDefaultTrack=!0,o.registerListeners(),o}var a=h.prototype;return a.registerListeners=function(){var o=this.hls;o.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.on(V.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.off(V.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,f.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(o,s){this.tracks=s.audioTracks||[]},a.onAudioTrackLoaded=function(o,s){var l=s.id,d=s.details,O=this.tracksInGroup[l];if(!O){this.warn("Invalid audio track id "+l);return}var w=O.details;O.details=s.details,this.log("audioTrack "+l+" loaded ["+d.startSN+"-"+d.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,w))},a.onLevelLoading=function(o,s){this.switchLevel(s.level)},a.onLevelSwitching=function(o,s){this.switchLevel(s.level)},a.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.audioGroupIds))return;var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var d=this.tracks.filter(function(w){return!l||w.groupId===l});this.selectDefaultTrack&&!d.some(function(w){return w.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var O={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,O),this.selectInitialTrack()}},a.onError=function(o,s){if(f.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===G.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.setAudioTrack=function(o){var s=this.tracksInGroup;if(o<0||o>=s.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+o);var d=s[o],O=d.id,w=d.groupId,x=w===void 0?"":w,R=d.name,A=d.type,T=d.url;if(this.trackId=o,this.trackName=R,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:O,groupId:x,name:R,type:A,url:T}),d.details&&!d.details.live)return;var E=this.switchParams(d.url,l==null?void 0:l.details);this.loadPlaylist(E)},a.selectInitialTrack=function(){var o=this.tracksInGroup;console.assert(o.length,"Initial audio track should be selected when tracks are known");var s=this.trackName,l=this.findTrackId(s)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(o){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var d=s[l];if((!this.selectDefaultTrack||d.default)&&(!o||o===d.name))return d.id}return-1},a.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,d=s.groupId,O=s.url;if(o)try{O=o.addDirectives(O)}catch(w){this.warn("Could not construct new URL with HLS Delivery Directives: "+w)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:O,id:l,groupId:d,deliveryDirectives:o||null})}},M(h,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1,this.setAudioTrack(o)}}]),h}(D.default);Z.default=p},"./src/controller/base-playlist-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return M});var V=k("./src/polyfills/number.ts"),F=k("./src/types/level.ts"),D=k("./src/controller/level-helper.ts"),G=k("./src/utils/logger.ts"),j=k("./src/errors.ts"),M=function(){function I(p,f){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=G.logger.log.bind(G.logger,f+":"),this.warn=G.logger.warn.bind(G.logger,f+":"),this.hls=p}var g=I.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(f,h){h.fatal&&h.type===j.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(f,h){var a=h==null?void 0:h.renditionReports;if(a)for(var c=0;c<a.length;c++){var o=a[c],s=""+o.URI;if(s===f.substr(-s.length)){var l=parseInt(o["LAST-MSN"]),d=parseInt(o["LAST-PART"]);if(h&&this.hls.config.lowLatencyMode){var O=Math.min(h.age-h.partTarget,h.targetduration);d!==void 0&&O>h.partTarget&&(d+=1)}if(Object(V.isFiniteNumber)(l))return new F.HlsUrlParameters(l,Object(V.isFiniteNumber)(d)?d:void 0,F.HlsSkip.No)}}},g.loadPlaylist=function(f){},g.shouldLoadTrack=function(f){return this.canLoad&&f&&!!f.url&&(!f.details||f.details.live)},g.playlistLoaded=function(f,h,a){var c=this,o=h.details,s=h.stats,l=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(o.advancedDateTime=Date.now()-l,o.live||a!=null&&a.live){if(o.reloaded(a),a&&this.log("live playlist "+f+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:"MISSED")),a&&o.fragments.length>0&&Object(D.mergeDetails)(a,o),!this.canLoad||!o.live)return;var d,O=void 0,w=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var x=this.hls.config.lowLatencyMode,R=o.lastPartSn,A=o.endSN,T=o.lastPartIndex,E=T!==-1,y=R===A,u=x?0:T;E?(O=y?A+1:R,w=y?u:T+1):O=A+1;var _=o.age,m=_+o.ageHeader,b=Math.min(m-o.partTarget,o.targetduration*1.5);if(b>0){if(a&&b>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+b+" with playlist age: "+o.age),b=0;else{var P=Math.floor(b/o.targetduration);if(O+=P,w!==void 0){var N=Math.round(b%o.targetduration/o.partTarget);w+=N}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+b+" skip sn "+P+" to part "+w)}o.tuneInGoal=b}if(d=this.getDeliveryDirectives(o,h.deliveryDirectives,O,w),x||!y){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(o,h.deliveryDirectives,O,w);var K=Object(D.computeReloadInterval)(o,s);O!==void 0&&o.canBlockReload&&(K-=o.partTarget||1),this.log("reload live playlist "+f+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return c.loadPlaylist(d)},K)}else this.clearTimer()},g.getDeliveryDirectives=function(f,h,a,c){var o=Object(F.getSkipValue)(f,a);return h!=null&&h.skip&&f.deltaUpdateFailed&&(a=h.msn,c=h.part,o=F.HlsSkip.No),new F.HlsUrlParameters(a,c,o)},g.retryLoadingOrFail=function(f){var h=this,a=this.hls.config,c=this.retryCount<a.levelLoadingMaxRetry;if(c){var o;if(this.retryCount++,f.details.indexOf("LoadTimeOut")>-1&&(o=f.context)!==null&&o!==void 0&&o.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+f.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*a.levelLoadingRetryDelay,a.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return h.loadPlaylist()},s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+f.details+'"')}}else this.warn('cannot recover from error "'+f.details+'"'),this.clearTimer(),f.fatal=!0;return c},I}()},"./src/controller/base-stream-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"State",function(){return A}),k.d(Z,"default",function(){return T});var V=k("./src/polyfills/number.ts"),F=k("./src/task-loop.ts"),D=k("./src/controller/fragment-tracker.ts"),G=k("./src/utils/buffer-helper.ts"),j=k("./src/utils/logger.ts"),M=k("./src/events.ts"),I=k("./src/errors.ts"),g=k("./src/types/transmuxer.ts"),p=k("./src/utils/mp4-tools.ts"),f=k("./src/utils/discontinuities.ts"),h=k("./src/controller/fragment-finders.ts"),a=k("./src/controller/level-helper.ts"),c=k("./src/loader/fragment-loader.ts"),o=k("./src/crypt/decrypter.ts"),s=k("./src/utils/time-ranges.ts"),l=k("./src/types/loader.ts");function d(E,y){for(var u=0;u<y.length;u++){var _=y[u];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(E,_.key,_)}}function O(E,y,u){return y&&d(E.prototype,y),u&&d(E,u),E}function w(E){if(E===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E}function x(E,y){E.prototype=Object.create(y.prototype),E.prototype.constructor=E,R(E,y)}function R(E,y){return R=Object.setPrototypeOf||function(_,m){return _.__proto__=m,_},R(E,y)}var A={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"},T=function(E){x(y,E);function y(_,m,b){var P;return P=E.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=A.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=b,P.log=j.logger.log.bind(j.logger,b+":"),P.warn=j.logger.warn.bind(j.logger,b+":"),P.hls=_,P.fragmentLoader=new c.default(_.config),P.fragmentTracker=m,P.config=_.config,P.decrypter=new o.default(_,_.config),_.on(M.Events.KEY_LOADED,P.onKeyLoaded,w(P)),P}var u=y.prototype;return u.doTick=function(){this.onTickEnd()},u.onTickEnd=function(){},u.startLoad=function(m){},u.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=A.STOPPED},u._streamEnded=function(m,b){var P=this.fragCurrent,N=this.fragmentTracker;if(!b.live&&P&&P.sn===b.endSN&&!m.nextStart){var K=N.getState(P);return K===D.FragmentState.PARTIAL||K===D.FragmentState.OK}return!1},u.onMediaAttached=function(m,b){var P=this.media=this.mediaBuffer=b.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var N=this.config;this.levels&&N.autoStartLoad&&this.state===A.STOPPED&&this.startLoad(N.startPosition)},u.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()},u.onMediaSeeking=function(){var m=this.config,b=this.fragCurrent,P=this.media,N=this.mediaBuffer,K=this.state,X=P?P.currentTime:0,B=G.BufferHelper.bufferInfo(N||P,X,m.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(X)?X.toFixed(3):X)+", state: "+K),K===A.ENDED)this.resetLoadingState();else if(b&&!B.len){var S=m.maxFragLookUpTolerance,Y=b.start-S,te=b.start+b.duration+S,re=X>te;(X<Y||re)&&(re&&b.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),b.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=X),!this.loadedmetadata&&!B.len&&(this.nextLoadPosition=this.startPosition=X),this.tickImmediate()},u.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},u.onKeyLoaded=function(m,b){if(this.state!==A.KEY_LOADING||b.frag!==this.fragCurrent||!this.levels)return;this.state=A.IDLE;var P=this.levels[b.frag.level].details;P&&this.loadFragment(b.frag,P,b.frag.start)},u.onHandlerDestroying=function(){this.stopLoad(),E.prototype.onHandlerDestroying.call(this)},u.onHandlerDestroyed=function(){this.state=A.STOPPED,this.hls.off(M.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,E.prototype.onHandlerDestroyed.call(this)},u.loadKey=function(m,b){this.log("Loading key for "+m.sn+" of ["+b.startSN+"-"+b.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=A.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(M.Events.KEY_LOADING,{frag:m})},u.loadFragment=function(m,b,P){this._loadFragForPlayback(m,b,P)},u._loadFragForPlayback=function(m,b,P){var N=this,K=function(B){if(N.fragContextChanged(m)){N.warn("Fragment "+m.sn+(B.part?" p: "+B.part.index:"")+" of level "+m.level+" was dropped during download."),N.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,N._handleFragmentLoadProgress(B)};this._doFragLoad(m,b,P,K).then(function(X){if(!X)return;N.fragLoadError=0;var B=N.state;if(N.fragContextChanged(m)){(B===A.FRAG_LOADING||B===A.BACKTRACKING||!N.fragCurrent&&B===A.PARSING)&&(N.fragmentTracker.removeFragment(m),N.state=A.IDLE);return}if("payload"in X&&(N.log("Loaded fragment "+m.sn+" of level "+m.level),N.hls.trigger(M.Events.FRAG_LOADED,X),N.state===A.BACKTRACKING)){N.fragmentTracker.backtrack(m,X),N.resetFragmentLoading(m);return}N._handleFragmentLoadComplete(X)}).catch(function(X){N.warn(X),N.resetFragmentLoading(m)})},u.flushMainBuffer=function(m,b,P){if(P===void 0&&(P=null),!(m-b))return;var N={startOffset:m,endOffset:b,type:P};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,N)},u._loadInitSegment=function(m){var b=this;this._doFragLoad(m).then(function(P){if(!P||b.fragContextChanged(m)||!b.levels)throw new Error("init load aborted");return P}).then(function(P){var N=b.hls,K=P.payload,X=m.decryptdata;if(K&&K.byteLength>0&&X&&X.key&&X.iv&&X.method==="AES-128"){var B=self.performance.now();return b.decrypter.webCryptoDecrypt(new Uint8Array(K),X.key.buffer,X.iv.buffer).then(function(S){var Y=self.performance.now();return N.trigger(M.Events.FRAG_DECRYPTED,{frag:m,payload:S,stats:{tstart:B,tdecrypt:Y}}),P.payload=S,P})}return P}).then(function(P){var N=b.fragCurrent,K=b.hls,X=b.levels;if(!X)throw new Error("init load aborted, missing levels");var B=X[m.level].details;console.assert(B,"Level details are defined when init segment is loaded");var S=m.stats;b.state=A.IDLE,b.fragLoadError=0,m.data=new Uint8Array(P.payload),S.parsing.start=S.buffering.start=self.performance.now(),S.parsing.end=S.buffering.end=self.performance.now(),P.frag===N&&K.trigger(M.Events.FRAG_BUFFERED,{stats:S,frag:N,part:null,id:m.type}),b.tick()}).catch(function(P){b.warn(P),b.resetFragmentLoading(m)})},u.fragContextChanged=function(m){var b=this.fragCurrent;return!m||!b||m.level!==b.level||m.sn!==b.sn||m.urlId!==b.urlId},u.fragBufferedComplete=function(m,b){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(b?" part: "+b.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+s.default.toString(G.BufferHelper.getBuffered(P))),this.state=A.IDLE,this.tick()},u._handleFragmentLoadComplete=function(m){var b=this.transmuxer;if(!b)return;var P=m.frag,N=m.part,K=m.partsLoaded,X=!K||K.length===0||K.some(function(S){return!S}),B=new g.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,N?N.index:-1,!X);b.flush(B)},u._handleFragmentLoadProgress=function(m){},u._doFragLoad=function(m,b,P,N){var K=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(m.start,P||0),this.config.lowLatencyMode&&b){var X=b.partList;if(X&&N){P>m.end&&b.fragmentHint&&(m=b.fragmentHint);var B=this.getNextPart(X,m,P);if(B>-1){var S=X[B];return this.log("Loading part sn: "+m.sn+" p: "+S.index+" cc: "+m.cc+" of playlist ["+b.startSN+"-"+b.endSN+"] parts [0-"+B+"-"+(X.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=S.start+S.duration,this.state=A.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:m,part:X[B],targetBufferTime:P}),this.doFragPartsLoad(m,X,B,N).catch(function(Y){return K.handleFragLoadError(Y)})}else if(!m.url||this.loadedEndOfParts(X,P))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(b?"of ["+b.startSN+"-"+b.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),Object(V.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=A.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:m,targetBufferTime:P}),this.fragmentLoader.load(m,N).catch(function(Y){return K.handleFragLoadError(Y)})},u.doFragPartsLoad=function(m,b,P,N){var K=this;return new Promise(function(X,B){var S=[],Y=function te(re){var ce=b[re];K.fragmentLoader.loadPart(m,ce,N).then(function(Te){S[ce.index]=Te;var ye=Te.part;K.hls.trigger(M.Events.FRAG_LOADED,Te);var be=b[re+1];if(be&&be.fragment===m)te(re+1);else return X({frag:m,part:ye,partsLoaded:S})}).catch(B)};Y(P)})},u.handleFragLoadError=function(m){var b=m.data;return b&&b.details===I.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(b.frag,b.part):this.hls.trigger(M.Events.ERROR,b),null},u._handleTransmuxerFlush=function(m){var b=this.getCurrentContext(m);if(!b||this.state!==A.PARSING){this.fragCurrent||(this.state=A.IDLE);return}var P=b.frag,N=b.part,K=b.level,X=self.performance.now();P.stats.parsing.end=X,N&&(N.stats.parsing.end=X),this.updateLevelTiming(P,N,K,m.partial)},u.getCurrentContext=function(m){var b=this.levels,P=m.level,N=m.sn,K=m.part;if(!b||!b[P])return this.warn("Levels object was unset while buffering fragment "+N+" of level "+P+". The current chunk will not be buffered."),null;var X=b[P],B=K>-1?Object(a.getPartWith)(X,N,K):null,S=B?B.fragment:Object(a.getFragmentWithSN)(X,N,this.fragCurrent);return S?{frag:S,part:B,level:X}:null},u.bufferFragmentData=function(m,b,P,N){if(!m||this.state!==A.PARSING)return;var K=m.data1,X=m.data2,B=K;if(K&&X&&(B=Object(p.appendUint8Array)(K,X)),!B||!B.length)return;var S={type:m.type,frag:b,part:P,chunkMeta:N,parent:b.type,data:B};this.hls.trigger(M.Events.BUFFER_APPENDING,S),m.dropped&&m.independent&&!P&&this.flushBufferGap(b)},u.flushBufferGap=function(m){var b=this.media;if(!b)return;if(!G.BufferHelper.isBuffered(b,b.currentTime)){this.flushMainBuffer(0,m.start);return}var P=b.currentTime,N=G.BufferHelper.bufferInfo(b,P,0),K=m.duration,X=Math.min(this.config.maxFragLookUpTolerance*2,K*.25),B=Math.max(Math.min(m.start-X,N.end-X),P+X);m.start-B>X&&this.flushMainBuffer(B,m.start)},u.getFwdBufferInfo=function(m,b){var P=this.config,N=this.getLoadPosition();if(!Object(V.isFiniteNumber)(N))return null;var K=G.BufferHelper.bufferInfo(m,N,P.maxBufferHole);if(K.len===0&&K.nextStart!==void 0){var X=this.fragmentTracker.getBufferedFrag(N,b);if(X&&K.nextStart<X.end)return G.BufferHelper.bufferInfo(m,N,Math.max(K.nextStart,P.maxBufferHole))}return K},u.getMaxBufferLength=function(m){var b=this.config,P;return m?P=Math.max(8*b.maxBufferSize/m,b.maxBufferLength):P=b.maxBufferLength,Math.min(P,b.maxMaxBufferLength)},u.reduceMaxBufferLength=function(m){var b=this.config,P=m||b.maxBufferLength;return b.maxMaxBufferLength>=P?(b.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+b.maxMaxBufferLength+"s"),!0):!1},u.getNextFragment=function(m,b){var P,N,K=b.fragments,X=K.length;if(!X)return null;var B=this.config,S=K[0].start,Y;if(b.live){var te=B.initialLiveManifestSize;if(X<te)return this.warn("Not enough fragments to start playback (have: "+X+", need: "+te+")"),null;!b.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Y=this.getInitialLiveFragment(b,K),this.startPosition=Y?this.hls.liveSyncPosition||Y.start:m)}else m<=S&&(Y=K[0]);if(!Y){var re=B.lowLatencyMode?b.partEnd:b.fragmentEnd;Y=this.getFragmentAtPosition(m,re,b)}return(P=Y)!==null&&P!==void 0&&P.initSegment&&!((N=Y)!==null&&N!==void 0&&N.initSegment.data)&&!this.bitrateTest&&(Y=Y.initSegment),Y},u.getNextPart=function(m,b,P){for(var N=-1,K=!1,X=!0,B=0,S=m.length;B<S;B++){var Y=m[B];if(X=X&&!Y.independent,N>-1&&P<Y.start)break;var te=Y.loaded;!te&&(K||Y.independent||X)&&Y.fragment===b&&(N=B),K=te}return N},u.loadedEndOfParts=function(m,b){var P=m[m.length-1];return P&&b>P.start&&P.loaded},u.getInitialLiveFragment=function(m,b){var P=this.fragPrevious,N=null;if(P){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),N=Object(h.findFragmentByPDT)(b,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!N){var K=P.sn+1;if(K>=m.startSN&&K<=m.endSN){var X=b[K-m.startSN];P.cc===X.cc&&(N=X,this.log("Live playlist, switching playlist, load frag with next SN: "+N.sn))}N||(N=Object(h.findFragWithCC)(b,P.cc),N&&this.log("Live playlist, switching playlist, load frag with same CC: "+N.sn))}}else{var B=this.hls.liveSyncPosition;B!==null&&(N=this.getFragmentAtPosition(B,this.bitrateTest?m.fragmentEnd:m.edge,m))}return N},u.getFragmentAtPosition=function(m,b,P){var N=this.config,K=this.fragPrevious,X=P.fragments,B=P.endSN,S=P.fragmentHint,Y=N.maxFragLookUpTolerance,te=!!(N.lowLatencyMode&&P.partList&&S);te&&S&&!this.bitrateTest&&(X=X.concat(S),B=S.sn);var re;if(m<b){var ce=m>b-Y?0:Y;re=Object(h.findFragmentByPTS)(K,X,m,ce)}else re=X[X.length-1];if(re){var Te=re.sn-P.startSN,ye=K&&re.level===K.level,be=X[Te+1],we=this.fragmentTracker.getState(re);if(we===D.FragmentState.BACKTRACKED){re=null;for(var xe=Te;X[xe]&&this.fragmentTracker.getState(X[xe])===D.FragmentState.BACKTRACKED;)K?re=X[xe--]:re=X[--xe];re||(re=be)}else K&&re.sn===K.sn&&!te&&(ye&&(re.sn<B&&this.fragmentTracker.getState(be)!==D.FragmentState.OK?(this.log("SN "+re.sn+" just loaded, load next one: "+be.sn),re=be):re=null))}return re},u.synchronizeToLiveEdge=function(m){var b=this.config,P=this.media;if(!P)return;var N=this.hls.liveSyncPosition,K=P.currentTime,X=m.fragments[0].start,B=m.edge,S=K>=X-b.maxFragLookUpTolerance&&K<=B;if(N!==null&&P.duration>N&&(K<N||!S)){var Y=b.liveMaxLatencyDuration!==void 0?b.liveMaxLatencyDuration:b.liveMaxLatencyDurationCount*m.targetduration;(!S&&P.readyState<4||K<B-Y)&&(this.loadedmetadata||(this.nextLoadPosition=N),P.readyState&&(this.warn("Playback: "+K.toFixed(3)+" is located too far from the end of live sliding playlist: "+B+", reset currentTime to : "+N.toFixed(3)),P.currentTime=N))}},u.alignPlaylists=function(m,b){var P=this.levels,N=this.levelLastLoaded,K=this.fragPrevious,X=N!==null?P[N]:null,B=m.fragments.length;if(!B)return this.warn("No fragments in live playlist"),0;var S=m.fragments[0].start,Y=!b,te=m.alignedSliding&&Object(V.isFiniteNumber)(S);if(Y||!te&&!S){Object(f.alignStream)(K,X,m);var re=m.fragments[0].start;return this.log("Live playlist sliding: "+re.toFixed(2)+" start-sn: "+(b?b.startSN:"na")+"->"+m.startSN+" prev-sn: "+(K?K.sn:"na")+" fragments: "+B),re}return S},u.waitForCdnTuneIn=function(m){var b=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*b)},u.setStartPosition=function(m,b){var P=this.startPosition;if(P<b&&(P=-1),P===-1||this.lastCurrentTime===-1){var N=m.startTimeOffset;Object(V.isFiniteNumber)(N)?(P=b+N,N<0&&(P+=m.totalduration),P=Math.min(Math.max(b,P),b+m.totalduration),this.log("Start time offset "+N+" found in playlist, adjust startPosition to "+P),this.startPosition=P):m.live?P=this.hls.liveSyncPosition||b:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},u.getLoadPosition=function(){var m=this.media,b=0;return this.loadedmetadata&&m?b=m.currentTime:this.nextLoadPosition&&(b=this.nextLoadPosition),b},u.handleFragLoadAborted=function(m,b){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(b?" part"+b.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},u.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=A.IDLE)},u.onFragmentOrKeyLoadError=function(m,b){if(b.fatal)return;var P=b.frag;if(!P||P.type!==m)return;var N=this.fragCurrent;console.assert(N&&P.sn===N.sn&&P.level===N.level&&P.urlId===N.urlId,"Frag load error must match current frag to retry");var K=this.config;if(this.fragLoadError+1<=K.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var X=Math.min(Math.pow(2,this.fragLoadError)*K.fragLoadingRetryDelay,K.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+m+" "+P.level+" failed to load, retrying in "+X+"ms"),this.retryDate=self.performance.now()+X,this.fragLoadError++,this.state=A.FRAG_LOADING_WAITING_RETRY}else b.levelRetry?(m===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=A.IDLE):(j.logger.error(b.details+" reaches max retry, redispatch as fatal ..."),b.fatal=!0,this.hls.stopLoad(),this.state=A.ERROR)},u.afterBufferFlushed=function(m,b,P){if(!m)return;var N=G.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(b,N,P),this.state===A.ENDED&&this.resetLoadingState()},u.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=A.IDLE},u.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var b=this.levels?this.levels[m].details:null;if(b!=null&&b.live)return this.startPosition=-1,this.setStartPosition(b,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},u.updateLevelTiming=function(m,b,P,N){var K=this,X=P.details;console.assert(!!X,"level.details must be defined");var B=Object.keys(m.elementaryStreams).reduce(function(S,Y){var te=m.elementaryStreams[Y];if(te){var re=te.endPTS-te.startPTS;if(re<=0)return K.warn("Could not parse fragment "+m.sn+" "+Y+" duration reliably ("+re+") resetting transmuxer to fallback to playlist timing"),K.resetTransmuxer(),S||!1;var ce=N?0:Object(a.updateFragPTSDTS)(X,m,te.startPTS,te.endPTS,te.startDTS,te.endDTS);return K.hls.trigger(M.Events.LEVEL_PTS_UPDATED,{details:X,level:P,drift:ce,type:Y,frag:m,start:te.startPTS,end:te.endPTS}),!0}return S},!1);B?(this.state=A.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:m,part:b})):this.resetLoadingState()},u.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},O(y,[{key:"state",get:function(){return this._state},set:function(m){var b=this._state;b!==m&&(this._state=m,this.log(b+"->"+m))}}]),y}(F.default)},"./src/controller/buffer-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return h});var V=k("./src/polyfills/number.ts"),F=k("./src/events.ts"),D=k("./src/utils/logger.ts"),G=k("./src/errors.ts"),j=k("./src/utils/buffer-helper.ts"),M=k("./src/utils/mediasource-helper.ts"),I=k("./src/loader/fragment.ts"),g=k("./src/controller/buffer-operation-queue.ts"),p=Object(M.getMediaSource)(),f=/([ha]vc.)(?:\.[^.,]+)+/,h=function(){function a(o){var s=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=s.hls,d=s.media,O=s.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),d&&(s.updateMediaElementDuration(),l.trigger(F.Events.MEDIA_ATTACHED,{media:d})),O&&O.removeEventListener("sourceopen",s._onMediaSourceOpen),s.checkPendingTracks()},this._onMediaSourceClose=function(){D.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.logger.log("[buffer-controller]: Media source ended")},this.hls=o,this._initSourceBuffer(),this.registerListeners()}var c=a.prototype;return c.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},c.destroy=function(){this.unregisterListeners(),this.details=null},c.registerListeners=function(){var s=this.hls;s.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(F.Events.BUFFER_RESET,this.onBufferReset,this),s.on(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),s.on(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),s.on(F.Events.BUFFER_EOS,this.onBufferEos,this),s.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),s.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),s.on(F.Events.FRAG_PARSED,this.onFragParsed,this),s.on(F.Events.FRAG_CHANGED,this.onFragChanged,this)},c.unregisterListeners=function(){var s=this.hls;s.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(F.Events.BUFFER_RESET,this.onBufferReset,this),s.off(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),s.off(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),s.off(F.Events.BUFFER_EOS,this.onBufferEos,this),s.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),s.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),s.off(F.Events.FRAG_PARSED,this.onFragParsed,this),s.off(F.Events.FRAG_CHANGED,this.onFragChanged,this)},c._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},c.onManifestParsed=function(s,l){var d=2;(l.audio&&!l.video||!l.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},c.onMediaAttaching=function(s,l){var d=this.media=l.media;if(d&&p){var O=this.mediaSource=new p;O.addEventListener("sourceopen",this._onMediaSourceOpen),O.addEventListener("sourceended",this._onMediaSourceEnded),O.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(O),this._objectUrl=d.src}},c.onMediaDetaching=function(){var s=this.media,l=this.mediaSource,d=this._objectUrl;if(l){if(D.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(O){D.logger.warn("[buffer-controller]: onMediaDetaching: "+O.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),s&&(d&&self.URL.revokeObjectURL(d),s.src===d?(s.removeAttribute("src"),s.load()):D.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(F.Events.MEDIA_DETACHED,void 0)},c.onBufferReset=function(){var s=this;this.getSourceBufferTypes().forEach(function(l){var d=s.sourceBuffer[l];try{d&&(s.removeBufferListeners(l),s.mediaSource&&s.mediaSource.removeSourceBuffer(d),s.sourceBuffer[l]=void 0)}catch(O){D.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",O)}}),this._initSourceBuffer()},c.onBufferCodecs=function(s,l){var d=this,O=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(w){if(O){var x=d.tracks[w];if(x&&typeof x.buffer.changeType=="function"){var R=l[w],A=R.codec,T=R.levelCodec,E=R.container,y=(x.levelCodec||x.codec).replace(f,"$1"),u=(T||A).replace(f,"$1");if(y!==u){var _=E+";codecs="+(T||A);d.appendChangeType(w,_)}}}else d.pendingTracks[w]=l[w]}),O)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},c.appendChangeType=function(s,l){var d=this,O=this.operationQueue,w={execute:function(){var R=d.sourceBuffer[s];R&&(D.logger.log("[buffer-controller]: changing "+s+" sourceBuffer type to "+l),R.changeType(l)),O.shiftAndExecuteNext(s)},onStart:function(){},onComplete:function(){},onError:function(R){D.logger.warn("[buffer-controller]: Failed to change "+s+" SourceBuffer type",R)}};O.append(w,s)},c.onBufferAppending=function(s,l){var d=this,O=this.hls,w=this.operationQueue,x=this.tracks,R=l.data,A=l.type,T=l.frag,E=l.part,y=l.chunkMeta,u=y.buffering[A],_=self.performance.now();u.start=_;var m=T.stats.buffering,b=E?E.stats.buffering:null;m.start===0&&(m.start=_),b&&b.start===0&&(b.start=_);var P=x.audio,N=A==="audio"&&y.id===1&&(P==null?void 0:P.container)==="audio/mpeg",K={execute:function(){if(u.executeStart=self.performance.now(),N){var B=d.sourceBuffer[A];if(B){var S=T.start-B.timestampOffset;Math.abs(S)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+T.start+" (delta: "+S+") sn: "+T.sn+")"),B.timestampOffset=T.start)}}d.appendExecutor(R,A)},onStart:function(){},onComplete:function(){var B=self.performance.now();u.executeEnd=u.end=B,m.first===0&&(m.first=B),b&&b.first===0&&(b.first=B);var S=d.sourceBuffer,Y={};for(var te in S)Y[te]=j.BufferHelper.getBuffered(S[te]);d.appendError=0,d.hls.trigger(F.Events.BUFFER_APPENDED,{type:A,frag:T,part:E,chunkMeta:y,parent:T.type,timeRanges:Y})},onError:function(B){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+A+" SourceBuffer",B);var S={type:G.ErrorTypes.MEDIA_ERROR,parent:T.type,details:G.ErrorDetails.BUFFER_APPEND_ERROR,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?S.details=G.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,S.details=G.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>O.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+O.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),S.fatal=!0)),O.trigger(F.Events.ERROR,S)}};w.append(K,A)},c.onBufferFlushing=function(s,l){var d=this,O=this.operationQueue,w=function(R){return{execute:d.removeExecutor.bind(d,R,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(F.Events.BUFFER_FLUSHED,{type:R})},onError:function(T){D.logger.warn("[buffer-controller]: Failed to remove from "+R+" SourceBuffer",T)}}};l.type?O.append(w(l.type),l.type):this.getSourceBufferTypes().forEach(function(x){O.append(w(x),x)})},c.onFragParsed=function(s,l){var d=this,O=l.frag,w=l.part,x=[],R=w?w.elementaryStreams:O.elementaryStreams;R[I.ElementaryStreamTypes.AUDIOVIDEO]?x.push("audiovideo"):(R[I.ElementaryStreamTypes.AUDIO]&&x.push("audio"),R[I.ElementaryStreamTypes.VIDEO]&&x.push("video"));var A=function(){var E=self.performance.now();O.stats.buffering.end=E,w&&(w.stats.buffering.end=E);var y=w?w.stats:O.stats;d.hls.trigger(F.Events.FRAG_BUFFERED,{frag:O,part:w,stats:y,id:O.type})};x.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+O.type+" level: "+O.level+" sn: "+O.sn),this.blockBuffers(A,x)},c.onFragChanged=function(s,l){this.flushBackBuffer()},c.onBufferEos=function(s,l){var d=this,O=this.getSourceBufferTypes().reduce(function(w,x){var R=d.sourceBuffer[x];return(!l.type||l.type===x)&&(R&&!R.ended&&(R.ended=!0,D.logger.log("[buffer-controller]: "+x+" sourceBuffer now EOS"))),w&&!!(!R||R.ended)},!0);O&&this.blockBuffers(function(){var w=d.mediaSource;if(!w||w.readyState!=="open")return;w.endOfStream()})},c.onLevelUpdated=function(s,l){var d=l.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},c.flushBackBuffer=function(){var s=this.hls,l=this.details,d=this.media,O=this.sourceBuffer;if(!d||l===null)return;var w=this.getSourceBufferTypes();if(!w.length)return;var x=l.live&&s.config.liveBackBufferLength!==null?s.config.liveBackBufferLength:s.config.backBufferLength;if(!Object(V.isFiniteNumber)(x)||x<0)return;var R=d.currentTime,A=l.levelTargetDuration,T=Math.max(x,A),E=Math.floor(R/A)*A-T;w.forEach(function(y){var u=O[y];if(u){var _=j.BufferHelper.getBuffered(u);_.length>0&&E>_.start(0)&&(s.trigger(F.Events.BACK_BUFFER_REACHED,{bufferEnd:E}),l.live&&s.trigger(F.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:E}),s.trigger(F.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:E,type:y}))}})},c.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var s=this.details,l=this.hls,d=this.media,O=this.mediaSource,w=s.fragments[0].start+s.totalduration,x=d.duration,R=Object(V.isFiniteNumber)(O.duration)?O.duration:0;s.live&&l.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),O.duration=Infinity,this.updateSeekableRange(s)):(w>R&&w>x||!Object(V.isFiniteNumber)(x))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+w.toFixed(3)),O.duration=w)},c.updateSeekableRange=function(s){var l=this.mediaSource,d=s.fragments,O=d.length;if(O&&s.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var w=Math.max(0,d[0].start),x=Math.max(w,w+s.totalduration);l.setLiveSeekableRange(w,x)}},c.checkPendingTracks=function(){var s=this.bufferCodecEventsExpected,l=this.operationQueue,d=this.pendingTracks,O=Object.keys(d).length;if(O&&!s||O===2){this.createSourceBuffers(d),this.pendingTracks={};var w=this.getSourceBufferTypes();if(w.length===0){this.hls.trigger(F.Events.ERROR,{type:G.ErrorTypes.MEDIA_ERROR,details:G.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}w.forEach(function(x){l.executeNext(x)})}},c.createSourceBuffers=function(s){var l=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var O=0;for(var w in s)if(!l[w]){var x=s[w];if(!x)throw Error("source buffer exists for track "+w+", however track does not");var R=x.levelCodec||x.codec,A=x.container+";codecs="+R;D.logger.log("[buffer-controller]: creating sourceBuffer("+A+")");try{var T=l[w]=d.addSourceBuffer(A),E=w;this.addBufferListener(E,"updatestart",this._onSBUpdateStart),this.addBufferListener(E,"updateend",this._onSBUpdateEnd),this.addBufferListener(E,"error",this._onSBUpdateError),this.tracks[w]={buffer:T,codec:R,container:x.container,levelCodec:x.levelCodec,id:x.id},O++}catch(y){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+y.message),this.hls.trigger(F.Events.ERROR,{type:G.ErrorTypes.MEDIA_ERROR,details:G.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:y,mimeType:A})}}O&&this.hls.trigger(F.Events.BUFFER_CREATED,{tracks:this.tracks})},c._onSBUpdateStart=function(s){var l=this.operationQueue,d=l.current(s);d.onStart()},c._onSBUpdateEnd=function(s){var l=this.operationQueue,d=l.current(s);d.onComplete(),l.shiftAndExecuteNext(s)},c._onSBUpdateError=function(s,l){D.logger.error("[buffer-controller]: "+s+" SourceBuffer error",l),this.hls.trigger(F.Events.ERROR,{type:G.ErrorTypes.MEDIA_ERROR,details:G.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(s);d&&d.onError(l)},c.removeExecutor=function(s,l,d){var O=this.media,w=this.mediaSource,x=this.operationQueue,R=this.sourceBuffer,A=R[s];if(!O||!w||!A){D.logger.warn("[buffer-controller]: Attempting to remove from the "+s+" SourceBuffer, but it does not exist"),x.shiftAndExecuteNext(s);return}var T=Object(V.isFiniteNumber)(O.duration)?O.duration:Infinity,E=Object(V.isFiniteNumber)(w.duration)?w.duration:Infinity,y=Math.max(0,l),u=Math.min(d,T,E);u>y?(D.logger.log("[buffer-controller]: Removing ["+y+","+u+"] from the "+s+" SourceBuffer"),console.assert(!A.updating,s+" sourceBuffer must not be updating"),A.remove(y,u)):x.shiftAndExecuteNext(s)},c.appendExecutor=function(s,l){var d=this.operationQueue,O=this.sourceBuffer,w=O[l];if(!w){D.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(l);return}w.ended=!1,console.assert(!w.updating,l+" sourceBuffer must not be updating"),w.appendBuffer(s)},c.blockBuffers=function(s,l){var d=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(s);return}var O=this.operationQueue,w=l.map(function(x){return O.appendBlocker(x)});Promise.all(w).then(function(){s(),l.forEach(function(x){var R=d.sourceBuffer[x];(!R||!R.updating)&&O.shiftAndExecuteNext(x)})})},c.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},c.addBufferListener=function(s,l,d){var O=this.sourceBuffer[s];if(!O)return;var w=d.bind(this,s);this.listeners[s].push({event:l,listener:w}),O.addEventListener(l,w)},c.removeBufferListeners=function(s){var l=this.sourceBuffer[s];if(!l)return;this.listeners[s].forEach(function(d){l.removeEventListener(d.event,d.listener)})},a}()},"./src/controller/buffer-operation-queue.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return F});var V=k("./src/utils/logger.ts"),F=function(){function D(j){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=j}var G=D.prototype;return G.append=function(M,I){var g=this.queues[I];g.push(M),g.length===1&&this.buffers[I]&&this.executeNext(I)},G.insertAbort=function(M,I){var g=this.queues[I];g.unshift(M),this.executeNext(I)},G.appendBlocker=function(M){var I,g=new Promise(function(f){I=f}),p={execute:I,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(p,M),g},G.executeNext=function(M){var I=this.buffers,g=this.queues,p=I[M],f=g[M];if(f.length){var h=f[0];try{h.execute()}catch(a){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(a),(!p||!p.updating)&&(f.shift(),this.executeNext(M))}}},G.shiftAndExecuteNext=function(M){this.queues[M].shift(),this.executeNext(M)},G.current=function(M){return this.queues[M][0]},D}()},"./src/controller/cap-level-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts");function F(j,M){for(var I=0;I<M.length;I++){var g=M[I];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(j,g.key,g)}}function D(j,M,I){return M&&F(j.prototype,M),I&&F(j,I),j}var G=function(){function j(I){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=I,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var M=j.prototype;return M.setStreamController=function(g){this.streamController=g},M.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},M.registerListeners=function(){var g=this.hls;g.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var g=this.hls;g.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(g,p){j.isLevelAllowed(p.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(p.droppedLevel)},M.onMediaAttaching=function(g,p){this.media=p.media instanceof HTMLVideoElement?p.media:null},M.onManifestParsed=function(g,p){var f=this.hls;this.restrictedLevels=[],this.firstLevel=p.firstLevel,f.config.capLevelToPlayerSize&&p.video&&this.startCapping()},M.onBufferCodecs=function(g,p){var f=this.hls;f.config.capLevelToPlayerSize&&p.video&&this.startCapping()},M.onMediaDetaching=function(){this.stopCapping()},M.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var p=this.hls;p.autoLevelCapping=this.getMaxLevel(g.length-1),p.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=p.autoLevelCapping}}},M.getMaxLevel=function(g){var p=this,f=this.hls.levels;if(!f.length)return-1;var h=f.filter(function(a,c){return j.isLevelAllowed(c,p.restrictedLevels)&&c<=g});return this.clientRect=null,j.getMaxLevelByMediaSize(h,this.mediaWidth,this.mediaHeight)},M.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},M.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},M.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,p={width:0,height:0};if(g){var f=g.getBoundingClientRect();p.width=f.width,p.height=f.height,!p.width&&!p.height&&(p.width=f.right-f.left||g.width||0,p.height=f.bottom-f.top||g.height||0)}return this.clientRect=p,p},j.isLevelAllowed=function(g,p){return p===void 0&&(p=[]),p.indexOf(g)===-1},j.getMaxLevelByMediaSize=function(g,p,f){if(!g||!g.length)return-1;for(var h=function(l,d){return d?l.width!==d.width||l.height!==d.height:!0},a=g.length-1,c=0;c<g.length;c+=1){var o=g[c];if((o.width>=p||o.height>=f)&&h(o,g[c+1])){a=c;break}}return a},D(j,[{key:"mediaWidth",get:function(){return this.getDimensions().width*j.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*j.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var g=1;try{g=self.devicePixelRatio}catch(p){}return g}}]),j}();Z.default=G},"./src/controller/cmcd-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return h});var V=k("./src/events.ts"),F=k("./src/types/cmcd.ts"),D=k("./src/utils/buffer-helper.ts"),G=k("./src/utils/logger.ts");function j(a,c){for(var o=0;o<c.length;o++){var s=c[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(a,s.key,s)}}function M(a,c,o){return c&&j(a.prototype,c),o&&j(a,o),a}function I(a,c){var o=typeof Symbol!="undefined"&&a[Symbol.iterator]||a["@@iterator"];if(o)return(o=o.call(a)).next.bind(o);if(Array.isArray(a)||(o=g(a))||c&&a&&typeof a.length=="number"){o&&(a=o);var s=0;return function(){return s>=a.length?{done:!0}:{done:!1,value:a[s++]}}}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 g(a,c){if(!a)return;if(typeof a=="string")return p(a,c);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(a);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return p(a,c)}function p(a,c){(c==null||c>a.length)&&(c=a.length);for(var o=0,s=new Array(c);o<c;o++)s[o]=a[o];return s}function f(){return f=Object.assign||function(a){for(var c=1;c<arguments.length;c++){var o=arguments[c];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(a[s]=o[s])}return a},f.apply(this,arguments)}var h=function(){function a(o){var s=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(){s.initialized&&(s.starved=!0),s.buffering=!0},this.onPlaying=function(){s.initialized||(s.initialized=!0),s.buffering=!1},this.applyPlaylistData=function(O){try{s.apply(O,{ot:F.CMCDObjectType.MANIFEST,su:!s.initialized})}catch(w){G.logger.warn("Could not generate manifest CMCD data.",w)}},this.applyFragmentData=function(O){try{var w=O.frag,x=s.hls.levels[w.level],R=s.getObjectType(w),A={d:w.duration*1e3,ot:R};(R===F.CMCDObjectType.VIDEO||R===F.CMCDObjectType.AUDIO||R==F.CMCDObjectType.MUXED)&&(A.br=x.bitrate/1e3,A.tb=s.getTopBandwidth(R),A.bl=s.getBufferLength(R)),s.apply(O,A)}catch(T){G.logger.warn("Could not generate segment CMCD data.",T)}},this.hls=o;var l=this.config=o.config,d=l.cmcd;d!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||a.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var c=a.prototype;return c.registerListeners=function(){var s=this.hls;s.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),s.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},c.unregisterListeners=function(){var s=this.hls;s.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),s.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},c.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},c.onMediaAttached=function(s,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},c.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},c.onBufferCreated=function(s,l){var d,O;this.audioBuffer=(d=l.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(O=l.tracks.video)===null||O===void 0?void 0:O.buffer},c.createData=function(){var s;return{v:F.CMCDVersion,sf:F.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(s=this.media)===null||s===void 0?void 0:s.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},c.apply=function(s,l){l===void 0&&(l={}),f(l,this.createData());var d=l.ot===F.CMCDObjectType.INIT||l.ot===F.CMCDObjectType.VIDEO||l.ot===F.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 O=a.toHeaders(l);if(!Object.keys(O).length)return;s.headers||(s.headers={}),f(s.headers,O)}else{var w=a.toQuery(l);if(!w)return;s.url=a.appendQueryToUri(s.url,w)}},c.getObjectType=function(s){var l=s.type;return l==="subtitle"?F.CMCDObjectType.TIMED_TEXT:s.sn==="initSegment"?F.CMCDObjectType.INIT:l==="audio"?F.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?F.CMCDObjectType.VIDEO:F.CMCDObjectType.MUXED:void 0},c.getTopBandwidth=function(s){for(var l=0,d=s===F.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,O=I(d),w;!(w=O()).done;){var x=w.value;x.bitrate>l&&(l=x.bitrate)}return l>0?l:NaN},c.getBufferLength=function(s){var l=this.hls.media,d=s===F.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!l)return NaN;var O=D.BufferHelper.bufferInfo(d,l.currentTime,this.config.maxBufferHole);return O.len*1e3},c.createPlaylistLoader=function(){var s=this.config.pLoader,l=this.applyPlaylistData,d=s||this.config.loader;return function(){function O(x){this.loader=void 0,this.loader=new d(x)}var w=O.prototype;return w.destroy=function(){this.loader.destroy()},w.abort=function(){this.loader.abort()},w.load=function(R,A,T){l(R),this.loader.load(R,A,T)},M(O,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),O}()},c.createFragmentLoader=function(){var s=this.config.fLoader,l=this.applyFragmentData,d=s||this.config.loader;return function(){function O(x){this.loader=void 0,this.loader=new d(x)}var w=O.prototype;return w.destroy=function(){this.loader.destroy()},w.abort=function(){this.loader.abort()},w.load=function(R,A,T){l(R),this.loader.load(R,A,T)},M(O,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),O}()},a.uuid=function(){var s=URL.createObjectURL(new Blob),l=s.toString();return URL.revokeObjectURL(s),l.substr(l.lastIndexOf("/")+1)},a.serialize=function(s){for(var l=[],d=function(N){return!Number.isNaN(N)&&N!=null&&N!==""&&N!==!1},O=function(N){return Math.round(N)},w=function(N){return O(N/100)*100},x=function(N){return encodeURIComponent(N)},R={br:O,d:O,bl:w,dl:w,mtp:w,nor:x,rtp:w,tb:O},A=Object.keys(s||{}).sort(),T=I(A),E;!(E=T()).done;){var y=E.value,u=s[y];if(!d(u))continue;if(y==="v"&&u===1)continue;if(y=="pr"&&u===1)continue;var _=R[y];_&&(u=_(u));var m=typeof u,b=void 0;y==="ot"||y==="sf"||y==="st"?b=y+"="+u:m==="boolean"?b=y:m==="number"?b=y+"="+u:b=y+"="+JSON.stringify(u),l.push(b)}return l.join(",")},a.toHeaders=function(s){for(var l=Object.keys(s),d={},O=["Object","Request","Session","Status"],w=[{},{},{},{}],x={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},R=0,A=l;R<A.length;R++){var T=A[R],E=x[T]!=null?x[T]:1;w[E][T]=s[T]}for(var y=0;y<w.length;y++){var u=a.serialize(w[y]);u&&(d["CMCD-"+O[y]]=u)}return d},a.toQuery=function(s){return"CMCD="+encodeURIComponent(a.serialize(s))},a.appendQueryToUri=function(s,l){if(!l)return s;var d=s.includes("?")?"&":"?";return""+s+d+l},a}()},"./src/controller/eme-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts"),F=k("./src/errors.ts"),D=k("./src/utils/logger.ts"),G=k("./src/utils/mediakeys-helper.ts");function j(h,a){for(var c=0;c<a.length;c++){var o=a[c];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(h,o.key,o)}}function M(h,a,c){return a&&j(h.prototype,a),c&&j(h,c),h}var I=3,g=function(a,c,o){var s={audioCapabilities:[],videoCapabilities:[]};return a.forEach(function(l){s.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:o.audioRobustness||""})}),c.forEach(function(l){s.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:o.videoRobustness||""})}),[s]},p=function(a,c,o,s){switch(a){case G.KeySystems.WIDEVINE:return g(c,o,s);default:throw new Error("Unknown key-system: "+a)}},f=function(){function h(c){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=c,this._config=c.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 a=h.prototype;return a.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},a._registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},a._unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},a.getLicenseServerUrl=function(o){switch(o){case G.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+o+'"')},a._attemptKeySystemAccess=function(o,s,l){var d=this,O=p(o,s,l,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var w=this.requestMediaKeySystemAccess(o,O);this.mediaKeysPromise=w.then(function(x){return d._onMediaKeySystemAccessObtained(o,x)}),w.catch(function(x){D.logger.error('Failed to obtain key-system "'+o+'" access:',x)})},a._onMediaKeySystemAccessObtained=function(o,s){var l=this;D.logger.log('Access for key-system "'+o+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:s,mediaKeySystemDomain:o};this._mediaKeysList.push(d);var O=Promise.resolve().then(function(){return s.createMediaKeys()}).then(function(w){return d.mediaKeys=w,D.logger.log('Media-keys created for key-system "'+o+'"'),l._onMediaKeysCreated(),w});return O.catch(function(w){D.logger.error("Failed to create media-keys:",w)}),O},a._onMediaKeysCreated=function(){var o=this;this._mediaKeysList.forEach(function(s){s.mediaKeysSession||(s.mediaKeysSession=s.mediaKeys.createSession(),o._onNewMediaKeySession(s.mediaKeysSession))})},a._onNewMediaKeySession=function(o){var s=this;D.logger.log("New key-system session "+o.sessionId),o.addEventListener("message",function(l){s._onKeySessionMessage(o,l.message)},!1)},a._onKeySessionMessage=function(o,s){D.logger.log("Got EME message event, creating license request"),this._requestLicense(s,function(l){D.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),o.update(l)})},a.onMediaEncrypted=function(o){var s=this;if(D.logger.log('Media is encrypted using "'+o.initDataType+'" init data type'),!this.mediaKeysPromise){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(O){if(!s._media)return;s._attemptSetMediaKeys(O),s._generateRequestWithPreferredKeySession(o.initDataType,o.initData)};this.mediaKeysPromise.then(l).catch(l)},a._attemptSetMediaKeys=function(o){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var s=this._mediaKeysList[0];if(!s||!s.mediaKeys){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(s.mediaKeys),this._hasSetMediaKeys=!0}},a._generateRequestWithPreferredKeySession=function(o,s){var l=this,d=this._mediaKeysList[0];if(!d){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var O=d.mediaKeysSession;if(!O){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!s){D.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+o+'" init data type'),d.mediaKeysSessionInitialized=!0,O.generateRequest(o,s).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(w){D.logger.error("Error generating key-session request:",w),l.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},a._createLicenseXhr=function(o,s,l){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,o,s,l);var O=this._licenseXhrSetup;if(O)try{O.call(this.hls,d,o),O=void 0}catch(w){D.logger.error(w)}try{d.readyState||d.open("POST",o,!0),O&&O.call(this.hls,d,o)}catch(w){throw new Error("issue setting up KeySystem license XHR "+w)}return d},a._onLicenseRequestReadyStageChange=function(o,s,l,d){switch(o.readyState){case 4:if(o.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var O=o.response,w=this._licenseResponseCallback;if(w)try{O=w.call(this.hls,o,s)}catch(R){D.logger.error(R)}d(O)}else{if(D.logger.error("License Request XHR failed ("+s+"). Status: "+o.status+" ("+o.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>I){this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var x=I-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+x+" attempts left"),this._requestLicense(l,d)}break}},a._generateLicenseRequestChallenge=function(o,s){switch(o.mediaKeySystemDomain){case G.KeySystems.WIDEVINE:return s}throw new Error("unsupported key-system: "+o.mediaKeySystemDomain)},a._requestLicense=function(o,s){D.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(l.mediaKeySystemDomain),O=this._createLicenseXhr(d,o,s);D.logger.log("Sending license request to URL: "+d);var w=this._generateLicenseRequestChallenge(l,o);O.send(w)}catch(x){D.logger.error("Failure requesting DRM license: "+x),this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},a.onMediaAttached=function(o,s){if(!this._emeEnabled)return;var l=s.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},a.onMediaDetached=function(){var o=this._media,s=this._mediaKeysList;if(!o)return;o.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(s.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return o.setMediaKeys(null)}).catch(function(){})},a.onManifestParsed=function(o,s){if(!this._emeEnabled)return;var l=s.levels.map(function(O){return O.audioCodec}).filter(function(O){return!!O}),d=s.levels.map(function(O){return O.videoCodec}).filter(function(O){return!!O});this._attemptKeySystemAccess(G.KeySystems.WIDEVINE,l,d)},M(h,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),h}();Z.default=f},"./src/controller/fps-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts"),F=k("./src/utils/logger.ts"),D=function(){function G(M){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=M,this.registerListeners()}var j=G.prototype;return j.setStreamController=function(I){this.streamController=I},j.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},j.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},j.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},j.onMediaAttaching=function(I,g){var p=this.hls.config;if(p.capLevelOnFPSDrop){var f=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=f,f&&typeof f.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),p.fpsDroppedMonitoringPeriod)}},j.checkFPS=function(I,g,p){var f=performance.now();if(g){if(this.lastTime){var h=f-this.lastTime,a=p-this.lastDroppedFrames,c=g-this.lastDecodedFrames,o=1e3*a/h,s=this.hls;if(s.trigger(V.Events.FPS_DROP,{currentDropped:a,currentDecoded:c,totalDroppedFrames:p}),o>0&&a>s.config.fpsDroppedMonitoringThreshold*c){var l=s.currentLevel;F.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(s.autoLevelCapping===-1||s.autoLevelCapping>=l)&&(l=l-1,s.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:s.currentLevel}),s.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=f,this.lastDroppedFrames=p,this.lastDecodedFrames=g}},j.checkFPSInterval=function(){var I=this.media;if(I)if(this.isVideoPlaybackQualityAvailable){var g=I.getVideoPlaybackQuality();this.checkFPS(I,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(I,I.webkitDecodedFrameCount,I.webkitDroppedFrameCount)},G}();Z.default=D},"./src/controller/fragment-finders.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"findFragmentByPDT",function(){return D}),k.d(Z,"findFragmentByPTS",function(){return G}),k.d(Z,"fragmentWithinToleranceTest",function(){return j}),k.d(Z,"pdtWithinToleranceTest",function(){return M}),k.d(Z,"findFragWithCC",function(){return I});var V=k("./src/polyfills/number.ts"),F=k("./src/utils/binary-search.ts");function D(g,p,f){if(p===null||!Array.isArray(g)||!g.length||!Object(V.isFiniteNumber)(p))return null;var h=g[0].programDateTime;if(p<(h||0))return null;var a=g[g.length-1].endProgramDateTime;if(p>=(a||0))return null;f=f||0;for(var c=0;c<g.length;++c){var o=g[c];if(M(p,f,o))return o}return null}function G(g,p,f,h){f===void 0&&(f=0),h===void 0&&(h=0);var a=null;if(g?a=p[g.sn-p[0].sn+1]||null:f===0&&p[0].start===0&&(a=p[0]),a&&j(f,h,a)===0)return a;var c=F.default.search(p,j.bind(null,f,h));return c||a}function j(g,p,f){g===void 0&&(g=0),p===void 0&&(p=0);var h=Math.min(p,f.duration+(f.deltaPTS?f.deltaPTS:0));return f.start+f.duration-h<=g?1:f.start-h>g&&f.start?-1:0}function M(g,p,f){var h=Math.min(p,f.duration+(f.deltaPTS?f.deltaPTS:0))*1e3,a=f.endProgramDateTime||0;return a-h>g}function I(g,p){return F.default.search(g,function(f){return f.cc<p?1:f.cc>p?-1:0})}},"./src/controller/fragment-tracker.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"FragmentState",function(){return D}),k.d(Z,"FragmentTracker",function(){return G});var V=k("./src/events.ts"),F=k("./src/types/loader.ts"),D;(function(I){I.NOT_LOADED="NOT_LOADED",I.BACKTRACKED="BACKTRACKED",I.APPENDING="APPENDING",I.PARTIAL="PARTIAL",I.OK="OK"})(D||(D={}));var G=function(){function I(p){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=p,this._registerListeners()}var g=I.prototype;return g._registerListeners=function(){var f=this.hls;f.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),f.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var f=this.hls;f.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),f.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(f,h){if(h===F.PlaylistLevelType.MAIN){var a=this.activeFragment,c=this.activeParts;if(!a)return null;if(c)for(var o=c.length;o--;){var s=c[o],l=s?s.end:a.appendedPTS;if(s.start<=f&&l!==void 0&&f<=l)return o>9&&(this.activeParts=c.slice(o-9)),s}else if(a.start<=f&&a.appendedPTS!==void 0&&f<=a.appendedPTS)return a}return this.getBufferedFrag(f,h)},g.getBufferedFrag=function(f,h){for(var a=this.fragments,c=Object.keys(a),o=c.length;o--;){var s=a[c[o]];if((s==null?void 0:s.body.type)===h&&s.buffered){var l=s.body;if(l.start<=f&&f<=l.end)return l}}return null},g.detectEvictedFragments=function(f,h,a){var c=this;Object.keys(this.fragments).forEach(function(o){var s=c.fragments[o];if(!s)return;if(!s.buffered){s.body.type===a&&c.removeFragment(s.body);return}var l=s.range[f];if(!l)return;l.time.some(function(d){var O=!c.isTimeBuffered(d.startPTS,d.endPTS,h);return O&&c.removeFragment(s.body),O})})},g.detectPartialFragments=function(f){var h=this,a=this.timeRanges,c=f.frag,o=f.part;if(!a||c.sn==="initSegment")return;var s=M(c),l=this.fragments[s];if(!l)return;Object.keys(a).forEach(function(d){var O=c.elementaryStreams[d];if(!O)return;var w=a[d],x=o!==null||O.partial===!0;l.range[d]=h.getBufferedTimes(c,o,x,w)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},g.fragBuffered=function(f){var h=M(f),a=this.fragments[h];a&&(a.backtrack=a.loaded=null,a.buffered=!0)},g.getBufferedTimes=function(f,h,a,c){for(var o={time:[],partial:a},s=h?h.start:f.start,l=h?h.end:f.end,d=f.minEndPTS||l,O=f.maxStartPTS||s,w=0;w<c.length;w++){var x=c.start(w)-this.bufferPadding,R=c.end(w)+this.bufferPadding;if(O>=x&&d<=R){o.time.push({startPTS:Math.max(s,c.start(w)),endPTS:Math.min(l,c.end(w))});break}else if(s<R&&l>x)o.partial=!0,o.time.push({startPTS:Math.max(s,c.start(w)),endPTS:Math.min(l,c.end(w))});else if(l<=x)break}return o},g.getPartialFragment=function(f){var h=null,a,c,o,s=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(O){var w=d[O];if(!w)return;j(w)&&(c=w.body.start-l,o=w.body.end+l,f>=c&&f<=o&&(a=Math.min(f-c,o-f),s<=a&&(h=w.body,s=a)))}),h},g.getState=function(f){var h=M(f),a=this.fragments[h];return a?a.buffered?j(a)?D.PARTIAL:D.OK:a.backtrack?D.BACKTRACKED:D.APPENDING:D.NOT_LOADED},g.backtrack=function(f,h){var a=M(f),c=this.fragments[a];if(!c||c.backtrack)return null;var o=c.backtrack=h||c.loaded;return c.loaded=null,o},g.getBacktrackData=function(f){var h=M(f),a=this.fragments[h];if(a){var c,o=a.backtrack;if(o!=null&&(c=o.payload)!==null&&c!==void 0&&c.byteLength)return o;this.removeFragment(f)}return null},g.isTimeBuffered=function(f,h,a){for(var c,o,s=0;s<a.length;s++){if(c=a.start(s)-this.bufferPadding,o=a.end(s)+this.bufferPadding,f>=c&&h<=o)return!0;if(h<=c)return!1}return!1},g.onFragLoaded=function(f,h){var a=h.frag,c=h.part;if(a.sn==="initSegment"||a.bitrateTest||c)return;var o=M(a);this.fragments[o]={body:a,loaded:h,backtrack:null,buffered:!1,range:Object.create(null)}},g.onBufferAppended=function(f,h){var a=this,c=h.frag,o=h.part,s=h.timeRanges;if(c.type===F.PlaylistLevelType.MAIN)if(this.activeFragment=c,o){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(o)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach(function(d){var O=s[d];if(a.detectEvictedFragments(d,O),!o)for(var w=0;w<O.length;w++)c.appendedPTS=Math.max(O.end(w),c.appendedPTS||0)})},g.onFragBuffered=function(f,h){this.detectPartialFragments(h)},g.hasFragment=function(f){var h=M(f);return!!this.fragments[h]},g.removeFragmentsInRange=function(f,h,a){var c=this;Object.keys(this.fragments).forEach(function(o){var s=c.fragments[o];if(!s)return;if(s.buffered){var l=s.body;l.type===a&&l.start<h&&l.end>f&&c.removeFragment(l)}})},g.removeFragment=function(f){var h=M(f);f.stats.loaded=0,f.clearElementaryStreamInfo(),delete this.fragments[h]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},I}();function j(I){var g,p;return I.buffered&&(((g=I.range.video)===null||g===void 0?void 0:g.partial)||((p=I.range.audio)===null||p===void 0?void 0:p.partial))}function M(I){return I.type+"_"+I.level+"_"+I.urlId+"_"+I.sn}},"./src/controller/gap-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"STALL_MINIMUM_DURATION_MS",function(){return j}),k.d(Z,"MAX_START_GAP_JUMP",function(){return M}),k.d(Z,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return I}),k.d(Z,"SKIP_BUFFER_RANGE_START",function(){return g}),k.d(Z,"default",function(){return p});var V=k("./src/utils/buffer-helper.ts"),F=k("./src/errors.ts"),D=k("./src/events.ts"),G=k("./src/utils/logger.ts"),j=250,M=2,I=.1,g=.05,p=function(){function f(a,c,o,s){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=a,this.media=c,this.fragmentTracker=o,this.hls=s}var h=f.prototype;return h.destroy=function(){this.hls=this.fragmentTracker=this.media=null},h.poll=function(c){var o=this.config,s=this.media,l=this.stalled,d=s.currentTime,O=s.seeking,w=this.seeking&&!O,x=!this.seeking&&O;if(this.seeking=O,d!==c){if(this.moved=!0,l!==null){if(this.stallReported){var R=self.performance.now()-l;G.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(R)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((x||w)&&(this.stalled=null),s.paused||s.ended||s.playbackRate===0||!V.BufferHelper.getBuffered(s).length)return;var A=V.BufferHelper.bufferInfo(s,d,0),T=A.len>0,E=A.nextStart||0;if(!T&&!E)return;if(O){var y=A.len>M,u=!E||E-d>M&&!this.fragmentTracker.getPartialFragment(d);if(y||u)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var _,m=Math.max(E,A.start||0)-d,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=b==null||((_=b.details)===null||_===void 0)?void 0:_.live,N=P?b.details.targetduration*2:M;if(m>0&&m<=N){this._trySkipBufferHole(null);return}}var K=self.performance.now();if(l===null){this.stalled=K;return}var X=K-l;!O&&X>=j&&this._reportStall(A.len);var B=V.BufferHelper.bufferInfo(s,d,o.maxBufferHole);this._tryFixBufferStall(B,X)},h._tryFixBufferStall=function(c,o){var s=this.config,l=this.fragmentTracker,d=this.media,O=d.currentTime,w=l.getPartialFragment(O);if(w){var x=this._trySkipBufferHole(w);if(x)return}c.len>s.maxBufferHole&&o>s.highBufferWatchdogPeriod*1e3&&(G.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},h._reportStall=function(c){var o=this.hls,s=this.media,l=this.stallReported;l||(this.stallReported=!0,G.logger.warn("Playback stalling at @"+s.currentTime+" due to low buffer (buffer="+c+")"),o.trigger(D.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:c}))},h._trySkipBufferHole=function(c){for(var o=this.config,s=this.hls,l=this.media,d=l.currentTime,O=0,w=V.BufferHelper.getBuffered(l),x=0;x<w.length;x++){var R=w.start(x);if(d+o.maxBufferHole>=O&&d<R){var A=Math.max(R+g,l.currentTime+I);return G.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+A),this.moved=!0,this.stalled=null,l.currentTime=A,c&&s.trigger(D.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+A,frag:c}),A}O=w.end(x)}return 0},h._tryNudgeBuffer=function(){var c=this.config,o=this.hls,s=this.media,l=s.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<c.nudgeMaxRetry){var O=l+d*c.nudgeOffset;G.logger.warn("Nudging 'currentTime' from "+l+" to "+O),s.currentTime=O,o.trigger(D.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else G.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+c.nudgeMaxRetry+" nudges"),o.trigger(D.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},f}()},"./src/controller/id3-track-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts"),F=k("./src/utils/texttrack-utils.ts"),D=k("./src/demux/id3.ts"),G=.25,j=function(){function M(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var I=M.prototype;return I.destroy=function(){this._unregisterListeners()},I._registerListeners=function(){var p=this.hls;p.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),p.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},I._unregisterListeners=function(){var p=this.hls;p.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),p.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},I.onMediaAttached=function(p,f){this.media=f.media},I.onMediaDetaching=function(){if(!this.id3Track)return;Object(F.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},I.getID3Track=function(p){if(!this.media)return;for(var f=0;f<p.length;f++){var h=p[f];if(h.kind==="metadata"&&h.label==="id3")return Object(F.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")},I.onFragParsingMetadata=function(p,f){if(!this.media)return;var h=f.frag,a=f.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var c=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,o=0;o<a.length;o++){var s=D.getID3Frames(a[o].data);if(s){var l=a[o].pts,d=o<a.length-1?a[o+1].pts:h.end,O=d-l;O<=0&&(d=l+G);for(var w=0;w<s.length;w++){var x=s[w];if(!D.isTimeStampFrame(x)){var R=new c(l,d,"");R.value=x,this.id3Track.addCue(R)}}}}},I.onBufferFlushing=function(p,f){var h=f.startOffset,a=f.endOffset,c=f.type;if(!c||c==="audio"){var o=this.id3Track;o&&Object(F.removeCuesInRange)(o,h,a)}},M}();Z.default=j},"./src/controller/latency-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return M});var V=k("./src/errors.ts"),F=k("./src/events.ts"),D=k("./src/utils/logger.ts");function G(I,g){for(var p=0;p<g.length;p++){var f=g[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(I,f.key,f)}}function j(I,g,p){return g&&G(I.prototype,g),p&&G(I,p),I}var M=function(){function I(p){var f=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 f.timeupdate()},this.hls=p,this.config=p.config,this.registerListeners()}var g=I.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(F.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(F.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(F.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(F.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(F.Events.ERROR,this.onError)},g.onMediaAttached=function(f,h){this.media=h.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(f,h){var a=h.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(f,h){if(h.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},g.timeupdate=function(){var f=this.media,h=this.levelDetails;if(!f||!h)return;this.currentTime=f.currentTime;var a=this.computeLatency();if(a===null)return;this._latency=a;var c=this.config,o=c.lowLatencyMode,s=c.maxLiveSyncPlaybackRate;if(!o||s===1)return;var l=this.targetLatency;if(l===null)return;var d=a-l,O=Math.min(this.maxLatency,l+h.targetduration),w=d<O;if(h.live&&w&&d>.05&&this.forwardBufferLength>1){var x=Math.min(2,Math.max(1,s)),R=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;f.playbackRate=Math.min(x,Math.max(1,R))}else f.playbackRate!==1&&f.playbackRate!==0&&(f.playbackRate=1)},g.estimateLiveEdge=function(){var f=this.levelDetails;return f===null?null:f.edge+f.age},g.computeLatency=function(){var f=this.estimateLiveEdge();return f===null?null:f-this.currentTime},j(I,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var f=this.config,h=this.levelDetails;return f.liveMaxLatencyDuration!==void 0?f.liveMaxLatencyDuration:h?f.liveMaxLatencyDurationCount*h.targetduration:0}},{key:"targetLatency",get:function(){var f=this.levelDetails;if(f===null)return null;var h=f.holdBack,a=f.partHoldBack,c=f.targetduration,o=this.config,s=o.liveSyncDuration,l=o.liveSyncDurationCount,d=o.lowLatencyMode,O=this.hls.userConfig,w=d&&a||h;(O.liveSyncDuration||O.liveSyncDurationCount||w===0)&&(w=s!==void 0?s:l*c);var x=c,R=1;return w+Math.min(this.stallCount*R,x)}},{key:"liveSyncPosition",get:function(){var f=this.estimateLiveEdge(),h=this.targetLatency,a=this.levelDetails;if(f===null||h===null||a===null)return null;var c=a.edge,o=f-h-this.edgeStalled,s=c-a.totalduration,l=c-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(s,o),l)}},{key:"drift",get:function(){var f=this.levelDetails;return f===null?1:f.drift}},{key:"edgeStalled",get:function(){var f=this.levelDetails;if(f===null)return 0;var h=(this.config.lowLatencyMode&&f.partTarget||f.targetduration)*3;return Math.max(f.age-h,0)}},{key:"forwardBufferLength",get:function(){var f=this.media,h=this.levelDetails;if(!f||!h)return 0;var a=f.buffered.length;return a?f.buffered.end(a-1):h.edge-this.currentTime}}]),I}()},"./src/controller/level-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return o});var V=k("./src/types/level.ts"),F=k("./src/events.ts"),D=k("./src/errors.ts"),G=k("./src/utils/codecs.ts"),j=k("./src/controller/level-helper.ts"),M=k("./src/controller/base-playlist-controller.ts"),I=k("./src/types/loader.ts");function g(){return g=Object.assign||function(s){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var O in d)Object.prototype.hasOwnProperty.call(d,O)&&(s[O]=d[O])}return s},g.apply(this,arguments)}function p(s,l){for(var d=0;d<l.length;d++){var O=l[d];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(s,O.key,O)}}function f(s,l,d){return l&&p(s.prototype,l),d&&p(s,d),s}function h(s,l){s.prototype=Object.create(l.prototype),s.prototype.constructor=s,a(s,l)}function a(s,l){return a=Object.setPrototypeOf||function(O,w){return O.__proto__=w,O},a(s,l)}var c=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),o=function(s){h(l,s);function l(O){var w;return w=s.call(this,O,"[level-controller]")||this,w._levels=[],w._firstLevel=-1,w._startLevel=void 0,w.currentLevelIndex=-1,w.manualLevelIndex=-1,w.onParsedComplete=void 0,w._registerListeners(),w}var d=l.prototype;return d._registerListeners=function(){var w=this.hls;w.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),w.on(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),w.on(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),w.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),w.on(F.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var w=this.hls;w.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),w.off(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),w.off(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),w.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),w.off(F.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,s.prototype.destroy.call(this)},d.startLoad=function(){var w=this._levels;w.forEach(function(x){x.loadError=0}),s.prototype.startLoad.call(this)},d.onManifestLoaded=function(w,x){var R=[],A=[],T=[],E,y={},u,_=!1,m=!1,b=!1;if(x.levels.forEach(function(X){var B=X.attrs;_=_||!!(X.width&&X.height),m=m||!!X.videoCodec,b=b||!!X.audioCodec,c&&X.audioCodec&&X.audioCodec.indexOf("mp4a.40.34")!==-1&&(X.audioCodec=void 0);var S=X.bitrate+"-"+X.attrs.RESOLUTION+"-"+X.attrs.CODECS;u=y[S],u?u.url.push(X.url):(u=new V.Level(X),y[S]=u,R.push(u)),B&&(B.AUDIO&&Object(j.addGroupId)(u,"audio",B.AUDIO),B.SUBTITLES&&Object(j.addGroupId)(u,"text",B.SUBTITLES))}),(_||m)&&b&&(R=R.filter(function(X){var B=X.videoCodec,S=X.width,Y=X.height;return!!B||!!(S&&Y)})),R=R.filter(function(X){var B=X.audioCodec,S=X.videoCodec;return(!B||Object(G.isCodecSupportedInMp4)(B,"audio"))&&(!S||Object(G.isCodecSupportedInMp4)(S,"video"))}),x.audioTracks&&(A=x.audioTracks.filter(function(X){return!X.audioCodec||Object(G.isCodecSupportedInMp4)(X.audioCodec,"audio")}),Object(j.assignTrackIdsByGroup)(A)),x.subtitles&&(T=x.subtitles,Object(j.assignTrackIdsByGroup)(T)),R.length>0){E=R[0].bitrate,R.sort(function(X,B){return X.bitrate-B.bitrate}),this._levels=R;for(var P=0;P<R.length;P++)if(R[P].bitrate===E){this._firstLevel=P,this.log("manifest loaded, "+R.length+" level(s) found, first bitrate: "+E);break}var N=b&&!m,K={levels:R,audioTracks:A,subtitleTracks:T,firstLevel:this._firstLevel,stats:x.stats,audio:b,video:m,altAudio:!N&&A.some(function(X){return!!X.url})};this.hls.trigger(F.Events.MANIFEST_PARSED,K),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(F.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:x.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(w,x){if(s.prototype.onError.call(this,w,x),x.fatal)return;var R=x.context,A=this._levels[this.currentLevelIndex];if(R&&(R.type===I.PlaylistContextType.AUDIO_TRACK&&A.audioGroupIds&&R.groupId===A.audioGroupIds[A.urlId]||R.type===I.PlaylistContextType.SUBTITLE_TRACK&&A.textGroupIds&&R.groupId===A.textGroupIds[A.urlId])){this.redundantFailover(this.currentLevelIndex);return}var T=!1,E=!0,y;switch(x.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(x.frag){var u=this._levels[x.frag.level];u?(u.fragmentError++,u.fragmentError>this.hls.config.fragLoadingMaxRetry&&(y=x.frag.level)):y=x.frag.level}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:R&&(R.deliveryDirectives&&(E=!1),y=R.level),T=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:y=x.level,T=!0;break}y!==void 0&&this.recoverLevel(x,y,T,E)},d.recoverLevel=function(w,x,R,A){var T=w.details,E=this._levels[x];if(E.loadError++,R){var y=this.retryLoadingOrFail(w);if(y)w.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(A){var u=E.url.length;if(u>1&&E.loadError<u)w.levelRetry=!0,this.redundantFailover(x);else if(this.manualLevelIndex===-1){var _=x===0?this._levels.length-1:x-1;this.currentLevelIndex!==_&&this._levels[_].loadError===0&&(this.warn(T+": switch to "+_),w.levelRetry=!0,this.hls.nextAutoLevel=_)}}},d.redundantFailover=function(w){var x=this._levels[w],R=x.url.length;if(R>1){var A=(x.urlId+1)%R;this.warn("Switching to redundant URL-id "+A),this._levels.forEach(function(T){T.urlId=A}),this.level=w}},d.onFragLoaded=function(w,x){var R=x.frag;if(R!==void 0&&R.type===I.PlaylistLevelType.MAIN){var A=this._levels[R.level];A!==void 0&&(A.fragmentError=0,A.loadError=0)}},d.onLevelLoaded=function(w,x){var R,A=x.level,T=x.details,E=this._levels[A];if(!E){var y;this.warn("Invalid level index "+A),(y=x.deliveryDirectives)!==null&&y!==void 0&&y.skip&&(T.deltaUpdateFailed=!0);return}A===this.currentLevelIndex?(E.fragmentError===0&&(E.loadError=0,this.retryCount=0),this.playlistLoaded(A,x,E.details)):(R=x.deliveryDirectives)!==null&&R!==void 0&&R.skip&&(T.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(w,x){var R=this.hls.levels[this.currentLevelIndex];if(!R)return;if(R.audioGroupIds){for(var A=-1,T=this.hls.audioTracks[x.id].groupId,E=0;E<R.audioGroupIds.length;E++)if(R.audioGroupIds[E]===T){A=E;break}A!==R.urlId&&(R.urlId=A,this.startLoad())}},d.loadPlaylist=function(w){var x=this.currentLevelIndex,R=this._levels[x];if(this.canLoad&&R&&R.url.length>0){var A=R.urlId,T=R.url[A];if(w)try{T=w.addDirectives(T)}catch(E){this.warn("Could not construct new URL with HLS Delivery Directives: "+E)}this.log("Attempt loading level index "+x+(w?" at sn "+w.msn+" part "+w.part:"")+" with URL-id "+A+" "+T),this.clearTimer(),this.hls.trigger(F.Events.LEVEL_LOADING,{url:T,level:x,id:A,deliveryDirectives:w||null})}},d.removeLevel=function(w,x){var R=function(E,y){return y!==x},A=this._levels.filter(function(T,E){return E!==w?!0:T.url.length>1&&x!==void 0?(T.url=T.url.filter(R),T.audioGroupIds&&(T.audioGroupIds=T.audioGroupIds.filter(R)),T.textGroupIds&&(T.textGroupIds=T.textGroupIds.filter(R)),T.urlId=0,!0):!1}).map(function(T,E){var y=T.details;return y!=null&&y.fragments&&y.fragments.forEach(function(u){u.level=E}),T});this._levels=A,this.hls.trigger(F.Events.LEVELS_UPDATED,{levels:A})},f(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(w){var x,R=this._levels;if(R.length===0)return;if(this.currentLevelIndex===w&&(x=R[w])!==null&&x!==void 0&&x.details)return;if(w<0||w>=R.length){var A=w<0;if(this.hls.trigger(F.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:w,fatal:A,reason:"invalid level idx"}),A)return;w=Math.min(w,R.length-1)}this.clearTimer();var T=this.currentLevelIndex,E=R[T],y=R[w];this.log("switching to level "+w+" from "+T),this.currentLevelIndex=w;var u=g({},y,{level:w,maxBitrate:y.maxBitrate,uri:y.uri,urlId:y.urlId});delete u._urlId,this.hls.trigger(F.Events.LEVEL_SWITCHING,u);var _=y.details;if(!_||_.live){var m=this.switchParams(y.uri,E==null?void 0:E.details);this.loadPlaylist(m)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(w){this.manualLevelIndex=w,this._startLevel===void 0&&(this._startLevel=w),w!==-1&&(this.level=w)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(w){this._firstLevel=w}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var w=this.hls.config.startLevel;return w!==void 0?w:this._firstLevel}else return this._startLevel},set:function(w){this._startLevel=w}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(w){this.level=w,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=w)}}]),l}(M.default)},"./src/controller/level-helper.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"addGroupId",function(){return D}),k.d(Z,"assignTrackIdsByGroup",function(){return G}),k.d(Z,"updatePTS",function(){return j}),k.d(Z,"updateFragPTSDTS",function(){return I}),k.d(Z,"mergeDetails",function(){return g}),k.d(Z,"mapPartIntersection",function(){return p}),k.d(Z,"mapFragmentIntersection",function(){return f}),k.d(Z,"adjustSliding",function(){return h}),k.d(Z,"addSliding",function(){return a}),k.d(Z,"computeReloadInterval",function(){return c}),k.d(Z,"getFragmentWithSN",function(){return o}),k.d(Z,"getPartWith",function(){return s});var V=k("./src/polyfills/number.ts"),F=k("./src/utils/logger.ts");function D(l,d,O){switch(d){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(O);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(O);break}}function G(l){var d={};l.forEach(function(O){var w=O.groupId||"";O.id=d[w]=d[w]||0,d[w]++})}function j(l,d,O){var w=l[d],x=l[O];M(w,x)}function M(l,d){var O=d.startPTS;if(Object(V.isFiniteNumber)(O)){var w=0,x;d.sn>l.sn?(w=O-l.start,x=l):(w=l.start-O,x=d),x.duration!==w&&(x.duration=w)}else if(d.sn>l.sn){var R=l.cc===d.cc;R&&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 I(l,d,O,w,x,R){var A=w-O;A<=0&&(F.logger.warn("Fragment should have a positive duration",d),w=O+d.duration,R=x+d.duration);var T=O,E=w,y=d.startPTS,u=d.endPTS;if(Object(V.isFiniteNumber)(y)){var _=Math.abs(y-O);Object(V.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(_,d.deltaPTS):d.deltaPTS=_,T=Math.max(O,y),O=Math.min(O,y),x=Math.min(x,d.startDTS),E=Math.min(w,u),w=Math.max(w,u),R=Math.max(R,d.endDTS)}d.duration=w-O;var m=O-d.start;d.appendedPTS=w,d.start=d.startPTS=O,d.maxStartPTS=T,d.startDTS=x,d.endPTS=w,d.minEndPTS=E,d.endDTS=R;var b=d.sn;if(!l||b<l.startSN||b>l.endSN)return 0;var P,N=b-l.startSN,K=l.fragments;for(K[N]=d,P=N;P>0;P--)M(K[P],K[P-1]);for(P=N;P<K.length-1;P++)M(K[P],K[P+1]);return l.fragmentHint&&M(K[K.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,m}function g(l,d){for(var O=null,w=l.fragments,x=w.length-1;x>=0;x--){var R=w[x].initSegment;if(R){O=R;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var A=0,T;if(f(l,d,function(P,N){P.relurl&&(A=P.cc-N.cc),Object(V.isFiniteNumber)(P.startPTS)&&Object(V.isFiniteNumber)(P.endPTS)&&(N.start=N.startPTS=P.startPTS,N.startDTS=P.startDTS,N.appendedPTS=P.appendedPTS,N.maxStartPTS=P.maxStartPTS,N.endPTS=P.endPTS,N.endDTS=P.endDTS,N.minEndPTS=P.minEndPTS,N.duration=P.endPTS-P.startPTS,N.duration&&(T=N),d.PTSKnown=d.alignedSliding=!0),N.elementaryStreams=P.elementaryStreams,N.loader=P.loader,N.stats=P.stats,N.urlId=P.urlId,P.initSegment&&(N.initSegment=P.initSegment,O=P.initSegment)}),O){var E=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;E.forEach(function(P){var N;(!P.initSegment||P.initSegment.relurl===((N=O)===null||N===void 0?void 0:N.relurl))&&(P.initSegment=O)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(P){return!P}),d.deltaUpdateFailed)){F.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var y=d.skippedSegments;y--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var u=d.fragments;if(A){F.logger.warn("discontinuity sliding from playlist, take drift into account");for(var _=0;_<u.length;_++)u[_].cc+=A}d.skippedSegments&&(d.startCC=d.fragments[0].cc),p(l.partList,d.partList,function(P,N){N.elementaryStreams=P.elementaryStreams,N.stats=P.stats}),T?I(d,T,T.startPTS,T.endPTS,T.startDTS,T.endDTS):h(l,d),u.length&&(d.totalduration=d.edge-u[0].start),d.driftStartTime=l.driftStartTime,d.driftStart=l.driftStart;var m=d.advancedDateTime;if(d.advanced&&m){var b=d.edge;d.driftStart||(d.driftStartTime=m,d.driftStart=b),d.driftEndTime=m,d.driftEnd=b}else d.driftEndTime=l.driftEndTime,d.driftEnd=l.driftEnd,d.advancedDateTime=l.advancedDateTime}function p(l,d,O){if(l&&d)for(var w=0,x=0,R=l.length;x<=R;x++){var A=l[x],T=d[x+w];A&&T&&A.index===T.index&&A.fragment.sn===T.fragment.sn?O(A,T):w--}}function f(l,d,O){for(var w=d.skippedSegments,x=Math.max(l.startSN,d.startSN)-d.startSN,R=(l.fragmentHint?1:0)+(w?d.endSN:Math.min(l.endSN,d.endSN))-d.startSN,A=d.startSN-l.startSN,T=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,E=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,y=x;y<=R;y++){var u=E[A+y],_=T[y];w&&!_&&y<w&&(_=d.fragments[y]=u),u&&_&&O(u,_)}}function h(l,d){var O=d.startSN+d.skippedSegments-l.startSN,w=l.fragments;if(O<0||O>=w.length)return;a(d,w[O].start)}function a(l,d){if(d){for(var O=l.fragments,w=l.skippedSegments;w<O.length;w++)O[w].start+=d;l.fragmentHint&&(l.fragmentHint.start+=d)}}function c(l,d){var O=1e3*l.levelTargetDuration,w=O/2,x=l.age,R=x>0&&x<O*3,A=d.loading.end-d.loading.start,T,E=l.availabilityDelay;if(l.updated===!1)if(R){var y=333*l.misses;T=Math.max(Math.min(w,A*2),y),l.availabilityDelay=(l.availabilityDelay||0)+T}else T=w;else R?(E=Math.min(E||O/2,x),l.availabilityDelay=E,T=E+O-x):T=O-A;return Math.round(T)}function o(l,d,O){if(!l||!l.details)return null;var w=l.details,x=w.fragments[d-w.startSN];return x||(x=w.fragmentHint,x&&x.sn===d?x:d<w.startSN&&O&&O.sn===d?O:null)}function s(l,d,O){if(!l||!l.details)return null;var w=l.details.partList;if(w)for(var x=w.length;x--;){var R=w[x];if(R.index===O&&R.fragment.sn===d)return R}return null}},"./src/controller/stream-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return w});var V=k("./src/polyfills/number.ts"),F=k("./src/controller/base-stream-controller.ts"),D=k("./src/is-supported.ts"),G=k("./src/events.ts"),j=k("./src/utils/buffer-helper.ts"),M=k("./src/controller/fragment-tracker.ts"),I=k("./src/types/loader.ts"),g=k("./src/loader/fragment.ts"),p=k("./src/demux/transmuxer-interface.ts"),f=k("./src/types/transmuxer.ts"),h=k("./src/controller/gap-controller.ts"),a=k("./src/errors.ts"),c=k("./src/utils/logger.ts");function o(x,R){for(var A=0;A<R.length;A++){var T=R[A];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(x,T.key,T)}}function s(x,R,A){return R&&o(x.prototype,R),A&&o(x,A),x}function l(x,R){x.prototype=Object.create(R.prototype),x.prototype.constructor=x,d(x,R)}function d(x,R){return d=Object.setPrototypeOf||function(T,E){return T.__proto__=E,T},d(x,R)}var O=100,w=function(x){l(R,x);function R(T,E){var y;return y=x.call(this,T,E,"[stream-controller]")||this,y.audioCodecSwap=!1,y.gapController=null,y.level=-1,y._forceStartLoad=!1,y.altAudio=!1,y.audioOnly=!1,y.fragPlaying=null,y.onvplaying=null,y.onvseeked=null,y.fragLastKbps=0,y.stalled=!1,y.couldBacktrack=!1,y.audioCodecSwitch=!1,y.videoBuffer=null,y._registerListeners(),y}var A=R.prototype;return A._registerListeners=function(){var E=this.hls;E.on(G.Events.MEDIA_ATTACHED,this.onMediaAttached,this),E.on(G.Events.MEDIA_DETACHING,this.onMediaDetaching,this),E.on(G.Events.MANIFEST_LOADING,this.onManifestLoading,this),E.on(G.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(G.Events.LEVEL_LOADING,this.onLevelLoading,this),E.on(G.Events.LEVEL_LOADED,this.onLevelLoaded,this),E.on(G.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),E.on(G.Events.ERROR,this.onError,this),E.on(G.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),E.on(G.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),E.on(G.Events.BUFFER_CREATED,this.onBufferCreated,this),E.on(G.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),E.on(G.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),E.on(G.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A._unregisterListeners=function(){var E=this.hls;E.off(G.Events.MEDIA_ATTACHED,this.onMediaAttached,this),E.off(G.Events.MEDIA_DETACHING,this.onMediaDetaching,this),E.off(G.Events.MANIFEST_LOADING,this.onManifestLoading,this),E.off(G.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(G.Events.LEVEL_LOADED,this.onLevelLoaded,this),E.off(G.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),E.off(G.Events.ERROR,this.onError,this),E.off(G.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),E.off(G.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),E.off(G.Events.BUFFER_CREATED,this.onBufferCreated,this),E.off(G.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),E.off(G.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),E.off(G.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},A.startLoad=function(E){if(this.levels){var y=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(O),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var _=u.startLevel;_===-1&&(u.config.testBandwidth?(_=0,this.bitrateTest=!0):_=u.nextAutoLevel),this.level=u.nextLoadLevel=_,this.loadedmetadata=!1}y>0&&E===-1&&(this.log("Override startPosition with lastCurrentTime @"+y.toFixed(3)),E=y),this.state=F.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=E,this.tick()}else this._forceStartLoad=!0,this.state=F.State.STOPPED},A.stopLoad=function(){this._forceStartLoad=!1,x.prototype.stopLoad.call(this)},A.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_LEVEL:{var E,y=this.levels,u=this.level,_=y==null||((E=y[u])===null||E===void 0)?void 0:E.details;if(_&&(!_.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(_))break;this.state=F.State.IDLE;break}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var m,b=self.performance.now(),P=this.retryDate;(!P||b>=P||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=F.State.IDLE)}break;default:break}this.onTickEnd()},A.onTickEnd=function(){x.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},A.doTickIdle=function(){var E,y,u=this.hls,_=this.levelLastLoaded,m=this.levels,b=this.media,P=u.config,N=u.nextLoadLevel;if(_===null||!b&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!m||!m[N])return;var K=m[N];this.level=u.nextLoadLevel=N;var X=K.details;if(!X||this.state===F.State.WAITING_LEVEL||X.live&&this.levelLastLoaded!==N){this.state=F.State.WAITING_LEVEL;return}var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:b,I.PlaylistLevelType.MAIN);if(B===null)return;var S=B.len,Y=this.getMaxBufferLength(K.maxBitrate);if(S>=Y)return;if(this._streamEnded(B,X)){var te={};this.altAudio&&(te.type="video"),this.hls.trigger(G.Events.BUFFER_EOS,te),this.state=F.State.ENDED;return}var re=B.end,ce=this.getNextFragment(re,X);if(this.couldBacktrack&&!this.fragPrevious&&ce&&ce.sn!=="initSegment"){var Te=ce.sn-X.startSN;Te>1&&(ce=X.fragments[Te-1],this.fragmentTracker.removeFragment(ce))}if(ce&&this.fragmentTracker.getState(ce)===M.FragmentState.OK&&this.nextLoadPosition>re){var ye=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(b,ye,I.PlaylistLevelType.MAIN),ce=this.getNextFragment(this.nextLoadPosition,X)}if(!ce)return;ce.initSegment&&!ce.initSegment.data&&!this.bitrateTest&&(ce=ce.initSegment),((E=ce.decryptdata)===null||E===void 0?void 0:E.keyFormat)==="identity"&&!((y=ce.decryptdata)!==null&&y!==void 0&&y.key)?this.loadKey(ce,X):this.loadFragment(ce,X,re)},A.loadFragment=function(E,y,u){var _,m=this.fragmentTracker.getState(E);if(this.fragCurrent=E,m===M.FragmentState.BACKTRACKED){var b=this.fragmentTracker.getBacktrackData(E);if(b){this._handleFragmentLoadProgress(b),this._handleFragmentLoadComplete(b);return}else m=M.FragmentState.NOT_LOADED}m===M.FragmentState.NOT_LOADED||m===M.FragmentState.PARTIAL?E.sn==="initSegment"?this._loadInitSegment(E):this.bitrateTest?(E.bitrateTest=!0,this.log("Fragment "+E.sn+" of level "+E.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(E)):(this.startFragRequested=!0,x.prototype.loadFragment.call(this,E,y,u)):m===M.FragmentState.APPENDING?this.reduceMaxBufferLength(E.duration)&&this.fragmentTracker.removeFragment(E):((_=this.media)===null||_===void 0?void 0:_.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},A.getAppendedFrag=function(E){var y=this.fragmentTracker.getAppendedFrag(E,I.PlaylistLevelType.MAIN);return y&&"fragment"in y?y.fragment:y},A.getBufferedFrag=function(E){return this.fragmentTracker.getBufferedFrag(E,I.PlaylistLevelType.MAIN)},A.followingBufferedFrag=function(E){return E?this.getBufferedFrag(E.end+.5):null},A.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},A.nextLevelSwitch=function(){var E=this.levels,y=this.media;if(y!=null&&y.readyState){var u,_=this.getAppendedFrag(y.currentTime);if(_&&_.start>1&&this.flushMainBuffer(0,_.start-1),!y.paused&&E){var m=this.hls.nextLoadLevel,b=E[m],P=this.fragLastKbps;P&&this.fragCurrent?u=this.fragCurrent.duration*b.maxBitrate/(1e3*P)+1:u=0}else u=0;var N=this.getBufferedFrag(y.currentTime+u);if(N){var K=this.followingBufferedFrag(N);if(K){this.abortCurrentFrag();var X=K.maxStartPTS?K.maxStartPTS:K.start,B=K.duration,S=Math.max(N.end,X+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(S,Number.POSITIVE_INFINITY)}}}},A.abortCurrentFrag=function(){var E=this.fragCurrent;this.fragCurrent=null,E!=null&&E.loader&&E.loader.abort(),this.state===F.State.KEY_LOADING&&(this.state=F.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},A.flushMainBuffer=function(E,y){x.prototype.flushMainBuffer.call(this,E,y,this.altAudio?"video":null)},A.onMediaAttached=function(E,y){x.prototype.onMediaAttached.call(this,E,y);var u=y.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new h.default(this.config,u,this.fragmentTracker,this.hls)},A.onMediaDetaching=function(){var E=this.media;E&&(E.removeEventListener("playing",this.onvplaying),E.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),x.prototype.onMediaDetaching.call(this)},A.onMediaPlaying=function(){this.tick()},A.onMediaSeeked=function(){var E=this.media,y=E?E.currentTime:null;Object(V.isFiniteNumber)(y)&&this.log("Media seeked to "+y.toFixed(3)),this.tick()},A.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(G.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},A.onManifestParsed=function(E,y){var u=!1,_=!1,m;y.levels.forEach(function(b){m=b.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(u=!0),m.indexOf("mp4a.40.5")!==-1&&(_=!0))}),this.audioCodecSwitch=u&&_&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=y.levels,this.startFragRequested=!1},A.onLevelLoading=function(E,y){var u=this.levels;if(!u||this.state!==F.State.IDLE)return;var _=u[y.level];(!_.details||_.details.live&&this.levelLastLoaded!==y.level||this.waitForCdnTuneIn(_.details))&&(this.state=F.State.WAITING_LEVEL)},A.onLevelLoaded=function(E,y){var u,_=this.levels,m=y.level,b=y.details,P=b.totalduration;if(!_){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+b.startSN+","+b.endSN+"], cc ["+b.startCC+", "+b.endCC+"] duration:"+P);var N=this.fragCurrent;N&&(this.state===F.State.FRAG_LOADING||this.state===F.State.FRAG_LOADING_WAITING_RETRY)&&(N.level!==y.level&&N.loader&&(this.state=F.State.IDLE,N.loader.abort()));var K=_[m],X=0;if(b.live||(u=K.details)!==null&&u!==void 0&&u.live){if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed)return;X=this.alignPlaylists(b,K.details)}if(K.details=b,this.levelLastLoaded=m,this.hls.trigger(G.Events.LEVEL_UPDATED,{details:b,level:m}),this.state===F.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(b))return;this.state=F.State.IDLE}this.startFragRequested?b.live&&this.synchronizeToLiveEdge(b):this.setStartPosition(b,X),this.tick()},A._handleFragmentLoadProgress=function(E){var y,u=E.frag,_=E.part,m=E.payload,b=this.levels;if(!b){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var P=b[u.level],N=P.details;if(!N){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var K=P.videoCodec,X=N.PTSKnown||!N.live,B=(y=u.initSegment)===null||y===void 0?void 0:y.data,S=this._getAudioCodec(P),Y=this.transmuxer=this.transmuxer||new p.default(this.hls,I.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),te=_?_.index:-1,re=te!==-1,ce=new f.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,m.byteLength,te,re),Te=this.initPTS[u.cc];Y.push(m,B,S,K,u,_,N.totalduration,X,ce,Te)},A.onAudioTrackSwitching=function(E,y){var u=this.altAudio,_=!!y.url,m=y.id;if(!_){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var b=this.fragCurrent;b!=null&&b.loader&&(this.log("Switching to main audio track, cancel main fragment load"),b.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;u&&P.trigger(G.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(G.Events.AUDIO_TRACK_SWITCHED,{id:m})}},A.onAudioTrackSwitched=function(E,y){var u=y.id,_=!!this.hls.audioTracks[u].url;if(_){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=_,this.tick()},A.onBufferCreated=function(E,y){var u=y.tracks,_,m,b=!1;for(var P in u){var N=u[P];if(N.id==="main"){if(m=P,_=N,P==="video"){var K=u[P];K&&(this.videoBuffer=K.buffer)}}else b=!0}b&&_?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=_.buffer):this.mediaBuffer=this.media},A.onFragBuffered=function(E,y){var u=y.frag,_=y.part;if(u&&u.type!==I.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(_?" p: "+_.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===F.State.PARSED&&(this.state=F.State.IDLE);return}var m=_?_.stats:u.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,_)},A.onError=function(E,y){switch(y.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(I.PlaylistLevelType.MAIN,y);break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==F.State.ERROR&&(y.fatal?(this.warn(""+y.details),this.state=F.State.ERROR):!y.levelRetry&&this.state===F.State.WAITING_LEVEL&&(this.state=F.State.IDLE));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if(y.parent==="main"&&(this.state===F.State.PARSING||this.state===F.State.PARSED)){var u=!0,_=this.getFwdBufferInfo(this.media,I.PlaylistLevelType.MAIN);_&&_.len>.5&&(u=!this.reduceMaxBufferLength(_.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},A.checkBuffer=function(){var E=this.media,y=this.gapController;if(!E||!y||!E.readyState)return;var u=j.BufferHelper.getBuffered(E);!this.loadedmetadata&&u.length?(this.loadedmetadata=!0,this.seekToStartPos()):y.poll(this.lastCurrentTime),this.lastCurrentTime=E.currentTime},A.onFragLoadEmergencyAborted=function(){this.state=F.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},A.onBufferFlushed=function(E,y){var u=y.type;if(u!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var _=(u===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(_,u,I.PlaylistLevelType.MAIN)}},A.onLevelsUpdated=function(E,y){this.levels=y.levels},A.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},A.seekToStartPos=function(){var E=this.media,y=E.currentTime,u=this.startPosition;if(u>=0&&y<u){if(E.seeking){c.logger.log("could not seek to "+u+", already seeking at "+y);return}var _=j.BufferHelper.getBuffered(E),m=_.length?_.start(0):0,b=m-u;b>0&&(b<this.config.maxBufferHole||b<this.config.maxFragLookUpTolerance)&&(c.logger.log("adjusting start position by "+b+" to match buffer start"),u+=b,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+y),E.currentTime=u}},A._getAudioCodec=function(E){var y=this.config.defaultAudioCodec||E.audioCodec;return this.audioCodecSwap&&y&&(this.log("Swapping audio codec"),y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5"),y},A._loadBitrateTestFrag=function(E){var y=this;this._doFragLoad(E).then(function(u){var _=y.hls;if(!u||_.nextLoadLevel||y.fragContextChanged(E))return;y.fragLoadError=0,y.state=F.State.IDLE,y.startFragRequested=!1,y.bitrateTest=!1;var m=E.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),_.trigger(G.Events.FRAG_LOADED,u)})},A._handleTransmuxComplete=function(E){var y,u="main",_=this.hls,m=E.remuxResult,b=E.chunkMeta,P=this.getCurrentContext(b);if(!P){this.warn("The loading context changed while buffering fragment "+b.sn+" of level "+b.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(b.level);return}var N=P.frag,K=P.part,X=P.level,B=m.video,S=m.text,Y=m.id3,te=m.initSegment,re=this.altAudio?void 0:m.audio;if(this.fragContextChanged(N))return;if(this.state=F.State.PARSING,te){te.tracks&&(this._bufferInitSegment(X,te.tracks,N,b),_.trigger(G.Events.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:u,tracks:te.tracks}));var ce=te.initPTS,Te=te.timescale;Object(V.isFiniteNumber)(ce)&&(this.initPTS[N.cc]=ce,_.trigger(G.Events.INIT_PTS_FOUND,{frag:N,id:u,initPTS:ce,timescale:Te}))}if(B&&m.independent!==!1){if(X.details){var ye=B.startPTS,be=B.endPTS,we=B.startDTS,xe=B.endDTS;if(K)K.elementaryStreams[B.type]={startPTS:ye,endPTS:be,startDTS:we,endDTS:xe};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var ve=this.getLoadPosition()+this.config.maxBufferHole;if(ve<ye){this.backtrack(N);return}N.setElementaryStreamInfo(B.type,N.start,be,N.start,xe,!0)}N.setElementaryStreamInfo(B.type,ye,be,we,xe),this.bufferFragmentData(B,N,K,b)}}else if(m.independent===!1){this.backtrack(N);return}if(re){var oe=re.startPTS,Re=re.endPTS,Ye=re.startDTS,Ue=re.endDTS;K&&(K.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:oe,endPTS:Re,startDTS:Ye,endDTS:Ue}),N.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,oe,Re,Ye,Ue),this.bufferFragmentData(re,N,K,b)}if(Y!=null&&(y=Y.samples)!==null&&y!==void 0&&y.length){var rt={frag:N,id:u,samples:Y.samples};_.trigger(G.Events.FRAG_PARSING_METADATA,rt)}if(S){var ot={frag:N,id:u,samples:S.samples};_.trigger(G.Events.FRAG_PARSING_USERDATA,ot)}},A._bufferInitSegment=function(E,y,u,_){var m=this;if(this.state!==F.State.PARSING)return;this.audioOnly=!!y.audio&&!y.video,this.altAudio&&!this.audioOnly&&delete y.audio;var b=y.audio,P=y.video,N=y.audiovideo;if(b){var K=E.audioCodec,X=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(K&&(K.indexOf("mp4a.40.5")!==-1?K="mp4a.40.2":K="mp4a.40.5"),b.metadata.channelCount!==1&&X.indexOf("firefox")===-1&&(K="mp4a.40.5")),X.indexOf("android")!==-1&&b.container!=="audio/mpeg"&&(K="mp4a.40.2",this.log("Android: force audio codec to "+K)),E.audioCodec&&E.audioCodec!==K&&this.log('Swapping manifest audio codec "'+E.audioCodec+'" for "'+K+'"'),b.levelCodec=K,b.id="main",this.log("Init audio buffer, container:"+b.container+", codecs[selected/level/parsed]=["+(K||"")+"/"+(E.audioCodec||"")+"/"+b.codec+"]")}P&&(P.levelCodec=E.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(E.videoCodec||"")+"/"+P.codec+"]")),N&&this.log("Init audiovideo buffer, container:"+N.container+", codecs[level/parsed]=["+(E.attrs.CODECS||"")+"/"+N.codec+"]"),this.hls.trigger(G.Events.BUFFER_CODECS,y),Object.keys(y).forEach(function(B){var S=y[B],Y=S.initSegment;Y!=null&&Y.byteLength&&m.hls.trigger(G.Events.BUFFER_APPENDING,{type:B,data:Y,frag:u,part:null,chunkMeta:_,parent:u.type})}),this.tick()},A.backtrack=function(E){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(E);var y=this.fragmentTracker.backtrack(E);this.fragPrevious=null,this.nextLoadPosition=E.start,y?this.resetFragmentLoading(E):this.state=F.State.BACKTRACKING},A.checkFragmentChanged=function(){var E=this.media,y=null;if(E&&E.readyState>1&&E.seeking===!1){var u=E.currentTime;if(j.BufferHelper.isBuffered(E,u)?y=this.getAppendedFrag(u):j.BufferHelper.isBuffered(E,u+.1)&&(y=this.getAppendedFrag(u+.1)),y){var _=this.fragPlaying,m=y.level;(!_||y.sn!==_.sn||_.level!==m||y.urlId!==_.urlId)&&(this.hls.trigger(G.Events.FRAG_CHANGED,{frag:y}),(!_||_.level!==m)&&this.hls.trigger(G.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=y)}}},s(R,[{key:"nextLevel",get:function(){var E=this.nextBufferedFrag;return E?E.level:-1}},{key:"currentLevel",get:function(){var E=this.media;if(E){var y=this.getAppendedFrag(E.currentTime);if(y)return y.level}return-1}},{key:"nextBufferedFrag",get:function(){var E=this.media;if(E){var y=this.getAppendedFrag(E.currentTime);return this.followingBufferedFrag(y)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),R}(F.default)},"./src/controller/subtitle-stream-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"SubtitleStreamController",function(){return l});var V=k("./src/events.ts"),F=k("./src/utils/logger.ts"),D=k("./src/utils/buffer-helper.ts"),G=k("./src/controller/fragment-finders.ts"),j=k("./src/utils/discontinuities.ts"),M=k("./src/controller/level-helper.ts"),I=k("./src/controller/fragment-tracker.ts"),g=k("./src/controller/base-stream-controller.ts"),p=k("./src/types/loader.ts"),f=k("./src/types/level.ts");function h(d,O){for(var w=0;w<O.length;w++){var x=O[w];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(d,x.key,x)}}function a(d,O,w){return O&&h(d.prototype,O),w&&h(d,w),d}function c(d,O){d.prototype=Object.create(O.prototype),d.prototype.constructor=d,o(d,O)}function o(d,O){return o=Object.setPrototypeOf||function(x,R){return x.__proto__=R,x},o(d,O)}var s=500,l=function(d){c(O,d);function O(x,R){var A;return A=d.call(this,x,R,"[subtitle-stream-controller]")||this,A.levels=[],A.currentTrackId=-1,A.tracksBuffered=[],A.mainDetails=null,A._registerListeners(),A}var w=O.prototype;return w.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},w._registerListeners=function(){var R=this.hls;R.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),R.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),R.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),R.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),R.on(V.Events.ERROR,this.onError,this),R.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),R.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),R.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),R.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),R.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w._unregisterListeners=function(){var R=this.hls;R.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),R.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),R.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),R.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),R.off(V.Events.ERROR,this.onError,this),R.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),R.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),R.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),R.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),R.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w.startLoad=function(){this.stopLoad(),this.state=g.State.IDLE,this.setInterval(s),this.tick()},w.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},w.onLevelLoaded=function(R,A){this.mainDetails=A.details},w.onSubtitleFragProcessed=function(R,A){var T=A.frag,E=A.success;if(this.fragPrevious=T,this.state=g.State.IDLE,!E)return;var y=this.tracksBuffered[this.currentTrackId];if(!y)return;for(var u,_=T.start,m=0;m<y.length;m++)if(_>=y[m].start&&_<=y[m].end){u=y[m];break}var b=T.start+T.duration;u?u.end=b:(u={start:_,end:b},y.push(u)),this.fragmentTracker.fragBuffered(T)},w.onBufferFlushing=function(R,A){var T=A.startOffset,E=A.endOffset;if(T===0&&E!==Number.POSITIVE_INFINITY){var y=this.currentTrackId,u=this.levels;if(!u.length||!u[y]||!u[y].details)return;var _=u[y].details,m=_.targetduration,b=E-m;if(b<=0)return;A.endOffsetSubtitles=Math.max(0,b),this.tracksBuffered.forEach(function(P){for(var N=0;N<P.length;){if(P[N].end<=b){P.shift();continue}else if(P[N].start<b)P[N].start=b;else break;N++}}),this.fragmentTracker.removeFragmentsInRange(T,b,p.PlaylistLevelType.SUBTITLE)}},w.onError=function(R,A){var T,E=A.frag;if(!E||E.type!==p.PlaylistLevelType.SUBTITLE)return;(T=this.fragCurrent)!==null&&T!==void 0&&T.loader&&this.fragCurrent.loader.abort(),this.state=g.State.IDLE},w.onSubtitleTracksUpdated=function(R,A){var T=this,E=A.subtitleTracks;this.tracksBuffered=[],this.levels=E.map(function(y){return new f.Level(y)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(y){T.tracksBuffered[y.id]=[]}),this.mediaBuffer=null},w.onSubtitleTrackSwitch=function(R,A){if(this.currentTrackId=A.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var T=this.levels[this.currentTrackId];T!=null&&T.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,T&&this.setInterval(s)},w.onSubtitleTrackLoaded=function(R,A){var T,E=A.details,y=A.id,u=this.currentTrackId,_=this.levels;if(!_.length)return;var m=_[u];if(y>=_.length||y!==u||!m)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,E.live||(T=m.details)!==null&&T!==void 0&&T.live){var b=this.mainDetails;if(E.deltaUpdateFailed||!b)return;var P=b.fragments[0];if(!m.details)E.hasProgramDateTime&&b.hasProgramDateTime?Object(j.alignMediaPlaylistByPDT)(E,b):P&&Object(M.addSliding)(E,P.start);else{var N=this.alignPlaylists(E,m.details);N===0&&P&&Object(M.addSliding)(E,P.start)}}if(m.details=E,this.levelLastLoaded=y,this.tick(),E.live&&!this.fragCurrent&&this.media&&this.state===g.State.IDLE){var K=Object(G.findFragmentByPTS)(null,E.fragments,this.media.currentTime,0);K||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}},w._handleFragmentLoadComplete=function(R){var A=R.frag,T=R.payload,E=A.decryptdata,y=this.hls;if(this.fragContextChanged(A))return;if(T&&T.byteLength>0&&E&&E.key&&E.iv&&E.method==="AES-128"){var u=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(T),E.key.buffer,E.iv.buffer).then(function(_){var m=performance.now();y.trigger(V.Events.FRAG_DECRYPTED,{frag:A,payload:_,stats:{tstart:u,tdecrypt:m}})})}},w.doTick=function(){if(!this.media){this.state=g.State.IDLE;return}if(this.state===g.State.IDLE){var R,A=this.currentTrackId,T=this.levels;if(!T.length||!T[A]||!T[A].details)return;var E=T[A].details,y=E.targetduration,u=this.config,_=this.media,m=D.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,_.currentTime-y,u.maxBufferHole),b=m.end,P=m.len,N=this.getMaxBufferLength()+y;if(P>N)return;console.assert(E,"Subtitle track details are defined on idle subtitle stream controller tick");var K=E.fragments,X=K.length,B=E.edge,S,Y=this.fragPrevious;if(b<B){var te=u.maxFragLookUpTolerance;Y&&E.hasProgramDateTime&&(S=Object(G.findFragmentByPDT)(K,Y.endProgramDateTime,te)),S||(S=Object(G.findFragmentByPTS)(Y,K,b,te),!S&&Y&&Y.start<K[0].start&&(S=K[0]))}else S=K[X-1];(R=S)!==null&&R!==void 0&&R.encrypted?(F.logger.log("Loading key for "+S.sn),this.state=g.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:S})):S&&this.fragmentTracker.getState(S)===I.FragmentState.NOT_LOADED&&this.loadFragment(S,E,b)}},w.loadFragment=function(R,A,T){this.fragCurrent=R,d.prototype.loadFragment.call(this,R,A,T)},a(O,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),O}(g.default)},"./src/controller/subtitle-track-controller.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/events.ts"),F=k("./src/utils/texttrack-utils.ts"),D=k("./src/controller/base-playlist-controller.ts"),G=k("./src/types/loader.ts");function j(h,a){for(var c=0;c<a.length;c++){var o=a[c];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(h,o.key,o)}}function M(h,a,c){return a&&j(h.prototype,a),c&&j(h,c),h}function I(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,g(h,a)}function g(h,a){return g=Object.setPrototypeOf||function(o,s){return o.__proto__=s,o},g(h,a)}var p=function(h){I(a,h);function a(o){var s;return s=h.call(this,o,"[subtitle-track-controller]")||this,s.media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s.subtitleDisplay=!0,s.registerListeners(),s}var c=a.prototype;return c.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,h.prototype.destroy.call(this)},c.registerListeners=function(){var s=this.hls;s.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),s.on(V.Events.ERROR,this.onError,this)},c.unregisterListeners=function(){var s=this.hls;s.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),s.off(V.Events.ERROR,this.onError,this)},c.onMediaAttached=function(s,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},c.pollTrackChange=function(s){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,s)},c.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var s=f(this.media.textTracks);s.forEach(function(l){Object(F.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},c.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},c.onManifestParsed=function(s,l){this.tracks=l.subtitleTracks},c.onSubtitleTrackLoaded=function(s,l){var d=l.id,O=l.details,w=this.trackId,x=this.tracksInGroup[w];if(!x){this.warn("Invalid subtitle track id "+d);return}var R=x.details;x.details=l.details,this.log("subtitle track "+d+" loaded ["+O.startSN+"-"+O.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,l,R))},c.onLevelLoading=function(s,l){this.switchLevel(l.level)},c.onLevelSwitching=function(s,l){this.switchLevel(l.level)},c.switchLevel=function(s){var l=this.hls.levels[s];if(!(l!=null&&l.textGroupIds))return;var d=l.textGroupIds[l.urlId];if(this.groupId!==d){var O=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,w=this.tracks.filter(function(A){return!d||A.groupId===d});this.tracksInGroup=w;var x=this.findTrackId(O==null?void 0:O.name)||this.findTrackId();this.groupId=d;var R={subtitleTracks:w};this.log("Updating subtitle tracks, "+w.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,R),x!==-1&&this.setSubtitleTrack(x,O)}},c.findTrackId=function(s){for(var l=this.tracksInGroup,d=0;d<l.length;d++){var O=l[d];if((!this.selectDefaultTrack||O.default)&&(!s||s===O.name))return O.id}return-1},c.onError=function(s,l){if(h.prototype.onError.call(this,s,l),l.fatal||!l.context)return;l.context.type===G.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},c.loadPlaylist=function(s){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var d=l.id,O=l.groupId,w=l.url;if(s)try{w=s.addDirectives(w)}catch(x){this.warn("Could not construct new URL with HLS Delivery Directives: "+x)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:w,id:d,groupId:O,deliveryDirectives:s||null})}},c.toggleTrackModes=function(s){var l=this,d=this.media,O=this.subtitleDisplay,w=this.trackId;if(!d)return;var x=f(d.textTracks),R=x.filter(function(E){return E.groupId===l.groupId});if(s===-1)[].slice.call(x).forEach(function(E){E.mode="disabled"});else{var A=R[w];A&&(A.mode="disabled")}var T=R[s];T&&(T.mode=O?"showing":"hidden")},c.setSubtitleTrack=function(s,l){var d,O=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=s;return}if(this.trackId!==s&&this.toggleTrackModes(s),this.trackId===s&&(s===-1||(d=O[s])!==null&&d!==void 0&&d.details)||s<-1||s>=O.length)return;this.clearTimer();var w=O[s];if(this.log("Switching to subtitle track "+s),this.trackId=s,w){var x=w.id,R=w.groupId,A=R===void 0?"":R,T=w.name,E=w.type,y=w.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:x,groupId:A,name:T,type:E,url:y});var u=this.switchParams(w.url,l==null?void 0:l.details);this.loadPlaylist(u)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:s})},c.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var s=-1,l=f(this.media.textTracks),d=0;d<l.length;d++)if(l[d].mode==="hidden")s=d;else if(l[d].mode==="showing"){s=d;break}this.subtitleTrack!==s&&(this.subtitleTrack=s)},M(a,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(s,l)}}]),a}(D.default);function f(h){for(var a=[],c=0;c<h.length;c++){var o=h[c];o.kind==="subtitles"&&o.label&&a.push(h[c])}return a}Z.default=p},"./src/controller/timeline-controller.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"TimelineController",function(){return f});var V=k("./src/polyfills/number.ts"),F=k("./src/events.ts"),D=k("./src/utils/cea-608-parser.ts"),G=k("./src/utils/output-filter.ts"),j=k("./src/utils/webvtt-parser.ts"),M=k("./src/utils/texttrack-utils.ts"),I=k("./src/utils/imsc1-ttml-parser.ts"),g=k("./src/types/loader.ts"),p=k("./src/utils/logger.ts"),f=function(){function o(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=c(),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 G.default(this,"textTrack1"),O=new G.default(this,"textTrack2"),w=new G.default(this,"textTrack3"),x=new G.default(this,"textTrack4");this.cea608Parser1=new D.default(1,d,O),this.cea608Parser2=new D.default(3,w,x)}l.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(F.Events.FRAG_LOADING,this.onFragLoading,this),l.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=o.prototype;return s.destroy=function(){var d=this.hls;d.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(F.Events.FRAG_LOADING,this.onFragLoading,this),d.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(d,O,w,x,R){for(var A=!1,T=R.length;T--;){var E=R[T],y=a(E[0],E[1],O,w);if(y>=0&&(E[0]=Math.min(E[0],O),E[1]=Math.max(E[1],w),A=!0,y/(w-O)>.5))return}if(A||R.push([O,w]),this.config.renderTextTracksNatively){var u=this.captionsTracks[d];this.Cues.newCue(u,O,w,x)}else{var _=this.Cues.newCue(null,O,w,x);this.hls.trigger(F.Events.CUES_PARSED,{type:"captions",cues:_,track:d})}},s.onInitPtsFound=function(d,O){var w=this,x=O.frag,R=O.id,A=O.initPTS,T=O.timescale,E=this.unparsedVttFrags;R==="main"&&(this.initPTS[x.cc]=A,this.timescale[x.cc]=T),E.length&&(this.unparsedVttFrags=[],E.forEach(function(y){w.onFragLoaded(F.Events.FRAG_LOADED,y)}))},s.getExistingTrack=function(d){var O=this.media;if(O)for(var w=0;w<O.textTracks.length;w++){var x=O.textTracks[w];if(x[d])return x}return null},s.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},s.createNativeTrack=function(d){if(this.captionsTracks[d])return;var O=this.captionsProperties,w=this.captionsTracks,x=this.media,R=O[d],A=R.label,T=R.languageCode,E=this.getExistingTrack(d);if(E)w[d]=E,Object(M.clearCurrentCues)(w[d]),Object(M.sendAddTrackEvent)(w[d],x);else{var y=this.createTextTrack("captions",A,T);y&&(y[d]=!0,w[d]=y)}},s.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var O=this.captionsProperties[d];if(!O)return;var w=O.label,x={_id:d,label:w,kind:"captions",default:O.media?!!O.media.default:!1,closedCaptions:O.media};this.nonNativeCaptionsTracks[d]=x,this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[x]})},s.createTextTrack=function(d,O,w){var x=this.media;return x?x.addTextTrack(d,O,w):void 0},s.onMediaAttaching=function(d,O){this.media=O.media,this._cleanTracks()},s.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(O){Object(M.clearCurrentCues)(d[O]),delete d[O]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=c(),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())},s._cleanTracks=function(){var d=this.media;if(!d)return;var O=d.textTracks;if(O)for(var w=0;w<O.length;w++)Object(M.clearCurrentCues)(O[w])},s.onSubtitleTracksUpdated=function(d,O){var w=this;this.textTracks=[];var x=O.subtitleTracks||[],R=x.some(function(y){return y.textCodec===I.IMSC1_CODEC});if(this.config.enableWebVTT||R&&this.config.enableIMSC1){var A=this.tracks&&x&&this.tracks.length===x.length;if(this.tracks=x||[],this.config.renderTextTracksNatively){var T=this.media?this.media.textTracks:[];this.tracks.forEach(function(y,u){var _;if(u<T.length){for(var m=null,b=0;b<T.length;b++)if(h(T[b],y)){m=T[b];break}m&&(_=m)}_?Object(M.clearCurrentCues)(_):(_=w.createTextTrack("subtitles",y.name,y.lang),_&&(_.mode="disabled")),_&&(_.groupId=y.groupId,w.textTracks.push(_))})}else if(!A&&this.tracks&&this.tracks.length){var E=this.tracks.map(function(y){return{label:y.name,kind:y.type.toLowerCase(),default:y.default,subtitleTrack:y}});this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:E})}}},s.onManifestLoaded=function(d,O){var w=this;this.config.enableCEA708Captions&&O.captions&&O.captions.forEach(function(x){var R=/(?:CC|SERVICE)([1-4])/.exec(x.instreamId);if(!R)return;var A="textTrack"+R[1],T=w.captionsProperties[A];if(!T)return;T.label=x.name,x.lang&&(T.languageCode=x.lang),T.media=x})},s.onFragLoading=function(d,O){var w=this.cea608Parser1,x=this.cea608Parser2,R=this.lastSn,A=this.lastPartIndex;if(!this.enabled||!(w&&x))return;if(O.frag.type===g.PlaylistLevelType.MAIN){var T,E,y=O.frag.sn,u=(T=O==null||((E=O.part)===null||E===void 0)?void 0:E.index)!=null?T:-1;y===R+1||y===R&&u===A+1||(w.reset(),x.reset()),this.lastSn=y,this.lastPartIndex=u}},s.onFragLoaded=function(d,O){var w=O.frag,x=O.payload,R=this.initPTS,A=this.unparsedVttFrags;if(w.type===g.PlaylistLevelType.SUBTITLE)if(x.byteLength){if(!Object(V.isFiniteNumber)(R[w.cc])){A.push(O),R.length&&this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:w,error:new Error("Missing initial subtitle PTS")});return}var T=w.decryptdata;if(T==null||T.key==null||T.method!=="AES-128"){var E=this.tracks[w.level],y=this.vttCCs;y[w.cc]||(y[w.cc]={start:w.start,prevCC:this.prevCC,new:!0},this.prevCC=w.cc),E&&E.textCodec===I.IMSC1_CODEC?this._parseIMSC1(w,x):this._parseVTTs(w,x,y)}}else this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:w,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(d,O){var w=this,x=this.hls;Object(I.parseIMSC1)(O,this.initPTS[d.cc],this.timescale[d.cc],function(R){w._appendCues(R,d.level),x.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(R){p.logger.log("Failed to parse IMSC1: "+R),x.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:R})})},s._parseVTTs=function(d,O,w){var x=this,R=this.hls;Object(j.parseWebVTT)(O,this.initPTS[d.cc],this.timescale[d.cc],w,d.cc,d.start,function(A){x._appendCues(A,d.level),R.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(A){x._fallbackToIMSC1(d,O),p.logger.log("Failed to parse VTT cue: "+A),R.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:A})})},s._fallbackToIMSC1=function(d,O){var w=this,x=this.tracks[d.level];x.textCodec||Object(I.parseIMSC1)(O,this.initPTS[d.cc],this.timescale[d.cc],function(){x.textCodec=I.IMSC1_CODEC,w._parseIMSC1(d,O)},function(){x.textCodec="wvtt"})},s._appendCues=function(d,O){var w=this.hls;if(this.config.renderTextTracksNatively){var x=this.textTracks[O];if(x.mode==="disabled")return;d.forEach(function(T){return Object(M.addCueToTrack)(x,T)})}else{var R=this.tracks[O],A=R.default?"default":"subtitles"+O;w.trigger(F.Events.CUES_PARSED,{type:"subtitles",cues:d,track:A})}},s.onFragDecrypted=function(d,O){var w=O.frag;if(w.type===g.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[w.cc])){this.unparsedVttFrags.push(O);return}this.onFragLoaded(F.Events.FRAG_LOADED,O)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(d,O){var w=this.cea608Parser1,x=this.cea608Parser2;if(!this.enabled||!(w&&x))return;for(var R=0;R<O.samples.length;R++){var A=O.samples[R].bytes;if(A){var T=this.extractCea608Data(A);w.addData(O.samples[R].pts,T[0]),x.addData(O.samples[R].pts,T[1])}}},s.onBufferFlushing=function(d,O){var w=O.startOffset,x=O.endOffset,R=O.endOffsetSubtitles,A=O.type,T=this.media;if(!T||T.currentTime<x)return;if(!A||A==="video"){var E=this.captionsTracks;Object.keys(E).forEach(function(u){return Object(M.removeCuesInRange)(E[u],w,x)})}if(this.config.renderTextTracksNatively&&(w===0&&R!==void 0)){var y=this.textTracks;Object.keys(y).forEach(function(u){return Object(M.removeCuesInRange)(y[u],w,R)})}},s.extractCea608Data=function(d){for(var O=d[0]&31,w=2,x=[[],[]],R=0;R<O;R++){var A=d[w++],T=127&d[w++],E=127&d[w++],y=(4&A)!==0,u=3&A;if(T===0&&E===0)continue;y&&((u===0||u===1)&&(x[u].push(T),x[u].push(E)))}return x},o}();function h(o,s){return o&&o.label===s.name&&!(o.textTrack1||o.textTrack2)}function a(o,s,l,d){return Math.min(s,d)-Math.max(o,l)}function c(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return V});var V=function(){function F(G,j){this.subtle=void 0,this.aesIV=void 0,this.subtle=G,this.aesIV=j}var D=F.prototype;return D.decrypt=function(j,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,j)},F}()},"./src/crypt/aes-decryptor.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"removePadding",function(){return F}),k.d(Z,"default",function(){return D});var V=k("./src/utils/typed-array.ts");function F(G){var j=G.byteLength,M=j&&new DataView(G.buffer).getUint8(j-1);return M?Object(V.sliceUint8)(G,0,j-M):G}var D=function(){function G(){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 j=G.prototype;return j.uint8ArrayToUint32Array_=function(I){for(var g=new DataView(I),p=new Uint32Array(4),f=0;f<4;f++)p[f]=g.getUint32(f*4);return p},j.initTable=function(){var I=this.sBox,g=this.invSBox,p=this.subMix,f=p[0],h=p[1],a=p[2],c=p[3],o=this.invSubMix,s=o[0],l=o[1],d=o[2],O=o[3],w=new Uint32Array(256),x=0,R=0,A=0;for(A=0;A<256;A++)A<128?w[A]=A<<1:w[A]=A<<1^283;for(A=0;A<256;A++){var T=R^R<<1^R<<2^R<<3^R<<4;T=T>>>8^T&255^99,I[x]=T,g[T]=x;var E=w[x],y=w[E],u=w[y],_=w[T]*257^T*16843008;f[x]=_<<24|_>>>8,h[x]=_<<16|_>>>16,a[x]=_<<8|_>>>24,c[x]=_,_=u*16843009^y*65537^E*257^x*16843008,s[T]=_<<24|_>>>8,l[T]=_<<16|_>>>16,d[T]=_<<8|_>>>24,O[T]=_,x?(x=E^w[w[w[u^E]]],R^=w[w[R]]):x=R=1}},j.expandKey=function(I){for(var g=this.uint8ArrayToUint32Array_(I),p=!0,f=0;f<g.length&&p;)p=g[f]===this.key[f],f++;if(p)return;this.key=g;var h=this.keySize=g.length;if(h!==4&&h!==6&&h!==8)throw new Error("Invalid aes key size="+h);var a=this.ksRows=(h+6+1)*4,c,o,s=this.keySchedule=new Uint32Array(a),l=this.invKeySchedule=new Uint32Array(a),d=this.sBox,O=this.rcon,w=this.invSubMix,x=w[0],R=w[1],A=w[2],T=w[3],E,y;for(c=0;c<a;c++){if(c<h){E=s[c]=g[c];continue}y=E,c%h===0?(y=y<<8|y>>>24,y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[y&255],y^=O[c/h|0]<<24):h>6&&c%h===4&&(y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[y&255]),s[c]=E=(s[c-h]^y)>>>0}for(o=0;o<a;o++)c=a-o,o&3?y=s[c]:y=s[c-4],o<4||c<=4?l[o]=y:l[o]=x[d[y>>>24]]^R[d[y>>>16&255]]^A[d[y>>>8&255]]^T[d[y&255]],l[o]=l[o]>>>0},j.networkToHostOrderSwap=function(I){return I<<24|(I&65280)<<8|(I&16711680)>>8|I>>>24},j.decrypt=function(I,g,p){for(var f=this.keySize+6,h=this.invKeySchedule,a=this.invSBox,c=this.invSubMix,o=c[0],s=c[1],l=c[2],d=c[3],O=this.uint8ArrayToUint32Array_(p),w=O[0],x=O[1],R=O[2],A=O[3],T=new Int32Array(I),E=new Int32Array(T.length),y,u,_,m,b,P,N,K,X,B,S,Y,te,re,ce=this.networkToHostOrderSwap;g<T.length;){for(X=ce(T[g]),B=ce(T[g+1]),S=ce(T[g+2]),Y=ce(T[g+3]),b=X^h[0],P=Y^h[1],N=S^h[2],K=B^h[3],te=4,re=1;re<f;re++)y=o[b>>>24]^s[P>>16&255]^l[N>>8&255]^d[K&255]^h[te],u=o[P>>>24]^s[N>>16&255]^l[K>>8&255]^d[b&255]^h[te+1],_=o[N>>>24]^s[K>>16&255]^l[b>>8&255]^d[P&255]^h[te+2],m=o[K>>>24]^s[b>>16&255]^l[P>>8&255]^d[N&255]^h[te+3],b=y,P=u,N=_,K=m,te=te+4;y=a[b>>>24]<<24^a[P>>16&255]<<16^a[N>>8&255]<<8^a[K&255]^h[te],u=a[P>>>24]<<24^a[N>>16&255]<<16^a[K>>8&255]<<8^a[b&255]^h[te+1],_=a[N>>>24]<<24^a[K>>16&255]<<16^a[b>>8&255]<<8^a[P&255]^h[te+2],m=a[K>>>24]<<24^a[b>>16&255]<<16^a[P>>8&255]<<8^a[N&255]^h[te+3],E[g]=ce(y^w),E[g+1]=ce(m^x),E[g+2]=ce(_^R),E[g+3]=ce(u^A),w=X,x=B,R=S,A=Y,g=g+4}return E.buffer},G}()},"./src/crypt/decrypter.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return g});var V=k("./src/crypt/aes-crypto.ts"),F=k("./src/crypt/fast-aes-key.ts"),D=k("./src/crypt/aes-decryptor.ts"),G=k("./src/utils/logger.ts"),j=k("./src/utils/mp4-tools.ts"),M=k("./src/utils/typed-array.ts"),I=16,g=function(){function p(h,a,c){var o=c===void 0?{}:c,s=o.removePKCS7Padding,l=s===void 0?!0:s;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=h,this.config=a,this.removePKCS7Padding=l,l)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(O){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var f=p.prototype;return f.destroy=function(){this.observer=null},f.isSync=function(){return this.config.enableSoftwareAES},f.flush=function(){var a=this.currentResult;if(!a){this.reset();return}var c=new Uint8Array(a);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(c):c},f.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},f.decrypt=function(a,c,o,s){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(a),c,o);var l=this.flush();l&&s(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(a),c,o).then(s)},f.softwareDecrypt=function(a,c,o){var s=this.currentIV,l=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(a=Object(j.appendUint8Array)(d,a),this.remainderData=null);var O=this.getValidChunk(a);if(!O.length)return null;s&&(o=s);var w=this.softwareDecrypter;w||(w=this.softwareDecrypter=new D.default),w.expandKey(c);var x=l;return this.currentResult=w.decrypt(O.buffer,0,o),this.currentIV=Object(M.sliceUint8)(O,-16).buffer,x||null},f.webCryptoDecrypt=function(a,c,o){var s=this,l=this.subtle;return(this.key!==c||!this.fastAesKey)&&(this.key=c,this.fastAesKey=new F.default(l,c)),this.fastAesKey.expandKey().then(function(d){if(!l)return Promise.reject(new Error("web crypto not initialized"));var O=new V.default(l,o);return O.decrypt(a.buffer,d)}).catch(function(d){return s.onWebCryptoError(d,a,c,o)})},f.onWebCryptoError=function(a,c,o,s){return G.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",a),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(c,o,s)},f.getValidChunk=function(a){var c=a,o=a.length-a.length%I;return o!==a.length&&(c=Object(M.sliceUint8)(a,0,o),this.remainderData=Object(M.sliceUint8)(a,o)),c},f.logOnce=function(a){if(!this.logEnabled)return;G.logger.log("[decrypter.ts]: "+a),this.logEnabled=!1},p}()},"./src/crypt/fast-aes-key.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return V});var V=function(){function F(G,j){this.subtle=void 0,this.key=void 0,this.subtle=G,this.key=j}var D=F.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},F}()},"./src/demux/aacdemuxer.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/demux/base-audio-demuxer.ts"),F=k("./src/demux/adts.ts"),D=k("./src/utils/logger.ts"),G=k("./src/demux/id3.ts");function j(g,p){g.prototype=Object.create(p.prototype),g.prototype.constructor=g,M(g,p)}function M(g,p){return M=Object.setPrototypeOf||function(h,a){return h.__proto__=a,h},M(g,p)}var I=function(g){j(p,g);function p(h,a){var c;return c=g.call(this)||this,c.observer=void 0,c.config=void 0,c.observer=h,c.config=a,c}var f=p.prototype;return f.resetInitSegment=function(a,c,o){g.prototype.resetInitSegment.call(this,a,c,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:a,duration:o,inputTimeScale:9e4,dropped:0}},p.probe=function(a){if(!a)return!1;for(var c=G.getID3Data(a,0)||[],o=c.length,s=a.length;o<s;o++)if(F.probe(a,o))return D.logger.log("ADTS sync word found !"),!0;return!1},f.canParse=function(a,c){return F.canParse(a,c)},f.appendFrame=function(a,c,o){F.initTrackConfig(a,this.observer,c,o,a.manifestCodec);var s=F.appendFrame(a,c,o,this.initPTS,this.frameIndex);if(s&&s.missing===0)return s},p}(V.default);I.minProbeByteLength=9,Z.default=I},"./src/demux/adts.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"getAudioConfig",function(){return G}),k.d(Z,"isHeaderPattern",function(){return j}),k.d(Z,"getHeaderLength",function(){return M}),k.d(Z,"getFullFrameLength",function(){return I}),k.d(Z,"canGetFrameLength",function(){return g}),k.d(Z,"isHeader",function(){return p}),k.d(Z,"canParse",function(){return f}),k.d(Z,"probe",function(){return h}),k.d(Z,"initTrackConfig",function(){return a}),k.d(Z,"getFrameDuration",function(){return c}),k.d(Z,"parseFrameHeader",function(){return o}),k.d(Z,"appendFrame",function(){return s});var V=k("./src/utils/logger.ts"),F=k("./src/errors.ts"),D=k("./src/events.ts");function G(l,d,O,w){var x,R,A,T,E=navigator.userAgent.toLowerCase(),y=w,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];x=((d[O+2]&192)>>>6)+1;var _=(d[O+2]&60)>>>2;if(_>u.length-1){l.trigger(D.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+_});return}return A=(d[O+2]&1)<<2,A|=(d[O+3]&192)>>>6,V.logger.log("manifest codec:"+w+", ADTS type:"+x+", samplingIndex:"+_),/firefox/i.test(E)?_>=6?(x=5,T=new Array(4),R=_-3):(x=2,T=new Array(2),R=_):E.indexOf("android")!==-1?(x=2,T=new Array(2),R=_):(x=5,T=new Array(4),w&&(w.indexOf("mp4a.40.29")!==-1||w.indexOf("mp4a.40.5")!==-1)||!w&&_>=6?R=_-3:((w&&w.indexOf("mp4a.40.2")!==-1&&(_>=6&&A===1||/vivaldi/i.test(E))||!w&&A===1)&&(x=2,T=new Array(2)),R=_)),T[0]=x<<3,T[0]|=(_&14)>>1,T[1]|=(_&1)<<7,T[1]|=A<<3,x===5&&(T[1]|=(R&14)>>1,T[2]=(R&1)<<7,T[2]|=2<<2,T[3]=0),{config:T,samplerate:u[_],channelCount:A,codec:"mp4a.40."+x,manifestCodec:y}}function j(l,d){return l[d]===255&&(l[d+1]&246)===240}function M(l,d){return l[d+1]&1?7:9}function I(l,d){return(l[d+3]&3)<<11|l[d+4]<<3|(l[d+5]&224)>>>5}function g(l,d){return d+5<l.length}function p(l,d){return d+1<l.length&&j(l,d)}function f(l,d){return g(l,d)&&j(l,d)&&I(l,d)<=l.length-d}function h(l,d){if(p(l,d)){var O=M(l,d);if(d+O>=l.length)return!1;var w=I(l,d);if(w<=O)return!1;var x=d+w;return x===l.length||p(l,x)}return!1}function a(l,d,O,w,x){if(!l.samplerate){var R=G(d,O,w,x);if(!R)return;l.config=R.config,l.samplerate=R.samplerate,l.channelCount=R.channelCount,l.codec=R.codec,l.manifestCodec=R.manifestCodec,V.logger.log("parsed codec:"+l.codec+", rate:"+R.samplerate+", channels:"+R.channelCount)}}function c(l){return 1024*9e4/l}function o(l,d,O,w,x){var R=M(l,d),A=I(l,d);if(A-=R,A>0){var T=O+w*x;return{headerLength:R,frameLength:A,stamp:T}}}function s(l,d,O,w,x){var R=c(l.samplerate),A=o(d,O,w,x,R);if(A){var T=A.frameLength,E=A.headerLength,y=A.stamp,u=E+T,_=Math.max(0,O+u-d.length),m;_?(m=new Uint8Array(u-E),m.set(d.subarray(O+E,d.length),0)):m=d.subarray(O+E,O+u);var b={unit:m,pts:y};return _||l.samples.push(b),{sample:b,length:u,missing:_}}}},"./src/demux/base-audio-demuxer.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"initPTSFn",function(){return I});var V=k("./src/polyfills/number.ts"),F=k("./src/demux/id3.ts"),D=k("./src/demux/dummy-demuxed-track.ts"),G=k("./src/utils/mp4-tools.ts"),j=k("./src/utils/typed-array.ts"),M=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var p=g.prototype;return p.resetInitSegment=function(h,a,c){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},p.resetTimeStamp=function(){},p.resetContiguity=function(){},p.canParse=function(h,a){return!1},p.appendFrame=function(h,a,c){},p.demux=function(h,a){this.cachedData&&(h=Object(G.appendUint8Array)(this.cachedData,h),this.cachedData=null);var c=F.getID3Data(h,0),o=c?c.length:0,s,l,d=this._audioTrack,O=this._id3Track,w=c?F.getTimeStamp(c):void 0,x=h.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=I(w,a)),c&&c.length>0&&O.samples.push({pts:this.initPTS,dts:this.initPTS,data:c}),l=this.initPTS;o<x;){if(this.canParse(h,o)){var R=this.appendFrame(d,h,o);R?(this.frameIndex++,l=R.sample.pts,o+=R.length,s=o):o=x}else F.canParse(h,o)?(c=F.getID3Data(h,o),O.samples.push({pts:l,dts:l,data:c}),o+=c.length,s=o):o++;if(o===x&&s!==x){var A=Object(j.sliceUint8)(h,s);this.cachedData?this.cachedData=Object(G.appendUint8Array)(this.cachedData,A):this.cachedData=A}}return{audioTrack:d,avcTrack:Object(D.dummyTrack)(),id3Track:O,textTrack:Object(D.dummyTrack)()}},p.demuxSampleAes=function(h,a,c){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},p.flush=function(h){var a=this.cachedData;return a&&(this.cachedData=null,this.demux(a,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(D.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(D.dummyTrack)()}},p.destroy=function(){},g}(),I=function(p,f){return Object(V.isFiniteNumber)(p)?p*90:f*9e4};Z.default=M},"./src/demux/chunk-cache.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return V});var V=function(){function D(){this.chunks=[],this.dataLength=0}var G=D.prototype;return G.push=function(M){this.chunks.push(M),this.dataLength+=M.length},G.flush=function(){var M=this.chunks,I=this.dataLength,g;if(M.length)M.length===1?g=M[0]:g=F(M,I);else return new Uint8Array(0);return this.reset(),g},G.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function F(D,G){for(var j=new Uint8Array(G),M=0,I=0;I<D.length;I++){var g=D[I];j.set(g,M),M+=g.length}return j}},"./src/demux/dummy-demuxed-track.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/utils/logger.ts"),F=function(){function D(j){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=j,this.bytesAvailable=j.byteLength,this.word=0,this.bitsAvailable=0}var G=D.prototype;return G.loadWord=function(){var M=this.data,I=this.bytesAvailable,g=M.byteLength-I,p=new Uint8Array(4),f=Math.min(4,I);if(f===0)throw new Error("no bytes available");p.set(M.subarray(g,g+f)),this.word=new DataView(p.buffer).getUint32(0),this.bitsAvailable=f*8,this.bytesAvailable-=f},G.skipBits=function(M){var I;this.bitsAvailable>M?(this.word<<=M,this.bitsAvailable-=M):(M-=this.bitsAvailable,I=M>>3,M-=I>>3,this.bytesAvailable-=I,this.loadWord(),this.word<<=M,this.bitsAvailable-=M)},G.readBits=function(M){var I=Math.min(this.bitsAvailable,M),g=this.word>>>32-I;return M>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=I,this.bitsAvailable>0?this.word<<=I:this.bytesAvailable>0&&this.loadWord(),I=M-I,I>0&&this.bitsAvailable?g<<I|this.readBits(I):g},G.skipLZ=function(){var M;for(M=0;M<this.bitsAvailable;++M)if((this.word&2147483648>>>M)!==0)return this.word<<=M,this.bitsAvailable-=M,M;return this.loadWord(),M+this.skipLZ()},G.skipUEG=function(){this.skipBits(1+this.skipLZ())},G.skipEG=function(){this.skipBits(1+this.skipLZ())},G.readUEG=function(){var M=this.skipLZ();return this.readBits(M+1)-1},G.readEG=function(){var M=this.readUEG();return 1&M?1+M>>>1:-1*(M>>>1)},G.readBoolean=function(){return this.readBits(1)===1},G.readUByte=function(){return this.readBits(8)},G.readUShort=function(){return this.readBits(16)},G.readUInt=function(){return this.readBits(32)},G.skipScalingList=function(M){for(var I=8,g=8,p,f=0;f<M;f++)g!==0&&(p=this.readEG(),g=(I+p+256)%256),I=g===0?I:g},G.readSPS=function(){var M=0,I=0,g=0,p=0,f,h,a,c=this.readUByte.bind(this),o=this.readBits.bind(this),s=this.readUEG.bind(this),l=this.readBoolean.bind(this),d=this.skipBits.bind(this),O=this.skipEG.bind(this),w=this.skipUEG.bind(this),x=this.skipScalingList.bind(this);c();var R=c();if(o(5),d(3),c(),w(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){var A=s();if(A===3&&d(1),w(),w(),d(1),l())for(h=A!==3?8:12,a=0;a<h;a++)l()&&(a<6?x(16):x(64))}w();var T=s();if(T===0)s();else if(T===1)for(d(1),O(),O(),f=s(),a=0;a<f;a++)O();w(),d(1);var E=s(),y=s(),u=o(1);u===0&&d(1),d(1),l()&&(M=s(),I=s(),g=s(),p=s());var _=[1,1];if(l()&&l()){var m=c();switch(m){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[c()<<8|c(),c()<<8|c()];break}}}return{width:Math.ceil((E+1)*16-M*2-I*2),height:(2-u)*(y+1)*16-(u?2:4)*(g+p),pixelRatio:_}},G.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();Z.default=F},"./src/demux/id3.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"isHeader",function(){return V}),k.d(Z,"isFooter",function(){return F}),k.d(Z,"getID3Data",function(){return D}),k.d(Z,"canParse",function(){return j}),k.d(Z,"getTimeStamp",function(){return M}),k.d(Z,"isTimeStampFrame",function(){return I}),k.d(Z,"getID3Frames",function(){return p}),k.d(Z,"decodeFrame",function(){return f}),k.d(Z,"utf8ArrayToStr",function(){return s}),k.d(Z,"testables",function(){return l});var V=function(x,R){return R+10<=x.length&&(x[R]===73&&x[R+1]===68&&x[R+2]===51&&(x[R+3]<255&&x[R+4]<255&&(x[R+6]<128&&x[R+7]<128&&x[R+8]<128&&x[R+9]<128)))},F=function(x,R){return R+10<=x.length&&(x[R]===51&&x[R+1]===68&&x[R+2]===73&&(x[R+3]<255&&x[R+4]<255&&(x[R+6]<128&&x[R+7]<128&&x[R+8]<128&&x[R+9]<128)))},D=function(x,R){for(var A=R,T=0;V(x,R);){T+=10;var E=G(x,R+6);T+=E,F(x,R+10)&&(T+=10),R+=T}return T>0?x.subarray(A,A+T):void 0},G=function(x,R){var A=0;return A=(x[R]&127)<<21,A|=(x[R+1]&127)<<14,A|=(x[R+2]&127)<<7,A|=x[R+3]&127,A},j=function(x,R){return V(x,R)&&G(x,R+6)+10<=x.length-R},M=function(x){for(var R=p(x),A=0;A<R.length;A++){var T=R[A];if(I(T))return o(T)}return},I=function(x){return x&&x.key==="PRIV"&&x.info==="com.apple.streaming.transportStreamTimestamp"},g=function(x){var R=String.fromCharCode(x[0],x[1],x[2],x[3]),A=G(x,4),T=10;return{type:R,size:A,data:x.subarray(T,T+A)}},p=function(x){for(var R=0,A=[];V(x,R);){var T=G(x,R+6);R+=10;for(var E=R+T;R+8<E;){var y=g(x.subarray(R)),u=f(y);u&&A.push(u),R+=y.size+10}F(x,R)&&(R+=10)}return A},f=function(x){return x.type==="PRIV"?h(x):x.type[0]==="W"?c(x):a(x)},h=function(x){if(x.size<2)return;var R=s(x.data,!0),A=new Uint8Array(x.data.subarray(R.length+1));return{key:x.type,info:R,data:A.buffer}},a=function(x){if(x.size<2)return;if(x.type==="TXXX"){var R=1,A=s(x.data.subarray(R),!0);R+=A.length+1;var T=s(x.data.subarray(R));return{key:x.type,info:A,data:T}}var E=s(x.data.subarray(1));return{key:x.type,data:E}},c=function(x){if(x.type==="WXXX"){if(x.size<2)return;var R=1,A=s(x.data.subarray(R),!0);R+=A.length+1;var T=s(x.data.subarray(R));return{key:x.type,info:A,data:T}}var E=s(x.data);return{key:x.type,data:E}},o=function(x){if(x.data.byteLength===8){var R=new Uint8Array(x.data),A=R[3]&1,T=(R[4]<<23)+(R[5]<<15)+(R[6]<<7)+R[7];return T/=45,A&&(T+=4772185884e-2),Math.round(T)}return},s=function(x,R){R===void 0&&(R=!1);var A=O();if(A){var T=A.decode(x);if(R){var E=T.indexOf("\0");return E!==-1?T.substring(0,E):T}return T.replace(/\0/g,"")}for(var y=x.length,u,_,m,b="",P=0;P<y;){if(u=x[P++],u===0&&R)return b;if(u===0||u===3)continue;switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:b+=String.fromCharCode(u);break;case 12:case 13:_=x[P++],b+=String.fromCharCode((u&31)<<6|_&63);break;case 14:_=x[P++],m=x[P++],b+=String.fromCharCode((u&15)<<12|(_&63)<<6|(m&63)<<0);break;default:}}return b},l={decodeTextFrame:a},d;function O(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/demux/base-audio-demuxer.ts"),F=k("./src/demux/id3.ts"),D=k("./src/utils/logger.ts"),G=k("./src/demux/mpegaudio.ts");function j(g,p){g.prototype=Object.create(p.prototype),g.prototype.constructor=g,M(g,p)}function M(g,p){return M=Object.setPrototypeOf||function(h,a){return h.__proto__=a,h},M(g,p)}var I=function(g){j(p,g);function p(){return g.apply(this,arguments)||this}var f=p.prototype;return f.resetInitSegment=function(a,c,o){g.prototype.resetInitSegment.call(this,a,c,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:a,duration:o,inputTimeScale:9e4,dropped:0}},p.probe=function(a){if(!a)return!1;for(var c=F.getID3Data(a,0)||[],o=c.length,s=a.length;o<s;o++)if(G.probe(a,o))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},f.canParse=function(a,c){return G.canParse(a,c)},f.appendFrame=function(a,c,o){return this.initPTS===null?void 0:G.appendFrame(a,c,o,this.initPTS,this.frameIndex)},p}(V.default);I.minProbeByteLength=4,Z.default=I},"./src/demux/mp4demuxer.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/utils/mp4-tools.ts"),F=k("./src/demux/dummy-demuxed-track.ts"),D=function(){function G(M,I){this.remainderData=null,this.config=void 0,this.config=I}var j=G.prototype;return j.resetTimeStamp=function(){},j.resetInitSegment=function(){},j.resetContiguity=function(){},G.probe=function(I){return Object(V.findBox)({data:I,start:0,end:Math.min(I.length,16384)},["moof"]).length>0},j.demux=function(I){var g=I,p=Object(F.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(V.appendUint8Array)(this.remainderData,I));var f=Object(V.segmentValidRange)(g);this.remainderData=f.remainder,p.samples=f.valid||new Uint8Array}else p.samples=g;return{audioTrack:Object(F.dummyTrack)(),avcTrack:p,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},j.flush=function(){var I=Object(F.dummyTrack)();return I.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(F.dummyTrack)(),avcTrack:I,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},j.demuxSampleAes=function(I,g,p){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},j.destroy=function(){},G}();D.minProbeByteLength=1024,Z.default=D},"./src/demux/mpegaudio.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"appendFrame",function(){return M}),k.d(Z,"parseHeader",function(){return I}),k.d(Z,"isHeaderPattern",function(){return g}),k.d(Z,"isHeader",function(){return p}),k.d(Z,"canParse",function(){return f}),k.d(Z,"probe",function(){return h});var V=null,F=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],D=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],G=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],j=[0,1,1,4];function M(a,c,o,s,l){if(o+24>c.length)return;var d=I(c,o);if(d&&o+d.frameLength<=c.length){var O=d.samplesPerFrame*9e4/d.sampleRate,w=s+l*O,x={unit:c.subarray(o,o+d.frameLength),pts:w,dts:w};return a.config=[],a.channelCount=d.channelCount,a.samplerate=d.sampleRate,a.samples.push(x),{sample:x,length:d.frameLength,missing:0}}}function I(a,c){var o=a[c+1]>>3&3,s=a[c+1]>>1&3,l=a[c+2]>>4&15,d=a[c+2]>>2&3;if(o!==1&&l!==0&&l!==15&&d!==3){var O=a[c+2]>>1&1,w=a[c+3]>>6,x=o===3?3-s:s===3?3:4,R=F[x*14+l-1]*1e3,A=o===3?0:o===2?1:2,T=D[A*3+d],E=w===3?1:2,y=G[o][s],u=j[s],_=y*8*u,m=Math.floor(y*R/T+O)*u;if(V===null){var b=navigator.userAgent||"",P=b.match(/Chrome\/(\d+)/i);V=P?parseInt(P[1]):0}var N=!!V&&V<=87;return N&&s===2&&R>=224e3&&w===0&&(a[c+3]=a[c+3]|128),{sampleRate:T,channelCount:E,frameLength:m,samplesPerFrame:_}}}function g(a,c){return a[c]===255&&(a[c+1]&224)===224&&(a[c+1]&6)!==0}function p(a,c){return c+1<a.length&&g(a,c)}function f(a,c){var o=4;return g(a,c)&&o<=a.length-c}function h(a,c){if(c+1<a.length&&g(a,c)){var o=4,s=I(a,c),l=o;s!=null&&s.frameLength&&(l=s.frameLength);var d=c+l;return d===a.length||p(a,d)}return!1}},"./src/demux/sample-aes.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/crypt/decrypter.ts"),F=k("./src/demux/tsdemuxer.ts"),D=function(){function G(M,I,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new V.default(M,I,{removePKCS7Padding:!1})}var j=G.prototype;return j.decryptBuffer=function(I,g){this.decrypter.decrypt(I,this.keyData.key.buffer,this.keyData.iv.buffer,g)},j.decryptAacSample=function(I,g,p,f){var h=I[g].unit,a=h.subarray(16,h.length-h.length%16),c=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(c,function(s){var l=new Uint8Array(s);h.set(l,16),f||o.decryptAacSamples(I,g+1,p)})},j.decryptAacSamples=function(I,g,p){for(;;g++){if(g>=I.length){p();return}if(I[g].unit.length<32)continue;var f=this.decrypter.isSync();if(this.decryptAacSample(I,g,p,f),!f)return}},j.getAvcEncryptedData=function(I){for(var g=Math.floor((I.length-48)/160)*16+16,p=new Int8Array(g),f=0,h=32;h<=I.length-16;h+=160,f+=16)p.set(I.subarray(h,h+16),f);return p},j.getAvcDecryptedUnit=function(I,g){for(var p=new Uint8Array(g),f=0,h=32;h<=I.length-16;h+=160,f+=16)I.set(p.subarray(f,f+16),h);return I},j.decryptAvcSample=function(I,g,p,f,h,a){var c=Object(F.discardEPB)(h.data),o=this.getAvcEncryptedData(c),s=this;this.decryptBuffer(o.buffer,function(l){h.data=s.getAvcDecryptedUnit(c,l),a||s.decryptAvcSamples(I,g,p+1,f)})},j.decryptAvcSamples=function(I,g,p,f){if(I instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,p=0){if(g>=I.length){f();return}for(var h=I[g].units;!(p>=h.length);p++){var a=h[p];if(a.data.length<=48||a.type!==1&&a.type!==5)continue;var c=this.decrypter.isSync();if(this.decryptAvcSample(I,g,p,f,a,c),!c)return}}},G}();Z.default=D},"./src/demux/transmuxer-interface.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return h});var V=k("./node_modules/webworkify-webpack/index.js"),F=k.n(V),D=k("./src/events.ts"),G=k("./src/demux/transmuxer.ts"),j=k("./src/utils/logger.ts"),M=k("./src/errors.ts"),I=k("./src/utils/mediasource-helper.ts"),g=k("./node_modules/eventemitter3/index.js"),p=k.n(g),f=Object(I.getMediaSource)()||{isTypeSupported:function(){return!1}},h=function(){function a(o,s,l,d){var O=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=o,this.id=s,this.onTransmuxComplete=l,this.onFlush=d;var w=o.config,x=function(y,u){u=u||{},u.frag=O.frag,u.id=O.id,o.trigger(y,u)};this.observer=new g.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,x),this.observer.on(D.Events.ERROR,x);var R={mp4:f.isTypeSupported("video/mp4"),mpeg:f.isTypeSupported("audio/mpeg"),mp3:f.isTypeSupported('audio/mp4; codecs="mp3"')},A=navigator.vendor;if(w.enableWorker&&typeof Worker!="undefined"){j.logger.log("demuxing in webworker");var T;try{T=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),T.addEventListener("message",this.onwmsg),T.onerror=function(E){o.trigger(D.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(E.message+" ("+E.filename+":"+E.lineno+")")})},T.postMessage({cmd:"init",typeSupported:R,vendor:A,id:s,config:JSON.stringify(w)})}catch(E){j.logger.warn("Error in worker:",E),j.logger.error("Error while initializing DemuxerWorker, fallback to inline"),T&&self.URL.revokeObjectURL(T.objectURL),this.transmuxer=new G.default(this.observer,R,w,A,s),this.worker=null}}else this.transmuxer=new G.default(this.observer,R,w,A,s)}var c=a.prototype;return c.destroy=function(){var s=this.worker;if(s)s.removeEventListener("message",this.onwmsg),s.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},c.push=function(s,l,d,O,w,x,R,A,T,E){var y=this;T.transmuxing.start=self.performance.now();var u=this.transmuxer,_=this.worker,m=x?x.start:w.start,b=w.decryptdata,P=this.frag,N=!(P&&w.cc===P.cc),K=!(P&&T.level===P.level),X=P?T.sn-P.sn:-1,B=this.part?T.part-this.part.index:1,S=!K&&(X===1||X===0&&B===1),Y=self.performance.now();(K||X||w.stats.parsing.start===0)&&(w.stats.parsing.start=Y),x&&(B||!S)&&(x.stats.parsing.start=Y);var te=new G.TransmuxState(N,S,A,K,m);if(!S||N){j.logger.log("[transmuxer-interface, "+w.type+"]: Starting new transmux session for sn: "+T.sn+" p: "+T.part+" level: "+T.level+" id: "+T.id+`
discontinuity: `+N+`
trackSwitch: `+K+`
contiguous: `+S+`
accurateTimeOffset: `+A+`
timeOffset: `+m);var re=new G.TransmuxConfig(d,O,l,R,E);this.configureTransmuxer(re)}if(this.frag=w,this.part=x,_)_.postMessage({cmd:"demux",data:s,decryptdata:b,chunkMeta:T,state:te},s instanceof ArrayBuffer?[s]:[]);else if(u){var ce=u.push(s,b,T,te);Object(G.isPromise)(ce)?ce.then(function(Te){y.handleTransmuxComplete(Te)}):this.handleTransmuxComplete(ce)}},c.flush=function(s){var l=this;s.transmuxing.start=self.performance.now();var d=this.transmuxer,O=this.worker;if(O)O.postMessage({cmd:"flush",chunkMeta:s});else if(d){var w=d.flush(s);Object(G.isPromise)(w)?w.then(function(x){l.handleFlushResult(x,s)}):this.handleFlushResult(w,s)}},c.handleFlushResult=function(s,l){var d=this;s.forEach(function(O){d.handleTransmuxComplete(O)}),this.onFlush(l)},c.onWorkerMessage=function(s){var l=s.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}}},c.configureTransmuxer=function(s){var l=this.worker,d=this.transmuxer;l?l.postMessage({cmd:"configure",config:s}):d&&d.configure(s)},c.handleTransmuxComplete=function(s){s.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(s)},a}()},"./src/demux/transmuxer-worker.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return M});var V=k("./src/demux/transmuxer.ts"),F=k("./src/events.ts"),D=k("./src/utils/logger.ts"),G=k("./node_modules/eventemitter3/index.js"),j=k.n(G);function M(h){var a=new G.EventEmitter,c=function(s,l){h.postMessage({event:s,data:l})};a.on(F.Events.FRAG_DECRYPTED,c),a.on(F.Events.ERROR,c),h.addEventListener("message",function(o){var s=o.data;switch(s.cmd){case"init":{var l=JSON.parse(s.config);h.transmuxer=new V.default(a,s.typeSupported,l,s.vendor,s.id),Object(D.enableLogs)(l.debug),c("init",null);break}case"configure":{h.transmuxer.configure(s.config);break}case"demux":{var d=h.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(V.isPromise)(d)?d.then(function(x){I(h,x)}):I(h,d);break}case"flush":{var O=s.chunkMeta,w=h.transmuxer.flush(O);Object(V.isPromise)(w)?w.then(function(x){p(h,x,O)}):p(h,w,O);break}default:break}})}function I(h,a){if(f(a.remuxResult))return;var c=[],o=a.remuxResult,s=o.audio,l=o.video;s&&g(c,s),l&&g(c,l),h.postMessage({event:"transmuxComplete",data:a},c)}function g(h,a){a.data1&&h.push(a.data1.buffer),a.data2&&h.push(a.data2.buffer)}function p(h,a,c){a.forEach(function(o){I(h,o)}),h.postMessage({event:"flush",data:c})}function f(h){return!h.audio&&!h.video&&!h.text&&!h.id3&&!h.initSegment}},"./src/demux/transmuxer.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return l}),k.d(Z,"isPromise",function(){return w}),k.d(Z,"TransmuxConfig",function(){return x}),k.d(Z,"TransmuxState",function(){return R});var V=k("./src/events.ts"),F=k("./src/errors.ts"),D=k("./src/crypt/decrypter.ts"),G=k("./src/demux/aacdemuxer.ts"),j=k("./src/demux/mp4demuxer.ts"),M=k("./src/demux/tsdemuxer.ts"),I=k("./src/demux/mp3demuxer.ts"),g=k("./src/remux/mp4-remuxer.ts"),p=k("./src/remux/passthrough-remuxer.ts"),f=k("./src/demux/chunk-cache.ts"),h=k("./src/utils/mp4-tools.ts"),a=k("./src/utils/logger.ts"),c;try{c=self.performance.now.bind(self.performance)}catch(A){a.logger.debug("Unable to use Performance API on this environment"),c=self.Date.now}var o=[{demux:M.default,remux:g.default},{demux:j.default,remux:p.default},{demux:G.default,remux:g.default},{demux:I.default,remux:g.default}],s=1024;o.forEach(function(A){var T=A.demux;s=Math.max(s,T.minProbeByteLength)});var l=function(){function A(E,y,u,_,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 f.default,this.observer=E,this.typeSupported=y,this.config=u,this.vendor=_,this.id=m}var T=A.prototype;return T.configure=function(y){this.transmuxConfig=y,this.decrypter&&this.decrypter.reset()},T.push=function(y,u,_,m){var b=this,P=_.transmuxing;P.executeStart=c();var N=new Uint8Array(y),K=this.cache,X=this.config,B=this.currentTransmuxState,S=this.transmuxConfig;m&&(this.currentTransmuxState=m);var Y=d(N,u);if(Y&&Y.method==="AES-128"){var te=this.getDecrypter();if(X.enableSoftwareAES){var re=te.softwareDecrypt(N,Y.key.buffer,Y.iv.buffer);if(!re)return P.executeEnd=c(),O(_);N=new Uint8Array(re)}else return this.decryptionPromise=te.webCryptoDecrypt(N,Y.key.buffer,Y.iv.buffer).then(function(Me){var We=b.push(Me,null,_);return b.decryptionPromise=null,We}),this.decryptionPromise}var ce=m||B,Te=ce.contiguous,ye=ce.discontinuity,be=ce.trackSwitch,we=ce.accurateTimeOffset,xe=ce.timeOffset,ve=S.audioCodec,oe=S.videoCodec,Re=S.defaultInitPts,Ye=S.duration,Ue=S.initSegmentData;if((ye||be)&&this.resetInitSegment(Ue,ve,oe,Ye),ye&&this.resetInitialTimestamp(Re),Te||this.resetContiguity(),this.needsProbing(N,ye,be)){if(K.dataLength){var rt=K.flush();N=Object(h.appendUint8Array)(rt,N)}this.configureTransmuxer(N,S)}var ot=this.transmux(N,Y,xe,we,_),Oe=this.currentTransmuxState;return Oe.contiguous=!0,Oe.discontinuity=!1,Oe.trackSwitch=!1,P.executeEnd=c(),ot},T.flush=function(y){var u=this,_=y.transmuxing;_.executeStart=c();var m=this.decrypter,b=this.cache,P=this.currentTransmuxState,N=this.decryptionPromise;if(N)return N.then(function(){return u.flush(y)});var K=[],X=P.timeOffset;if(m){var B=m.flush();B&&K.push(this.push(B,null,y))}var S=b.dataLength;b.reset();var Y=this.demuxer,te=this.remuxer;if(!Y||!te)return S>=s&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),_.executeEnd=c(),[O(y)];var re=Y.flush(X);return w(re)?re.then(function(ce){return u.flushRemux(K,ce,y),K}):(this.flushRemux(K,re,y),K)},T.flushRemux=function(y,u,_){var m=u.audioTrack,b=u.avcTrack,P=u.id3Track,N=u.textTrack,K=this.currentTransmuxState,X=K.accurateTimeOffset,B=K.timeOffset;a.logger.log("[transmuxer.ts]: Flushed fragment "+_.sn+(_.part>-1?" p: "+_.part:"")+" of level "+_.level);var S=this.remuxer.remux(m,b,P,N,B,X,!0,this.id);y.push({remuxResult:S,chunkMeta:_}),_.transmuxing.executeEnd=c()},T.resetInitialTimestamp=function(y){var u=this.demuxer,_=this.remuxer;if(!u||!_)return;u.resetTimeStamp(y),_.resetTimeStamp(y)},T.resetContiguity=function(){var y=this.demuxer,u=this.remuxer;if(!y||!u)return;y.resetContiguity(),u.resetNextTimestamp()},T.resetInitSegment=function(y,u,_,m){var b=this.demuxer,P=this.remuxer;if(!b||!P)return;b.resetInitSegment(u,_,m),P.resetInitSegment(y,u,_)},T.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},T.transmux=function(y,u,_,m,b){var P;return u&&u.method==="SAMPLE-AES"?P=this.transmuxSampleAes(y,u,_,m,b):P=this.transmuxUnencrypted(y,_,m,b),P},T.transmuxUnencrypted=function(y,u,_,m){var b=this.demuxer.demux(y,u,!1,!this.config.progressive),P=b.audioTrack,N=b.avcTrack,K=b.id3Track,X=b.textTrack,B=this.remuxer.remux(P,N,K,X,u,_,!1,this.id);return{remuxResult:B,chunkMeta:m}},T.transmuxSampleAes=function(y,u,_,m,b){var P=this;return this.demuxer.demuxSampleAes(y,u,_).then(function(N){var K=P.remuxer.remux(N.audioTrack,N.avcTrack,N.id3Track,N.textTrack,_,m,!1,P.id);return{remuxResult:K,chunkMeta:b}})},T.configureTransmuxer=function(y,u){for(var _=this.config,m=this.observer,b=this.typeSupported,P=this.vendor,N=u.audioCodec,K=u.defaultInitPts,X=u.duration,B=u.initSegmentData,S=u.videoCodec,Y,te=0,re=o.length;te<re;te++)if(o[te].demux.probe(y)){Y=o[te];break}Y||(a.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Y={demux:j.default,remux:p.default});var ce=this.demuxer,Te=this.remuxer,ye=Y.remux,be=Y.demux;(!Te||!(Te instanceof ye))&&(this.remuxer=new ye(m,_,b,P)),(!ce||!(ce instanceof be))&&(this.demuxer=new be(m,_,b),this.probe=be.probe),this.resetInitSegment(B,N,S,X),this.resetInitialTimestamp(K)},T.needsProbing=function(y,u,_){return!this.demuxer||!this.remuxer||u||_},T.getDecrypter=function(){var y=this.decrypter;return y||(y=this.decrypter=new D.default(this.observer,this.config)),y},A}();function d(A,T){var E=null;return A.byteLength>0&&T!=null&&T.key!=null&&T.iv!==null&&T.method!=null&&(E=T),E}var O=function(T){return{remuxResult:{},chunkMeta:T}};function w(A){return"then"in A&&A.then instanceof Function}var x=function(T,E,y,u,_){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=T,this.videoCodec=E,this.initSegmentData=y,this.duration=u,this.defaultInitPts=_},R=function(T,E,y,u,_){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=T,this.contiguous=E,this.accurateTimeOffset=y,this.trackSwitch=u,this.timeOffset=_}},"./src/demux/tsdemuxer.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"discardEPB",function(){return O});var V=k("./src/demux/adts.ts"),F=k("./src/demux/mpegaudio.ts"),D=k("./src/demux/exp-golomb.ts"),G=k("./src/demux/id3.ts"),j=k("./src/demux/sample-aes.ts"),M=k("./src/events.ts"),I=k("./src/utils/mp4-tools.ts"),g=k("./src/utils/logger.ts"),p=k("./src/errors.ts"),f={video:1,audio:2,id3:3,text:4},h=function(){function w(R,A,T){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=R,this.config=A,this.typeSupported=T}w.probe=function(A){var T=w.syncOffset(A);return T<0?!1:(T&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+T+", junk ahead ?"),!0)},w.syncOffset=function(A){for(var T=Math.min(1e3,A.length-3*188),E=0;E<T;){if(A[E]===71&&A[E+188]===71&&A[E+2*188]===71)return E;E++}return-1},w.createTrack=function(A,T){return{container:A==="video"||A==="audio"?"video/mp2t":void 0,type:A,id:f[A],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:A==="audio"?T:void 0}};var x=w.prototype;return x.resetInitSegment=function(A,T,E){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=w.createTrack("video",E),this._audioTrack=w.createTrack("audio",E),this._id3Track=w.createTrack("id3",E),this._txtTrack=w.createTrack("text",E),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=A,this.videoCodec=T,this._duration=E},x.resetTimeStamp=function(){},x.resetContiguity=function(){var A=this._audioTrack,T=this._avcTrack,E=this._id3Track;A&&(A.pesData=null),T&&(T.pesData=null),E&&(E.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},x.demux=function(A,T,E,y){E===void 0&&(E=!1),y===void 0&&(y=!1),E||(this.sampleAes=null);var u,_=this._avcTrack,m=this._audioTrack,b=this._id3Track,P=_.pid,N=_.pesData,K=m.pid,X=b.pid,B=m.pesData,S=b.pesData,Y=!1,te=this.pmtParsed,re=this._pmtId,ce=A.length;if(this.remainderData&&(A=Object(I.appendUint8Array)(this.remainderData,A),ce=A.length,this.remainderData=null),ce<188&&!y)return this.remainderData=A,{audioTrack:m,avcTrack:_,id3Track:b,textTrack:this._txtTrack};var Te=Math.max(0,w.syncOffset(A));ce-=(ce+Te)%188,ce<A.byteLength&&!y&&(this.remainderData=new Uint8Array(A.buffer,ce,A.buffer.byteLength-ce));for(var ye=Te;ye<ce;ye+=188)if(A[ye]===71){var be=!!(A[ye+1]&64),we=((A[ye+1]&31)<<8)+A[ye+2],xe=(A[ye+3]&48)>>4,ve=void 0;if(xe>1){if(ve=ye+5+A[ye+4],ve===ye+188)continue}else ve=ye+4;switch(we){case P:be&&(N&&(u=s(N))&&this.parseAVCPES(u,!1),N={data:[],size:0}),N&&(N.data.push(A.subarray(ve,ye+188)),N.size+=ye+188-ve);break;case K:be&&(B&&(u=s(B))&&(m.isAAC?this.parseAACPES(u):this.parseMPEGPES(u)),B={data:[],size:0}),B&&(B.data.push(A.subarray(ve,ye+188)),B.size+=ye+188-ve);break;case X:be&&(S&&(u=s(S))&&this.parseID3PES(u),S={data:[],size:0}),S&&(S.data.push(A.subarray(ve,ye+188)),S.size+=ye+188-ve);break;case 0:be&&(ve+=A[ve]+1),re=this._pmtId=c(A,ve);break;case re:{be&&(ve+=A[ve]+1);var oe=o(A,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,E);P=oe.avc,P>0&&(_.pid=P),K=oe.audio,K>0&&(m.pid=K,m.isAAC=oe.isAAC),X=oe.id3,X>0&&(b.pid=X),Y&&!te&&(g.logger.log("reparse from beginning"),Y=!1,ye=Te-188),te=this.pmtParsed=!0;break}case 17:case 8191:break;default:Y=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});_.pesData=N,m.pesData=B,b.pesData=S;var Re={audioTrack:m,avcTrack:_,id3Track:b,textTrack:this._txtTrack};return y&&this.extractRemainingSamples(Re),Re},x.flush=function(){var A=this.remainderData;this.remainderData=null;var T;return A?T=this.demux(A,-1,!1,!0):T={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(T),this.sampleAes?this.decrypt(T,this.sampleAes):T},x.extractRemainingSamples=function(A){var T=A.audioTrack,E=A.avcTrack,y=A.id3Track,u=E.pesData,_=T.pesData,m=y.pesData,b;u&&(b=s(u))?(this.parseAVCPES(b,!0),E.pesData=null):E.pesData=u,_&&(b=s(_))?(T.isAAC?this.parseAACPES(b):this.parseMPEGPES(b),T.pesData=null):(_!=null&&_.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),T.pesData=_),m&&(b=s(m))?(this.parseID3PES(b),y.pesData=null):y.pesData=m},x.demuxSampleAes=function(A,T,E){var y=this.demux(A,E,!0,!this.config.progressive),u=this.sampleAes=new j.default(this.observer,this.config,T);return this.decrypt(y,u)},x.decrypt=function(A,T){return new Promise(function(E){var y=A.audioTrack,u=A.avcTrack;y.samples&&y.isAAC?T.decryptAacSamples(y.samples,0,function(){u.samples?T.decryptAvcSamples(u.samples,0,0,function(){E(A)}):E(A)}):u.samples&&T.decryptAvcSamples(u.samples,0,0,function(){E(A)})})},x.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},x.parseAVCPES=function(A,T){var E=this,y=this._avcTrack,u=this.parseAVCNALu(A.data),_=!1,m=this.avcSample,b,P=!1;A.data=null,m&&u.length&&!y.audFound&&(l(m,y),m=this.avcSample=a(!1,A.pts,A.dts,"")),u.forEach(function(N){switch(N.type){case 1:{b=!0,m||(m=E.avcSample=a(!0,A.pts,A.dts,"")),_&&(m.debug+="NDR "),m.frame=!0;var K=N.data;if(P&&K.length>4){var X=new D.default(K).readSliceType();(X===2||X===4||X===7||X===9)&&(m.key=!0)}break}case 5:b=!0,m||(m=E.avcSample=a(!0,A.pts,A.dts,"")),_&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{b=!0,_&&m&&(m.debug+="SEI ");var B=new D.default(O(N.data));B.readUByte();for(var S=0,Y=0,te=!1,re=0;!te&&B.bytesAvailable>1;){S=0;do re=B.readUByte(),S+=re;while(re===255);Y=0;do re=B.readUByte(),Y+=re;while(re===255);if(S===4&&B.bytesAvailable!==0){te=!0;var ce=B.readUByte();if(ce===181){var Te=B.readUShort();if(Te===49){var ye=B.readUInt();if(ye===1195456820){var be=B.readUByte();if(be===3){for(var we=B.readUByte(),xe=B.readUByte(),ve=31&we,oe=[we,xe],Re=0;Re<ve;Re++)oe.push(B.readUByte()),oe.push(B.readUByte()),oe.push(B.readUByte());d(E._txtTrack.samples,{type:3,pts:A.pts,bytes:oe})}}}}}else if(S===5&&B.bytesAvailable!==0){if(te=!0,Y>16){for(var Ye=[],Ue=0;Ue<16;Ue++)Ye.push(B.readUByte().toString(16)),(Ue===3||Ue===5||Ue===7||Ue===9)&&Ye.push("-");for(var rt=Y-16,ot=new Uint8Array(rt),Oe=0;Oe<rt;Oe++)ot[Oe]=B.readUByte();d(E._txtTrack.samples,{pts:A.pts,payloadType:S,uuid:Ye.join(""),userData:Object(G.utf8ArrayToStr)(ot),userDataBytes:ot})}}else if(Y<B.bytesAvailable)for(var Me=0;Me<Y;Me++)B.readUByte()}break}case 7:if(b=!0,P=!0,_&&m&&(m.debug+="SPS "),!y.sps){var We=new D.default(N.data),qe=We.readSPS();y.width=qe.width,y.height=qe.height,y.pixelRatio=qe.pixelRatio,y.sps=[N.data],y.duration=E._duration;for(var Ve=N.data.subarray(1,4),je="avc1.",Fe=0;Fe<3;Fe++){var ht=Ve[Fe].toString(16);ht.length<2&&(ht="0"+ht),je+=ht}y.codec=je}break;case 8:b=!0,_&&m&&(m.debug+="PPS "),y.pps||(y.pps=[N.data]);break;case 9:b=!1,y.audFound=!0,m&&l(m,y),m=E.avcSample=a(!1,A.pts,A.dts,_?"AUD ":"");break;case 12:b=!1;break;default:b=!1,m&&(m.debug+="unknown NAL "+N.type+" ");break}if(m&&b){var He=m.units;He.push(N)}}),T&&m&&(l(m,y),this.avcSample=null)},x.getLastNalUnit=function(){var A,T=this.avcSample,E;if(!T||T.units.length===0){var y=this._avcTrack.samples;T=y[y.length-1]}if((A=T)!==null&&A!==void 0&&A.units){var u=T.units;E=u[u.length-1]}return E},x.parseAVCNALu=function(A){var T=A.byteLength,E=this._avcTrack,y=E.naluState||0,u=y,_=[],m=0,b,P,N,K=-1,X=0;for(y===-1&&(K=0,X=A[0]&31,y=0,m=1);m<T;){if(b=A[m++],!y){y=b?0:1;continue}if(y===1){y=b?0:2;continue}if(!b)y=3;else if(b===1){if(K>=0){var B={data:A.subarray(K,m-y-1),type:X};_.push(B)}else{var S=this.getLastNalUnit();if(S&&(u&&m<=4-u&&(S.state&&(S.data=S.data.subarray(0,S.data.byteLength-u))),P=m-y-1,P>0)){var Y=new Uint8Array(S.data.byteLength+P);Y.set(S.data,0),Y.set(A.subarray(0,P),S.data.byteLength),S.data=Y,S.state=0}}m<T?(N=A[m]&31,K=m,X=N,y=0):y=-1}else y=0}if(K>=0&&y>=0){var te={data:A.subarray(K,T),type:X,state:y};_.push(te)}if(_.length===0){var re=this.getLastNalUnit();if(re){var ce=new Uint8Array(re.data.byteLength+A.byteLength);ce.set(re.data,0),ce.set(A,re.data.byteLength),re.data=ce}}return E.naluState=y,_},x.parseAACPES=function(A){var T=0,E=this._audioTrack,y=this.aacOverFlow,u=A.data;if(y){this.aacOverFlow=null;var _=y.sample.unit.byteLength,m=Math.min(y.missing,_),b=_-m;y.sample.unit.set(u.subarray(0,m),b),E.samples.push(y.sample),T=y.missing}var P,N;for(P=T,N=u.length;P<N-1&&!V.isHeader(u,P);P++);if(P!==T){var K,X;if(P<N-1?(K="AAC PES did not start with ADTS header,offset:"+P,X=!1):(K="no ADTS header found in AAC PES",X=!0),g.logger.warn("parsing error:"+K),this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:X,reason:K}),X)return}V.initTrackConfig(E,this.observer,u,P,this.audioCodec);var B;if(A.pts!==void 0)B=A.pts;else if(y){var S=V.getFrameDuration(E.samplerate);B=y.sample.pts+S}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Y=0;P<N;)if(V.isHeader(u,P)){if(P+5<N){var te=V.appendFrame(E,u,P,B,Y);if(te)if(te.missing)this.aacOverFlow=te;else{P+=te.length,Y++;continue}}break}else P++},x.parseMPEGPES=function(A){var T=A.data,E=T.length,y=0,u=0,_=A.pts;if(_===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;u<E;)if(F.isHeader(T,u)){var m=F.appendFrame(this._audioTrack,T,u,_,y);if(m)u+=m.length,y++;else break}else u++},x.parseID3PES=function(A){if(A.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(A)},w}();h.minProbeByteLength=188;function a(w,x,R,A){return{key:w,frame:!1,pts:x,dts:R,units:[],debug:A,length:0}}function c(w,x){return(w[x+10]&31)<<8|w[x+11]}function o(w,x,R,A){var T={audio:-1,avc:-1,id3:-1,isAAC:!0},E=(w[x+1]&15)<<8|w[x+2],y=x+3+E-4,u=(w[x+10]&15)<<8|w[x+11];for(x+=12+u;x<y;){var _=(w[x+1]&31)<<8|w[x+2];switch(w[x]){case 207:if(!A){g.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:T.audio===-1&&(T.audio=_);break;case 21:T.id3===-1&&(T.id3=_);break;case 219:if(!A){g.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:T.avc===-1&&(T.avc=_);break;case 3:case 4:R?T.audio===-1&&(T.audio=_,T.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser");break;case 36:g.logger.warn("Unsupported HEVC stream type found");break;default:break}x+=((w[x+3]&15)<<8|w[x+4])+5}return T}function s(w){var x=0,R,A,T,E,y,u=w.data;if(!w||w.size===0)return null;for(;u[0].length<19&&u.length>1;){var _=new Uint8Array(u[0].length+u[1].length);_.set(u[0]),_.set(u[1],u[0].length),u[0]=_,u.splice(1,1)}R=u[0];var m=(R[0]<<16)+(R[1]<<8)+R[2];if(m===1){if(A=(R[4]<<8)+R[5],A&&A>w.size-6)return null;var b=R[7];b&192&&(E=(R[9]&14)*536870912+(R[10]&255)*4194304+(R[11]&254)*16384+(R[12]&255)*128+(R[13]&254)/2,b&64?(y=(R[14]&14)*536870912+(R[15]&255)*4194304+(R[16]&254)*16384+(R[17]&255)*128+(R[18]&254)/2,E-y>60*9e4&&(g.logger.warn(Math.round((E-y)/9e4)+"s delta between PTS and DTS, align them"),E=y)):y=E),T=R[8];var P=T+9;if(w.size<=P)return null;w.size-=P;for(var N=new Uint8Array(w.size),K=0,X=u.length;K<X;K++){R=u[K];var B=R.byteLength;if(P)if(P>B){P-=B;continue}else R=R.subarray(P),B-=P,P=0;N.set(R,x),x+=B}return A&&(A-=T+3),{data:N,pts:E,dts:y,len:A}}return null}function l(w,x){if(w.units.length&&w.frame){if(w.pts===void 0){var R=x.samples,A=R.length;if(A){var T=R[A-1];w.pts=T.pts,w.dts=T.dts}else{x.dropped++;return}}x.samples.push(w)}w.debug.length&&g.logger.log(w.pts+"/"+w.dts+":"+w.debug)}function d(w,x){var R=w.length;if(R>0){if(x.pts>=w[R-1].pts)w.push(x);else for(var A=R-1;A>=0;A--)if(x.pts<w[A].pts){w.splice(A,0,x);break}}else w.push(x)}function O(w){for(var x=w.byteLength,R=[],A=1;A<x-2;)w[A]===0&&w[A+1]===0&&w[A+2]===3?(R.push(A+2),A+=2):A++;if(R.length===0)return w;var T=x-R.length,E=new Uint8Array(T),y=0;for(A=0;A<T;y++,A++)y===R[0]&&(y++,R.shift()),E[A]=w[y];return E}Z.default=h},"./src/errors.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"ErrorTypes",function(){return V}),k.d(Z,"ErrorDetails",function(){return F});var V;(function(D){D.NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError"})(V||(V={}));var F;(function(D){D.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"})(F||(F={}))},"./src/events.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"Events",function(){return V});var V;(function(F){F.MEDIA_ATTACHING="hlsMediaAttaching",F.MEDIA_ATTACHED="hlsMediaAttached",F.MEDIA_DETACHING="hlsMediaDetaching",F.MEDIA_DETACHED="hlsMediaDetached",F.BUFFER_RESET="hlsBufferReset",F.BUFFER_CODECS="hlsBufferCodecs",F.BUFFER_CREATED="hlsBufferCreated",F.BUFFER_APPENDING="hlsBufferAppending",F.BUFFER_APPENDED="hlsBufferAppended",F.BUFFER_EOS="hlsBufferEos",F.BUFFER_FLUSHING="hlsBufferFlushing",F.BUFFER_FLUSHED="hlsBufferFlushed",F.MANIFEST_LOADING="hlsManifestLoading",F.MANIFEST_LOADED="hlsManifestLoaded",F.MANIFEST_PARSED="hlsManifestParsed",F.LEVEL_SWITCHING="hlsLevelSwitching",F.LEVEL_SWITCHED="hlsLevelSwitched",F.LEVEL_LOADING="hlsLevelLoading",F.LEVEL_LOADED="hlsLevelLoaded",F.LEVEL_UPDATED="hlsLevelUpdated",F.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",F.LEVELS_UPDATED="hlsLevelsUpdated",F.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",F.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",F.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",F.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",F.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",F.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",F.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",F.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",F.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",F.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",F.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",F.CUES_PARSED="hlsCuesParsed",F.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",F.INIT_PTS_FOUND="hlsInitPtsFound",F.FRAG_LOADING="hlsFragLoading",F.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",F.FRAG_LOADED="hlsFragLoaded",F.FRAG_DECRYPTED="hlsFragDecrypted",F.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",F.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",F.FRAG_PARSING_METADATA="hlsFragParsingMetadata",F.FRAG_PARSED="hlsFragParsed",F.FRAG_BUFFERED="hlsFragBuffered",F.FRAG_CHANGED="hlsFragChanged",F.FPS_DROP="hlsFpsDrop",F.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",F.ERROR="hlsError",F.DESTROYING="hlsDestroying",F.KEY_LOADING="hlsKeyLoading",F.KEY_LOADED="hlsKeyLoaded",F.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",F.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return w});var V=k("./node_modules/url-toolkit/src/url-toolkit.js"),F=k.n(V),D=k("./src/loader/playlist-loader.ts"),G=k("./src/loader/key-loader.ts"),j=k("./src/controller/id3-track-controller.ts"),M=k("./src/controller/latency-controller.ts"),I=k("./src/controller/level-controller.ts"),g=k("./src/controller/fragment-tracker.ts"),p=k("./src/controller/stream-controller.ts"),f=k("./src/is-supported.ts"),h=k("./src/utils/logger.ts"),a=k("./src/config.ts"),c=k("./node_modules/eventemitter3/index.js"),o=k.n(c),s=k("./src/events.ts"),l=k("./src/errors.ts");function d(x,R){for(var A=0;A<R.length;A++){var T=R[A];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(x,T.key,T)}}function O(x,R,A){return R&&d(x.prototype,R),A&&d(x,A),x}var w=function(){x.isSupported=function(){return Object(f.isSupported)()};function x(A){A===void 0&&(A={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new c.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 T=this.config=Object(a.mergeConfig)(x.DefaultConfig,A);this.userConfig=A,Object(h.enableLogs)(T.debug),this._autoLevelCapping=-1,T.progressive&&Object(a.enableStreamingMode)(T);var E=T.abrController,y=T.bufferController,u=T.capLevelController,_=T.fpsController,m=this.abrController=new E(this),b=this.bufferController=new y(this),P=this.capLevelController=new u(this),N=new _(this),K=new D.default(this),X=new G.default(this),B=new j.default(this),S=this.levelController=new I.default(this),Y=new g.FragmentTracker(this),te=this.streamController=new p.default(this,Y);P.setStreamController(te),N.setStreamController(te);var re=[S,te];this.networkControllers=re;var ce=[K,X,m,b,P,N,B,Y];this.audioTrackController=this.createController(T.audioTrackController,null,re),this.createController(T.audioStreamController,Y,re),this.subtitleTrackController=this.createController(T.subtitleTrackController,null,re),this.createController(T.subtitleStreamController,Y,re),this.createController(T.timelineController,null,ce),this.emeController=this.createController(T.emeController,null,ce),this.cmcdController=this.createController(T.cmcdController,null,ce),this.latencyController=this.createController(M.default,null,ce),this.coreComponents=ce}var R=x.prototype;return R.createController=function(T,E,y){if(T){var u=E?new T(this,E):new T(this);return y&&y.push(u),u}return null},R.on=function(T,E,y){y===void 0&&(y=this),this._emitter.on(T,E,y)},R.once=function(T,E,y){y===void 0&&(y=this),this._emitter.once(T,E,y)},R.removeAllListeners=function(T){this._emitter.removeAllListeners(T)},R.off=function(T,E,y,u){y===void 0&&(y=this),this._emitter.off(T,E,y,u)},R.listeners=function(T){return this._emitter.listeners(T)},R.emit=function(T,E,y){return this._emitter.emit(T,E,y)},R.trigger=function(T,E){if(this.config.debug)return this.emit(T,T,E);try{return this.emit(T,T,E)}catch(y){h.logger.error("An internal error happened while handling event "+T+'. Error message: "'+y.message+'". Here is a stacktrace:',y),this.trigger(s.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:T,error:y})}return!1},R.listenerCount=function(T){return this._emitter.listenerCount(T)},R.destroy=function(){h.logger.log("destroy"),this.trigger(s.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(T){return T.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(T){return T.destroy()}),this.coreComponents.length=0},R.attachMedia=function(T){h.logger.log("attachMedia"),this._media=T,this.trigger(s.Events.MEDIA_ATTACHING,{media:T})},R.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(s.Events.MEDIA_DETACHING,void 0),this._media=null},R.loadSource=function(T){this.stopLoad();var E=this.media,y=this.url,u=this.url=V.buildAbsoluteURL(self.location.href,T,{alwaysNormalize:!0});h.logger.log("loadSource:"+u),E&&y&&y!==u&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(E)),this.trigger(s.Events.MANIFEST_LOADING,{url:T})},R.startLoad=function(T){T===void 0&&(T=-1),h.logger.log("startLoad("+T+")"),this.networkControllers.forEach(function(E){E.startLoad(T)})},R.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach(function(T){T.stopLoad()})},R.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},R.recoverMediaError=function(){h.logger.log("recoverMediaError");var T=this._media;this.detachMedia(),T&&this.attachMedia(T)},R.removeLevel=function(T,E){E===void 0&&(E=0),this.levelController.removeLevel(T,E)},O(x,[{key:"levels",get:function(){var T=this.levelController.levels;return T||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(T){h.logger.log("set currentLevel:"+T),this.loadLevel=T,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(T){h.logger.log("set nextLevel:"+T),this.levelController.manualLevel=T,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(T){h.logger.log("set loadLevel:"+T),this.levelController.manualLevel=T}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(T){this.levelController.nextLoadLevel=T}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(T){h.logger.log("set firstLevel:"+T),this.levelController.firstLevel=T}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(T){h.logger.log("set startLevel:"+T),T!==-1&&(T=Math.max(T,this.minAutoLevel)),this.levelController.startLevel=T}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(T){var E=!!T;E!==this.config.capLevelToPlayerSize&&(E?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=E)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(T){this._autoLevelCapping!==T&&(h.logger.log("set autoLevelCapping:"+T),this._autoLevelCapping=T)}},{key:"bandwidthEstimate",get:function(){var T=this.abrController.bwEstimator;return T?T.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var T=this.levels,E=this.config.minAutoBitrate;if(!T)return 0;for(var y=T.length,u=0;u<y;u++)if(T[u].maxBitrate>E)return u;return 0}},{key:"maxAutoLevel",get:function(){var T=this.levels,E=this.autoLevelCapping,y;return E===-1&&T&&T.length?y=T.length-1:y=E,y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(T){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,T)}},{key:"audioTracks",get:function(){var T=this.audioTrackController;return T?T.audioTracks:[]}},{key:"audioTrack",get:function(){var T=this.audioTrackController;return T?T.audioTrack:-1},set:function(T){var E=this.audioTrackController;E&&(E.audioTrack=T)}},{key:"subtitleTracks",get:function(){var T=this.subtitleTrackController;return T?T.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var T=this.subtitleTrackController;return T?T.subtitleTrack:-1},set:function(T){var E=this.subtitleTrackController;E&&(E.subtitleTrack=T)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var T=this.subtitleTrackController;return T?T.subtitleDisplay:!1},set:function(T){var E=this.subtitleTrackController;E&&(E.subtitleDisplay=T)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(T){this.config.lowLatencyMode=T}},{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 s.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return x.defaultConfig?x.defaultConfig:a.hlsDefaultConfig},set:function(T){x.defaultConfig=T}}]),x}();w.defaultConfig=void 0},"./src/is-supported.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"isSupported",function(){return D}),k.d(Z,"changeTypeSupported",function(){return G});var V=k("./src/utils/mediasource-helper.ts");function F(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var j=Object(V.getMediaSource)();if(!j)return!1;var M=F(),I=j&&typeof j.isTypeSupported=="function"&&j.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!I&&!!g}function G(){var j,M=F();return typeof(M==null||((j=M.prototype)===null||j===void 0)?void 0:j.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return h}),k.d(Z,"LoadError",function(){return c});var V=k("./src/polyfills/number.ts"),F=k("./src/errors.ts");function D(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,g(o,s)}function G(o){var s=typeof Map=="function"?new Map:void 0;return G=function(d){if(d===null||!I(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof s!="undefined"){if(s.has(d))return s.get(d);s.set(d,O)}function O(){return j(d,arguments,p(this).constructor)}return O.prototype=Object.create(d.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),g(O,d)},G(o)}function j(o,s,l){return M()?j=Reflect.construct:j=function(O,w,x){var R=[null];R.push.apply(R,w);var A=Function.bind.apply(O,R),T=new A;return x&&g(T,x.prototype),T},j.apply(null,arguments)}function M(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(o){return!1}}function I(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function g(o,s){return g=Object.setPrototypeOf||function(d,O){return d.__proto__=O,d},g(o,s)}function p(o){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},p(o)}var f=Math.pow(2,17),h=function(){function o(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var s=o.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(d,O){var w=this,x=d.url;if(!x)return Promise.reject(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(x?"part list":"url")));this.abort();var R=this.config,A=R.fLoader,T=R.loader;return new Promise(function(E,y){w.loader&&w.loader.destroy();var u=w.loader=d.loader=A?new A(R):new T(R),_=a(d),m={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout,highWaterMark:f};d.stats=u.stats,u.load(_,m,{onSuccess:function(P,N,K,X){w.resetLoader(d,u),E({frag:d,part:null,payload:P.data,networkDetails:X})},onError:function(P,N,K){w.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:P,networkDetails:K}))},onAbort:function(P,N,K){w.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:K}))},onTimeout:function(P,N,K){w.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:K}))},onProgress:function(P,N,K,X){O&&O({frag:d,part:null,payload:K,networkDetails:X})}})})},s.loadPart=function(d,O,w){var x=this;this.abort();var R=this.config,A=R.fLoader,T=R.loader;return new Promise(function(E,y){x.loader&&x.loader.destroy();var u=x.loader=d.loader=A?new A(R):new T(R),_=a(d,O),m={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout,highWaterMark:f};O.stats=u.stats,u.load(_,m,{onSuccess:function(P,N,K,X){x.resetLoader(d,u),x.updateStatsFromPart(d,O);var B={frag:d,part:O,payload:P.data,networkDetails:X};w(B),E(B)},onError:function(P,N,K){x.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:O,response:P,networkDetails:K}))},onAbort:function(P,N,K){d.stats.aborted=O.stats.aborted,x.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:O,networkDetails:K}))},onTimeout:function(P,N,K){x.resetLoader(d,u),y(new c({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:O,networkDetails:K}))}})})},s.updateStatsFromPart=function(d,O){var w=d.stats,x=O.stats,R=x.total;if(w.loaded+=x.loaded,R){var A=Math.round(d.duration/O.duration),T=Math.min(Math.round(w.loaded/R),A),E=A-T,y=E*Math.round(w.loaded/T);w.total=w.loaded+y}else w.total=Math.max(w.loaded,w.total);var u=w.loading,_=x.loading;u.start?u.first+=_.first-_.start:(u.start=_.start,u.first=_.first),u.end=_.end},s.resetLoader=function(d,O){d.loader=null,this.loader===O&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),O.destroy()},o}();function a(o,s){s===void 0&&(s=null);var l=s||o,d={frag:o,part:s,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},O=l.byteRangeStartOffset,w=l.byteRangeEndOffset;return Object(V.isFiniteNumber)(O)&&Object(V.isFiniteNumber)(w)&&(d.rangeStart=O,d.rangeEnd=w),d}var c=function(o){D(s,o);function s(l){for(var d,O=arguments.length,w=new Array(O>1?O-1:0),x=1;x<O;x++)w[x-1]=arguments[x];return d=o.call.apply(o,[this].concat(w))||this,d.data=void 0,d.data=l,d}return s}(G(Error))},"./src/loader/fragment.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"ElementaryStreamTypes",function(){return h}),k.d(Z,"BaseSegment",function(){return a}),k.d(Z,"Fragment",function(){return c}),k.d(Z,"Part",function(){return o});var V=k("./src/polyfills/number.ts"),F=k("./node_modules/url-toolkit/src/url-toolkit.js"),D=k.n(F),G=k("./src/utils/logger.ts"),j=k("./src/loader/level-key.ts"),M=k("./src/loader/load-stats.ts");function I(s,l){s.prototype=Object.create(l.prototype),s.prototype.constructor=s,g(s,l)}function g(s,l){return g=Object.setPrototypeOf||function(O,w){return O.__proto__=w,O},g(s,l)}function p(s,l){for(var d=0;d<l.length;d++){var O=l[d];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(s,O.key,O)}}function f(s,l,d){return l&&p(s.prototype,l),d&&p(s,d),s}var h;(function(s){s.AUDIO="audio",s.VIDEO="video",s.AUDIOVIDEO="audiovideo"})(h||(h={}));var a=function(){function s(d){var O;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(O={},O[h.AUDIO]=null,O[h.VIDEO]=null,O[h.AUDIOVIDEO]=null,O),this.baseurl=d}var l=s.prototype;return l.setByteRange=function(O,w){var x=O.split("@",2),R=[];x.length===1?R[0]=w?w.byteRangeEndOffset:0:R[0]=parseInt(x[1]),R[1]=parseInt(x[0])+R[0],this._byteRange=R},f(s,[{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(F.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(O){this._url=O}}]),s}(),c=function(s){I(l,s);function l(O,w){var x;return x=s.call(this,w)||this,x._decryptdata=null,x.rawProgramDateTime=null,x.programDateTime=null,x.tagList=[],x.duration=0,x.sn=0,x.levelkey=void 0,x.type=void 0,x.loader=null,x.level=-1,x.cc=0,x.startPTS=void 0,x.endPTS=void 0,x.appendedPTS=void 0,x.startDTS=void 0,x.endDTS=void 0,x.start=0,x.deltaPTS=void 0,x.maxStartPTS=void 0,x.minEndPTS=void 0,x.stats=new M.LoadStats,x.urlId=0,x.data=void 0,x.bitrateTest=!1,x.title=null,x.initSegment=null,x.type=O,x}var d=l.prototype;return d.createInitializationVector=function(w){for(var x=new Uint8Array(16),R=12;R<16;R++)x[R]=w>>8*(15-R)&255;return x},d.setDecryptDataFromLevelKey=function(w,x){var R=w;return(w==null?void 0:w.method)==="AES-128"&&w.uri&&!w.iv&&(R=j.LevelKey.fromURI(w.uri),R.method=w.method,R.iv=this.createInitializationVector(x),R.keyFormat="identity"),R},d.setElementaryStreamInfo=function(w,x,R,A,T,E){E===void 0&&(E=!1);var y=this.elementaryStreams,u=y[w];if(!u){y[w]={startPTS:x,endPTS:R,startDTS:A,endDTS:T,partial:E};return}u.startPTS=Math.min(u.startPTS,x),u.endPTS=Math.max(u.endPTS,R),u.startDTS=Math.min(u.startDTS,A),u.endDTS=Math.max(u.endDTS,T)},d.clearElementaryStreamInfo=function(){var w=this.elementaryStreams;w[h.AUDIO]=null,w[h.VIDEO]=null,w[h.AUDIOVIDEO]=null},f(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var w=this.sn;typeof w!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&G.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),w=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,w)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(V.isFiniteNumber)(this.programDateTime))return null;var w=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+w*1e3}},{key:"encrypted",get:function(){var w;return!!((w=this.decryptdata)!==null&&w!==void 0&&w.keyFormat&&this.decryptdata.uri)}}]),l}(a),o=function(s){I(l,s);function l(d,O,w,x,R){var A;A=s.call(this,w)||this,A.fragOffset=0,A.duration=0,A.gap=!1,A.independent=!1,A.relurl=void 0,A.fragment=void 0,A.index=void 0,A.stats=new M.LoadStats,A.duration=d.decimalFloatingPoint("DURATION"),A.gap=d.bool("GAP"),A.independent=d.bool("INDEPENDENT"),A.relurl=d.enumeratedString("URI"),A.fragment=O,A.index=x;var T=d.enumeratedString("BYTERANGE");return T&&A.setByteRange(T,R),R&&(A.fragOffset=R.fragOffset+R.duration),A}return f(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 O=this.elementaryStreams;return!!(O.audio||O.video||O.audiovideo)}}]),l}(a)},"./src/loader/key-loader.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return G});var V=k("./src/events.ts"),F=k("./src/errors.ts"),D=k("./src/utils/logger.ts"),G=function(){function j(I){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=I,this._registerListeners()}var M=j.prototype;return M._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},M._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},M.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var p=this.loaders[g];p&&p.destroy()}this.loaders={}},M.onKeyLoading=function(g,p){var f=p.frag,h=f.type,a=this.loaders[h];if(!f.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var c=f.decryptdata.uri;if(c!==this.decrypturl||this.decryptkey===null){var o=this.hls.config;if(a&&(D.logger.warn("abort previous key loader for type:"+h),a.abort()),!c){D.logger.warn("key uri is falsy");return}var s=o.loader,l=f.loader=this.loaders[h]=new s(o);this.decrypturl=c,this.decryptkey=null;var d={url:c,frag:f,responseType:"arraybuffer"},O={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:0},w={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(d,O,w)}else this.decryptkey&&(f.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:f}))},M.loadsuccess=function(g,p,f){var h=f.frag;if(!h.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=h.decryptdata.key=new Uint8Array(g.data),h.loader=null,delete this.loaders[h.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:h})},M.loaderror=function(g,p){var f=p.frag,h=f.loader;h&&h.abort(),delete this.loaders[f.type],this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:f,response:g})},M.loadtimeout=function(g,p){var f=p.frag,h=f.loader;h&&h.abort(),delete this.loaders[f.type],this.hls.trigger(V.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:f})},j}()},"./src/loader/level-details.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"LevelDetails",function(){return j});var V=k("./src/polyfills/number.ts");function F(M,I){for(var g=0;g<I.length;g++){var p=I[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(M,p.key,p)}}function D(M,I,g){return I&&F(M.prototype,I),g&&F(M,g),M}var G=10,j=function(){function M(g){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=g}var I=M.prototype;return I.reloaded=function(p){if(!p){this.advanced=!0,this.updated=!0;return}var f=this.lastPartSn-p.lastPartSn,h=this.lastPartIndex-p.lastPartIndex;this.updated=this.endSN!==p.endSN||!!h||!!f,this.advanced=this.endSN>p.endSN||f>0||f===0&&h>0,this.updated||this.advanced?this.misses=Math.floor(p.misses*.6):this.misses=p.misses+1,this.availabilityDelay=p.availabilityDelay},D(M,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(V.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||G}},{key:"drift",get:function(){var p=this.driftEndTime-this.driftStartTime;if(p>0){var f=this.driftEnd-this.driftStart;return f*1e3/p}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var p;return(p=this.partList)!==null&&p!==void 0&&p.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var p;return(p=this.fragments)!==null&&p!==void 0&&p.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 p;return(p=this.partList)!==null&&p!==void 0&&p.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var p;return(p=this.partList)!==null&&p!==void 0&&p.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),M}()},"./src/loader/level-key.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"LevelKey",function(){return j});var V=k("./node_modules/url-toolkit/src/url-toolkit.js"),F=k.n(V);function D(M,I){for(var g=0;g<I.length;g++){var p=I[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(M,p.key,p)}}function G(M,I,g){return I&&D(M.prototype,I),g&&D(M,g),M}var j=function(){M.fromURL=function(g,p){return new M(g,p)},M.fromURI=function(g){return new M(g)};function M(I,g){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,g?this._uri=Object(V.buildAbsoluteURL)(I,g,{alwaysNormalize:!0}):this._uri=I}return G(M,[{key:"uri",get:function(){return this._uri}}]),M}()},"./src/loader/load-stats.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"LoadStats",function(){return V});var V=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return l});var V=k("./src/polyfills/number.ts"),F=k("./node_modules/url-toolkit/src/url-toolkit.js"),D=k.n(F),G=k("./src/loader/fragment.ts"),j=k("./src/loader/level-details.ts"),M=k("./src/loader/level-key.ts"),I=k("./src/utils/attr-list.ts"),g=k("./src/utils/logger.ts"),p=k("./src/utils/codecs.ts"),f=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,h=/#EXT-X-MEDIA:(.*)/g,a=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),c=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("|")),o=/\.(mp4|m4s|m4v|m4a)$/i;function s(R){var A,T;return o.test((A=(T=F.parseURL(R))===null||T===void 0?void 0:T.path)!=null?A:"")}var l=function(){function R(){}return R.findGroup=function(T,E){for(var y=0;y<T.length;y++){var u=T[y];if(u.id===E)return u}},R.convertAVC1ToAVCOTI=function(T){var E=T.split(".");if(E.length>2){var y=E.shift()+".";return y+=parseInt(E.shift()).toString(16),y+=("000"+parseInt(E.shift()).toString(16)).substr(-4),y}return T},R.resolve=function(T,E){return F.buildAbsoluteURL(E,T,{alwaysNormalize:!0})},R.parseMasterPlaylist=function(T,E){var y=[],u={},_=!1;f.lastIndex=0;for(var m;(m=f.exec(T))!=null;)if(m[1]){var b=new I.AttrList(m[1]),P={attrs:b,bitrate:b.decimalInteger("AVERAGE-BANDWIDTH")||b.decimalInteger("BANDWIDTH"),name:b.NAME,url:R.resolve(m[2],E)},N=b.decimalResolution("RESOLUTION");N&&(P.width=N.width,P.height=N.height),d((b.CODECS||"").split(/[ ,]+/).filter(function(X){return X}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=R.convertAVC1ToAVCOTI(P.videoCodec)),y.push(P)}else if(m[3]){var K=new I.AttrList(m[3]);K["DATA-ID"]&&(_=!0,u[K["DATA-ID"]]=K)}return{levels:y,sessionData:_?u:null}},R.parseMasterPlaylistMedia=function(T,E,y,u){u===void 0&&(u=[]);var _,m=[],b=0;for(h.lastIndex=0;(_=h.exec(T))!==null;){var P=new I.AttrList(_[1]);if(P.TYPE===y){var N={attrs:P,bitrate:0,id:b++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:y,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?R.resolve(P.URI,E):""};if(u.length){var K=R.findGroup(u,N.groupId)||u[0];O(N,K,"audioCodec"),O(N,K,"textCodec")}m.push(N)}}return m},R.parseLevelPlaylist=function(T,E,y,u,_){var m=new j.LevelDetails(E),b=m.fragments,P=null,N=0,K=0,X=0,B=0,S=null,Y=new G.Fragment(u,E),te,re,ce,Te=-1,ye=!1;for(a.lastIndex=0,m.m3u8=T;(te=a.exec(T))!==null;){ye&&(ye=!1,Y=new G.Fragment(u,E),Y.start=X,Y.sn=N,Y.cc=B,Y.level=y,P&&(Y.initSegment=P,Y.rawProgramDateTime=P.rawProgramDateTime));var be=te[1];if(be){Y.duration=parseFloat(be);var we=(" "+te[2]).slice(1);Y.title=we||null,Y.tagList.push(we?["INF",be,we]:["INF",be])}else if(te[3])Object(V.isFiniteNumber)(Y.duration)&&(Y.start=X,ce&&(Y.levelkey=ce),Y.sn=N,Y.level=y,Y.cc=B,Y.urlId=_,b.push(Y),Y.relurl=(" "+te[3]).slice(1),x(Y,S),S=Y,X+=Y.duration,N++,K=0,ye=!0);else if(te[4]){var xe=(" "+te[4]).slice(1);S?Y.setByteRange(xe,S):Y.setByteRange(xe)}else if(te[5])Y.rawProgramDateTime=(" "+te[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),Te===-1&&(Te=b.length);else{if(te=te[0].match(c),!te){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(re=1;re<te.length&&!(typeof te[re]!="undefined");re++);var ve=(" "+te[re]).slice(1),oe=(" "+te[re+1]).slice(1),Re=te[re+2]?(" "+te[re+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":m.type=oe.toUpperCase();break;case"MEDIA-SEQUENCE":N=m.startSN=parseInt(oe);break;case"SKIP":{var Ye=new I.AttrList(oe),Ue=Ye.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(Ue)){m.skippedSegments=Ue;for(var rt=Ue;rt--;)b.unshift(null);N+=Ue}var ot=Ye.enumeratedString("RECENTLY-REMOVED-DATERANGES");ot&&(m.recentlyRemovedDateranges=ot.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(oe);break;case"VERSION":m.version=parseInt(oe);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(oe||Re)&&Y.tagList.push(Re?[oe,Re]:[oe]);break;case"DIS":B++;case"GAP":Y.tagList.push([ve]);break;case"BITRATE":Y.tagList.push([ve,oe]);break;case"DISCONTINUITY-SEQ":B=parseInt(oe);break;case"KEY":{var Oe,Me=new I.AttrList(oe),We=Me.enumeratedString("METHOD"),qe=Me.URI,Ve=Me.hexadecimalInteger("IV"),je=Me.enumeratedString("KEYFORMATVERSIONS"),Fe=Me.enumeratedString("KEYID"),ht=(Oe=Me.enumeratedString("KEYFORMAT"))!=null?Oe:"identity",He=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(He.indexOf(ht)>-1){g.logger.warn("Keyformat "+ht+" is not supported from the manifest");continue}else if(ht!=="identity")continue;We&&(ce=M.LevelKey.fromURL(E,qe),qe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(We)>=0&&(ce.method=We,ce.keyFormat=ht,Fe&&(ce.keyID=Fe),je&&(ce.keyFormatVersions=je),ce.iv=Ve));break}case"START":{var Pe=new I.AttrList(oe),Xe=Pe.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(Xe)&&(m.startTimeOffset=Xe);break}case"MAP":{var tt=new I.AttrList(oe);Y.relurl=tt.URI,tt.BYTERANGE&&Y.setByteRange(tt.BYTERANGE),Y.level=y,Y.sn="initSegment",ce&&(Y.levelkey=ce),Y.initSegment=null,P=Y,ye=!0;break}case"SERVER-CONTROL":{var Ke=new I.AttrList(oe);m.canBlockReload=Ke.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=Ke.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&Ke.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=Ke.optionalFloat("PART-HOLD-BACK",0),m.holdBack=Ke.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var et=new I.AttrList(oe);m.partTarget=et.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ae=m.partList;Ae||(Ae=m.partList=[]);var nt=K>0?Ae[Ae.length-1]:void 0,Je=K++,Se=new G.Part(new I.AttrList(oe),Y,E,Je,nt);Ae.push(Se),Y.duration+=Se.duration;break}case"PRELOAD-HINT":{var ke=new I.AttrList(oe);m.preloadHint=ke;break}case"RENDITION-REPORT":{var me=new I.AttrList(oe);m.renditionReports=m.renditionReports||[],m.renditionReports.push(me);break}default:g.logger.warn("line parsed but not handled: "+te);break}}}S&&!S.relurl?(b.pop(),X-=S.duration,m.partList&&(m.fragmentHint=S)):m.partList&&(x(Y,S),Y.cc=B,m.fragmentHint=Y);var he=b.length,de=b[0],ie=b[he-1];if(X+=m.skippedSegments*m.targetduration,X>0&&he&&ie){m.averagetargetduration=X/he;var q=ie.sn;m.endSN=q!=="initSegment"?q:0,de&&(m.startCC=de.cc,de.initSegment||m.fragments.every(function(se){return se.relurl&&s(se.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new G.Fragment(u,E),Y.relurl=ie.relurl,Y.level=y,Y.sn="initSegment",de.initSegment=Y,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(X+=m.fragmentHint.duration),m.totalduration=X,m.endCC=B,Te>0&&w(b,Te),m},R}();function d(R,A){["video","audio","text"].forEach(function(T){var E=R.filter(function(u){return Object(p.isCodecType)(u,T)});if(E.length){var y=E.filter(function(u){return u.lastIndexOf("avc1",0)===0||u.lastIndexOf("mp4a",0)===0});A[T+"Codec"]=y.length>0?y[0]:E[0],R=R.filter(function(u){return E.indexOf(u)===-1})}}),A.unknownCodecs=R}function O(R,A,T){var E=A[T];E&&(R[T]=E)}function w(R,A){for(var T=R[A],E=A;E--;){var y=R[E];if(!y)return;y.programDateTime=T.programDateTime-y.duration*1e3,T=y}}function x(R,A){R.rawProgramDateTime?R.programDateTime=Date.parse(R.rawProgramDateTime):A!=null&&A.programDateTime&&(R.programDateTime=A.endProgramDateTime),Object(V.isFiniteNumber)(R.programDateTime)||(R.programDateTime=null,R.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/polyfills/number.ts"),F=k("./src/events.ts"),D=k("./src/errors.ts"),G=k("./src/utils/logger.ts"),j=k("./src/utils/mp4-tools.ts"),M=k("./src/loader/m3u8-parser.ts"),I=k("./src/types/loader.ts"),g=k("./src/utils/attr-list.ts");function p(a){var c=a.type;switch(c){case I.PlaylistContextType.AUDIO_TRACK:return I.PlaylistLevelType.AUDIO;case I.PlaylistContextType.SUBTITLE_TRACK:return I.PlaylistLevelType.SUBTITLE;default:return I.PlaylistLevelType.MAIN}}function f(a,c){var o=a.url;return(o===void 0||o.indexOf("data:")===0)&&(o=c.url),o}var h=function(){function a(o){this.hls=void 0,this.loaders=Object.create(null),this.hls=o,this.registerListeners()}var c=a.prototype;return c.registerListeners=function(){var s=this.hls;s.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(F.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),s.on(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},c.unregisterListeners=function(){var s=this.hls;s.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(F.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),s.off(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},c.createInternalLoader=function(s){var l=this.hls.config,d=l.pLoader,O=l.loader,w=d||O,x=new w(l);return s.loader=x,this.loaders[s.type]=x,x},c.getInternalLoader=function(s){return this.loaders[s.type]},c.resetInternalLoader=function(s){this.loaders[s]&&delete this.loaders[s]},c.destroyInternalLoaders=function(){for(var s in this.loaders){var l=this.loaders[s];l&&l.destroy(),this.resetInternalLoader(s)}},c.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},c.onManifestLoading=function(s,l){var d=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:I.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},c.onLevelLoading=function(s,l){var d=l.id,O=l.level,w=l.url,x=l.deliveryDirectives;this.load({id:d,groupId:null,level:O,responseType:"text",type:I.PlaylistContextType.LEVEL,url:w,deliveryDirectives:x})},c.onAudioTrackLoading=function(s,l){var d=l.id,O=l.groupId,w=l.url,x=l.deliveryDirectives;this.load({id:d,groupId:O,level:null,responseType:"text",type:I.PlaylistContextType.AUDIO_TRACK,url:w,deliveryDirectives:x})},c.onSubtitleTrackLoading=function(s,l){var d=l.id,O=l.groupId,w=l.url,x=l.deliveryDirectives;this.load({id:d,groupId:O,level:null,responseType:"text",type:I.PlaylistContextType.SUBTITLE_TRACK,url:w,deliveryDirectives:x})},c.load=function(s){var l,d=this.hls.config,O=this.getInternalLoader(s);if(O){var w=O.context;if(w&&w.url===s.url){G.logger.trace("[playlist-loader]: playlist request ongoing");return}G.logger.log("[playlist-loader]: aborting previous loader for type: "+s.type),O.abort()}var x,R,A,T;switch(s.type){case I.PlaylistContextType.MANIFEST:x=d.manifestLoadingMaxRetry,R=d.manifestLoadingTimeOut,A=d.manifestLoadingRetryDelay,T=d.manifestLoadingMaxRetryTimeout;break;case I.PlaylistContextType.LEVEL:case I.PlaylistContextType.AUDIO_TRACK:case I.PlaylistContextType.SUBTITLE_TRACK:x=0,R=d.levelLoadingTimeOut;break;default:x=d.levelLoadingMaxRetry,R=d.levelLoadingTimeOut,A=d.levelLoadingRetryDelay,T=d.levelLoadingMaxRetryTimeout;break}if(O=this.createInternalLoader(s),(l=s.deliveryDirectives)!==null&&l!==void 0&&l.part){var E;if(s.type===I.PlaylistContextType.LEVEL&&s.level!==null?E=this.hls.levels[s.level].details:s.type===I.PlaylistContextType.AUDIO_TRACK&&s.id!==null?E=this.hls.audioTracks[s.id].details:s.type===I.PlaylistContextType.SUBTITLE_TRACK&&s.id!==null&&(E=this.hls.subtitleTracks[s.id].details),E){var y=E.partTarget,u=E.targetduration;y&&u&&(R=Math.min(Math.max(y*3,u*.8)*1e3,R))}}var _={timeout:R,maxRetry:x,retryDelay:A,maxRetryDelay:T,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};O.load(s,_,m)},c.loadsuccess=function(s,l,d,O){if(O===void 0&&(O=null),d.isSidxRequest){this.handleSidxRequest(s,d),this.handlePlaylistLoaded(s,l,d,O);return}this.resetInternalLoader(d.type);var w=s.data;if(w.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(s,d,"no EXTM3U delimiter",O);return}l.parsing.start=performance.now(),w.indexOf("#EXTINF:")>0||w.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(s,l,d,O):this.handleMasterPlaylist(s,l,d,O)},c.loaderror=function(s,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!1,s)},c.loadtimeout=function(s,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!0)},c.handleMasterPlaylist=function(s,l,d,O){var w=this.hls,x=s.data,R=f(s,d),A=M.default.parseMasterPlaylist(x,R),T=A.levels,E=A.sessionData;if(!T.length){this.handleManifestParsingError(s,d,"no level found in manifest",O);return}var y=T.map(function(N){return{id:N.attrs.AUDIO,audioCodec:N.audioCodec}}),u=T.map(function(N){return{id:N.attrs.SUBTITLES,textCodec:N.textCodec}}),_=M.default.parseMasterPlaylistMedia(x,R,"AUDIO",y),m=M.default.parseMasterPlaylistMedia(x,R,"SUBTITLES",u),b=M.default.parseMasterPlaylistMedia(x,R,"CLOSED-CAPTIONS");if(_.length){var P=_.some(function(N){return!N.url});!P&&T[0].audioCodec&&!T[0].attrs.AUDIO&&(G.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),_.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new g.AttrList({}),bitrate:0,url:""}))}w.trigger(F.Events.MANIFEST_LOADED,{levels:T,audioTracks:_,subtitles:m,captions:b,url:R,stats:l,networkDetails:O,sessionData:E})},c.handleTrackOrLevelPlaylist=function(s,l,d,O){var w=this.hls,x=d.id,R=d.level,A=d.type,T=f(s,d),E=Object(V.isFiniteNumber)(x)?x:0,y=Object(V.isFiniteNumber)(R)?R:E,u=p(d),_=M.default.parseLevelPlaylist(s.data,T,y,u,E);if(!_.fragments.length){w.trigger(F.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:T,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(A===I.PlaylistContextType.MANIFEST){var m={attrs:new g.AttrList({}),bitrate:0,details:_,name:"",url:T};w.trigger(F.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:T,stats:l,networkDetails:O,sessionData:null})}if(l.parsing.end=performance.now(),_.needSidxRanges){var b,P=(b=_.fragments[0].initSegment)===null||b===void 0?void 0:b.url;this.load({url:P,isSidxRequest:!0,type:A,level:R,levelDetails:_,id:x,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=_,this.handlePlaylistLoaded(s,l,d,O)},c.handleSidxRequest=function(s,l){var d=Object(j.parseSegmentIndex)(new Uint8Array(s.data));if(!d)return;var O=d.references,w=l.levelDetails;O.forEach(function(x,R){var A=x.info,T=w.fragments[R];T.byteRange.length===0&&T.setByteRange(String(1+A.end-A.start)+"@"+String(A.start)),T.initSegment&&T.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},c.handleManifestParsingError=function(s,l,d,O){this.hls.trigger(F.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===I.PlaylistContextType.MANIFEST,url:s.url,reason:d,response:s,context:l,networkDetails:O})},c.handleNetworkError=function(s,l,d,O){d===void 0&&(d=!1),G.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+s.type+" level: "+s.level+" id: "+s.id+' group-id: "'+s.groupId+'"');var w=D.ErrorDetails.UNKNOWN,x=!1,R=this.getInternalLoader(s);switch(s.type){case I.PlaylistContextType.MANIFEST:w=d?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,x=!0;break;case I.PlaylistContextType.LEVEL:w=d?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,x=!1;break;case I.PlaylistContextType.AUDIO_TRACK:w=d?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,x=!1;break;case I.PlaylistContextType.SUBTITLE_TRACK:w=d?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,x=!1;break}R&&this.resetInternalLoader(s.type);var A={type:D.ErrorTypes.NETWORK_ERROR,details:w,fatal:x,url:s.url,loader:R,context:s,networkDetails:l};O&&(A.response=O),this.hls.trigger(F.Events.ERROR,A)},c.handlePlaylistLoaded=function(s,l,d,O){var w=d.type,x=d.level,R=d.id,A=d.groupId,T=d.loader,E=d.levelDetails,y=d.deliveryDirectives;if(!(E!=null&&E.targetduration)){this.handleManifestParsingError(s,d,"invalid target duration",O);return}if(!T)return;E.live&&(T.getCacheAge&&(E.ageHeader=T.getCacheAge()||0),(!T.getCacheAge||isNaN(E.ageHeader))&&(E.ageHeader=0));switch(w){case I.PlaylistContextType.MANIFEST:case I.PlaylistContextType.LEVEL:this.hls.trigger(F.Events.LEVEL_LOADED,{details:E,level:x||0,id:R||0,stats:l,networkDetails:O,deliveryDirectives:y});break;case I.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(F.Events.AUDIO_TRACK_LOADED,{details:E,id:R||0,groupId:A||"",stats:l,networkDetails:O,deliveryDirectives:y});break;case I.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(F.Events.SUBTITLE_TRACK_LOADED,{details:E,id:R||0,groupId:A||"",stats:l,networkDetails:O,deliveryDirectives:y});break}},a}();Z.default=h},"./src/polyfills/number.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"isFiniteNumber",function(){return V}),k.d(Z,"MAX_SAFE_INTEGER",function(){return F});var V=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},F=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ae,Z,k){"use strict";k.r(Z);var V=function(){function F(){}return F.getSilentFrame=function(G,j){switch(G){case"mp4a.40.2":if(j===1)return new Uint8Array([0,200,0,128,35,128]);if(j===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(j===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(j===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(j===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(j===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(j===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(j===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(j===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},F}();Z.default=V},"./src/remux/mp4-generator.ts":function(ae,Z,k){"use strict";k.r(Z);var V=Math.pow(2,32)-1,F=function(){function D(){}return D.init=function(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var j;for(j in D.types)D.types.hasOwnProperty(j)&&(D.types[j]=[j.charCodeAt(0),j.charCodeAt(1),j.charCodeAt(2),j.charCodeAt(3)]);var M=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),I=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);D.HDLR_TYPES={video:M,audio:I};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),p=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=p,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var f=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,f,a,f,h),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,g))},D.box=function(j){for(var M=8,I=arguments.length,g=new Array(I>1?I-1:0),p=1;p<I;p++)g[p-1]=arguments[p];for(var f=g.length,h=f;f--;)M+=g[f].byteLength;var a=new Uint8Array(M);for(a[0]=M>>24&255,a[1]=M>>16&255,a[2]=M>>8&255,a[3]=M&255,a.set(j,4),f=0,M=8;f<h;f++)a.set(g[f],M),M+=g[f].byteLength;return a},D.hdlr=function(j){return D.box(D.types.hdlr,D.HDLR_TYPES[j])},D.mdat=function(j){return D.box(D.types.mdat,j)},D.mdhd=function(j,M){M*=j;var I=Math.floor(M/(V+1)),g=Math.floor(M%(V+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,j>>24&255,j>>16&255,j>>8&255,j&255,I>>24,I>>16&255,I>>8&255,I&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},D.mdia=function(j){return D.box(D.types.mdia,D.mdhd(j.timescale,j.duration),D.hdlr(j.type),D.minf(j))},D.mfhd=function(j){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,j>>24,j>>16&255,j>>8&255,j&255]))},D.minf=function(j){return j.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(j)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(j))},D.moof=function(j,M,I){return D.box(D.types.moof,D.mfhd(j),D.traf(I,M))},D.moov=function(j){for(var M=j.length,I=[];M--;)I[M]=D.trak(j[M]);return D.box.apply(null,[D.types.moov,D.mvhd(j[0].timescale,j[0].duration)].concat(I).concat(D.mvex(j)))},D.mvex=function(j){for(var M=j.length,I=[];M--;)I[M]=D.trex(j[M]);return D.box.apply(null,[D.types.mvex].concat(I))},D.mvhd=function(j,M){M*=j;var I=Math.floor(M/(V+1)),g=Math.floor(M%(V+1)),p=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,j>>24&255,j>>16&255,j>>8&255,j&255,I>>24,I>>16&255,I>>8&255,I&255,g>>24,g>>16&255,g>>8&255,g&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,p)},D.sdtp=function(j){var M=j.samples||[],I=new Uint8Array(4+M.length),g,p;for(g=0;g<M.length;g++)p=M[g].flags,I[g+4]=p.dependsOn<<4|p.isDependedOn<<2|p.hasRedundancy;return D.box(D.types.sdtp,I)},D.stbl=function(j){return D.box(D.types.stbl,D.stsd(j),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(j){var M=[],I=[],g,p,f;for(g=0;g<j.sps.length;g++)p=j.sps[g],f=p.byteLength,M.push(f>>>8&255),M.push(f&255),M=M.concat(Array.prototype.slice.call(p));for(g=0;g<j.pps.length;g++)p=j.pps[g],f=p.byteLength,I.push(f>>>8&255),I.push(f&255),I=I.concat(Array.prototype.slice.call(p));var h=D.box(D.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|j.sps.length].concat(M).concat([j.pps.length]).concat(I))),a=j.width,c=j.height,o=j.pixelRatio[0],s=j.pixelRatio[1];return D.box(D.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,a&255,c>>8&255,c&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]),h,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([o>>24,o>>16&255,o>>8&255,o&255,s>>24,s>>16&255,s>>8&255,s&255])))},D.esds=function(j){var M=j.config.length;return new Uint8Array([0,0,0,0,3,23+M,0,1,0,4,15+M,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([M]).concat(j.config).concat([6,1,2]))},D.mp4a=function(j){var M=j.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,j.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),D.box(D.types.esds,D.esds(j)))},D.mp3=function(j){var M=j.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,j.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},D.stsd=function(j){return j.type==="audio"?!j.isAAC&&j.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(j)):D.box(D.types.stsd,D.STSD,D.mp4a(j)):D.box(D.types.stsd,D.STSD,D.avc1(j))},D.tkhd=function(j){var M=j.id,I=j.duration*j.timescale,g=j.width,p=j.height,f=Math.floor(I/(V+1)),h=Math.floor(I%(V+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&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,g>>8&255,g&255,0,0,p>>8&255,p&255,0,0]))},D.traf=function(j,M){var I=D.sdtp(j),g=j.id,p=Math.floor(M/(V+1)),f=Math.floor(M%(V+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,p>>24,p>>16&255,p>>8&255,p&255,f>>24,f>>16&255,f>>8&255,f&255])),D.trun(j,I.length+16+20+8+16+8+8),I)},D.trak=function(j){return j.duration=j.duration||4294967295,D.box(D.types.trak,D.tkhd(j),D.mdia(j))},D.trex=function(j){var M=j.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(j,M){var I=j.samples||[],g=I.length,p=12+16*g,f=new Uint8Array(p),h,a,c,o,s,l;for(M+=8+p,f.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),h=0;h<g;h++)a=I[h],c=a.duration,o=a.size,s=a.flags,l=a.cts,f.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,s.degradPrio&240<<8,s.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*h);return D.box(D.types.trun,f)},D.initSegment=function(j){D.types||D.init();var M=D.moov(j),I=new Uint8Array(D.FTYP.byteLength+M.byteLength);return I.set(D.FTYP),I.set(M,D.FTYP.byteLength),I},D}();F.types=void 0,F.HDLR_TYPES=void 0,F.STTS=void 0,F.STSC=void 0,F.STCO=void 0,F.STSZ=void 0,F.VMHD=void 0,F.SMHD=void 0,F.STSD=void 0,F.FTYP=void 0,F.DINF=void 0,Z.default=F},"./src/remux/mp4-remuxer.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return l}),k.d(Z,"normalizePts",function(){return d});var V=k("./src/polyfills/number.ts"),F=k("./src/remux/aac-helper.ts"),D=k("./src/remux/mp4-generator.ts"),G=k("./src/events.ts"),j=k("./src/errors.ts"),M=k("./src/utils/logger.ts"),I=k("./src/types/loader.ts"),g=k("./src/utils/timescale-conversion.ts");function p(){return p=Object.assign||function(R){for(var A=1;A<arguments.length;A++){var T=arguments[A];for(var E in T)Object.prototype.hasOwnProperty.call(T,E)&&(R[E]=T[E])}return R},p.apply(this,arguments)}var f=10*1e3,h=1024,a=1152,c=null,o=null,s=!1,l=function(){function R(T,E,y,u){if(u===void 0&&(u=""),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=T,this.config=E,this.typeSupported=y,this.ISGenerated=!1,c===null){var _=navigator.userAgent||"",m=_.match(/Chrome\/(\d+)/i);c=m?parseInt(m[1]):0}if(o===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);o=b?parseInt(b[1]):0}s=!!c&&c<75||!!o&&o<600}var A=R.prototype;return A.destroy=function(){},A.resetTimeStamp=function(E){M.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=E},A.resetNextTimestamp=function(){M.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},A.resetInitSegment=function(){M.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},A.getVideoStartPts=function(E){var y=!1,u=E.reduce(function(_,m){var b=m.pts-_;return b<-4294967296?(y=!0,d(_,m.pts)):b>0?_:m.pts},E[0].pts);return y&&M.logger.debug("PTS rollover detected"),u},A.remux=function(E,y,u,_,m,b,P,N){var K,X,B,S,Y,te,re=m,ce=m,Te=E.pid>-1,ye=y.pid>-1,be=y.samples.length,we=E.samples.length>0,xe=be>1,ve=(!Te||we)&&(!ye||xe)||this.ISGenerated||P;if(ve){this.ISGenerated||(B=this.generateIS(E,y,m));var oe=this.isVideoContiguous,Re=-1;if(xe&&(Re=O(y.samples),!oe&&this.config.forceKeyFrameOnDiscontinuity))if(te=!0,Re>0){M.logger.warn("[mp4-remuxer]: Dropped "+Re+" out of "+be+" video samples due to a missing keyframe");var Ye=this.getVideoStartPts(y.samples);y.samples=y.samples.slice(Re),y.dropped+=Re,ce+=(y.samples[0].pts-Ye)/(y.timescale||9e4)}else Re===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+be+" video samples"),te=!1);if(this.ISGenerated){if(we&&xe){var Ue=this.getVideoStartPts(y.samples),rt=d(E.samples[0].pts,Ue)-Ue,ot=rt/y.inputTimeScale;re+=Math.max(0,ot),ce+=Math.max(0,-ot)}if(we){if(E.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),B=this.generateIS(E,y,m)),X=this.remuxAudio(E,re,this.isAudioContiguous,b,ye||xe||N===I.PlaylistLevelType.AUDIO?ce:void 0),xe){var Oe=X?X.endPTS-X.startPTS:0;y.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),B=this.generateIS(E,y,m)),K=this.remuxVideo(y,ce,oe,Oe)}}else xe&&(K=this.remuxVideo(y,ce,oe,0));K&&(K.firstKeyFrame=Re,K.independent=Re!==-1)}}return this.ISGenerated&&(u.samples.length&&(Y=this.remuxID3(u,m)),_.samples.length&&(S=this.remuxText(_,m))),{audio:X,video:K,initSegment:B,independent:te,text:S,id3:Y}},A.generateIS=function(E,y,u){var _=E.samples,m=y.samples,b=this.typeSupported,P={},N=!Object(V.isFiniteNumber)(this._initPTS),K="audio/mp4",X,B,S;if(N&&(X=B=Infinity),E.config&&_.length&&(E.timescale=E.samplerate,E.isAAC||(b.mpeg?(K="audio/mpeg",E.codec=""):b.mp3&&(E.codec="mp3")),P.audio={id:"audio",container:K,codec:E.codec,initSegment:!E.isAAC&&b.mpeg?new Uint8Array(0):D.default.initSegment([E]),metadata:{channelCount:E.channelCount}},N&&(S=E.inputTimeScale,X=B=_[0].pts-Math.round(S*u))),y.sps&&y.pps&&m.length&&(y.timescale=y.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:y.codec,initSegment:D.default.initSegment([y]),metadata:{width:y.width,height:y.height}},N)){S=y.inputTimeScale;var Y=this.getVideoStartPts(m),te=Math.round(S*u);B=Math.min(B,d(m[0].dts,Y)-te),X=Math.min(X,Y-te)}if(Object.keys(P).length)return this.ISGenerated=!0,N&&(this._initPTS=X,this._initDTS=B),{tracks:P,initPTS:X,timescale:S}},A.remuxVideo=function(E,y,u,_){var m=E.inputTimeScale,b=E.samples,P=[],N=b.length,K=this._initPTS,X=this.nextAvcDts,B=8,S,Y,te,re=Number.POSITIVE_INFINITY,ce=Number.NEGATIVE_INFINITY,Te=0,ye=!1;if(!u||X===null){var be=y*m,we=b[0].pts-d(b[0].dts,b[0].pts);X=be-we}for(var xe=0;xe<N;xe++){var ve=b[xe];if(ve.pts=d(ve.pts-K,X),ve.dts=d(ve.dts-K,X),ve.dts>ve.pts){var oe=9e4*.2;Te=Math.max(Math.min(Te,ve.pts-ve.dts),-1*oe)}ve.dts<b[xe>0?xe-1:xe].dts&&(ye=!0)}ye&&b.sort(function(Ct,xt){var $e=Ct.dts-xt.dts,Rt=Ct.pts-xt.pts;return $e||Rt}),Y=b[0].dts,te=b[b.length-1].dts;var Re=Math.round((te-Y)/(N-1));if(Te<0){if(Te<Re*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-Re,!0)+" ms");for(var Ye=Te,Ue=0;Ue<N;Ue++)b[Ue].dts=Ye=Math.max(Ye,b[Ue].pts-Re),b[Ue].pts=Math.max(Ye,b[Ue].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(Te,!0)+" ms to overcome this issue");for(var rt=0;rt<N;rt++)b[rt].dts=b[rt].dts+Te}Y=b[0].dts}if(u){var ot=Y-X,Oe=ot>Re,Me=ot<-1;if(Oe||Me){Oe?M.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(ot,!0)+" ms ("+ot+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-ot,!0)+" ms ("+ot+"dts) overlapping between fragments detected"),Y=X;var We=b[0].pts-ot;b[0].dts=Y,b[0].pts=We,M.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(We,!0)+"/"+Object(g.toMsFromMpegTsClock)(Y,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(ot,!0)+" ms")}}s&&(Y=Math.max(0,Y));for(var qe=0,Ve=0,je=0;je<N;je++){for(var Fe=b[je],ht=Fe.units,He=ht.length,Pe=0,Xe=0;Xe<He;Xe++)Pe+=ht[Xe].data.length;Ve+=Pe,qe+=He,Fe.length=Pe,Fe.dts=Math.max(Fe.dts,Y),Fe.pts=Math.max(Fe.pts,Fe.dts,0),re=Math.min(Fe.pts,re),ce=Math.max(Fe.pts,ce)}te=b[N-1].dts;var tt=Ve+4*qe+8,Ke;try{Ke=new Uint8Array(tt)}catch(Ct){this.observer.emit(G.Events.ERROR,G.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:tt,reason:"fail allocating video mdat "+tt});return}var et=new DataView(Ke.buffer);et.setUint32(0,tt),Ke.set(D.default.types.mdat,4);for(var Ae=0;Ae<N;Ae++){for(var nt=b[Ae],Je=nt.units,Se=0,ke=0,me=Je.length;ke<me;ke++){var he=Je[ke],de=he.data,ie=he.data.byteLength;et.setUint32(B,ie),B+=4,Ke.set(de,B),B+=ie,Se+=4+ie}if(Ae<N-1)S=b[Ae+1].dts-nt.dts;else{var q=this.config,se=nt.dts-b[Ae>0?Ae-1:Ae].dts;if(q.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(q.maxBufferHole*m),ge=(_?re+_*m:this.nextAudioPts)-nt.pts;ge>ue?(S=ge-se,S<0&&(S=se),M.logger.log("[mp4-remuxer]: It is approximately "+ge/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=se}else S=se}var Ce=Math.round(nt.pts-nt.dts);P.push(new w(nt.key,S,Se,Ce))}if(P.length&&c&&c<70){var Le=P[0].flags;Le.dependsOn=2,Le.isNonSync=0}console.assert(S!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=X=te+S,this.isVideoContiguous=!0;var ze=D.default.moof(E.sequenceNumber++,Y,p({},E,{samples:P})),pt="video",ct={data1:ze,data2:Ke,startPTS:re/m,endPTS:(ce+S)/m,startDTS:Y/m,endDTS:X/m,type:pt,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:E.dropped};return E.samples=[],E.dropped=0,console.assert(Ke.length,"MDAT length must not be zero"),ct},A.remuxAudio=function(E,y,u,_,m){var b=E.inputTimeScale,P=E.samplerate?E.samplerate:b,N=b/P,K=E.isAAC?h:a,X=K*N,B=this._initPTS,S=!E.isAAC&&this.typeSupported.mpeg,Y=[],te=E.samples,re=S?0:8,ce=this.nextAudioPts||-1,Te=y*b;if(this.isAudioContiguous=u=u||te.length&&ce>0&&(_&&Math.abs(Te-ce)<9e3||Math.abs(d(te[0].pts-B,Te)-ce)<20*X),te.forEach(function(de){de.pts=d(de.pts-B,Te)}),!u||ce<0){if(te=te.filter(function(de){return de.pts>=0}),!te.length)return;m===0?ce=0:_?ce=Math.max(0,Te):ce=te[0].pts}if(E.isAAC)for(var ye=m!==void 0,be=this.config.maxAudioFramesDrift,we=0,xe=ce;we<te.length;we++){var ve=te[we],oe=ve.pts,Re=oe-xe,Ye=Math.abs(1e3*Re/b);if(Re<=-be*X&&ye)we===0&&(M.logger.warn("Audio frame @ "+(oe/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Re/b)+" ms."),this.nextAudioPts=ce=xe=oe);else if(Re>=be*X&&Ye<f&&ye){var Ue=Math.round(Re/X);xe=oe-Ue*X,xe<0&&(Ue--,xe+=X),we===0&&(this.nextAudioPts=ce=xe),M.logger.warn("[mp4-remuxer]: Injecting "+Ue+" audio frame @ "+(xe/b).toFixed(3)+"s due to "+Math.round(1e3*Re/b)+" ms gap.");for(var rt=0;rt<Ue;rt++){var ot=Math.max(xe,0),Oe=F.default.getSilentFrame(E.manifestCodec||E.codec,E.channelCount);Oe||(M.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Oe=ve.unit.subarray()),te.splice(we,0,{unit:Oe,pts:ot}),xe+=X,we++}}ve.pts=xe,xe+=X}for(var Me=null,We=null,qe,Ve=0,je=te.length;je--;)Ve+=te[je].unit.byteLength;for(var Fe=0,ht=te.length;Fe<ht;Fe++){var He=te[Fe],Pe=He.unit,Xe=He.pts;if(We!==null){var tt=Y[Fe-1];tt.duration=Math.round((Xe-We)/N)}else if(u&&E.isAAC&&(Xe=ce),Me=Xe,Ve>0){Ve+=re;try{qe=new Uint8Array(Ve)}catch(de){this.observer.emit(G.Events.ERROR,G.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ve,reason:"fail allocating audio mdat "+Ve});return}if(!S){var Ke=new DataView(qe.buffer);Ke.setUint32(0,Ve),qe.set(D.default.types.mdat,4)}}else return;qe.set(Pe,re);var et=Pe.byteLength;re+=et,Y.push(new w(!0,K,et,0)),We=Xe}var Ae=Y.length;if(!Ae)return;var nt=Y[Y.length-1];this.nextAudioPts=ce=We+N*nt.duration;var Je=S?new Uint8Array(0):D.default.moof(E.sequenceNumber++,Me/N,p({},E,{samples:Y}));E.samples=[];var Se=Me/b,ke=ce/b,me="audio",he={data1:Je,data2:qe,startPTS:Se,endPTS:ke,startDTS:Se,endDTS:ke,type:me,hasAudio:!0,hasVideo:!1,nb:Ae};return this.isAudioContiguous=!0,console.assert(qe.length,"MDAT length must not be zero"),he},A.remuxEmptyAudio=function(E,y,u,_){var m=E.inputTimeScale,b=E.samplerate?E.samplerate:m,P=m/b,N=this.nextAudioPts,K=(N!==null?N:_.startDTS*m)+this._initDTS,X=_.endDTS*m+this._initDTS,B=P*h,S=Math.ceil((X-K)/B),Y=F.default.getSilentFrame(E.manifestCodec||E.codec,E.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!Y){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var te=[],re=0;re<S;re++){var ce=K+re*B;te.push({unit:Y,pts:ce,dts:ce})}return E.samples=te,this.remuxAudio(E,y,u,!1)},A.remuxID3=function(E,y){var u=E.samples.length;if(!u)return;for(var _=E.inputTimeScale,m=this._initPTS,b=this._initDTS,P=0;P<u;P++){var N=E.samples[P];N.pts=d(N.pts-m,y*_)/_,N.dts=d(N.dts-b,y*_)/_}var K=E.samples;return E.samples=[],{samples:K}},A.remuxText=function(E,y){var u=E.samples.length;if(!u)return;for(var _=E.inputTimeScale,m=this._initPTS,b=0;b<u;b++){var P=E.samples[b];P.pts=d(P.pts-m,y*_)/_}E.samples.sort(function(K,X){return K.pts-X.pts});var N=E.samples;return E.samples=[],{samples:N}},R}();function d(R,A){var T;if(A===null)return R;for(A<R?T=-8589934592:T=8589934592;Math.abs(R-A)>4294967296;)R+=T;return R}function O(R){for(var A=0;A<R.length;A++)if(R[A].key)return A;return-1}var w=function(A,T,E,y){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=T,this.size=E,this.cts=y,this.flags=new x(A)},x=function(A){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=A?2:1,this.isNonSync=A?0:1}},"./src/remux/passthrough-remuxer.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/polyfills/number.ts"),F=k("./src/utils/mp4-tools.ts"),D=k("./src/loader/fragment.ts"),G=k("./src/utils/logger.ts"),j=function(){function g(){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 p=g.prototype;return p.destroy=function(){},p.resetTimeStamp=function(h){this.initPTS=h,this.lastEndDTS=null},p.resetNextTimestamp=function(){this.lastEndDTS=null},p.resetInitSegment=function(h,a,c){this.audioCodec=a,this.videoCodec=c,this.generateInitSegment(h),this.emitInitSegment=!0},p.generateInitSegment=function(h){var a=this.audioCodec,c=this.videoCodec;if(!h||!h.byteLength){this.initTracks=void 0,this.initData=void 0;return}var o=this.initData=Object(F.parseInitSegment)(h);a||(a=I(o.audio,D.ElementaryStreamTypes.AUDIO)),c||(c=I(o.video,D.ElementaryStreamTypes.VIDEO));var s={};o.audio&&o.video?s.audiovideo={container:"video/mp4",codec:a+","+c,initSegment:h,id:"main"}:o.audio?s.audio={container:"audio/mp4",codec:a,initSegment:h,id:"audio"}:o.video?s.video={container:"video/mp4",codec:c,initSegment:h,id:"main"}:G.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},p.remux=function(h,a,c,o,s){var l=this.initPTS,d=this.lastEndDTS,O={audio:void 0,video:void 0,text:o,id3:c,initSegment:void 0};Object(V.isFiniteNumber)(d)||(d=this.lastEndDTS=s||0);var w=a.samples;if(!w||!w.length)return O;var x={initPTS:void 0,timescale:1},R=this.initData;if((!R||!R.length)&&(this.generateInitSegment(w),R=this.initData),!R||!R.length)return G.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),O;this.emitInitSegment&&(x.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(l)||(this.initPTS=x.initPTS=l=M(R,w,d));var A=Object(F.getDuration)(w,R),T=d,E=A+T;Object(F.offsetStartDTS)(R,w,l),A>0?this.lastEndDTS=E:(G.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!R.audio,u=!!R.video,_="";y&&(_+="audio"),u&&(_+="video");var m={data1:w,startPTS:T,startDTS:T,endPTS:E,endDTS:E,type:_,hasAudio:y,hasVideo:u,nb:1,dropped:0};return O.audio=m.type==="audio"?m:void 0,O.video=m.type!=="audio"?m:void 0,O.text=o,O.id3=c,O.initSegment=x,O},g}(),M=function(p,f,h){return Object(F.getStartDTS)(p,f)-h};function I(g,p){var f=g==null?void 0:g.codec;return f&&f.length>4?f:f==="hvc1"?"hvc1.1.c.L120.90":f==="av01"?"av01.0.04M.08":f==="avc1"||p===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Z.default=j},"./src/task-loop.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return V});var V=function(){function F(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=F.prototype;return D.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},D.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},D.onHandlerDestroyed=function(){},D.hasInterval=function(){return!!this._tickInterval},D.hasNextTick=function(){return!!this._tickTimer},D.setInterval=function(j){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,j),!0)},D.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},D.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},D.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},D.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},D.doTick=function(){},F}()},"./src/types/cmcd.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"CMCDVersion",function(){return V}),k.d(Z,"CMCDObjectType",function(){return F}),k.d(Z,"CMCDStreamingFormat",function(){return D}),k.d(Z,"CMCDStreamType",function(){return G});var V=1,F;(function(j){j.MANIFEST="m",j.AUDIO="a",j.VIDEO="v",j.MUXED="av",j.INIT="i",j.CAPTION="c",j.TIMED_TEXT="tt",j.KEY="k",j.OTHER="o"})(F||(F={}));var D;(function(j){j.DASH="d",j.HLS="h",j.SMOOTH="s",j.OTHER="o"})(D||(D={}));var G;(function(j){j.VOD="v",j.LIVE="l"})(G||(G={}))},"./src/types/level.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"HlsSkip",function(){return D}),k.d(Z,"getSkipValue",function(){return G}),k.d(Z,"HlsUrlParameters",function(){return j}),k.d(Z,"Level",function(){return M});function V(I,g){for(var p=0;p<g.length;p++){var f=g[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(I,f.key,f)}}function F(I,g,p){return g&&V(I.prototype,g),p&&V(I,p),I}var D;(function(I){I.No="",I.Yes="YES",I.v2="v2"})(D||(D={}));function G(I,g){var p=I.canSkipUntil,f=I.canSkipDateRanges,h=I.endSN,a=g!==void 0?g-h:0;return p&&a<p?f?D.v2:D.Yes:D.No}var j=function(){function I(p,f,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=p,this.part=f,this.skip=h}var g=I.prototype;return g.addDirectives=function(f){var h=new self.URL(f);return this.msn!==void 0&&h.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&h.searchParams.set("_HLS_part",this.part.toString()),this.skip&&h.searchParams.set("_HLS_skip",this.skip),h.toString()},I}(),M=function(){function I(g){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(p){return p}).join(",").replace(/\.[^.,]+/g,"")}return F(I,[{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(p){var f=p%this.url.length;this._urlId!==f&&(this.details=void 0,this._urlId=f)}}]),I}()},"./src/types/loader.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"PlaylistContextType",function(){return V}),k.d(Z,"PlaylistLevelType",function(){return F});var V;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var F;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(F||(F={}))},"./src/types/transmuxer.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"ChunkMetadata",function(){return V});var V=function(G,j,M,I,g,p){I===void 0&&(I=0),g===void 0&&(g=-1),p===void 0&&(p=!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=F(),this.buffering={audio:F(),video:F(),audiovideo:F()},this.level=G,this.sn=j,this.id=M,this.size=I,this.part=g,this.partial=p};function F(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"AttrList",function(){return D});var V=/^(\d+)x(\d+)$/,F=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function G(M){typeof M=="string"&&(M=G.parseAttrList(M));for(var I in M)M.hasOwnProperty(I)&&(this[I]=M[I])}var j=G.prototype;return j.decimalInteger=function(I){var g=parseInt(this[I],10);return g>Number.MAX_SAFE_INTEGER?Infinity:g},j.hexadecimalInteger=function(I){if(this[I]){var g=(this[I]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var p=new Uint8Array(g.length/2),f=0;f<g.length/2;f++)p[f]=parseInt(g.slice(f*2,f*2+2),16);return p}else return null},j.hexadecimalIntegerAsNumber=function(I){var g=parseInt(this[I],16);return g>Number.MAX_SAFE_INTEGER?Infinity:g},j.decimalFloatingPoint=function(I){return parseFloat(this[I])},j.optionalFloat=function(I,g){var p=this[I];return p?parseFloat(p):g},j.enumeratedString=function(I){return this[I]},j.bool=function(I){return this[I]==="YES"},j.decimalResolution=function(I){var g=V.exec(this[I]);return g===null?void 0:{width:parseInt(g[1],10),height:parseInt(g[2],10)}},G.parseAttrList=function(I){var g,p={},f='"';for(F.lastIndex=0;(g=F.exec(I))!==null;){var h=g[2];h.indexOf(f)===0&&h.lastIndexOf(f)===h.length-1&&(h=h.slice(1,-1)),p[g[1]]=h}return p},G}()},"./src/utils/binary-search.ts":function(ae,Z,k){"use strict";k.r(Z);var V={search:function(D,G){for(var j=0,M=D.length-1,I=null,g=null;j<=M;){I=(j+M)/2|0,g=D[I];var p=G(g);if(p>0)j=I+1;else if(p<0)M=I-1;else return g}return null}};Z.default=V},"./src/utils/buffer-helper.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"BufferHelper",function(){return D});var V=k("./src/utils/logger.ts"),F={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function G(){}return G.isBuffered=function(M,I){try{if(M){for(var g=G.getBuffered(M),p=0;p<g.length;p++)if(I>=g.start(p)&&I<=g.end(p))return!0}}catch(f){}return!1},G.bufferInfo=function(M,I,g){try{if(M){var p=G.getBuffered(M),f=[],h;for(h=0;h<p.length;h++)f.push({start:p.start(h),end:p.end(h)});return this.bufferedInfo(f,I,g)}}catch(a){}return{len:0,start:I,end:I,nextStart:void 0}},G.bufferedInfo=function(M,I,g){I=Math.max(0,I),M.sort(function(x,R){var A=x.start-R.start;return A||R.end-x.end});var p=[];if(g)for(var f=0;f<M.length;f++){var h=p.length;if(h){var a=p[h-1].end;M[f].start-a<g?M[f].end>a&&(p[h-1].end=M[f].end):p.push(M[f])}else p.push(M[f])}else p=M;for(var c=0,o,s=I,l=I,d=0;d<p.length;d++){var O=p[d].start,w=p[d].end;if(I+g>=O&&I<w)s=O,l=w,c=l-I;else if(I+g<O){o=O;break}}return{len:c,start:s||0,end:l||0,nextStart:o}},G.getBuffered=function(M){try{return M.buffered}catch(I){return V.logger.log("failed to get media.buffered",I),F}},G}()},"./src/utils/cea-608-parser.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"Row",function(){return l}),k.d(Z,"CaptionScreen",function(){return d});var V=k("./src/utils/logger.ts"),F={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},D=function(E){var y=E;return F.hasOwnProperty(E)&&(y=F[E]),String.fromCharCode(y)},G=15,j=100,M={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},I={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},p={25:2,26:4,29:6,30:8,31:10,27:13,28:15},f=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],h;(function(T){T[T.ERROR=0]="ERROR",T[T.TEXT=1]="TEXT",T[T.WARNING=2]="WARNING",T[T.INFO=2]="INFO",T[T.DEBUG=3]="DEBUG",T[T.DATA=3]="DATA"})(h||(h={}));var a=function(){function T(){this.time=null,this.verboseLevel=h.ERROR}var E=T.prototype;return E.log=function(u,_){this.verboseLevel>=u&&V.logger.log(this.time+" ["+u+"] "+_)},T}(),c=function(E){for(var y=[],u=0;u<E.length;u++)y.push(E[u].toString(16));return y},o=function(){function T(y,u,_,m,b){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=y||"white",this.underline=u||!1,this.italics=_||!1,this.background=m||"black",this.flash=b||!1}var E=T.prototype;return E.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},E.setStyles=function(u){for(var _=["foreground","underline","italics","background","flash"],m=0;m<_.length;m++){var b=_[m];u.hasOwnProperty(b)&&(this[b]=u[b])}},E.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},E.equals=function(u){return this.foreground===u.foreground&&this.underline===u.underline&&this.italics===u.italics&&this.background===u.background&&this.flash===u.flash},E.copy=function(u){this.foreground=u.foreground,this.underline=u.underline,this.italics=u.italics,this.background=u.background,this.flash=u.flash},E.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},T}(),s=function(){function T(y,u,_,m,b,P){this.uchar=void 0,this.penState=void 0,this.uchar=y||" ",this.penState=new o(u,_,m,b,P)}var E=T.prototype;return E.reset=function(){this.uchar=" ",this.penState.reset()},E.setChar=function(u,_){this.uchar=u,this.penState.copy(_)},E.setPenState=function(u){this.penState.copy(u)},E.equals=function(u){return this.uchar===u.uchar&&this.penState.equals(u.penState)},E.copy=function(u){this.uchar=u.uchar,this.penState.copy(u.penState)},E.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},T}(),l=function(){function T(y){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var u=0;u<j;u++)this.chars.push(new s);this.logger=y,this.pos=0,this.currPenState=new o}var E=T.prototype;return E.equals=function(u){for(var _=!0,m=0;m<j;m++)if(!this.chars[m].equals(u.chars[m])){_=!1;break}return _},E.copy=function(u){for(var _=0;_<j;_++)this.chars[_].copy(u.chars[_])},E.isEmpty=function(){for(var u=!0,_=0;_<j;_++)if(!this.chars[_].isEmpty()){u=!1;break}return u},E.setCursor=function(u){this.pos!==u&&(this.pos=u),this.pos<0?(this.logger.log(h.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>j&&(this.logger.log(h.DEBUG,"Too large cursor position "+this.pos),this.pos=j)},E.moveCursor=function(u){var _=this.pos+u;if(u>1)for(var m=this.pos+1;m<_+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(_)},E.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},E.insertChar=function(u){u>=144&&this.backSpace();var _=D(u);if(this.pos>=j){this.logger.log(h.ERROR,"Cannot insert "+u.toString(16)+" ("+_+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(_,this.currPenState),this.moveCursor(1)},E.clearFromPos=function(u){var _;for(_=u;_<j;_++)this.chars[_].reset()},E.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},E.clearToEndOfRow=function(){this.clearFromPos(this.pos)},E.getTextString=function(){for(var u=[],_=!0,m=0;m<j;m++){var b=this.chars[m].uchar;b!==" "&&(_=!1),u.push(b)}return _?"":u.join("")},E.setPenStyles=function(u){this.currPenState.setStyles(u);var _=this.chars[this.pos];_.setPenState(this.currPenState)},T}(),d=function(){function T(y){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var u=0;u<G;u++)this.rows.push(new l(y));this.logger=y,this.currRow=G-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var E=T.prototype;return E.reset=function(){for(var u=0;u<G;u++)this.rows[u].clear();this.currRow=G-1},E.equals=function(u){for(var _=!0,m=0;m<G;m++)if(!this.rows[m].equals(u.rows[m])){_=!1;break}return _},E.copy=function(u){for(var _=0;_<G;_++)this.rows[_].copy(u.rows[_])},E.isEmpty=function(){for(var u=!0,_=0;_<G;_++)if(!this.rows[_].isEmpty()){u=!1;break}return u},E.backSpace=function(){var u=this.rows[this.currRow];u.backSpace()},E.clearToEndOfRow=function(){var u=this.rows[this.currRow];u.clearToEndOfRow()},E.insertChar=function(u){var _=this.rows[this.currRow];_.insertChar(u)},E.setPen=function(u){var _=this.rows[this.currRow];_.setPenStyles(u)},E.moveCursor=function(u){var _=this.rows[this.currRow];_.moveCursor(u)},E.setCursor=function(u){this.logger.log(h.INFO,"setCursor: "+u);var _=this.rows[this.currRow];_.setCursor(u)},E.setPAC=function(u){this.logger.log(h.INFO,"pacData = "+JSON.stringify(u));var _=u.row-1;if(this.nrRollUpRows&&_<this.nrRollUpRows-1&&(_=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==_){for(var m=0;m<G;m++)this.rows[m].clear();var b=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var N=P.rows[b].cueStartTime,K=this.logger.time;if(N&&K!==null&&N<K)for(var X=0;X<this.nrRollUpRows;X++)this.rows[_-this.nrRollUpRows+X+1].copy(P.rows[b+X])}}this.currRow=_;var B=this.rows[this.currRow];if(u.indent!==null){var S=u.indent,Y=Math.max(S-1,0);B.setCursor(u.indent),u.color=B.chars[Y].penState.foreground}var te={foreground:u.color,underline:u.underline,italics:u.italics,background:"black",flash:!1};this.setPen(te)},E.setBkgData=function(u){this.logger.log(h.INFO,"bkgData = "+JSON.stringify(u)),this.backSpace(),this.setPen(u),this.insertChar(32)},E.setRollUpRows=function(u){this.nrRollUpRows=u},E.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(h.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(h.TEXT,this.getDisplayText());var u=this.currRow+1-this.nrRollUpRows,_=this.rows.splice(u,1)[0];_.clear(),this.rows.splice(this.currRow,0,_),this.logger.log(h.INFO,"Rolling up")},E.getDisplayText=function(u){u=u||!1;for(var _=[],m="",b=-1,P=0;P<G;P++){var N=this.rows[P].getTextString();N&&(b=P+1,u?_.push("Row "+b+": '"+N+"'"):_.push(N.trim()))}return _.length>0&&(u?m="["+_.join(" | ")+"]":m=_.join(`
`)),m},E.getTextAndFormat=function(){return this.rows},T}(),O=function(){function T(y,u,_){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=y,this.outputFilter=u,this.mode=null,this.verbose=0,this.displayedMemory=new d(_),this.nonDisplayedMemory=new d(_),this.lastOutputScreen=new d(_),this.currRollUpRow=this.displayedMemory.rows[G-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=_}var E=T.prototype;return E.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[G-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},E.getHandler=function(){return this.outputFilter},E.setHandler=function(u){this.outputFilter=u},E.setPAC=function(u){this.writeScreen.setPAC(u)},E.setBkgData=function(u){this.writeScreen.setBkgData(u)},E.setMode=function(u){if(u===this.mode)return;this.mode=u,this.logger.log(h.INFO,"MODE="+u),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=u},E.insertChars=function(u){for(var _=0;_<u.length;_++)this.writeScreen.insertChar(u[_]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(h.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(h.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},E.ccRCL=function(){this.logger.log(h.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},E.ccBS=function(){if(this.logger.log(h.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},E.ccAOF=function(){},E.ccAON=function(){},E.ccDER=function(){this.logger.log(h.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},E.ccRU=function(u){this.logger.log(h.INFO,"RU("+u+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(u)},E.ccFON=function(){this.logger.log(h.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},E.ccRDC=function(){this.logger.log(h.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},E.ccTR=function(){this.logger.log(h.INFO,"TR"),this.setMode("MODE_TEXT")},E.ccRTD=function(){this.logger.log(h.INFO,"RTD"),this.setMode("MODE_TEXT")},E.ccEDM=function(){this.logger.log(h.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},E.ccCR=function(){this.logger.log(h.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},E.ccENM=function(){this.logger.log(h.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},E.ccEOC=function(){if(this.logger.log(h.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var u=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=u,this.writeScreen=this.nonDisplayedMemory,this.logger.log(h.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},E.ccTO=function(u){this.logger.log(h.INFO,"TO("+u+") - Tab Offset"),this.writeScreen.moveCursor(u)},E.ccMIDROW=function(u){var _={flash:!1};if(_.underline=u%2===1,_.italics=u>=46,_.italics)_.foreground="white";else{var m=Math.floor(u/2)-16,b=["white","green","blue","cyan","red","yellow","magenta"];_.foreground=b[m]}this.logger.log(h.INFO,"MIDROW: "+JSON.stringify(_)),this.writeScreen.setPen(_)},E.outputDataUpdate=function(u){u===void 0&&(u=!1);var _=this.logger.time;if(_===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=_:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,_,this.lastOutputScreen),u&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:_),this.lastOutputScreen.copy(this.displayedMemory))},E.cueSplitAtTime=function(u){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,u,this.displayedMemory),this.cueStartTime=u))},T}(),w=function(){function T(y,u,_){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new a;this.channels=[null,new O(y,u,m),new O(y+1,_,m)],this.cmdHistory=A(),this.logger=m}var E=T.prototype;return E.getHandler=function(u){return this.channels[u].getHandler()},E.setHandler=function(u,_){this.channels[u].setHandler(_)},E.addData=function(u,_){var m,b,P,N=!1;this.logger.time=u;for(var K=0;K<_.length;K+=2){if(b=_[K]&127,P=_[K+1]&127,b===0&&P===0)continue;if(this.logger.log(h.DATA,"["+c([_[K],_[K+1]])+"] -> ("+c([b,P])+")"),m=this.parseCmd(b,P),m||(m=this.parseMidrow(b,P)),m||(m=this.parsePAC(b,P)),m||(m=this.parseBackgroundAttributes(b,P)),!m&&(N=this.parseChars(b,P),N)){var X=this.currentChannel;if(X&&X>0){var B=this.channels[X];B.insertChars(N)}else this.logger.log(h.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!N&&this.logger.log(h.WARNING,"Couldn't parse cleaned data "+c([b,P])+" orig: "+c([_[K],_[K+1]]))}},E.parseCmd=function(u,_){var m=this.cmdHistory,b=(u===20||u===28||u===21||u===29)&&_>=32&&_<=47,P=(u===23||u===31)&&_>=33&&_<=35;if(!(b||P))return!1;if(R(u,_,m))return x(null,null,m),this.logger.log(h.DEBUG,"Repeated command ("+c([u,_])+") is dropped"),!0;var N=u===20||u===21||u===23?1:2,K=this.channels[N];return u===20||u===21||u===28||u===29?_===32?K.ccRCL():_===33?K.ccBS():_===34?K.ccAOF():_===35?K.ccAON():_===36?K.ccDER():_===37?K.ccRU(2):_===38?K.ccRU(3):_===39?K.ccRU(4):_===40?K.ccFON():_===41?K.ccRDC():_===42?K.ccTR():_===43?K.ccRTD():_===44?K.ccEDM():_===45?K.ccCR():_===46?K.ccENM():_===47&&K.ccEOC():K.ccTO(_-32),x(u,_,m),this.currentChannel=N,!0},E.parseMidrow=function(u,_){var m=0;if((u===17||u===25)&&_>=32&&_<=47){if(u===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(h.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[m];return b?(b.ccMIDROW(_),this.logger.log(h.DEBUG,"MIDROW ("+c([u,_])+")"),!0):!1}return!1},E.parsePAC=function(u,_){var m,b=this.cmdHistory,P=(u>=17&&u<=23||u>=25&&u<=31)&&_>=64&&_<=127,N=(u===16||u===24)&&_>=64&&_<=95;if(!(P||N))return!1;if(R(u,_,b))return x(null,null,b),!0;var K=u<=23?1:2;_>=64&&_<=95?m=K===1?M[u]:g[u]:m=K===1?I[u]:p[u];var X=this.channels[K];return X?(X.setPAC(this.interpretPAC(m,_)),x(u,_,b),this.currentChannel=K,!0):!1},E.interpretPAC=function(u,_){var m,b={color:null,italics:!1,indent:null,underline:!1,row:u};return _>95?m=_-96:m=_-64,b.underline=(m&1)===1,m<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(b.italics=!0,b.color="white"):b.indent=Math.floor((m-16)/2)*4,b},E.parseChars=function(u,_){var m,b=null,P=null;if(u>=25?(m=2,P=u-8):(m=1,P=u),P>=17&&P<=19){var N;P===17?N=_+80:P===18?N=_+112:N=_+144,this.logger.log(h.INFO,"Special char '"+D(N)+"' in channel "+m),b=[N]}else u>=32&&u<=127&&(b=_===0?[u]:[u,_]);if(b){var K=c(b);this.logger.log(h.DEBUG,"Char codes = "+K.join(",")),x(u,_,this.cmdHistory)}return b},E.parseBackgroundAttributes=function(u,_){var m=(u===16||u===24)&&_>=32&&_<=47,b=(u===23||u===31)&&_>=45&&_<=47;if(!(m||b))return!1;var P,N={};u===16||u===24?(P=Math.floor((_-32)/2),N.background=f[P],_%2===1&&(N.background=N.background+"_semi")):_===45?N.background="transparent":(N.foreground="black",_===47&&(N.underline=!0));var K=u<=23?1:2,X=this.channels[K];return X.setBkgData(N),x(u,_,this.cmdHistory),!0},E.reset=function(){for(var u=0;u<Object.keys(this.channels).length;u++){var _=this.channels[u];_&&_.reset()}this.cmdHistory=A()},E.cueSplitAtTime=function(u){for(var _=0;_<this.channels.length;_++){var m=this.channels[_];m&&m.cueSplitAtTime(u)}},T}();function x(T,E,y){y.a=T,y.b=E}function R(T,E,y){return y.a===T&&y.b===E}function A(){return{a:null,b:null}}Z.default=w},"./src/utils/codecs.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"isCodecType",function(){return F}),k.d(Z,"isCodecSupportedInMp4",function(){return D});var V={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function F(G,j){var M=V[j];return!!M&&M[G.slice(0,4)]===!0}function D(G,j){return MediaSource.isTypeSupported((j||"video")+'/mp4;codecs="'+G+'"')}},"./src/utils/cues.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/utils/vttparser.ts"),F=k("./src/utils/webvtt-parser.ts"),D=k("./src/utils/texttrack-utils.ts"),G=/\s/,j={newCue:function(I,g,p,f){for(var h=[],a,c,o,s,l,d=self.VTTCue||self.TextTrackCue,O=0;O<f.rows.length;O++)if(a=f.rows[O],o=!0,s=0,l="",!a.isEmpty()){for(var w=0;w<a.chars.length;w++)G.test(a.chars[w].uchar)&&o?s++:(l+=a.chars[w].uchar,o=!1);a.cueStartTime=g,g===p&&(p+=1e-4),s>=16?s--:s++;var x=Object(V.fixLineBreaks)(l.trim()),R=Object(F.generateCueId)(g,p,x);(!I||!I.cues||!I.cues.getCueById(R))&&(c=new d(g,p,x),c.id=R,c.line=O+1,c.align="left",c.position=10+Math.min(80,Math.floor(s*8/32)*10),h.push(c))}return I&&h.length&&(h.sort(function(A,T){return A.line==="auto"||T.line==="auto"?0:A.line>8&&T.line>8?T.line-A.line:A.line-T.line}),h.forEach(function(A){return Object(D.addCueToTrack)(I,A)})),h}};Z.default=j},"./src/utils/discontinuities.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"findFirstFragWithCC",function(){return G}),k.d(Z,"shouldAlignOnDiscontinuities",function(){return j}),k.d(Z,"findDiscontinuousReferenceFrag",function(){return M}),k.d(Z,"adjustSlidingStart",function(){return g}),k.d(Z,"alignStream",function(){return p}),k.d(Z,"alignPDT",function(){return h}),k.d(Z,"alignFragmentByPDTDelta",function(){return a}),k.d(Z,"alignMediaPlaylistByPDT",function(){return c});var V=k("./src/polyfills/number.ts"),F=k("./src/utils/logger.ts"),D=k("./src/controller/level-helper.ts");function G(o,s){for(var l=null,d=0,O=o.length;d<O;d++){var w=o[d];if(w&&w.cc===s){l=w;break}}return l}function j(o,s,l){return!!(s.details&&(l.endCC>l.startCC||o&&o.cc<l.startCC))}function M(o,s){var l=o.fragments,d=s.fragments;if(!d.length||!l.length){F.logger.log("No fragments to align");return}var O=G(l,d[0].cc);if(!O||O&&!O.startPTS){F.logger.log("No frag in previous level to align on");return}return O}function I(o,s){if(o){var l=o.start+s;o.start=o.startPTS=l,o.endPTS=l+o.duration}}function g(o,s){for(var l=s.fragments,d=0,O=l.length;d<O;d++)I(l[d],o);s.fragmentHint&&I(s.fragmentHint,o),s.alignedSliding=!0}function p(o,s,l){if(!s)return;f(o,l,s),!l.alignedSliding&&s.details&&h(l,s.details),!l.alignedSliding&&s.details&&!l.skippedSegments&&Object(D.adjustSliding)(s.details,l)}function f(o,s,l){if(j(o,l,s)){var d=M(l.details,s);d&&Object(V.isFiniteNumber)(d.start)&&(F.logger.log("Adjusting PTS using last level due to CC increase within current level "+s.url),g(d.start,s))}}function h(o,s){if(!s.fragments.length||!o.hasProgramDateTime||!s.hasProgramDateTime)return;var l=s.fragments[0].programDateTime,d=o.fragments[0].programDateTime,O=(d-l)/1e3+s.fragments[0].start;O&&Object(V.isFiniteNumber)(O)&&(F.logger.log("Adjusting PTS using programDateTime delta "+(d-l)+"ms, sliding:"+O.toFixed(3)+" "+o.url+" "),g(O,o))}function a(o,s){var l=o.programDateTime;if(!l)return;var d=(l-s)/1e3;o.start=o.startPTS=d,o.endPTS=d+o.duration}function c(o,s){if(!s.fragments.length||!o.hasProgramDateTime||!s.hasProgramDateTime)return;var l=s.fragments[0].programDateTime,d=s.fragments[0].start,O=l-d*1e3;o.fragments.forEach(function(w){a(w,O)}),o.fragmentHint&&a(o.fragmentHint,O),o.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/utils/ewma.ts"),F=function(){function D(j,M,I){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=I,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(j),this.fast_=new V.default(M)}var G=D.prototype;return G.update=function(M,I){var g=this.slow_,p=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new V.default(M,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==I&&(this.fast_=new V.default(I,p.getEstimate(),p.getTotalWeight()))},G.sample=function(M,I){M=Math.max(M,this.minDelayMs_);var g=8*I,p=M/1e3,f=g/p;this.fast_.sample(p,f),this.slow_.sample(p,f)},G.canEstimate=function(){var M=this.fast_;return M&&M.getTotalWeight()>=this.minWeight_},G.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},G.destroy=function(){},D}();Z.default=F},"./src/utils/ewma.ts":function(ae,Z,k){"use strict";k.r(Z);var V=function(){function F(G,j,M){j===void 0&&(j=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=G,this.alpha_=G?Math.exp(Math.log(.5)/G):0,this.estimate_=j,this.totalWeight_=M}var D=F.prototype;return D.sample=function(j,M){var I=Math.pow(this.alpha_,j);this.estimate_=M*(1-I)+I*this.estimate_,this.totalWeight_+=j},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var j=1-Math.pow(this.alpha_,this.totalWeight_);if(j)return this.estimate_/j}return this.estimate_},F}();Z.default=V},"./src/utils/fetch-loader.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"fetchSupported",function(){return a});var V=k("./src/polyfills/number.ts"),F=k("./src/loader/load-stats.ts"),D=k("./src/demux/chunk-cache.ts");function G(d,O){d.prototype=Object.create(O.prototype),d.prototype.constructor=d,p(d,O)}function j(d){var O=typeof Map=="function"?new Map:void 0;return j=function(x){if(x===null||!g(x))return x;if(typeof x!="function")throw new TypeError("Super expression must either be null or a function");if(typeof O!="undefined"){if(O.has(x))return O.get(x);O.set(x,R)}function R(){return M(x,arguments,f(this).constructor)}return R.prototype=Object.create(x.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),p(R,x)},j(d)}function M(d,O,w){return I()?M=Reflect.construct:M=function(R,A,T){var E=[null];E.push.apply(E,A);var y=Function.bind.apply(R,E),u=new y;return T&&p(u,T.prototype),u},M.apply(null,arguments)}function I(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function g(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function p(d,O){return p=Object.setPrototypeOf||function(x,R){return x.__proto__=R,x},p(d,O)}function f(d){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)},f(d)}function h(){return h=Object.assign||function(d){for(var O=1;O<arguments.length;O++){var w=arguments[O];for(var x in w)Object.prototype.hasOwnProperty.call(w,x)&&(d[x]=w[x])}return d},h.apply(this,arguments)}function a(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var c=function(){function d(w){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=w.fetchSetup||s,this.controller=new self.AbortController,this.stats=new F.LoadStats}var O=d.prototype;return O.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},O.abortInternal=function(){var x=this.response;(!x||!x.ok)&&(this.stats.aborted=!0,this.controller.abort())},O.abort=function(){var x;this.abortInternal(),(x=this.callbacks)!==null&&x!==void 0&&x.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},O.load=function(x,R,A){var T=this,E=this.stats;if(E.loading.start)throw new Error("Loader can only be used once.");E.loading.start=self.performance.now();var y=o(x,this.controller.signal),u=A.onProgress,_=x.responseType==="arraybuffer",m=_?"byteLength":"length";this.context=x,this.config=R,this.callbacks=A,this.request=this.fetchSetup(x,y),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){T.abortInternal(),A.onTimeout(E,x,T.response)},R.timeout),self.fetch(this.request).then(function(b){if(T.response=T.loader=b,!b.ok){var P=b.status,N=b.statusText;throw new l(N||"fetch, bad network response",P,b)}return E.loading.first=Math.max(self.performance.now(),E.loading.start),E.total=parseInt(b.headers.get("Content-Length")||"0"),u&&Object(V.isFiniteNumber)(R.highWaterMark)?T.loadProgressively(b,E,x,R.highWaterMark,u):_?b.arrayBuffer():b.text()}).then(function(b){var P=T.response;self.clearTimeout(T.requestTimeout),E.loading.end=Math.max(self.performance.now(),E.loading.first),E.loaded=E.total=b[m];var N={url:P.url,data:b};u&&!Object(V.isFiniteNumber)(R.highWaterMark)&&u(E,x,b,P),A.onSuccess(N,E,x,P)}).catch(function(b){if(self.clearTimeout(T.requestTimeout),E.aborted)return;var P=b.code||0;A.onError({code:P,text:b.message},x,b.details)})},O.getCacheAge=function(){var x=null;if(this.response){var R=this.response.headers.get("age");x=R?parseFloat(R):null}return x},O.loadProgressively=function(x,R,A,T,E){T===void 0&&(T=0);var y=new D.default,u=x.body.getReader(),_=function m(){return u.read().then(function(b){if(b.done)return y.dataLength&&E(R,A,y.flush(),x),Promise.resolve(new ArrayBuffer(0));var P=b.value,N=P.length;return R.loaded+=N,N<T||y.dataLength?(y.push(P),y.dataLength>=T&&E(R,A,y.flush(),x)):E(R,A,P,x),m()}).catch(function(){return Promise.reject()})};return _()},d}();function o(d,O){var w={method:"GET",mode:"cors",credentials:"same-origin",signal:O,headers:new self.Headers(h({},d.headers))};return d.rangeEnd&&w.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),w}function s(d,O){return new self.Request(d.url,O)}var l=function(d){G(O,d);function O(w,x,R){var A;return A=d.call(this,w)||this,A.code=void 0,A.details=void 0,A.code=x,A.details=R,A}return O}(j(Error));Z.default=c},"./src/utils/imsc1-ttml-parser.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"IMSC1_CODEC",function(){return g}),k.d(Z,"parseIMSC1",function(){return a});var V=k("./src/utils/mp4-tools.ts"),F=k("./src/utils/vttparser.ts"),D=k("./src/utils/vttcue.ts"),G=k("./src/demux/id3.ts"),j=k("./src/utils/timescale-conversion.ts"),M=k("./src/utils/webvtt-parser.ts");function I(){return I=Object.assign||function(T){for(var E=1;E<arguments.length;E++){var y=arguments[E];for(var u in y)Object.prototype.hasOwnProperty.call(y,u)&&(T[u]=y[u])}return T},I.apply(this,arguments)}var g="stpp.ttml.im1t",p=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,f=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,h={left:"start",center:"center",right:"end",start:"start",end:"end"};function a(T,E,y,u,_){var m=Object(V.findBox)(new Uint8Array(T),["mdat"]);if(m.length===0){_(new Error("Could not parse IMSC1 mdat"));return}var b=m[0],P=Object(G.utf8ArrayToStr)(new Uint8Array(T,b.start,b.end-b.start)),N=Object(j.toTimescaleFromScale)(E,1,y);try{u(c(P,N))}catch(K){_(K)}}function c(T,E){var y=new DOMParser,u=y.parseFromString(T,"text/xml"),_=u.getElementsByTagName("tt")[0];if(!_)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},b=Object.keys(m).reduce(function(B,S){return B[S]=_.getAttribute("ttp:"+S)||m[S],B},{}),P=_.getAttribute("xml:space")!=="preserve",N=s(o(_,"styling","style")),K=s(o(_,"layout","region")),X=o(_,"body","[begin]");return[].map.call(X,function(B){var S=l(B,P);if(!S||!B.hasAttribute("begin"))return null;var Y=x(B.getAttribute("begin"),b),te=x(B.getAttribute("dur"),b),re=x(B.getAttribute("end"),b);if(Y===null)throw w(B);if(re===null){if(te===null)throw w(B);re=Y+te}var ce=new D.default(Y-E,re-E,S);ce.id=Object(M.generateCueId)(ce.startTime,ce.endTime,ce.text);var Te=K[B.getAttribute("region")],ye=N[B.getAttribute("style")];ce.position=10,ce.size=80;var be=d(Te,ye),we=be.textAlign;if(we){var xe=h[we];xe&&(ce.lineAlign=xe),ce.align=we}return I(ce,be),ce}).filter(function(B){return B!==null})}function o(T,E,y){var u=T.getElementsByTagName(E)[0];return u?[].slice.call(u.querySelectorAll(y)):[]}function s(T){return T.reduce(function(E,y){var u=y.getAttribute("xml:id");return u&&(E[u]=y),E},{})}function l(T,E){return[].slice.call(T.childNodes).reduce(function(y,u,_){var m;return u.nodeName==="br"&&_?y+`
`:(m=u.childNodes)!==null&&m!==void 0&&m.length?l(u,E):E?y+u.textContent.trim().replace(/\s+/g," "):y+u.textContent},"")}function d(T,E){var y="http://www.w3.org/ns/ttml#styling",u=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return u.reduce(function(_,m){var b=O(E,y,m)||O(T,y,m);return b&&(_[m]=b),_},{})}function O(T,E,y){return T.hasAttributeNS(E,y)?T.getAttributeNS(E,y):null}function w(T){return new Error("Could not parse ttml timestamp "+T)}function x(T,E){if(!T)return null;var y=Object(F.parseTimeStamp)(T);return y===null&&(p.test(T)?y=R(T,E):f.test(T)&&(y=A(T,E))),y}function R(T,E){var y=p.exec(T),u=(y[4]|0)+(y[5]|0)/E.subFrameRate;return(y[1]|0)*3600+(y[2]|0)*60+(y[3]|0)+u/E.frameRate}function A(T,E){var y=f.exec(T),u=Number(y[1]),_=y[2];switch(_){case"h":return u*3600;case"m":return u*60;case"ms":return u*1e3;case"f":return u/E.frameRate;case"t":return u/E.tickRate}return u}},"./src/utils/logger.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"enableLogs",function(){return M}),k.d(Z,"logger",function(){return I});var V=function(){},F={trace:V,debug:V,log:V,warn:V,info:V,error:V},D=F;function G(g){var p=self.console[g];return p?p.bind(self.console,"["+g+"] >"):V}function j(g){for(var p=arguments.length,f=new Array(p>1?p-1:0),h=1;h<p;h++)f[h-1]=arguments[h];f.forEach(function(a){D[a]=g[a]?g[a].bind(g):G(a)})}function M(g){if(self.console&&g===!0||typeof g=="object"){j(g,"debug","log","info","warn","error");try{D.log()}catch(p){D=F}}else D=F}var I=D},"./src/utils/mediakeys-helper.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"KeySystems",function(){return V}),k.d(Z,"requestMediaKeySystemAccess",function(){return F});var V;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})(V||(V={}));var F=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"bin2str",function(){return j}),k.d(Z,"readUint16",function(){return M}),k.d(Z,"readUint32",function(){return I}),k.d(Z,"writeUint32",function(){return g}),k.d(Z,"findBox",function(){return p}),k.d(Z,"parseSegmentIndex",function(){return f}),k.d(Z,"parseInitSegment",function(){return h}),k.d(Z,"getStartDTS",function(){return a}),k.d(Z,"getDuration",function(){return c}),k.d(Z,"computeRawDurationFromSamples",function(){return o}),k.d(Z,"offsetStartDTS",function(){return s}),k.d(Z,"segmentValidRange",function(){return l}),k.d(Z,"appendUint8Array",function(){return d});var V=k("./src/utils/typed-array.ts"),F=k("./src/loader/fragment.ts"),D=Math.pow(2,32)-1,G=[].push;function j(O){return String.fromCharCode.apply(null,O)}function M(O,w){"data"in O&&(w+=O.start,O=O.data);var x=O[w]<<8|O[w+1];return x<0?65536+x:x}function I(O,w){"data"in O&&(w+=O.start,O=O.data);var x=O[w]<<24|O[w+1]<<16|O[w+2]<<8|O[w+3];return x<0?4294967296+x:x}function g(O,w,x){"data"in O&&(w+=O.start,O=O.data),O[w]=x>>24,O[w+1]=x>>16&255,O[w+2]=x>>8&255,O[w+3]=x&255}function p(O,w){var x=[];if(!w.length)return x;var R,A,T;"data"in O?(R=O.data,A=O.start,T=O.end):(R=O,A=0,T=R.byteLength);for(var E=A;E<T;){var y=I(R,E),u=j(R.subarray(E+4,E+8)),_=y>1?E+y:T;if(u===w[0])if(w.length===1)x.push({data:R,start:E+8,end:_});else{var m=p({data:R,start:E+8,end:_},w.slice(1));m.length&&G.apply(x,m)}E=_}return x}function f(O){var w=p(O,["moov"]),x=w[0],R=x?x.end:null,A=p(O,["sidx"]);if(!A||!A[0])return null;var T=[],E=A[0],y=E.data[0],u=y===0?8:16,_=I(E,u);u+=4;var m=0,b=0;y===0?u+=8:u+=16,u+=2;var P=E.end+b,N=M(E,u);u+=2;for(var K=0;K<N;K++){var X=u,B=I(E,X);X+=4;var S=B&2147483647,Y=(B&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var te=I(E,X);X+=4,T.push({referenceSize:S,subsegmentDuration:te,info:{duration:te/_,start:P,end:P+S-1}}),P+=S,X+=4,u=X}return{earliestPresentationTime:m,timescale:_,version:y,referencesCount:N,references:T,moovEndOffset:R}}function h(O){for(var w=[],x=p(O,["moov","trak"]),R=0;R<x.length;R++){var A=x[R],T=p(A,["tkhd"])[0];if(T){var E=T.data[T.start],y=E===0?12:20,u=I(T,y),_=p(A,["mdia","mdhd"])[0];if(_){E=_.data[_.start],y=E===0?12:20;var m=I(_,y),b=p(A,["mdia","hdlr"])[0];if(b){var P=j(b.data.subarray(b.start+8,b.start+12)),N={soun:F.ElementaryStreamTypes.AUDIO,vide:F.ElementaryStreamTypes.VIDEO}[P];if(N){var K=p(A,["mdia","minf","stbl","stsd"])[0],X=void 0;K&&(X=j(K.data.subarray(K.start+12,K.start+16))),w[u]={timescale:m,type:N},w[N]={timescale:m,id:u,codec:X}}}}}}var B=p(O,["moov","mvex","trex"]);return B.forEach(function(S){var Y=I(S,4),te=w[Y];te&&(te.default={duration:I(S,12),flags:I(S,20)})}),w}function a(O,w){return p(w,["moof","traf"]).reduce(function(x,R){var A=p(R,["tfdt"])[0],T=A.data[A.start],E=p(R,["tfhd"]).reduce(function(y,u){var _=I(u,4),m=O[_];if(m){var b=I(A,4);T===1&&(b*=Math.pow(2,32),b+=I(A,8));var P=m.timescale||9e4,N=b/P;if(isFinite(N)&&(y===null||N<y))return N}return y},null);return E!==null&&isFinite(E)&&(x===null||E<x)?E:x},null)||0}function c(O,w){for(var x=0,R=0,A=0,T=p(O,["moof","traf"]),E=0;E<T.length;E++){var y=T[E],u=p(y,["tfhd"])[0],_=I(u,4),m=w[_];if(!m)continue;var b=m.default,P=I(u,0)|(b==null?void 0:b.flags),N=b==null?void 0:b.duration;P&8&&(P&2?N=I(u,12):N=I(u,8));for(var K=m.timescale||9e4,X=p(y,["trun"]),B=0;B<X.length;B++){if(N){var S=I(X[B],4);x=N*S}else x=o(X[B]);m.type===F.ElementaryStreamTypes.VIDEO?R+=x/K:m.type===F.ElementaryStreamTypes.AUDIO&&(A+=x/K)}}if(R===0&&A===0){var Y=f(O);if(Y!=null&&Y.references)return Y.references.reduce(function(te,re){return te+re.info.duration||0},0)}return R||A}function o(O){var w=I(O,0),x=8;w&1&&(x+=4),w&4&&(x+=4);for(var R=0,A=I(O,4),T=0;T<A;T++){if(w&256){var E=I(O,x);R+=E,x+=4}w&512&&(x+=4),w&1024&&(x+=4),w&2048&&(x+=4)}return R}function s(O,w,x){p(w,["moof","traf"]).forEach(function(R){p(R,["tfhd"]).forEach(function(A){var T=I(A,4),E=O[T];if(!E)return;var y=E.timescale||9e4;p(R,["tfdt"]).forEach(function(u){var _=u.data[u.start],m=I(u,4);if(_===0)g(u,4,m-x*y);else{m*=Math.pow(2,32),m+=I(u,8),m-=x*y,m=Math.max(m,0);var b=Math.floor(m/(D+1)),P=Math.floor(m%(D+1));g(u,4,b),g(u,8,P)}})})})}function l(O){var w={valid:null,remainder:null},x=p(O,["moof"]);if(x){if(x.length<2)return w.remainder=O,w}else return w;var R=x[x.length-1];return w.valid=Object(V.sliceUint8)(O,0,R.start-8),w.remainder=Object(V.sliceUint8)(O,R.start-8),w}function d(O,w){var x=new Uint8Array(O.length+w.length);return x.set(O),x.set(w,O.length),x}},"./src/utils/output-filter.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"default",function(){return V});var V=function(){function F(G,j){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=G,this.trackName=j}var D=F.prototype;return D.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},D.newCue=function(j,M,I){(this.startTime===null||this.startTime>j)&&(this.startTime=j),this.endTime=M,this.screen=I,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[]},F}()},"./src/utils/texttrack-utils.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"sendAddTrackEvent",function(){return F}),k.d(Z,"addCueToTrack",function(){return D}),k.d(Z,"clearCurrentCues",function(){return G}),k.d(Z,"removeCuesInRange",function(){return j}),k.d(Z,"getCuesInRange",function(){return I});var V=k("./src/utils/logger.ts");function F(g,p){var f;try{f=new Event("addtrack")}catch(h){f=document.createEvent("Event"),f.initEvent("addtrack",!1,!1)}f.track=g,p.dispatchEvent(f)}function D(g,p){var f=g.mode;if(f==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(p.id))try{if(g.addCue(p),!g.cues.getCueById(p.id))throw new Error("addCue is failed for: "+p)}catch(a){V.logger.debug("[texttrack-utils]: "+a);var h=new self.TextTrackCue(p.startTime,p.endTime,p.text);h.id=p.id,g.addCue(h)}f==="disabled"&&(g.mode=f)}function G(g){var p=g.mode;if(p==="disabled"&&(g.mode="hidden"),g.cues)for(var f=g.cues.length;f--;)g.removeCue(g.cues[f]);p==="disabled"&&(g.mode=p)}function j(g,p,f){var h=g.mode;if(h==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var a=I(g.cues,p,f),c=0;c<a.length;c++)g.removeCue(a[c]);h==="disabled"&&(g.mode=h)}function M(g,p){if(p<g[0].startTime)return 0;var f=g.length-1;if(p>g[f].endTime)return-1;for(var h=0,a=f;h<=a;){var c=Math.floor((a+h)/2);if(p<g[c].startTime)a=c-1;else if(p>g[c].startTime&&h<f)h=c+1;else return c}return g[h].startTime-p<p-g[a].startTime?h:a}function I(g,p,f){var h=[],a=M(g,p);if(a>-1)for(var c=a,o=g.length;c<o;c++){var s=g[c];if(s.startTime>=p&&s.endTime<=f)h.push(s);else if(s.startTime>f)return h}return h}},"./src/utils/time-ranges.ts":function(ae,Z,k){"use strict";k.r(Z);var V={toString:function(D){for(var G="",j=D.length,M=0;M<j;M++)G+="["+D.start(M).toFixed(3)+","+D.end(M).toFixed(3)+"]";return G}};Z.default=V},"./src/utils/timescale-conversion.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"toTimescaleFromBase",function(){return F}),k.d(Z,"toTimescaleFromScale",function(){return D}),k.d(Z,"toMsFromMpegTsClock",function(){return G}),k.d(Z,"toMpegTsClockFromTimescale",function(){return j});var V=9e4;function F(M,I,g,p){g===void 0&&(g=1),p===void 0&&(p=!1);var f=M*I*g;return p?Math.round(f):f}function D(M,I,g,p){return g===void 0&&(g=1),p===void 0&&(p=!1),F(M,I,1/g,p)}function G(M,I){return I===void 0&&(I=!1),F(M,1e3,1/V,I)}function j(M,I){return I===void 0&&(I=1),F(M,V,1/I)}},"./src/utils/typed-array.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"sliceUint8",function(){return V});function V(F,D,G){return Uint8Array.prototype.slice?F.slice(D,G):new Uint8Array(Array.prototype.slice.call(F,D,G))}},"./src/utils/vttcue.ts":function(ae,Z,k){"use strict";k.r(Z),Z.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],F=["start","middle","end","left","right"];function D(g,p){if(typeof p!="string")return!1;if(!Array.isArray(g))return!1;var f=p.toLowerCase();return~g.indexOf(f)?f:!1}function G(g){return D(V,g)}function j(g){return D(F,g)}function M(g){for(var p=arguments.length,f=new Array(p>1?p-1:0),h=1;h<p;h++)f[h-1]=arguments[h];for(var a=1;a<arguments.length;a++){var c=arguments[a];for(var o in c)g[o]=c[o]}return g}function I(g,p,f){var h=this,a={enumerable:!0};h.hasBeenReset=!1;var c="",o=!1,s=g,l=p,d=f,O=null,w="",x=!0,R="auto",A="start",T=50,E="middle",y=50,u="middle";Object.defineProperty(h,"id",M({},a,{get:function(){return c},set:function(m){c=""+m}})),Object.defineProperty(h,"pauseOnExit",M({},a,{get:function(){return o},set:function(m){o=!!m}})),Object.defineProperty(h,"startTime",M({},a,{get:function(){return s},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");s=m,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",M({},a,{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(h,"text",M({},a,{get:function(){return d},set:function(m){d=""+m,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",M({},a,{get:function(){return O},set:function(m){O=m,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",M({},a,{get:function(){return w},set:function(m){var b=G(m);if(b===!1)throw new SyntaxError("An invalid or illegal string was specified.");w=b,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",M({},a,{get:function(){return x},set:function(m){x=!!m,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",M({},a,{get:function(){return R},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=m,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",M({},a,{get:function(){return A},set:function(m){var b=j(m);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");A=b,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",M({},a,{get:function(){return T},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");T=m,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",M({},a,{get:function(){return E},set:function(m){var b=j(m);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");E=b,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",M({},a,{get:function(){return y},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");y=m,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",M({},a,{get:function(){return u},set:function(m){var b=j(m);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");u=b,this.hasBeenReset=!0}})),h.displayState=void 0}return I.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},I}()},"./src/utils/vttparser.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"parseTimeStamp",function(){return D}),k.d(Z,"fixLineBreaks",function(){return p}),k.d(Z,"VTTParser",function(){return f});var V=k("./src/utils/vttcue.ts"),F=function(){function h(){}var a=h.prototype;return a.decode=function(o,s){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},h}();function D(h){function a(o,s,l,d){return(o|0)*3600+(s|0)*60+(l|0)+parseFloat(d||0)}var c=h.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return c?parseFloat(c[2])>59?a(c[2],c[3],0,c[4]):a(c[1],c[2],c[3],c[4]):null}var G=function(){function h(){this.values=Object.create(null)}var a=h.prototype;return a.set=function(o,s){!this.get(o)&&s!==""&&(this.values[o]=s)},a.get=function(o,s,l){return l?this.has(o)?this.values[o]:s[l]:this.has(o)?this.values[o]:s},a.has=function(o){return o in this.values},a.alt=function(o,s,l){for(var d=0;d<l.length;++d)if(s===l[d]){this.set(o,s);break}},a.integer=function(o,s){/^-?\d+$/.test(s)&&this.set(o,parseInt(s,10))},a.percent=function(o,s){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(s)){var l=parseFloat(s);if(l>=0&&l<=100)return this.set(o,l),!0}return!1},h}();function j(h,a,c,o){var s=o?h.split(o):[h];for(var l in s){if(typeof s[l]!="string")continue;var d=s[l].split(c);if(d.length!==2)continue;var O=d[0],w=d[1];a(O,w)}}var M=new V.default(0,0,""),I=M.align==="middle"?"middle":"center";function g(h,a,c){var o=h;function s(){var O=D(h);if(O===null)throw new Error("Malformed timestamp: "+o);return h=h.replace(/^[^\sa-zA-Z-]+/,""),O}function l(O,w){var x=new G;j(O,function(T,E){var y;switch(T){case"region":for(var u=c.length-1;u>=0;u--)if(c[u].id===E){x.set(T,c[u].region);break}break;case"vertical":x.alt(T,E,["rl","lr"]);break;case"line":y=E.split(","),x.integer(T,y[0]),x.percent(T,y[0])&&x.set("snapToLines",!1),x.alt(T,y[0],["auto"]),y.length===2&&x.alt("lineAlign",y[1],["start",I,"end"]);break;case"position":y=E.split(","),x.percent(T,y[0]),y.length===2&&x.alt("positionAlign",y[1],["start",I,"end","line-left","line-right","auto"]);break;case"size":x.percent(T,E);break;case"align":x.alt(T,E,["start",I,"end","left","right"]);break}},/:/,/\s/),w.region=x.get("region",null),w.vertical=x.get("vertical","");var R=x.get("line","auto");R==="auto"&&M.line===-1&&(R=-1),w.line=R,w.lineAlign=x.get("lineAlign","start"),w.snapToLines=x.get("snapToLines",!0),w.size=x.get("size",100),w.align=x.get("align",I);var A=x.get("position","auto");A==="auto"&&M.position===50&&(A=w.align==="start"||w.align==="left"?0:w.align==="end"||w.align==="right"?100:50),w.position=A}function d(){h=h.replace(/^\s+/,"")}if(d(),a.startTime=s(),d(),h.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+o);h=h.substr(3),d(),a.endTime=s(),d(),l(h,a)}function p(h){return h.replace(/<br(?: \/)?>/gi,`
`)}var f=function(){function h(){this.state="INITIAL",this.buffer="",this.decoder=new F,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var a=h.prototype;return a.parse=function(o){var s=this;o&&(s.buffer+=s.decoder.decode(o,{stream:!0}));function l(){var A=s.buffer,T=0;for(A=p(A);T<A.length&&A[T]!=="\r"&&A[T]!==`
`;)++T;var E=A.substr(0,T);return A[T]==="\r"&&++T,A[T]===`
`&&++T,s.buffer=A.substr(T),E}function d(A){j(A,function(T,E){},/:/)}try{var O="";if(s.state==="INITIAL"){if(!/\r\n|\n/.test(s.buffer))return this;O=l();var w=O.match(/^()?WEBVTT([ \t].*)?$/);if(!w||!w[0])throw new Error("Malformed WebVTT signature.");s.state="HEADER"}for(var x=!1;s.buffer;){if(!/\r\n|\n/.test(s.buffer))return this;x?x=!1:O=l();switch(s.state){case"HEADER":/:/.test(O)?d(O):O||(s.state="ID");continue;case"NOTE":O||(s.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(O)){s.state="NOTE";break}if(!O)continue;if(s.cue=new V.default(0,0,""),s.state="CUE",O.indexOf("-->")===-1){s.cue.id=O;continue}case"CUE":if(!s.cue){s.state="BADCUE";continue}try{g(O,s.cue,s.regionList)}catch(A){s.cue=null,s.state="BADCUE";continue}s.state="CUETEXT";continue;case"CUETEXT":{var R=O.indexOf("-->")!==-1;if(!O||R&&(x=!0)){s.oncue&&s.cue&&s.oncue(s.cue),s.cue=null,s.state="ID";continue}if(s.cue===null)continue;s.cue.text&&(s.cue.text+=`
`),s.cue.text+=O}continue;case"BADCUE":O||(s.state="ID")}}}catch(A){s.state==="CUETEXT"&&s.cue&&s.oncue&&s.oncue(s.cue),s.cue=null,s.state=s.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},a.flush=function(){var o=this;try{if((o.cue||o.state==="HEADER")&&(o.buffer+=`
`,o.parse()),o.state==="INITIAL"||o.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(s){o.onparsingerror&&o.onparsingerror(s)}return o.onflush&&o.onflush(),this},h}()},"./src/utils/webvtt-parser.ts":function(ae,Z,k){"use strict";k.r(Z),k.d(Z,"generateCueId",function(){return f}),k.d(Z,"parseWebVTT",function(){return a});var V=k("./src/polyfills/number.ts"),F=k("./src/utils/vttparser.ts"),D=k("./src/demux/id3.ts"),G=k("./src/utils/timescale-conversion.ts"),j=k("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,I=function(o,s,l){return l===void 0&&(l=0),o.substr(l,s.length)===s},g=function(o){var s=parseInt(o.substr(-3)),l=parseInt(o.substr(-6,2)),d=parseInt(o.substr(-9,2)),O=o.length>9?parseInt(o.substr(0,o.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(s)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(d)||!Object(V.isFiniteNumber)(O))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+o);return s+=1e3*l,s+=60*1e3*d,s+=60*60*1e3*O,s},p=function(o){for(var s=5381,l=o.length;l;)s=s*33^o.charCodeAt(--l);return(s>>>0).toString()};function f(c,o,s){return p(c.toString())+p(o.toString())+p(s)}var h=function(o,s,l){var d=o[s],O=o[d.prevCC];if(!O||!O.new&&d.new){o.ccOffset=o.presentationOffset=d.start,d.new=!1;return}for(;(w=O)!==null&&w!==void 0&&w.new;){var w;o.ccOffset+=d.start-O.start,d.new=!1,d=O,O=o[d.prevCC]}o.presentationOffset=l};function a(c,o,s,l,d,O,w,x){var R=new F.VTTParser,A=Object(D.utf8ArrayToStr)(new Uint8Array(c)).trim().replace(M,`
`).split(`
`),T=[],E=Object(G.toMpegTsClockFromTimescale)(o,s),y="00:00.000",u=0,_=0,m,b=!0,P=!1;R.oncue=function(N){var K=l[d],X=l.ccOffset,B=(u-E)/9e4;if(K!=null&&K.new&&(_!==void 0?X=l.ccOffset=K.start:h(l,d,B)),B&&(X=B-l.presentationOffset),P){var S=N.endTime-N.startTime,Y=Object(j.normalizePts)((N.startTime+X-_)*9e4,O*9e4)/9e4;N.startTime=Y,N.endTime=Y+S}var te=N.text.trim();N.text=decodeURIComponent(encodeURIComponent(te)),N.id||(N.id=f(N.startTime,N.endTime,te)),N.endTime>0&&T.push(N)},R.onparsingerror=function(N){m=N},R.onflush=function(){if(m){x(m);return}w(T)},A.forEach(function(N){if(b)if(I(N,"X-TIMESTAMP-MAP=")){b=!1,P=!0,N.substr(16).split(",").forEach(function(K){I(K,"LOCAL:")?y=K.substr(6):I(K,"MPEGTS:")&&(u=parseInt(K.substr(7)))});try{_=g(y)/1e3}catch(K){P=!1,m=K}return}else N===""&&(b=!1);R.parse(N+`
`)}),R.flush()}},"./src/utils/xhr-loader.ts":function(ae,Z,k){"use strict";k.r(Z);var V=k("./src/utils/logger.ts"),F=k("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,G=function(){function j(I){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=I?I.xhrSetup:null,this.stats=new F.LoadStats,this.retryDelay=0}var M=j.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},M.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(g,p,f){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=p,this.callbacks=f,this.retryDelay=p.retryDelay,this.loadInternal()},M.loadInternal=function(){var g=this.config,p=this.context;if(!g)return;var f=this.loader=new self.XMLHttpRequest,h=this.stats;h.loading.first=0,h.loaded=0;var a=this.xhrSetup;try{if(a)try{a(f,p.url)}catch(s){f.open("GET",p.url,!0),a(f,p.url)}f.readyState||f.open("GET",p.url,!0);var c=this.context.headers;if(c)for(var o in c)f.setRequestHeader(o,c[o])}catch(s){this.callbacks.onError({code:f.status,text:s.message},p,f);return}p.rangeEnd&&f.setRequestHeader("Range","bytes="+p.rangeStart+"-"+(p.rangeEnd-1)),f.onreadystatechange=this.readystatechange.bind(this),f.onprogress=this.loadprogress.bind(this),f.responseType=p.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),f.send()},M.readystatechange=function(){var g=this.context,p=this.loader,f=this.stats;if(!g||!p)return;var h=p.readyState,a=this.config;if(f.aborted)return;if(h>=2)if(self.clearTimeout(this.requestTimeout),f.loading.first===0&&(f.loading.first=Math.max(self.performance.now(),f.loading.start)),h===4){p.onreadystatechange=null,p.onprogress=null;var c=p.status;if(c>=200&&c<300){f.loading.end=Math.max(self.performance.now(),f.loading.first);var o,s;if(g.responseType==="arraybuffer"?(o=p.response,s=o.byteLength):(o=p.responseText,s=o.length),f.loaded=f.total=s,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(f,g,o,p),!this.callbacks)return;var d={url:p.responseURL,data:o};this.callbacks.onSuccess(d,f,g,p)}else f.retry>=a.maxRetry||c>=400&&c<499?(V.logger.error(c+" while loading "+g.url),this.callbacks.onError({code:c,text:p.statusText},g,p)):(V.logger.warn(c+" while loading "+g.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,a.maxRetryDelay),f.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)},M.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(g){var p=this.stats;p.loaded=g.loaded,g.lengthComputable&&(p.total=g.total)},M.getCacheAge=function(){var g=null;if(this.loader&&D.test(this.loader.getAllResponseHeaders())){var p=this.loader.getResponseHeader("age");g=p?parseFloat(p):null}return g},j}();Z.default=G}}).default})},vHTk:function(_t,lt,ne){_t.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);