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.
361 lines
903 KiB
361 lines
903 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[244,7],{"+NIl":function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";ie.defineMode("stex",function($,D){"use strict";function V(_,A){_.cmdState.push(A)}function N(_){return _.cmdState.length>0?_.cmdState[_.cmdState.length-1]:null}function P(_){var A=_.cmdState.pop();A&&A.closeBracket()}function H(_){for(var A=_.cmdState,y=A.length-1;y>=0;y--){var u=A[y];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function F(_,A,y){return function(){this.name=_,this.bracketNo=0,this.style=A,this.styles=y,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=F("importmodule","tag",["string","builtin"]),M.documentclass=F("documentclass","tag",["","atom"]),M.usepackage=F("usepackage","tag",["atom"]),M.begin=F("begin","tag",["atom"]),M.end=F("end","tag",["atom"]),M.label=F("label","tag",["atom"]),M.ref=F("ref","tag",["atom"]),M.eqref=F("eqref","tag",["atom"]),M.cite=F("cite","tag",["atom"]),M.bibitem=F("bibitem","tag",["atom"]),M.Bibitem=F("Bibitem","tag",["atom"]),M.RBibitem=F("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(_,A){_.f=A}function b(_,A){var y;if(_.match(/^\\[a-zA-Z@]+/)){var u=_.current().slice(1);return y=M.hasOwnProperty(u)?M[u]:M.DEFAULT,y=new y,V(A,y),O(A,k),y.style}if(_.match(/^\\[$&%#{}_]/))return"tag";if(_.match(/^\\[,;!\/\\]/))return"tag";if(_.match("\\["))return O(A,function(l,h){return C(l,h,"\\]")}),"keyword";if(_.match("\\("))return O(A,function(l,h){return C(l,h,"\\)")}),"keyword";if(_.match("$$"))return O(A,function(l,h){return C(l,h,"$$")}),"keyword";if(_.match("$"))return O(A,function(l,h){return C(l,h,"$")}),"keyword";var a=_.next();if(a=="%")return _.skipToEnd(),"comment";if(a=="}"||a=="]"){if(y=N(A),y)y.closeBracket(a),O(A,k);else return"error";return"bracket"}else return a=="{"||a=="["?(y=M.DEFAULT,y=new y,V(A,y),"bracket"):/\d/.test(a)?(_.eatWhile(/[\w.%]/),"atom"):(_.eatWhile(/[\w\-_]/),y=H(A),y.name=="begin"&&(y.argument=_.current()),y.styleIdentifier())}function C(_,A,y){if(_.eatSpace())return null;if(y&&_.match(y))return O(A,b),"keyword";if(_.match(/^\\[a-zA-Z@]+/))return"tag";if(_.match(/^[a-zA-Z]+/))return"variable-2";if(_.match(/^\\[$&%#{}_]/))return"tag";if(_.match(/^\\[,;!\/]/))return"tag";if(_.match(/^[\^_&]/))return"tag";if(_.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(_.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=_.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(_.skipToEnd(),"comment"):"error"}function k(_,A){var y=_.peek(),u;return y=="{"||y=="["?(u=N(A),u.openBracket(y),_.eat(y),O(A,b),"bracket"):/[ \t\r]/.test(y)?(_.eat(y),null):(O(A,b),P(A),b(_,A))}return{startState:function(){var _=D.inMathMode?function(A,y){return C(A,y)}:b;return{cmdState:[],f:_}},copyState:function(_){return{cmdState:_.cmdState.slice(),f:_.f}},token:function(_,A){return A.f(_,A)},blankLine:function(_){_.f=b,_.cmdState.length=0},lineComment:"%"}}),ie.defineMIME("text/x-stex","stex"),ie.defineMIME("text/x-latex","stex")})},"19Vz":function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){ie.defineOption("placeholder","",function(F,M,O){var b=O&&O!=ie.Init;if(M&&!b)F.on("blur",N),F.on("change",P),F.on("swapDoc",P),ie.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){V(F)}),P(F);else if(!M&&b){F.off("blur",N),F.off("change",P),F.off("swapDoc",P),ie.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),$(F);var C=F.getWrapperElement();C.className=C.className.replace(" CodeMirror-empty","")}M&&!F.hasFocus()&&N(F)});function $(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function D(F){$(F);var M=F.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=F.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var O=F.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),M.appendChild(O),F.display.lineSpace.insertBefore(M,F.display.lineSpace.firstChild)}function V(F){setTimeout(function(){var M=!1,O=F.getInputField();O.nodeName=="TEXTAREA"?M=!O.value:F.lineCount()==1&&(M=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),M?D(F):$(F)},20)}function N(F){H(F)&&D(F)}function P(F){var M=F.getWrapperElement(),O=H(F);M.className=M.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?D(F):$(F)}function H(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";var $={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},D={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ie.defineMode("xml",function(V,N){var P=V.indentUnit,H={},F=N.htmlMode?$:D;for(var M in F)H[M]=F[M];for(var M in N)H[M]=N[M];var O,b;function C(o,E){function v(G){return E.tokenize=G,G(o,E)}var T=o.next();if(T=="<")return o.eat("!")?o.eat("[")?o.match("CDATA[")?v(A("atom","]]>")):null:o.match("--")?v(A("comment","-->")):o.match("DOCTYPE",!0,!0)?(o.eatWhile(/[\w\._\-]/),v(y(1))):null:o.eat("?")?(o.eatWhile(/[\w\._\-]/),E.tokenize=A("meta","?>"),"meta"):(O=o.eat("/")?"closeTag":"openTag",E.tokenize=k,"tag bracket");if(T=="&"){var I;return o.eat("#")?o.eat("x")?I=o.eatWhile(/[a-fA-F\d]/)&&o.eat(";"):I=o.eatWhile(/[\d]/)&&o.eat(";"):I=o.eatWhile(/[\w\.\-:]/)&&o.eat(";"),I?"atom":"error"}else return o.eatWhile(/[^&<]/),null}C.isInText=!0;function k(o,E){var v=o.next();if(v==">"||v=="/"&&o.eat(">"))return E.tokenize=C,O=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return O="equals",null;if(v=="<"){E.tokenize=C,E.state=h,E.tagName=E.tagStart=null;var T=E.tokenize(o,E);return T?T+" tag error":"tag error"}else return/[\'\"]/.test(v)?(E.tokenize=_(v),E.stringStartCol=o.column(),E.tokenize(o,E)):(o.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function _(o){var E=function(v,T){for(;!v.eol();)if(v.next()==o){T.tokenize=k;break}return"string"};return E.isInAttribute=!0,E}function A(o,E){return function(v,T){for(;!v.eol();){if(v.match(E)){T.tokenize=C;break}v.next()}return o}}function y(o){return function(E,v){for(var T;(T=E.next())!=null;){if(T=="<")return v.tokenize=y(o+1),v.tokenize(E,v);if(T==">")if(o==1){v.tokenize=C;break}else return v.tokenize=y(o-1),v.tokenize(E,v)}return"meta"}}function u(o,E,v){this.prev=o.context,this.tagName=E,this.indent=o.indented,this.startOfLine=v,(H.doNotIndent.hasOwnProperty(E)||o.context&&o.context.noIndent)&&(this.noIndent=!0)}function a(o){o.context&&(o.context=o.context.prev)}function l(o,E){for(var v;;){if(!o.context)return;if(v=o.context.tagName,!H.contextGrabbers.hasOwnProperty(v)||!H.contextGrabbers[v].hasOwnProperty(E))return;a(o)}}function h(o,E,v){return o=="openTag"?(v.tagStart=E.column(),w):o=="closeTag"?g:h}function w(o,E,v){return o=="word"?(v.tagName=E.current(),b="tag",x):H.allowMissingTagName&&o=="endTag"?(b="tag bracket",x(o,E,v)):(b="error",w)}function g(o,E,v){if(o=="word"){var T=E.current();return v.context&&v.context.tagName!=T&&H.implicitlyClosed.hasOwnProperty(v.context.tagName)&&a(v),v.context&&v.context.tagName==T||H.matchClosing===!1?(b="tag",m):(b="tag error",L)}else return H.allowMissingTagName&&o=="endTag"?(b="tag bracket",m(o,E,v)):(b="error",L)}function m(o,E,v){return o!="endTag"?(b="error",m):(a(v),h)}function L(o,E,v){return b="error",m(o,E,v)}function x(o,E,v){if(o=="word")return b="attribute",f;if(o=="endTag"||o=="selfcloseTag"){var T=v.tagName,I=v.tagStart;return v.tagName=v.tagStart=null,o=="selfcloseTag"||H.autoSelfClosers.hasOwnProperty(T)?l(v,T):(l(v,T),v.context=new u(v,T,I==v.indented)),h}return b="error",x}function f(o,E,v){return o=="equals"?p:(H.allowMissing||(b="error"),x(o,E,v))}function p(o,E,v){return o=="string"?d:o=="word"&&H.allowUnquoted?(b="string",x):(b="error",x(o,E,v))}function d(o,E,v){return o=="string"?d:x(o,E,v)}return{startState:function(o){var E={tokenize:C,state:h,indented:o||0,tagName:null,tagStart:null,context:null};return o!=null&&(E.baseIndent=o),E},token:function(o,E){if(!E.tagName&&o.sol()&&(E.indented=o.indentation()),o.eatSpace())return null;O=null;var v=E.tokenize(o,E);return(v||O)&&v!="comment"&&(b=null,E.state=E.state(O||v,o,E),b&&(v=b=="error"?v+" error":b)),v},indent:function(o,E,v){var T=o.context;if(o.tokenize.isInAttribute)return o.tagStart==o.indented?o.stringStartCol+1:o.indented+P;if(T&&T.noIndent)return ie.Pass;if(o.tokenize!=k&&o.tokenize!=C)return v?v.match(/^(\s*)/)[0].length:0;if(o.tagName)return H.multilineTagIndentPastTag!==!1?o.tagStart+o.tagName.length+2:o.tagStart+P*(H.multilineTagIndentFactor||1);if(H.alignCDATA&&/<!\[CDATA\[/.test(E))return 0;var I=E&&/^<(\/)?([\w_:\.-]*)/.exec(E);if(I&&I[1])for(;T;)if(T.tagName==I[2]){T=T.prev;break}else if(H.implicitlyClosed.hasOwnProperty(T.tagName))T=T.prev;else break;else if(I)for(;T;){var G=H.contextGrabbers[T.tagName];if(G&&G.hasOwnProperty(I[2]))T=T.prev;else break}for(;T&&T.prev&&!T.startOfLine;)T=T.prev;return T?T.indent+P:o.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:H.htmlMode?"html":"xml",helperType:H.htmlMode?"html":"xml",skipAttribute:function(o){o.state==p&&(o.state=x)},xmlCurrentTag:function(o){return o.tagName?{name:o.tagName,close:o.type=="closeTag"}:null},xmlCurrentContext:function(o){for(var E=[],v=o.context;v;v=v.prev)v.tagName&&E.push(v.tagName);return E.reverse()}}}),ie.defineMIME("text/xml","xml"),ie.defineMIME("application/xml","xml"),ie.mimeModes.hasOwnProperty("text/html")||ie.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"2RCv":function(Et,nt,re){"use strict";var ie=re("Awhp"),$=re("KrTs"),D=re("+L6B"),V=re("2/Rp"),N=re("5NDa"),P=re("5rEg"),H=re("0Owb"),F=re("oBTY"),M=re("tJVT"),O=re("PpiC"),b=re("q1tI"),C=re.n(b),k=function(A){var y=A.InputRight,u=A.value,a=u===void 0?[]:u,l=A.onChange,h=l===void 0?function(){}:l,w=Object(O.a)(A,["InputRight","value","onChange"]),g=Object(b.useState)(),m=Object(M.a)(g,2),L=m[0],x=m[1],f=function(o){var E=a.filter(function(v,T){return T!==o});h(E)},p=function(o){if(o.preventDefault(),!L)return;h([].concat(Object(F.a)(a),[L])),x(null)};return C.a.createElement("div",null,C.a.createElement(P.a,Object(H.a)({},w,{value:L,onChange:function(o){return x(o.target.value)},onPressEnter:p,onBlur:p})),y,C.a.createElement("div",{className:"mt20"},a==null?void 0:a.map(function(d,o){return C.a.createElement($.a,{className:"ml10 mr10",count:"x",onClick:function(){return f(o)}},C.a.createElement(V.a,{type:"primary",ghost:!0},d))})))};nt.a=k},"7Cbv":function(Et,nt,re){"use strict";var ie=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),$=new Uint8Array(16);function D(){if(!ie)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ie($)}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 N(k){return typeof k=="string"&&V.test(k)}for(var P=N,H=[],F=0;F<256;++F)H.push((F+256).toString(16).substr(1));function M(k){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(H[k[_+0]]+H[k[_+1]]+H[k[_+2]]+H[k[_+3]]+"-"+H[k[_+4]]+H[k[_+5]]+"-"+H[k[_+6]]+H[k[_+7]]+"-"+H[k[_+8]]+H[k[_+9]]+"-"+H[k[_+10]]+H[k[_+11]]+H[k[_+12]]+H[k[_+13]]+H[k[_+14]]+H[k[_+15]]).toLowerCase();if(!P(A))throw TypeError("Stringified UUID is invalid");return A}var O=M;function b(k,_,A){k=k||{};var y=k.random||(k.rng||D)();if(y[6]=y[6]&15|64,y[8]=y[8]&63|128,_){A=A||0;for(var u=0;u<16;++u)_[A+u]=y[u];return _}return O(y)}var C=nt.a=b},"7ahc":function(Et,nt,re){"use strict";re.d(nt,"a",function(){return w});var ie=re("k1fw"),$=re("0Owb"),D=re("+L6B"),V=re("2/Rp"),N=re("y8nQ"),P=re("Vl3Y"),H=re("tJVT"),F=re("OaEy"),M=re("2fM7"),O=re("q1tI"),b=re.n(O),C=re("VrN/"),k=re.n(C),_=re("p77/"),A=re.n(_),y=re("c5Ni"),u=re.n(y),a=M.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},h={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};nt.b=function(g){var m=g.callback,L=g.onCancel,x=Object(O.useState)("python"),f=Object(H.a)(x,2),p=f[0],d=f[1];function o(v){d(h[v][1])}function E(v){m(v)}return b.a.createElement(P.a,Object($.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:E}),b.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},b.a.createElement(M.a,{onChange:o},Object.keys(h).map(function(v){return b.a.createElement(a,{key:v,value:v},h[v][0])}))),b.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},b.a.createElement(w,{mode:p})),b.a.createElement("div",{className:"flex-container flex-end"},b.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),b.a.createElement(V.a,{type:"ghost",onClick:L},"\u53D6\u6D88")))};function w(g){var m=g.value,L=g.onChange,x=g.mode,f=g.options,p=f===void 0?{}:f,d=Object(O.useRef)(),o=Object(O.useState)(),E=Object(H.a)(o,2),v=E[0],T=E[1];return Object(O.useEffect)(function(){if(v){function I(G){var X=G.getValue();L&&L(X)}return v.on("change",I),function(){v.off("change",I)}}},[v,L]),Object(O.useEffect)(function(){v&&v.setOption("mode",x)},[v,x]),Object(O.useEffect)(function(){v&&((m!==v.getValue()||m==="")&&setTimeout(function(){v.setValue(m||" ")},300))},[v,m]),Object(O.useEffect)(function(){if(d.current&&!v){var I=k.a.fromTextArea(d.current,Object(ie.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));T(I)}},[d.current,v]),b.a.createElement("div",{className:"my-codemirror-container"},b.a.createElement("textarea",{ref:d}))}},"7ixt":function(Et,nt,re){"use strict";re.d(nt,"a",function(){return D});var ie={adjustX:1,adjustY:1},$=[0,0],D={left:{points:["cr","cl"],overflow:ie,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:ie,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:ie,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:ie,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:ie,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:ie,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:ie,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:ie,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:ie,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:ie,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:ie,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:ie,offset:[-4,0],targetOffset:$}},V=D},"8EBN":function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";ie.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var $=0;$<ie.modeInfo.length;$++){var D=ie.modeInfo[$];D.mimes&&(D.mime=D.mimes[0])}ie.findModeByMIME=function(V){V=V.toLowerCase();for(var N=0;N<ie.modeInfo.length;N++){var P=ie.modeInfo[N];if(P.mime==V)return P;if(P.mimes){for(var H=0;H<P.mimes.length;H++)if(P.mimes[H]==V)return P}}if(/\+xml$/.test(V))return ie.findModeByMIME("application/xml");if(/\+json$/.test(V))return ie.findModeByMIME("application/json")},ie.findModeByExtension=function(V){V=V.toLowerCase();for(var N=0;N<ie.modeInfo.length;N++){var P=ie.modeInfo[N];if(P.ext){for(var H=0;H<P.ext.length;H++)if(P.ext[H]==V)return P}}},ie.findModeByFileName=function(V){for(var N=0;N<ie.modeInfo.length;N++){var P=ie.modeInfo[N];if(P.file&&P.file.test(V))return P}var H=V.lastIndexOf("."),F=H>-1&&V.substring(H+1,V.length);if(F)return ie.findModeByExtension(F)},ie.findModeByName=function(V){V=V.toLowerCase();for(var N=0;N<ie.modeInfo.length;N++){var P=ie.modeInfo[N];if(P.name.toLowerCase()==V)return P;if(P.alias){for(var H=0;H<P.alias.length;H++)if(P.alias[H].toLowerCase()==V)return P}}}})},"8hTe":function(Et,nt,re){Et.exports={button:"button___1wy9m"}},"93VE":function(Et,nt,re){},"9Bee":function(Et,nt,re){"use strict";var ie=re("DYRE"),$=re("zeV3"),D=re("+L6B"),V=re("2/Rp"),N=re("k1fw"),P=re("9og8"),H=re("tJVT"),F=re("WmNS"),M=re.n(F),O=re("q1tI"),b=re.n(O),C=re("vg9a"),k=re("DlQD"),_=re.n(k),A=re("rUJ1");function y(j,s){var c=j.match(/^(\s+)(?:```)/);if(c===null)return s;var R=c[1];return s.split(`
|
|
`).map(function(Z){var U=Z.match(/^\s+/);if(U===null)return Z;var he=Object(H.a)(U,1),Re=he[0];return Re.length>=R.length?Z.slice(R.length):Z}).join(`
|
|
`)}var u=[],a=["<ul>"],l=new _.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function w(){u.length=0,a=["<ul>"]}var g={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(j,s,c,R){if(s>=j.length||j[s].level<=c)return s;var Z=j[s];R.push("<li><a href='#"+Z.anchor+"'>"+Z.text+"</a>"),s++;var U=[];return s=m(j,s,Z.level,U),U.length>0&&(R.push("<ul>"),U.forEach(function(he){R.push(he)}),R.push("</ul>")),R.push("</li>"),s=m(j,s,c,R),s}function L(){return m(u,0,0,a),a.push("</ul>"),a.join("")}var x={heading:function(s){var c=h.exec(s);if(c)return{type:"heading",raw:c[0],depth:c[1].length,text:c[2]}},fences:function(s){var c=this.rules.block.fences.exec(s);if(c){var R=c[0],Z=y(R,c[3]||""),U=c[2]?c[2].trim():c[2];if(["latex","katex","math"].indexOf(U)>=0){var he=d(),Re=Z;Z=he,o[he]={type:"block",expression:Re}}return{type:"code",raw:R,lang:U,text:Z}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,d=function(){return"__special_katext_id_".concat(p++,"__")},o={};function E(){return o}function v(){p=0,o={}}function T(j){return j=j.replace(f,function(s,c){var R=d();return o[R]={type:"inline",expression:c},R}),j}var I=l.listitem;l.listitem=function(j){return I(T(j))};var G=l.paragraph;l.paragraph=function(j){return G(T(j))};var X=l.tablecell;l.tablecell=function(j,s){return X(T(j),s)},l.code=function(j,s,c){var R=(s||"").match(/\S*/)[0];return R?["latex","katex","math"].indexOf(R)>=0?"<p class='editormd-tex'>".concat(j,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?j:Object(A.escape)(j,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(c?j:Object(A.escape)(j,!0))+"</code></pre>"},l.heading=function(j,s,c){var R=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:R,level:s,text:j}),"<h"+s+' id="'+R+'">'+j+"</h"+s+">"},_.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),_.a.use({tokenizer:x,renderer:l});var J=_.a,z=re("SJMd"),W=re("ulZh"),q=re.n(W),ne=re("m3rI"),ce=re("Oy/b"),ve=re("p5ED"),De=re("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var xe=function(j,s){return(xe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,R){c.__proto__=R}||function(c,R){for(var Z in R)Object.prototype.hasOwnProperty.call(R,Z)&&(c[Z]=R[Z])})(j,s)};function Ce(j,s){function c(){this.constructor=j}xe(j,s),j.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Te(j,s,c,R){return new(c||(c=Promise))(function(Z,U){function he(ft){try{ze(R.next(ft))}catch(Pe){U(Pe)}}function Re(ft){try{ze(R.throw(ft))}catch(Pe){U(Pe)}}function ze(ft){var Pe;ft.done?Z(ft.value):(Pe=ft.value,Pe instanceof c?Pe:new c(function(bt){bt(Pe)})).then(he,Re)}ze((R=R.apply(j,s||[])).next())})}function Ee(j,s){var c,R,Z,U,he={label:0,sent:function(){if(1&Z[0])throw Z[1];return Z[1]},trys:[],ops:[]};return U={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Re(ze){return function(ft){return function(Pe){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,R&&(Z=2&Pe[0]?R.return:Pe[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Pe[1])).done)return Z;switch(R=0,Z&&(Pe=[2&Pe[0],Z.value]),Pe[0]){case 0:case 1:Z=Pe;break;case 4:return he.label++,{value:Pe[1],done:!1};case 5:he.label++,R=Pe[1],Pe=[0];continue;case 7:Pe=he.ops.pop(),he.trys.pop();continue;default:if(!(Z=he.trys,(Z=Z.length>0&&Z[Z.length-1])||Pe[0]!==6&&Pe[0]!==2)){he=0;continue}if(Pe[0]===3&&(!Z||Pe[1]>Z[0]&&Pe[1]<Z[3])){he.label=Pe[1];break}if(Pe[0]===6&&he.label<Z[1]){he.label=Z[1],Z=Pe;break}if(Z&&he.label<Z[2]){he.label=Z[2],he.ops.push(Pe);break}Z[2]&&he.ops.pop(),he.trys.pop();continue}Pe=s.call(j,he)}catch(bt){Pe=[6,bt],R=0}finally{c=Z=0}if(5&Pe[0])throw Pe[1];return{value:Pe[0]?Pe[1]:void 0,done:!0}}([ze,ft])}}}function ge(){for(var j=0,s=0,c=arguments.length;s<c;s++)j+=arguments[s].length;var R=Array(j),Z=0;for(s=0;s<c;s++)for(var U=arguments[s],he=0,Re=U.length;he<Re;he++,Z++)R[Z]=U[he];return R}var se=function(){function j(){}return j.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},j.setAttributes=function(s,c){for(var R=0,Z=c;R<Z.length;R++){var U=Z[R],he=U[0],Re=U[1];s.setAttribute(he,Re)}},j.createRect=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect");return Z.setAttribute("width",s.toString()),Z.setAttribute("height",c.toString()),R&&j.setAttributes(Z,R),Z},j.createLine=function(s,c,R,Z,U){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",c.toString()),he.setAttribute("x2",R.toString()),he.setAttribute("y2",Z.toString()),U&&j.setAttributes(he,U),he},j.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&j.setAttributes(R,c),R},j.createCircle=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","circle");return R.setAttribute("cx",(s/2).toString()),R.setAttribute("cy",(s/2).toString()),R.setAttribute("r",s.toString()),c&&j.setAttributes(R,c),R},j.createEllipse=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Z.setAttribute("cx",(s/2).toString()),Z.setAttribute("cy",(c/2).toString()),Z.setAttribute("rx",(s/2).toString()),Z.setAttribute("ry",(c/2).toString()),R&&j.setAttributes(Z,R),Z},j.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&j.setAttributes(c,s),c},j.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},j.createMarker=function(s,c,R,Z,U,he,Re){var ze=document.createElementNS("http://www.w3.org/2000/svg","marker");return j.setAttributes(ze,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",he.toString()]]),ze.appendChild(Re),ze},j.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&j.setAttributes(c,s),c},j.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&j.setAttributes(R,c),R},j.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&j.setAttributes(c,s),c},j.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},j.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&j.setAttributes(R,c),R},j}(),ke=function(){function j(){}return j.addKey=function(s){j.key=s},Object.defineProperty(j,"isLicensed",{get:function(){return!!j.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(j.key)},enumerable:!1,configurable:!0}),j}(),Ve=function(){function j(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return j.prototype.rasterize=function(s,c,R){var Z=this;return new Promise(function(U){var he=R!==void 0?R:document.createElement("canvas");s===null&&(Z.markersOnly=!0,Z.naturalSize=!1);var Re=document.createElementNS("http://www.w3.org/2000/svg","svg");Re.setAttribute("xmlns","http://www.w3.org/2000/svg"),Re.setAttribute("width",c.width.baseVal.valueAsString),Re.setAttribute("height",c.height.baseVal.valueAsString),Re.setAttribute("viewBox","0 0 "+c.viewBox.baseVal.width.toString()+" "+c.viewBox.baseVal.height.toString()),Re.innerHTML=c.innerHTML,Z.naturalSize===!0?(Re.width.baseVal.value=s.naturalWidth,Re.height.baseVal.value=s.naturalHeight):Z.width!==void 0&&Z.height!==void 0&&(Re.width.baseVal.value=Z.width,Re.height.baseVal.value=Z.height),he.width=Re.width.baseVal.value,he.height=Re.height.baseVal.value;var ze=Re.outerHTML,ft=he.getContext("2d");Z.markersOnly!==!0&&ft.drawImage(s,0,0,he.width,he.height);var Pe=window.URL,bt=new Image(he.width,he.height);bt.setAttribute("crossOrigin","anonymous");var Ut=new Blob([ze],{type:"image/svg+xml"}),Yt=Pe.createObjectURL(Ut);bt.onload=function(){ft.drawImage(bt,0,0),Pe.revokeObjectURL(Yt);var Mr=he.toDataURL(Z.imageType,Z.imageQuality);U(Mr)},bt.src=Yt})},j}(),He=function(){},tt=function(){function j(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(j.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(j.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(j.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),j.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},j.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},j.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new Ke("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ke("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Ke("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Le("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Le("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},j.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},j}(),Ke=function(j,s){this.selector=j,this.style=s},Le=function(j,s){this.localName=j,this.style=s},Me=function(){function j(s,c,R,Z,U){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=c,this.markerItems=R,this.uiStyleSettings=Z,this.styles=U,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return j.prototype.show=function(s){var c=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var R=document.createElement("div");R.className=this.toolbarBlockStyleClass.name,R.style.whiteSpace="nowrap",this.uiContainer.appendChild(R),this.addActionButton(R,'<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(R,'<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(R,'<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(R,'<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(R,'<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(R,'<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(R,'<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(R,'<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(U){var he=document.createElement("div");he.className=""+c.toolbarButtonStyleClass.name,he.setAttribute("data-type-name",U.typeName),he.innerHTML=U.icon,he.addEventListener("click",function(){c.markerToolbarButtonClicked(he,U)}),c.buttons.push(he),c.markerButtons.push(he)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var Z=document.createElement("div");Z.className=this.toolbarBlockStyleClass.name,Z.style.whiteSpace="nowrap",Z.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(Z),this.addActionButton(Z,'<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(Z,'<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()},j.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},j.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},j.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},j.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var c=0;c<this.markerButtons.length;c++)c<s||c===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[c]):(c===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[c]))}},j.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")},j.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(c){c.className=c.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),c.className=c.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),c.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},j.prototype.addActionButton=function(s,c,R){var Z=this,U=document.createElement("div");switch(U.className=""+this.toolbarButtonStyleClass.name,U.innerHTML=c,U.setAttribute("data-action",R),U.addEventListener("click",function(){Z.actionToolbarButtonClicked(U,R)}),R){case"select":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":U.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":U.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":U.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(U),this.buttons.push(U)},j.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Le("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 Le("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Le("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Le("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 Le("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Le("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Le("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Le("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ke("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Ke("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},j.prototype.markerToolbarButtonClicked=function(s,c){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(R){return R("marker",c)}),this.markerButtonOverflowBlock.style.display="none"},j.prototype.actionToolbarButtonClicked=function(s,c){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(R){return R("action",c)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},j.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},j.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(R){return R.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},j.prototype.setCurrentMarker=function(s){var c=this;this.currentMarker=s,this.buttons.filter(function(R){return/delete|notes/.test(R.getAttribute("data-action"))}).forEach(function(R){c.currentMarker===void 0?(R.style.fillOpacity="0.4",R.style.pointerEvents="none"):(R.style.fillOpacity="1",R.style.pointerEvents="all")})},j}(),We=function(){function j(s,c,R,Z){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=c,this.uiStyleSettings=R,this.styles=Z,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return j.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Le("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 Le("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var c=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Le("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Le("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Le("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 Le("toolbox-panel-row_colors",`
|
|
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Le("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 Le("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Le("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Ke("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ke("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},j.prototype.show=function(s){var c;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((c=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},j.prototype.setPanelButtons=function(s){var c,R,Z=this;this.panels=s,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+" "+((R=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&R!==void 0?R:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(U){var he;U.uiStyleSettings=Z.uiStyleSettings;var Re=document.createElement("div");Re.className=Z.toolboxButtonStyleClass.name+" "+((he=Z.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&he!==void 0?he:Z.toolboxButtonStyleColorsClass.name),Re.innerHTML=U.icon,Re.title=U.title,Re.addEventListener("click",function(){Z.panelButtonClick(U)}),Z.panelButtons.push(Re),Z.buttonRow.appendChild(Re)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},j.prototype.panelButtonClick=function(s){var c=this,R=-1;if(s!==this.activePanel){R=this.panels.indexOf(s),this.panelRow.innerHTML="";var Z=s.getUi();Z.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(Z),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){c.displayMode==="inline"?c.panelRow.style.display="none":c.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(U,he){var Re,ze;U.className=c.toolboxButtonStyleClass.name+" "+(he===R?""+((Re=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Re!==void 0?Re:c.toolboxActiveButtonStyleColorsClass.name):""+((ze=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ze!==void 0?ze:c.toolboxButtonStyleColorsClass.name))})},j}(),Xe=function(j,s){this.title=j,this.icon=s},Ge=function(j){function s(c,R,Z,U){var he=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return he.colors=[],he.addTransparent=!1,he.colorBoxes=[],he.colors=R,he.currentColor=Z,he.setCurrentColor=he.setCurrentColor.bind(he),he.getColorBox=he.getColorBox.bind(he),he}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.overflow="hidden",R.style.whiteSpace="nowrap",this.colors.forEach(function(Z){var U=c.getColorBox(Z);R.appendChild(U),c.colorBoxes.push(U)}),R},s.prototype.getColorBox=function(c){var R=this,Z=this.uiStyleSettings.toolbarHeight/4,U=this.uiStyleSettings.toolbarHeight-Z,he=document.createElement("div");he.style.display="inline-block",he.style.boxSizing="content-box",he.style.width=U-2+"px",he.style.height=U-2+"px",he.style.padding="1px",he.style.marginRight="2px",he.style.marginBottom="2px",he.style.borderWidth="2px",he.style.borderStyle="solid",he.style.borderRadius=(U+2)/2+"px",he.style.borderColor=c===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",he.addEventListener("click",function(){R.setCurrentColor(c,he)});var Re=document.createElement("div");return Re.style.display="inline-block",Re.style.width=U-2+"px",Re.style.height=U-2+"px",Re.style.backgroundColor=c,Re.style.borderRadius=U/2+"px",c==="transparent"&&(Re.style.fill=this.uiStyleSettings.toolboxAccentColor,Re.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),he.appendChild(Re),he},s.prototype.setCurrentColor=function(c,R){var Z=this;this.currentColor=c,this.colorBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(c)},s}(Xe),Fe=function(){function j(s,c,R){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=c,this.globalSettings=R,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(j.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),j.prototype.ownsTarget=function(s){return!1},Object.defineProperty(j.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),j.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},j.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},j.prototype.pointerDown=function(s,c){},j.prototype.dblClick=function(s,c){},j.prototype.manipulate=function(s){},j.prototype.pointerUp=function(s){this.stateChanged()},j.prototype.dispose=function(){},j.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},j.prototype.getState=function(){return{typeName:j.typeName,state:this.state,notes:this.notes}},j.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},j.prototype.scale=function(s,c){},j.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},j.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},j.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},j.typeName="MarkerBase",j}(),Be=function(){function j(){this.findGripByVisual=this.findGripByVisual.bind(this)}return j.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},j}(),ot=function(){function j(){this.GRIP_SIZE=10,this.visual=se.createGroup(),this.visual.appendChild(se.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(se.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return j.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},j}(),et=function(){function j(){}return j.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},j.toSVGMatrix=function(s,c){return s.a=c.a,s.b=c.b,s.c=c.c,s.d=c.d,s.e=c.e,s.f=c.f,s},j}(),Ze=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.left=0,U.top=0,U.width=0,U.height=0,U.defaultSize={x:50,y:20},U.offsetX=0,U.offsetY=0,U.rotationAngle=0,U.CB_DISTANCE=10,U._suppressMarkerCreateEvent=!1,U.container.transform.baseVal.appendItem(se.createTransform()),U.setupControlBox(),U}return Ce(s,j),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(c){this._visual=c;var R=se.createTransform();this._visual.transform.baseVal.appendItem(R)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!!j.prototype.ownsTarget.call(this,c)||!!(this.controlGrips.findGripByVisual(c)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(c))},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),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 Z=this.unrotatePoint(c);if(this.manipulationStartX=Z.x,this.manipulationStartY=Z.y,this.offsetX=Z.x-this.left,this.offsetY=Z.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(R),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(R)){this.activeGrip=this.rotatorGrip;var U=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=U.x-this.width/2,this.top=U.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var he=this.container.transform.baseVal.getItem(0);he.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(he,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(c){var R=this.state;j.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",R==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(c){this.visual.style.transform="translate("+c.x+"px, "+c.y+"px)"},s.prototype.manipulate=function(c){var R=this.unrotatePoint(c);this.state==="creating"?this.resize(c):this.state==="move"?(this.left=this.manipulationStartLeft+(R.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(R.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(R):this.state==="rotate"&&this.rotate(c)},s.prototype.resize=function(c){var R=this.manipulationStartLeft,Z=this.manipulationStartWidth,U=this.manipulationStartTop,he=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:R=this.manipulationStartLeft+c.x-this.manipulationStartX,Z=this.manipulationStartWidth+this.manipulationStartLeft-R;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Z=this.manipulationStartWidth+c.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:U=this.manipulationStartTop+c.y-this.manipulationStartY,he=this.manipulationStartHeight+this.manipulationStartTop-U;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:he=this.manipulationStartHeight+c.y-this.manipulationStartY}Z>=0?(this.left=R,this.width=Z):(this.left=R+Z,this.width=-Z),he>=0?(this.top=U,this.height=he):(this.top=U+he,this.height=-he),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(c){if(Math.abs(c.x-this.centerX)>.1){var R=Math.sign(c.x-this.centerX);this.rotationAngle=180*Math.atan((c.y-this.centerY)/(c.x-this.centerX))/Math.PI+90*R,this.applyRotation()}},s.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)},s.prototype.rotatePoint=function(c){if(this.rotationAngle===0)return c;var R=this.container.getCTM(),Z=se.createPoint(c.x,c.y);return{x:(Z=Z.matrixTransform(R)).x,y:Z.y}},s.prototype.unrotatePoint=function(c){if(this.rotationAngle===0)return c;var R=this.container.getCTM();R=R.inverse();var Z=se.createPoint(c.x,c.y);return{x:(Z=Z.matrixTransform(R)).x,y:Z.y}},s.prototype.select=function(){j.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){j.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup();var c=se.createTransform();c.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(c),this.container.appendChild(this.controlBox),this.controlRect=se.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=se.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Be,this.addControlGrips(),this.controlBox.style.display="none"},s.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()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var c=new ot;return c.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.controlGrips.topLeft.GRIP_SIZE,R=-c/2,Z=R,U=(this.width+this.CB_DISTANCE)/2-c/2,he=(this.height+this.CB_DISTANCE)/2-c/2,Re=this.height+this.CB_DISTANCE-c/2,ze=this.width+this.CB_DISTANCE-c/2;this.positionGrip(this.controlGrips.topLeft.visual,R,Z),this.positionGrip(this.controlGrips.topCenter.visual,U,Z),this.positionGrip(this.controlGrips.topRight.visual,ze,Z),this.positionGrip(this.controlGrips.centerLeft.visual,R,he),this.positionGrip(this.controlGrips.centerRight.visual,ze,he),this.positionGrip(this.controlGrips.bottomLeft.visual,R,Re),this.positionGrip(this.controlGrips.bottomCenter.visual,U,Re),this.positionGrip(this.controlGrips.bottomRight.visual,ze,Re),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,U,Z-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(c,R,Z){var U=c.transform.baseVal.getItem(0);U.setTranslate(R,Z),c.transform.baseVal.replaceItem(U,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:et.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:et.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.left=R.left,this.top=R.top,this.width=R.width,this.height=R.height,this.rotationAngle=R.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(et.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,R.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(et.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,R.containerTransformMatrix))},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R);var Z=this.rotatePoint({x:this.left,y:this.top}),U=this.unrotatePoint({x:Z.x*c,y:Z.y*R});this.left=U.x,this.top=U.y,this.width=this.width*c,this.height=this.height*R,this.adjustControlBox()},s}(Fe),rt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.createVisual=U.createVisual.bind(U),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=se.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){j.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){j.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){var R=c;this.fillColor=R.fillColor,this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.opacity=R.opacity,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize()},s.title="Rectangle marker",s}(Ze),ht=function(j){function s(c,R,Z,U){var he=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return he.widths=[],he.widthBoxes=[],he.widths=R,he.currentWidth=Z,he.setCurrentWidth=he.setCurrentWidth.bind(he),he}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",this.widths.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.flexGrow="2",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=Z===c.currentWidth?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentWidth(Z,U)}),R.appendChild(U);var he=document.createElement("div");he.innerText=Z.toString(),he.style.marginRight="5px",U.appendChild(he);var Re=document.createElement("div");Re.style.minHeight="20px",Re.style.flexGrow="2",Re.style.display="flex",Re.style.alignItems="center";var ze=document.createElement("hr");ze.style.minWidth="20px",ze.style.border="0px",ze.style.borderTop=Z+"px solid "+c.uiStyleSettings.toolboxColor,ze.style.flexGrow="2",Re.appendChild(ze),U.appendChild(Re),c.widthBoxes.push(U)}),R},s.prototype.setCurrentWidth=function(c,R){var Z=this;this.currentWidth=c,this.widthBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(Xe),Qe=function(j){function s(c,R,Z,U){var he=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return he.styles=[],he.styleBoxes=[],he.styles=R,he.currentStyle=Z,he.setCurrentStyle=he.setCurrentStyle.bind(he),he}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",this.styles.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/c.styles.length-5+"%",U.style.borderColor=Z===c.currentStyle?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentStyle(Z,U)}),R.appendChild(U);var he=document.createElement("div");he.style.minHeight="20px",he.style.flexGrow="2",he.style.overflow="hidden";var Re=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+c.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Z!==""?'stroke-dasharray="'+Z+'"':"")+` />
|
|
</svg>`;he.innerHTML=Re,U.appendChild(he),c.styleBoxes.push(U)}),R},s.prototype.setCurrentStyle=function(c,R){var Z=this;this.currentStyle=c,this.styleBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(Xe),Je=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new Ge("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new Qe("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(rt),we=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1},lt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.x1=0,U.y1=0,U.x2=0,U.y2=0,U.defaultLength=50,U.manipulationStartX=0,U.manipulationStartY=0,U.manipulationStartX1=0,U.manipulationStartY1=0,U.manipulationStartX2=0,U.manipulationStartY2=0,U.setupControlBox(),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!!j.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),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(R)?this.activeGrip=this.grip1:this.grip2.ownsTarget(R)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(c){var R=this.state;j.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",R==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.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)},s.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()},s.prototype.select=function(){j.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){j.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var c=new ot;return c.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(c.visual),c},s.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)},s.prototype.positionGrip=function(c,R,Z){var U=c.transform.baseVal.getItem(0);U.setTranslate(R,Z),c.transform.baseVal.replaceItem(U,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.x1=R.x1,this.y1=R.y1,this.x2=R.x2,this.y2=R.y2},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.x1=this.x1*c,this.y1=this.y1*R,this.x2=this.x2*c,this.y2=this.y2*R,this.adjustVisual(),this.adjustControlBox()},s}(Fe),it=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new Ge("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new Qe("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorLine&&c!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),se.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(lt),Ae=function(j){function s(c,R,Z,U){var he=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return he.fonts=[],he.fontBoxes=[],he.fonts=R,he.currentFont=Z,he.setCurrentFont=he.setCurrentFont.bind(he),he}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.overflow="hidden",R.style.flexGrow="2",this.fonts.forEach(function(Z){var U=document.createElement("div");U.style.display="inline-block",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/c.fonts.length-5+"%",U.style.borderColor=Z===c.currentFont?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentFont(Z,U)}),R.appendChild(U);var he=document.createElement("div");he.style.display="flex",he.style.minHeight="20px",he.style.flexGrow="2",he.style.fontFamily=Z,he.style.overflow="hidden";var Re=document.createElement("div");Re.style.whiteSpace="nowrap",Re.style.overflow="hidden",Re.style.textOverflow="ellipsis",Re.innerHTML="The quick brown fox jumps over the lazy dog",he.appendChild(Re),U.appendChild(he),c.fontBoxes.push(U)}),R},s.prototype.setCurrentFont=function(c,R){var Z=this;this.currentFont=c,this.fontBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(Xe),Ne=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.color="transparent",U.padding=5,U.DEFAULT_TEXT="your text here",U.text=U.DEFAULT_TEXT,U.isMoved=!1,U.color=Z.defaultColor,U.fontFamily=Z.defaultFontFamily,U.defaultSize={x:100,y:30},U.setColor=U.setColor.bind(U),U.setFont=U.setFont.bind(U),U.renderText=U.renderText.bind(U),U.sizeText=U.sizeText.bind(U),U.textEditDivClicked=U.textEditDivClicked.bind(U),U.showTextEditor=U.showTextEditor.bind(U),U.setSize=U.setSize.bind(U),U.positionTextEditor=U.positionTextEditor.bind(U),U.colorPanel=new Ge("Color",Z.defaultColorSet,Z.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.fontFamilyPanel=new Ae("Font",Z.defaultFontFamilies,Z.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U}return Ce(s,j),s.prototype.ownsTarget=function(c){if(j.prototype.ownsTarget.call(this,c)||c===this.visual||c===this.textElement||c===this.bgRectangle)return!0;var R=!1;return this.textElement.childNodes.forEach(function(Z){Z===c&&(R=!0)}),R},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.bgRectangle=se.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=se.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.isMoved=!1,this.pointerDownPoint=c,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.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(R){c.textElement.appendChild(se.createTSpan(R.trim()===""?" ":R.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var c=this.textElement.getBBox(),R=1;if(c.width>0&&c.height>0){var Z=(1*this.width-this.width*this.padding*2/100)/c.width,U=(1*this.height-this.height*this.padding*2/100)/c.height;R=Math.min(Z,U)}return R},s.prototype.getTextPosition=function(c){var R=this.textElement.getBBox(),Z=0,U=0;return R.width>0&&R.height>0&&(Z=(this.width-R.width*c)/2,U=this.height/2-R.height*c/2),{x:Z,y:U}},s.prototype.sizeText=function(){var c=this.textElement.getBBox(),R=this.getTextScale(),Z=this.getTextPosition(R);Z.y-=c.y*R,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Z.x+"px, "+Z.y+"px) scale("+R+", "+R+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Z.x,Z.y),this.textElement.transform.baseVal.getItem(1).setScale(R,R))},s.prototype.manipulate=function(c){j.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)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){j.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(c){var R=this.state;R==="creating"&&(this._suppressMarkerCreateEvent=!0),j.prototype.pointerUp.call(this,c),this.setSize(),(R==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.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(R){R.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var R=Number.parseFloat(c.textEditor.style.fontSize);c.textEditor.clientWidth>=Number.parseInt(c.textEditor.style.maxWidth)&&R>.9;)R-=.1,c.textEditor.style.fontSize=Math.max(R,.9)+"em"}),this.textEditor.addEventListener("keyup",function(R){R.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(R){if(R.clipboardData){var Z=R.clipboardData.getData("text"),U=window.getSelection();if(!U.rangeCount)return!1;U.deleteFromDocument(),U.getRangeAt(0).insertNode(document.createTextNode(Z)),R.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")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var c=this.getTextScale(),R=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Z=this.textElement.getBBox(),U={x:Z.width*c,y:Z.height*c};R.x-=U.x/2,R.y-=U.y/2,this.textEditor.style.top=R.y+"px",this.textEditor.style.left=R.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-R.x+"px",this.textEditor.style.fontSize=Math.max(16*c,12)+"px",this.textElement.style.display="none"}},s.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()},s.prototype.select=function(){j.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),j.prototype.deselect.call(this)},s.prototype.dblClick=function(c,R){j.prototype.dblClick.call(this,c,R),this.showTextEditor()},s.prototype.setColor=function(c){this.textElement&&se.setAttributes(this.textElement,[["fill",c]]),this.color=c,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(c)},s.prototype.setFont=function(c){this.textElement&&se.setAttributes(this.textElement,[["font-family",c]]),this.fontFamily=c,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.color=R.color,this.fontFamily=R.fontFamily,this.padding=R.padding,this.text=R.text,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',s}(Ze),me=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.color="transparent",U.lineWidth=3,U.drawing=!1,U.pixelRatio=1,U.color=Z.defaultColor,U.lineWidth=Z.defaultStrokeWidth,U.pixelRatio=Z.freehandPixelRatio,U.setColor=U.setColor.bind(U),U.addCanvas=U.addCanvas.bind(U),U.finishCreation=U.finishCreation.bind(U),U.setLineWidth=U.setLineWidth.bind(U),U.colorPanel=new Ge("Color",Z.defaultColorSet,Z.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.lineWidthPanel=new ht("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.lineWidthPanel.onWidthChanged=U.setLineWidth,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.drawingImage=se.createImage(),this.visual.appendChild(this.drawingImage);var c=se.createTransform();this.visual.transform.baseVal.appendItem(c),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){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):j.prototype.pointerDown.call(this,c,R)},s.prototype.manipulate=function(c){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(c.x,c.y),this.canvasContext.stroke()):j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):j.prototype.pointerUp.call(this,c)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),j.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),j.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var c=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),R=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Z=R[0],U=R[1],he=R[2],Re=R[3],ze=!1,ft=0;ft<this.canvasElement.height;ft++)for(var Pe=0;Pe<this.canvasElement.width;Pe++)c.data[ft*this.canvasElement.width*4+4*Pe+3]>0&&(ze=!0,ft<U&&(U=ft),Pe<Z&&(Z=Pe),ft>Re&&(Re=ft),Pe>he&&(he=Pe));if(ze){this.left=Z/this.pixelRatio,this.top=U/this.pixelRatio,this.width=(he-Z)/this.pixelRatio,this.height=(Re-U)/this.pixelRatio;var bt=document.createElement("canvas");bt.width=he-Z,bt.height=Re-U,bt.getContext("2d").putImageData(this.canvasContext.getImageData(Z,U,he-Z,Re-U),0,0),this.drawingImgUrl=bt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(c){this.color=c,this.colorChanged(c)},s.prototype.setLineWidth=function(c){this.lineWidth=c},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({drawingImgUrl:this.drawingImgUrl},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),j.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',s}(Ze),de=function(j){function s(c,R,Z){var U=j.call(this,c,Z||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return U.typeBoxes=[],U.currentType=R,U.setCurrentType=U.setCurrentType.bind(U),U}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2";for(var Z=function(Re){var ze="both";switch(Re){case 0:ze="both";break;case 1:ze="start";break;case 2:ze="end";break;case 3:ze="none"}var ft=document.createElement("div");if(ft.style.display="flex",ft.style.flexGrow="2",ft.style.alignItems="center",ft.style.justifyContent="space-between",ft.style.padding="5px",ft.style.borderWidth="2px",ft.style.borderStyle="solid",ft.style.borderColor=ze===U.currentType?U.uiStyleSettings.toolboxAccentColor:"transparent",ft.addEventListener("click",function(){c.setCurrentType(ze,ft)}),R.appendChild(ft),ze==="both"||ze==="start"){var Pe=document.createElement("div");Pe.style.display="flex",Pe.style.alignItems="center",Pe.style.minHeight="20px",Pe.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="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Pe.style.marginLeft="5px",ft.appendChild(Pe)}var bt=document.createElement("div");bt.style.display="flex",bt.style.alignItems="center",bt.style.minHeight="20px",bt.style.flexGrow="2";var Ut=document.createElement("hr");if(Ut.style.minWidth="20px",Ut.style.border="0px",Ut.style.borderTop="3px solid "+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee"),Ut.style.flexGrow="2",bt.appendChild(Ut),ft.appendChild(bt),ze==="both"||ze==="end"){var Yt=document.createElement("div");Yt.style.display="flex",Yt.style.alignItems="center",Yt.style.minHeight="20px",Yt.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="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Yt.style.marginRight="5px",ft.appendChild(Yt)}U.typeBoxes.push(ft)},U=this,he=0;he<4;he++)Z(he);return R},s.prototype.setCurrentType=function(c,R){var Z=this;this.currentType=c,this.typeBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings!==void 0?Z.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(Xe),fe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.arrowType="end",U.arrowBaseHeight=10,U.arrowBaseWidth=10,U.getArrowPoints=U.getArrowPoints.bind(U),U.setArrowType=U.setArrowType.bind(U),U.arrowTypePanel=new de("Arrow type","end"),U.arrowTypePanel.onArrowTypeChanged=U.setArrowType,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.arrow1&&c!==this.arrow2)},s.prototype.getArrowPoints=function(c,R){var Z=this.arrowBaseWidth+2*this.strokeWidth,U=this.arrowBaseHeight+2*this.strokeWidth;return c-Z/2+","+(R+U/2)+" "+c+","+(R-U/2)+" "+(c+Z/2)+","+(R+U/2)},s.prototype.createTips=function(){this.arrow1=se.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=se.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(j.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",se.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),se.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),R=this.arrow1.transform.baseVal.getItem(0);R.setRotate(c,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(R,0);var Z=this.arrow2.transform.baseVal.getItem(0);Z.setRotate(c+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Z,0)}},s.prototype.setArrowType=function(c){this.arrowType=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({arrowType:this.arrowType},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.arrowType=R.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(it),ee=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor=Z.defaultFillColor,U.strokeWidth=0,U.fillPanel=new Ge("Color",Z.defaultColorSet,Z.defaultFillColor),U.fillPanel.onColorChanged=U.setFillColor,U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(rt),te=function(j){function s(c,R,Z,U){var he=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return he.opacities=[],he.opacityBoxes=[],he.opacities=R,he.currentOpacity=Z,he.setCurrentOpacity=he.setCurrentOpacity.bind(he),he}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",R.style.justifyContent="space-between",this.opacities.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="center",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=Z===c.currentOpacity?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentOpacity(Z,U)}),R.appendChild(U);var he=document.createElement("div");he.innerText=100*Z+"%",U.appendChild(he),c.opacityBoxes.push(U)}),R},s.prototype.setCurrentOpacity=function(c,R){var Z=this;this.currentOpacity=c,this.opacityBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(Xe),ae=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.setOpacity=U.setOpacity.bind(U),U.fillColor=Z.defaultHighlightColor,U.strokeWidth=0,U.opacity=Z.defaultHighlightOpacity,U.fillPanel=new Ge("Color",Z.defaultColorSet,U.fillColor),U.fillPanel.onColorChanged=U.setFillColor,U.opacityPanel=new te("Opacity",Z.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,j),s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',s}(ee),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>',pe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.bgColor="transparent",U.tipPosition={x:0,y:0},U.tipBase1Position={x:0,y:0},U.tipBase2Position={x:0,y:0},U.tipMoving=!1,U.color=Z.defaultStrokeColor,U.bgColor=Z.defaultFillColor,U.fontFamily=Z.defaultFontFamily,U.defaultSize={x:100,y:30},U.setBgColor=U.setBgColor.bind(U),U.getTipPoints=U.getTipPoints.bind(U),U.positionTip=U.positionTip.bind(U),U.setTipPoints=U.setTipPoints.bind(U),U.colorPanel=new Ge("Text color",Z.defaultColorSet,U.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>'),U.colorPanel.onColorChanged=U.setColor,U.bgColorPanel=new Ge("Fill color",Z.defaultColorSet,U.bgColor,ue),U.bgColorPanel.onColorChanged=U.setBgColor,U.fontFamilyPanel=new Ae("Font",Z.defaultFontFamilies,Z.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U.tipGrip=new ot,U.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),U.controlBox.appendChild(U.tipGrip.visual),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return j.prototype.ownsTarget.call(this,c)||this.tipGrip.ownsTarget(c)||this.tip===c},s.prototype.createTip=function(){se.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=se.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(c,R){this.state==="new"&&j.prototype.pointerDown.call(this,c,R),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(R)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):j.prototype.pointerDown.call(this,c,R)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,j.prototype.pointerUp.call(this,c);else{var R=this.state==="creating";j.prototype.pointerUp.call(this,c),this.setTipPoints(R),this.positionTip()}},s.prototype.manipulate=function(c){if(this.tipMoving){var R=this.unrotatePoint(c);this.tipPosition={x:R.x-this.manipulationStartLeft,y:R.y-this.manipulationStartTop},this.positionTip()}else j.prototype.manipulate.call(this,c)},s.prototype.setBgColor=function(c){this.bgRectangle&&this.tip&&(se.setAttributes(this.bgRectangle,[["fill",c]]),se.setAttributes(this.tip,[["fill",c]])),this.bgColor=c,this.fillColorChanged(c)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(c){c===void 0&&(c=!1);var R=Math.min(this.height/2,15),Z=this.height/5;c&&(this.tipPosition={x:R+Z/2,y:this.height+20});var U=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:R,y:0},this.tipBase2Position={x:R+Z,y:0}):(this.tipBase1Position={x:0,y:R},this.tipBase2Position={x:0,y:R+Z}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-R-Z,y:0},this.tipBase2Position={x:this.width-R,y:0}):(this.tipBase1Position={x:this.width,y:R},this.tipBase2Position={x:this.width,y:R+Z}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?U<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-R-Z,y:this.height},this.tipBase2Position={x:this.width-R,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-R-Z},this.tipBase2Position={x:this.width,y:this.height-R}):U<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:R,y:this.height},this.tipBase2Position={x:R+Z,y:this.height}):(this.tipBase1Position={x:0,y:this.height-R},this.tipBase2Position={x:0,y:this.height-R-Z})},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.positionTip()},s.prototype.positionTip=function(){se.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(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),j.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.bgColor=R.bgColor,this.tipPosition=R.tipPosition,j.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.tipPosition={x:this.tipPosition.x*c,y:this.tipPosition.y*R},this.positionTip()},s.typeName="CalloutMarker",s.title="Callout marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',s}(Ne),Se=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.fillColor=Z.defaultFillColor,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.setOpacity=U.setOpacity.bind(U),U.createVisual=U.createVisual.bind(U),U.strokePanel=new Ge("Line color",ge(Z.defaultColorSet,["transparent"]),Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.fillPanel=new Ge("Fill color",ge(Z.defaultColorSet,["transparent"]),U.fillColor,ue),U.fillPanel.onColorChanged=U.setFillColor,U.strokeWidthPanel=new ht("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new Qe("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U.opacityPanel=new te("Opacity",Z.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=se.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){j.prototype.setSize.call(this),se.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(c){j.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(c),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.fillColor=R.fillColor,this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.opacity=R.opacity,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize()},s.typeName="EllipseMarker",s.title="Ellipse marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Ze),Oe=function(j){function s(c,R,Z){return j.call(this,c,R,Z)||this}return Ce(s,j),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.tip1&&c!==this.tip2)},s.prototype.createTips=function(){this.tip1=se.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip1),this.tip2=se.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(j.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(se.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),R=this.tip1.transform.baseVal.getItem(0);R.setRotate(c,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(R,0);var Z=this.tip2.transform.baseVal.getItem(0);Z.setRotate(c+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Z,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',s}(it),qe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokePanel.colors=Z.defaultColorSet,U.fillColor="transparent",U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Se),pt=function(){function j(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(j.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),j.prototype.addUndoStep=function(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},j.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},j.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},j.prototype.undo=function(){if(this.undoStack.length>1){var s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},j.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},j}(),dt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.curveX=0,U.curveY=0,U.manipulationStartCurveX=0,U.manipulationStartCurveY=0,U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.positionGrips=U.positionGrips.bind(U),U.addControlGrips=U.addControlGrips.bind(U),U.adjustVisual=U.adjustVisual.bind(U),U.setupControlBox=U.setupControlBox.bind(U),U.resize=U.resize.bind(U),U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new Ge("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new Qe("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorCurve&&c!==this.visibleCurve&&!this.curveGrip.ownsTarget(c))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorCurve=se.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=se.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),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(R)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),se.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){j.prototype.setupControlBox.call(this),this.curveControlLine1=se.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=se.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,j.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){j.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()))},s.prototype.manipulate=function(c){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+c.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+c.y-this.manipulationStartY),j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),j.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)},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual()},s.prototype.scale=function(c,R){this.curveX=this.curveX*c,this.curveY=this.curveY*R,j.prototype.scale.call(this,c,R)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.curveX=R.curveX,this.curveY=R.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',s}(lt),Lt=function(){function j(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(j.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),j.prototype.preventDefault=function(){this._defaultPrevented=!0},j}(),Tt=function(j){function s(c,R,Z){var U=j.call(this,c,!1)||this;return U.dataUrl=R,U.state=Z,U}return Ce(s,j),s}(Lt),ut=function(j){function s(c,R,Z){Z===void 0&&(Z=!1);var U=j.call(this,c,Z)||this;return U.marker=R,U}return Ce(s,j),s}(Lt),Bt=function(){function j(){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 j.prototype.addEventListener=function(s,c){this[s].push(c)},j.prototype.removeEventListener=function(s,c){var R=this[s].indexOf(c);R>-1&&this[s].splice(R,1)},j}(),Ct=function(){function j(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new 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 Bt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=j.instanceCounter++,this.styles=new tt(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(j.prototype,"ALL_MARKER_TYPES",{get:function(){return[Je,me,fe,Ne,qe,Se,ae,pe,Oe,ee,it,dt]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Je,me,fe,Ne,Se,ae,pe]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Je,me,fe,Ne,ae]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var c=this;this._availableMarkerTypes.splice(0),s.forEach(function(R){if(typeof R=="string"){var Z=c.ALL_MARKER_TYPES.find(function(U){return U.typeName===R});Z!==void 0&&c._availableMarkerTypes.push(Z)}else c._availableMarkerTypes.push(R)})},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(s){this._zoomLevel=s,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),j.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),ke.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},j.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&He.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=He.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(c){return c(new Lt(s))})},j.prototype.render=function(){return Te(this,void 0,void 0,function(){var s;return Ee(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new Ve).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return c.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,c.sent()]}})})},j.prototype.close=function(s){var c=this;if(s===void 0&&(s=!1),this.isOpen){var R=!1;s||this.eventListeners.beforeclose.forEach(function(Z){var U=new Lt(c,!0);Z(U),U.defaultPrevented&&(R=!0)}),R||(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(Z){return Z(new Lt(c))}),this.detachEvents(),this._isOpen=!1)}},j.prototype.addMarkersToToolbar=function(){for(var s,c=[],R=0;R<arguments.length;R++)c[R]=arguments[R];(s=this._availableMarkerTypes).push.apply(s,c)},j.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},j.prototype.removeRenderEventListener=function(s){},j.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},j.prototype.removeCloseEventListener=function(s){},j.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},j.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,R=c<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(c,R)},j.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},j.prototype.resize=function(s,c){this._isResizing=!0;var R=s/this.imageWidth,Z=c/this.imageHeight;this.imageWidth=Math.round(s),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(R,Z),this._isResizing=!1},j.prototype.scaleMarkers=function(s,c){var R,Z=this;this._currentMarker&&this._currentMarker instanceof Ne?this._currentMarker.scale(s,c):(R=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(U){U!==Z._currentMarker&&U.scale(s,c)}),R!==void 0&&this.setCurrentMarker(R)},j.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"},j.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.top},j.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)},j.prototype.addDefs=function(){for(var s,c=[],R=0;R<arguments.length;R++)c[R]=arguments[R];this.defs=se.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,c)},j.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},j.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)},j.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},j.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},j.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)},j.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},j.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)},j.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},j.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")},j.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"},j.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},j.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new 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")},j.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},j.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},j.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())},j.prototype.toolbarButtonClicked=function(s,c){if(s==="marker"&&c!==void 0)this.createNewMarker(c);else if(s==="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()}},j.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Z){var U=new ut(s,s._currentMarker,!0);Z(U),U.defaultPrevented&&(c=!0)}),!c){var R=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(Z){return Z(new ut(s,R))})}}},j.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(he){var Re=new ut(s,void 0,!0);he(Re),Re.defaultPrevented&&(c=!0)}),!c)){this.setCurrentMarker();for(var R=function(he){var Re=Z.markers[he];Z.setCurrentMarker(Z.markers[he]),Z._currentMarker.dispose(),Z.markerImage.removeChild(Z._currentMarker.container),Z.markers.splice(Z.markers.indexOf(Z._currentMarker),1),Z.eventListeners.markerdelete.forEach(function(ze){return ze(new ut(s,Re))})},Z=this,U=this.markers.length-1;U>=0;U--)R(U);this.addUndoStep()}},Object.defineProperty(j.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),j.prototype.showNotesEditor=function(){var s;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},j.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)},j.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},j.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var c=this.getState(),R=this.undoRedoManager.getLastUndoStep();if(!R||R.width===c.width&&R.height===c.height){var Z=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(c),Z<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(U){return U(new Lt(s))})}else this.undoRedoManager.replaceLastUndoStep(c),this.eventListeners.statechange.forEach(function(U){return U(new Lt(s))})}},j.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},j.prototype.undoStep=function(){var s=this,c=this.undoRedoManager.undo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(R){return R(new Lt(s))}))},j.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},j.prototype.redoStep=function(){var s=this,c=this.undoRedoManager.redo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(R){return R(new Lt(s))}))},j.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},j.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},j.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var s,c,R=this;return Ee(this,function(Z){switch(Z.label){case 0:return[4,this.render()];case 1:return s=Z.sent(),c=this.getState(),this.eventListeners.render.forEach(function(U){return U(new Tt(R,s,c))}),this.close(!0),[2]}})})},j.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var c={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(R){return c.markers.push(R.getState())}),c},j.prototype.restoreState=function(s){var c=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(R){var Z=c._availableMarkerTypes.find(function(he){return he.typeName===R.typeName});if(Z!==void 0){var U=c.addNewMarker(Z);U.restoreState(R),c.markers.push(U)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(R){return R(new Lt(c))})},j.prototype.addNewMarker=function(s){var c=se.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},j.prototype.createNewMarker=function(s){var c,R=this;(c=typeof s=="string"?this._availableMarkerTypes.find(function(Z){return Z.typeName===s}):s)&&(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(Z){return Z(new ut(R,R._currentMarker))}))},j.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof me&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(me):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(R){return R(new ut(c,c._currentMarker))})},j.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},j.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},j.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(R){return R(new ut(c,s))})},j.prototype.setCurrentMarker=function(s){var c=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(R){return R(new ut(c,c._currentMarker))})),this._currentMarker=s,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(R){return R(new ut(c,c._currentMarker))}))},j.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var c=this.markers.find(function(R){return R.ownsTarget(s.target)});c!==void 0?(this.setCurrentMarker(c),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},j.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var c=this.markers.find(function(R){return R.ownsTarget(s.target)});c!==void 0&&c!==this._currentMarker&&this.setCurrentMarker(c),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},j.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},j.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},j.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},j.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.markerImage.getBoundingClientRect();return{x:(s-R.left)/this.zoomLevel,y:(c-R.top)/this.zoomLevel}},j.prototype.onWindowResize=function(){this.positionUI()},j.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},j.prototype.addLicenseKey=function(s){ke.addKey(s)},j.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},j.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},j.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(j.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),j.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(c){return c(new Lt(s))}))},j.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(c){return c(new Lt(s))}))},j.instanceCounter=0,j}();/* **********************************
|
|
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 _t=function(j,s){return(_t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,R){c.__proto__=R}||function(c,R){for(var Z in R)Object.prototype.hasOwnProperty.call(R,Z)&&(c[Z]=R[Z])})(j,s)};function Dt(j,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function c(){this.constructor=j}_t(j,s),j.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function mt(j,s,c,R){return new(c||(c=Promise))(function(Z,U){function he(ft){try{ze(R.next(ft))}catch(Pe){U(Pe)}}function Re(ft){try{ze(R.throw(ft))}catch(Pe){U(Pe)}}function ze(ft){var Pe;ft.done?Z(ft.value):(Pe=ft.value,Pe instanceof c?Pe:new c(function(bt){bt(Pe)})).then(he,Re)}ze((R=R.apply(j,s||[])).next())})}function or(j,s){var c,R,Z,U,he={label:0,sent:function(){if(1&Z[0])throw Z[1];return Z[1]},trys:[],ops:[]};return U={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Re(ze){return function(ft){return function(Pe){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,R&&(Z=2&Pe[0]?R.return:Pe[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Pe[1])).done)return Z;switch(R=0,Z&&(Pe=[2&Pe[0],Z.value]),Pe[0]){case 0:case 1:Z=Pe;break;case 4:return he.label++,{value:Pe[1],done:!1};case 5:he.label++,R=Pe[1],Pe=[0];continue;case 7:Pe=he.ops.pop(),he.trys.pop();continue;default:if(!(Z=he.trys,(Z=Z.length>0&&Z[Z.length-1])||Pe[0]!==6&&Pe[0]!==2)){he=0;continue}if(Pe[0]===3&&(!Z||Pe[1]>Z[0]&&Pe[1]<Z[3])){he.label=Pe[1];break}if(Pe[0]===6&&he.label<Z[1]){he.label=Z[1],Z=Pe;break}if(Z&&he.label<Z[2]){he.label=Z[2],he.ops.push(Pe);break}Z[2]&&he.ops.pop(),he.trys.pop();continue}Pe=s.call(j,he)}catch(bt){Pe=[6,bt],R=0}finally{c=Z=0}if(5&Pe[0])throw Pe[1];return{value:Pe[0]?Pe[1]:void 0,done:!0}}([ze,ft])}}}var Zt=function(){function j(){}return j.addKey=function(s){j.key=s},Object.defineProperty(j,"isLicensed",{get:function(){return!!j.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(j.key)},enumerable:!1,configurable:!0}),j}(),vt=function(){function j(){}return j.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},j.setAttributes=function(s,c){for(var R=0,Z=c;R<Z.length;R++){var U=Z[R],he=U[0],Re=U[1];s.setAttribute(he,Re)}},j.createRect=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect");return Z.setAttribute("width",s.toString()),Z.setAttribute("height",c.toString()),R&&j.setAttributes(Z,R),Z},j.createLine=function(s,c,R,Z,U){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",c.toString()),he.setAttribute("x2",R.toString()),he.setAttribute("y2",Z.toString()),U&&j.setAttributes(he,U),he},j.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&j.setAttributes(R,c),R},j.createCircle=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","circle");return R.setAttribute("cx",(s/2).toString()),R.setAttribute("cy",(s/2).toString()),R.setAttribute("r",s.toString()),c&&j.setAttributes(R,c),R},j.createEllipse=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Z.setAttribute("cx",(s/2).toString()),Z.setAttribute("cy",(c/2).toString()),Z.setAttribute("rx",(s/2).toString()),Z.setAttribute("ry",(c/2).toString()),R&&j.setAttributes(Z,R),Z},j.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&j.setAttributes(c,s),c},j.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},j.createMarker=function(s,c,R,Z,U,he,Re){var ze=document.createElementNS("http://www.w3.org/2000/svg","marker");return j.setAttributes(ze,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",he.toString()]]),ze.appendChild(Re),ze},j.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&j.setAttributes(c,s),c},j.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&j.setAttributes(R,c),R},j.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&j.setAttributes(c,s),c},j.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},j.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&j.setAttributes(R,c),R},j.createElement=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&j.setAttributes(R,c),R},j.getHollowRectanglePath=function(s,c,R,Z,U,he,Re,ze){return"M"+s+","+c+"V"+(c+Z)+"H"+(s+R)+"V"+c+"H"+U+"V"+he+"H"+(U+Re)+"V"+(he+ze)+"H"+U+"V"+c+"Z"},j}(),vr=function(){function j(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(j.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(j.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(j.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),j.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},j.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},j.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new sr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new sr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new sr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Kt("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Kt("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},j.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},j}(),sr=function(j,s){this.selector=j,this.style=s},Kt=function(j,s){this.localName=j,this.style=s},Fr=function(){function j(){this.blocks=[],this.display=""}return j.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},j.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},j.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(c){return s.appendChild(c.getUI())}),s},j}(),ci=function(){function j(){}return j.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},j}(),qr=function(j){function s(){var c=j!==null&&j.apply(this,arguments)||this;return c.buttons=[],c}return Dt(s,j),s.prototype.addButton=function(c){c.className=this.buttonClassName,c.colorsClassName=this.buttonColorsClassName,c.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(c)},s.prototype.getUI=function(){var c=j.prototype.getUI.call(this);return this.buttons.forEach(function(R){return c.appendChild(R.getUI())}),c},s}(ci),Ft=function(){function j(s,c){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=c,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(j.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),j.prototype.getUI=function(){var s=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},j.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,"")))},j.prototype.hide=function(){this._isHidden=!0},j}(),ct=function(j){function s(){var c=j!==null&&j.apply(this,arguments)||this;return c.elements=[],c}return Dt(s,j),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=j.prototype.getUI.call(this);return this.elements.forEach(function(R){return c.appendChild(R)}),c},s}(ci),Gr=function(){function j(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(j.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),j.prototype.getVerticalLength=function(s){return s/this.ratio},j.prototype.getHorizontalLength=function(s){return s*this.ratio},j}(),ei=function(){function j(){}return j.getIcon=function(s,c){if(s>0&&c>0){var R=new Gr(s,c),Z=R.ratio>=1?20:R.getHorizontalLength(20),U=R.ratio<1?20:R.getVerticalLength(20),he=document.createElementNS("http://www.w3.org/2000/svg","svg");he.setAttribute("xmlns","http://www.w3.org/2000/svg"),he.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(he);var Re=vt.createDefs();he.appendChild(Re);var ze=vt.createElement("clipPath",[["id","text-bg-clip"]]);Re.appendChild(ze);var ft=vt.createPath(vt.getHollowRectanglePath((24-Z)/2,(24-U)/2,Z,U,(24-Z)/2+2,(24-U)/2+2,Z-4,U-4));he.appendChild(ft);var Pe=vt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Pe.appendChild(vt.createTSpan(s+":"+c)),he.appendChild(Pe);var bt=Pe.getBBox();vt.setAttributes(Pe,[["x",((24-bt.width)/2).toString()],["y",((24-bt.height)/2-bt.y).toString()]]);var Ut=vt.createPath(vt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(bt.width))/2,(24-Math.ceil(bt.height))/2,Math.ceil(bt.width),Math.ceil(bt.height)));return ze.appendChild(Ut),vt.setAttributes(ft,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(he),he.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>'},j}(),yr=function(j){function s(c,R,Z){var U=j.call(this,c,R)||this;return U.isDropdownOpen=!1,U.onClick=U.dropdownButtonClicked,U.dropdownButtons=Z,U}return Dt(s,j),s.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(R){R.className=c.className,R.colorsClassName=c.colorsClassName,c.dropdownBlock.appendChild(R.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(Ft),Ot=function(){function j(s,c){this.GRIP_SIZE=10,this.color=s,this.fillColor=c,this.visual=vt.createGroup(),this.visual.appendChild(vt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(vt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return j.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},j.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(R){return vt.setAttributes(R,[["cx",s.toString()],["cy",c.toString()]])})},j}(),Ur=function(){function j(s,c,R,Z){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=c,this.margin=R,this.container=Z,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(j.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&vt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),j.prototype.open=function(){var s=this;this.cropShadeElement=vt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=vt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var c=0;c<this.numberOfGridLines;c++)this.horizontalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(R){return s.gridContainer.appendChild(R)}),this.verticalGridLines.forEach(function(R){return s.gridContainer.appendChild(R)}),this.cropRectElement=vt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},j.prototype.setCropRectangle=function(s){this.cropRect=s;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),vt.setAttributes(this.cropRectElement,[["x",c.x.toString()],["y",c.y.toString()],["width",c.width.toString()],["height",c.height.toString()]]);var R=c.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(U,he){var Re=c.y+R*(he+1);vt.setAttributes(U,[["x1",""+c.x],["y1",""+Re],["x2",""+(c.x+c.width)],["y2",""+Re]])});var Z=c.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(U,he){var Re=c.x+Z*(he+1);vt.setAttributes(U,[["x1",""+Re],["y1",""+c.y],["x2",""+Re],["y2",""+(c.y+c.height)]])}),vt.setAttributes(this.cropShadeElement,[["d",vt.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},j.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)},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.container.getBoundingClientRect();return{x:s-R.left+this.margin,y:c-R.top+this.margin}},j.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},j.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var c=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(c)}s.preventDefault()},j.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},j.prototype.move=function(s){var c=s.x-this.previousPoint.x,R=s.y-this.previousPoint.y;this.zoomFactor!==1&&(c=-c/this.zoomFactor,R=-R/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+R),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},j.prototype.resize=function(s){var c=Object.assign({},this.cropRect),R=s.x-this.previousPoint.x,Z=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:c.x+R<this.margin&&(R=this.margin-c.x),c.x+=R,c.width=this.cropRect.x+this.cropRect.width-c.x;break;case this.bottomRightGrip:case this.topRightGrip:c.width+R>this.canvasWidth*this.zoomFactor&&(R=this.canvasWidth*this.zoomFactor-c.width),c.width+=R}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(R),c.height=this.aspectRatio.getVerticalLength(c.width)):(c.y+=Z,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+=Z}c.width<10&&(c.x=this.cropRect.x,c.width=10),c.height<10&&(c.y=this.cropRect.y,c.height=10),this.previousPoint=s,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))},j.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,c=this.cropRect.y+this.cropRect.height/2,R=this.aspectRatio.getHorizontalLength(this.cropRect.height),Z=this.aspectRatio.getVerticalLength(this.cropRect.width);R/this.canvasWidth<Z/this.canvasHeight?this.cropRect.width=R:this.cropRect.height=Z,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=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)}},j.prototype.getRescaledRect=function(s,c,R,Z,U,he){var Re=R/s,ze=Z/c;return{x:(U.x-he)*Re+he,y:(U.y-he)*ze+he,width:U.width*Re,height:U.height*ze}},j.prototype.scaleCanvas=function(s,c){var R=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,c,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=c,this.onCropChange&&this.onCropChange(R),this.setCropRectangle(R)},j}(),Vr=function(){function j(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(j.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),j.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},j.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},j.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},j.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},j.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();vt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},j.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},j.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var c="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,R=1;R<=this.width/5+10;R++){var Z=R%5==0?this.height/3:this.height/6;c+="h4v"+-Z+"h1v"+Z}c+="v1H0Z",this.scaleShape=vt.createPath(c);var U=vt.createTransform();this.scaleShape.transform.baseVal.appendItem(U),s.appendChild(this.scaleShape),this.angleLabelElement=vt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=vt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var he=vt.createTSpan("");return he.innerHTML="°",this.angleLabelElement.appendChild(he),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},j}(),fi=function(){function j(){this.naturalSize=!1,this.imageType="image/png"}return j.prototype.rasterize=function(s,c,R,Z,U,he,Re){var ze=this;return new Promise(function(ft){var Pe=document.createElement("canvas");Pe.width=s.width.baseVal.value-2*Z,Pe.height=s.height.baseVal.value-2*Z;var bt=1,Ut=1;ze.naturalSize===!0?(bt=c.naturalWidth/(s.width.baseVal.value-2*Z)/he,Ut=c.naturalHeight/(s.height.baseVal.value-2*Z)/Re,Pe.width=c.naturalWidth/he,Pe.height=c.naturalHeight/Re):ze.width!==void 0&&ze.height!==void 0&&(bt=ze.width/R.width,Ut=ze.height/R.height,Pe.width*=bt,Pe.height*=Ut);var Yt=Pe.getContext("2d");Yt.translate(Pe.width/2,Pe.height/2),Yt.rotate(U*Math.PI/180),Yt.scale(he,Re),Yt.translate(-Pe.width/2,-Pe.height/2),Yt.drawImage(c,0,0,Pe.width,Pe.height);var Mr=document.createElement("canvas");Mr.width=R.width*bt,Mr.height=R.height*Ut,Mr.getContext("2d").putImageData(Yt.getImageData((R.x-Z)*bt,(R.y-Z)*Ut,R.width*bt,R.height*Ut),0,0),ft(Mr.toDataURL(ze.imageType,ze.imageQuality))})},j}(),Ue=function(){function j(s){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=j.instanceCounter++,this.styles=new vr(this.instanceNo),this.target=s,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(j.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),j.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},j.prototype.show=function(){this.showUI(),this.open()},j.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(c){return c()}),this._isOpen=!1)},j.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},j.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},j.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},j.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},j.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},j.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,R=c+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(c,R)}},j.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},j.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",vt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},j.prototype.resize=function(s,c){this.imageWidth=Math.round(s),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()},j.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var c=s.toDataURL();vt.setAttributes(this.editingTarget,[["href",c]]),this.setEditingTargetSize()},j.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left-this.CANVAS_MARGIN,this.top=s.top-c.top-this.CANVAS_MARGIN},j.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=vt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=vt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=vt.createGroup(),this.editingTargetRotationScaleContainer=vt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=vt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var c=vt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(c),this.editingTargetContainer=vt.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)},j.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},j.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=vt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Ur(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()},j.prototype.zoomToCrop=function(){if(this.cropRect){var s=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=s+"px "+c+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-c+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},j.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)},j.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},j.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},j.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"},j.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},j.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,c=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+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},j.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},j.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Fr,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(c);var R=[];this.aspectRatios.forEach(function(Ut){var Yt=new Ft(ei.getIcon(Ut.horizontal,Ut.vertical),Ut.horizontal===0&&Ut.vertical===0?"FREE":Ut.horizontal+":"+Ut.vertical);Yt.onClick=function(){return s.ratioButtonClicked(Ut)},R.push(Yt)}),this.aspectRatioButton=new yr(ei.getIcon(0,0),"Aspect ratio",R),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 Z=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");Z.isActive=this.isGridVisible,Z.onClick=function(){s.isGridVisible=!s.isGridVisible,Z.isActive=s.isGridVisible},c.addButton(Z);var U=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(U.isActive=this.zoomToCropEnabled,U.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,U.isActive=s.zoomToCropEnabled},c.addButton(U),!Zt.isLicensed){var he=new ct;this.topToolbar.addElementBlock(he);var Re=document.createElement("div");Re.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var ze=document.createElement("a");ze.style.color="currentColor",ze.href="https://markerjs.com/products/cropro",ze.target="_blank",ze.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>',Re.appendChild(ze),he.addElement(Re)}var ft=new qr;ft.minWidth=3*this.toolbarHeight+"px",ft.contentAlign="end",this.topToolbar.addButtonBlock(ft);var Pe=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");Pe.onClick=this.startRenderAndClose,ft.addButton(Pe),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Pe.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var bt=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");bt.onClick=this.close,ft.addButton(bt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(bt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},j.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Fr,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(c);var R=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");R.onClick=this.rotateLeftButtonClicked,c.addButton(R);var Z=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");Z.onClick=this.rotateRightButtonClicked,c.addButton(Z);var U=new ct;U.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(U),this.straightener=new Vr("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(ft){s.rotateBy(ft),s.straightener.angle=s.rotationAngle},U.addElement(this.straightener.getUI());var he=new qr;he.minWidth=2*this.toolbarHeight+"px",he.contentAlign="end",this.bottomToolbar.addButtonBlock(he);var Re=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");Re.onClick=this.flipHorizontallyButtonClicked,he.addButton(Re);var ze=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");ze.onClick=this.flipVerticallyButtonClicked,he.addButton(ze)},j.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},j.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},j.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Gr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},j.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},j.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},j.prototype.restoreState=function(s){if(s){var c=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(c),this.cropRectChanged(c),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.cropImage.getBoundingClientRect();return{x:s-R.left,y:c-R.top}},j.prototype.onWindowResize=function(){this.positionUI()},j.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},j.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},j.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},j.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},j.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},j.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var 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 R=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/R.width,this.imageHeight/R.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},j.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},j.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},j.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},j.prototype.startRenderAndClose=function(){return mt(this,void 0,void 0,function(){var s,c;return or(this,function(R){switch(R.label){case 0:return[4,this.render()];case 1:return s=R.sent(),c=this.getState(),this.renderEventListeners.forEach(function(Z){return Z(s,c)}),this.close(!0),[2]}})})},j.prototype.render=function(){return mt(this,void 0,void 0,function(){var s;return or(this,function(c){switch(c.label){case 0:return(s=new fi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),vt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return c.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,c.sent()]}})})},j.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Kt("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 Kt("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Kt("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Kt("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*s)+`px;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Kt("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Kt("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new sr("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new sr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new Kt("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 Kt("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Kt("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 Kt("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Kt("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},j.instanceCounter=0,j}(),wt=re("8hTe"),pi=re.n(wt),mi=/<pre[^>]*>/g;function gi(j){var s=document.createElement("div");return s.innerHTML=j,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=nt.a=function(j){var s=j.value,c=s===void 0?"":s,R=j.edit,Z=R===void 0?!1:R,U=j.className,he=j.showTextOnly,Re=j.showLines,ze=j.replaces,ft=j.zoomImg,Pe=j.hasMask,bt=j.style,Ut=bt===void 0?{}:bt,Yt=j.stylesPrev,Mr=Yt===void 0?{}:Yt,br=String(c),xr=Object(O.useRef)(),Xr=Object(O.useRef)(),Ri=Object(O.useState)(""),lr=Object(H.a)(Ri,2),jr=lr[0],oi=lr[1],si=Object(O.useState)("office"),Ir=Object(H.a)(si,2),Oi=Ir[0],yi=Ir[1],zi=function(){var jt=new Ue(Xr.current);jt.displayMode="popup",jt.addRenderEventListener(function(){var pr=Object(P.a)(M.a.mark(function Pt(tr){var Gt;return M.a.wrap(function(ur){for(;;)switch(ur.prev=ur.next){case 0:return xr.current.style.display="none",ur.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:tr}});case 3:Gt=ur.sent,Gt!=null&&Gt.id&&ze(Xr.current.getAttribute("src").replace(ne.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 5:case"end":return ur.stop()}},Pt)}));return function(Pt){return pr.apply(this,arguments)}}()),jt.show()},Ki=function(){var jt=new Ct(Xr.current);jt.settings.displayMode="popup",jt.addEventListener("render",function(){var pr=Object(P.a)(M.a.mark(function Pt(tr){var Gt;return M.a.wrap(function(ur){for(;;)switch(ur.prev=ur.next){case 0:if(xr.current.style.display="none",!Xr.current){ur.next=6;break}return ur.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:tr.dataUrl}});case 4:Gt=ur.sent,Gt!=null&&Gt.id&&ze(Xr.current.getAttribute("src").replace(ne.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 6:case"end":return ur.stop()}},Pt)}));return function(Pt){return pr.apply(this,arguments)}}()),jt.show(),window.markerArea=jt},Yr=Object(O.useMemo)(function(){xr.current&&(xr.current.style.zIndex=-1);try{var qt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,jt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,pr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;br=br.replace(qt,"("+ne.a.API_SERVER+"/api/attachments/").replace(jt,'"'+ne.a.API_SERVER+"/api/attachments/").replace(pr,'"'+ne.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`)}catch(ti){}var Pt=J(br),tr=E();if(br.match(/\[TOC\]/)&&(Pt=Pt.replace("<p>[TOC]</p>",L()),w()),Pt=Pt.replace(/(__special_katext_id_\d+__)/g,function(ti,ur){var Cr=tr[ur],Vi=Cr.type,Ei=Cr.expression;return Object(ce.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Pt=Pt.replace(/▁/g,"\u2581\u2581\u2581"),v(),he){var Gt=document.createElement("div");return Gt.innerHTML=Pt,Gt.innerText}return setTimeout(function(){return dn()},500),Pt},[br]),zr=Object(O.useRef)();g.WebkitLineClamp=Re,Re&&(Ut=Object(N.a)(Object(N.a)({},Ut),g));function bi(qt){var jt=qt.target;if(jt.tagName.toUpperCase()==="IMG"){if(ft){var pr=jt.getAttribute("src");oi(pr),yi("image")}}else if(jt.tagName.toUpperCase()==="A"){var Pt=jt.getAttribute("href");if(Pt.indexOf("office")>-1)qt.preventDefault(),oi(Pt),yi("office");else if(Pt.indexOf("application/pdf")>-1)qt.preventDefault(),oi(Pt),yi("pdf");else if(Pt.indexOf("text/html")>-1)qt.preventDefault(),oi(Pt),yi("html");else if(Pt.startsWith("#")){qt.preventDefault();var tr=document.getElementById(Pt.replace("#",""));tr&&tr.scrollIntoView(!0)}}}var dn=function(){var jt,pr=(jt=zr.current)===null||jt===void 0?void 0:jt.querySelectorAll("video");pr==null||pr.forEach(function(Pt){if(Pt.oncontextmenu=function(){return!1},Pt.src.indexOf(".m3u8")>-1&&!Pt.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var tr=new q.a;tr.loadSource(Pt.src),tr.attachMedia(Pt)}}})};Object(O.useEffect)(function(){if(zr.current&&Yr&&(Yr.match(mi)&&window.PR.prettyPrint()),zr.current)return zr.current.addEventListener("click",bi),function(){zr.current.removeEventListener("click",bi),v(),w()}},[Yr,zr.current,bi]);var xi=function(jt){if(!Z)return;jt.target.nodeName==="IMG"?(xr.current.style.zIndex=1,xr.current.style.display="flex",xr.current.style.width=jt.target.clientWidth+"px",xr.current.style.height=jt.target.clientHeight+"px",xr.current.style.top=jt.target.offsetTop+"px",xr.current.style.left=jt.target.offsetLeft+"px",Xr.current.src=jt.target.getAttribute("src")):xr.current.style.display="none"};return b.a.createElement("div",{style:{position:"relative"}},b.a.createElement("div",{ref:zr,style:Object(N.a)({},Ut),className:"".concat(U||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),b.a.createElement("div",{ref:xr,className:pi.a.button},b.a.createElement($.a,null,b.a.createElement(V.a,{onClick:function(){return zi()}},"\u88C1\u526A"),b.a.createElement(V.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),b.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),b.a.createElement(ve.a,{close:!0,data:jr,type:jr!=null&&jr.length?Oi:"",style:Object(N.a)({},Mr),onClose:function(){return oi("")}}))}},"9VGf":function(Et,nt,re){"use strict";re.d(nt,"a",function(){return D});var ie=re("q1tI"),$=re.n(ie);function D(V,N){var P=Object(ie.useRef)();Object(ie.useEffect)(function(){P.current=V}),Object(ie.useEffect)(function(){function H(){P.current()}if(N!==null){var F=setInterval(H,N);return function(){return clearInterval(F)}}},[N])}},"9ZNV":function(Et,nt,re){"use strict";re.d(nt,"a",function(){return O});var ie=re("0Owb"),$=re("+L6B"),D=re("2/Rp"),V=re("q1tI"),N=re.n(V),P=re("UUDw"),H=re.n(P),F=re("TSYQ"),M=re.n(F),O=function(C){var k=C.cancelText,_=k===void 0?"\u53D6\u6D88":k,A=C.okText,y=A===void 0?"\u786E\u5B9A":A,u=C.loading,a=u===void 0?!1:u,l=C.hasOkBtn,h=l===void 0?!0:l,w=C.okButtonProps,g=w===void 0?{}:w,m=C.onCancel,L=m===void 0?function(){}:m,x=C.onOk,f=x===void 0?function(){}:x,p=C.className,d=p===void 0?"":p;return N.a.createElement("div",{className:M()(H.a.buttonFixed,d)},N.a.createElement("div",{className:H.a.buttonWrap},N.a.createElement(D.a,{size:"large",className:"".concat(H.a.button," mr20"),onClick:L},_),h&&N.a.createElement(D.a,Object(ie.a)({size:"large",type:"primary",className:"".concat(H.a.button," mr20"),loading:a,onClick:f},g),y)))}},Bd2K:function(Et,nt,re){(function(ie){ie(re("VrN/"),re("osHv"))})(function(ie){ie.defineOption("autoCloseTags",!1,function(M,O,b){if(b!=ie.Init&&b&&M.removeKeyMap("autoCloseTags"),!O)return;var C={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(C["'/'"]=function(k){return P(k)}),(typeof O!="object"||O.whenOpening!==!1)&&(C["'>'"]=function(k){return V(k)}),M.addKeyMap(C)});var $=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],D=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function V(M){if(M.getOption("disableInput"))return ie.Pass;for(var O=M.listSelections(),b=[],C=M.getOption("autoCloseTags"),k=0;k<O.length;k++){if(!O[k].empty())return ie.Pass;var _=O[k].head,A=M.getTokenAt(_),y=ie.innerMode(M.getMode(),A.state),u=y.state,a=y.mode.xmlCurrentTag&&y.mode.xmlCurrentTag(u),l=a&&a.name;if(!l)return ie.Pass;var h=y.mode.configuration=="html",w=typeof C=="object"&&C.dontCloseTags||h&&$,g=typeof C=="object"&&C.indentTags||h&&D;A.end>_.ch&&(l=l.slice(0,l.length-A.end+_.ch));var m=l.toLowerCase();if(!l||A.type=="string"&&(A.end!=_.ch||!/[\"\']/.test(A.string.charAt(A.string.length-1))||A.string.length==1)||A.type=="tag"&&a.close||A.string.indexOf("/")==_.ch-A.start-1||w&&H(w,m)>-1||F(M,y.mode.xmlCurrentContext&&y.mode.xmlCurrentContext(u)||[],l,_,!0))return ie.Pass;var L=typeof C=="object"&&C.emptyTags;if(L&&H(L,l)>-1){b[k]={text:"/>",newPos:ie.Pos(_.line,_.ch+2)};continue}var x=g&&H(g,m)>-1;b[k]={indent:x,text:">"+(x?`
|
|
|
|
`:"")+"</"+l+">",newPos:x?ie.Pos(_.line+1,0):ie.Pos(_.line,_.ch+1)}}for(var f=typeof C=="object"&&C.dontIndentOnAutoClose,k=O.length-1;k>=0;k--){var p=b[k];M.replaceRange(p.text,O[k].head,O[k].anchor,"+insert");var d=M.listSelections().slice(0);d[k]={head:p.newPos,anchor:p.newPos},M.setSelections(d),!f&&p.indent&&(M.indentLine(p.newPos.line,null,!0),M.indentLine(p.newPos.line+1,null,!0))}}function N(M,O){for(var b=M.listSelections(),C=[],k=O?"/":"</",_=M.getOption("autoCloseTags"),A=typeof _=="object"&&_.dontIndentOnSlash,y=0;y<b.length;y++){if(!b[y].empty())return ie.Pass;var u=b[y].head,a=M.getTokenAt(u),l=ie.innerMode(M.getMode(),a.state),h=l.state;if(O&&(a.type=="string"||a.string.charAt(0)!="<"||a.start!=u.ch-1))return ie.Pass;var w,g=l.mode.name!="xml"&&M.getMode().name=="htmlmixed";if(g&&l.mode.name=="javascript")w=k+"script";else if(g&&l.mode.name=="css")w=k+"style";else{var m=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!m||m.length&&F(M,m,m[m.length-1],u))return ie.Pass;w=k+m[m.length-1]}M.getLine(u.line).charAt(a.end)!=">"&&(w+=">"),C[y]=w}if(M.replaceSelections(C),b=M.listSelections(),!A)for(var y=0;y<b.length;y++)(y==b.length-1||b[y].head.line<b[y+1].head.line)&&M.indentLine(b[y].head.line)}function P(M){return M.getOption("disableInput")?ie.Pass:N(M,!0)}ie.commands.closeTag=function(M){return N(M)};function H(M,O){if(M.indexOf)return M.indexOf(O);for(var b=0,C=M.length;b<C;++b)if(M[b]==O)return b;return-1}function F(M,O,b,C,k){if(!ie.scanForClosingTag)return!1;var _=Math.min(M.lastLine()+1,C.line+500),A=ie.scanForClosingTag(M,C,null,_);if(!A||A.tag!=b)return!1;for(var y=k?1:0,u=O.length-1;u>=0&&O[u]==b;u--)++y;C=A.to;for(var u=1;u<y;u++){var a=ie.scanForClosingTag(M,C,null,_);if(!a||a.tag!=b)return!1;C=a.to}return!0}})},BjJ7:function(Et,nt,re){"use strict";re.d(nt,"d",function(){return $}),re.d(nt,"c",function(){return D}),re.d(nt,"e",function(){return V}),re.d(nt,"b",function(){return N}),re.d(nt,"a",function(){return H});var ie=re("m3rI");function $(F){var M=!0;if(F.length>0){for(var O=0;O<F.length;O++)if(F[O].compile_success==0||!F[O].compile_success){M=!1;break}}else M=!1;return M}function D(F){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],b=0;b<F.length;b++){var C=F[b],k=M?"".concat(M,"/").concat(C.name):"".concat(C.name);O.push({title:C.name,isLeaf:!(C.type==="tree"),key:k})}return O}function V(F,M,O){for(var b=0;b<F.length;b++){var C=F[b];if(C.key===M){C.children=O;break}C.children&&V(C.children,M,O)}return F}function N(F,M,O){var b;return function(){var C=this,k=arguments,_=function(){b=null,O||F.apply(C,k)},A=O&&!b;clearTimeout(b),b=setTimeout(_,M),A&&F.apply(C,k)}}var P=!0,H=ie.a.API_SERVER},"C+DQ":function(Et,nt,re){},DlQD:function(Et,nt,re){(function(ie,$){Et.exports=$()})(this,function(){"use strict";function ie(me,de){for(var fe=0;fe<de.length;fe++){var ee=de[fe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(me,ee.key,ee)}}function $(me,de,fe){return de&&ie(me.prototype,de),fe&&ie(me,fe),me}function D(me,de){if(!me)return;if(typeof me=="string")return V(me,de);var fe=Object.prototype.toString.call(me).slice(8,-1);if(fe==="Object"&&me.constructor&&(fe=me.constructor.name),fe==="Map"||fe==="Set")return Array.from(me);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return V(me,de)}function V(me,de){(de==null||de>me.length)&&(de=me.length);for(var fe=0,ee=new Array(de);fe<de;fe++)ee[fe]=me[fe];return ee}function N(me,de){var fe;if(typeof Symbol=="undefined"||me[Symbol.iterator]==null){if(Array.isArray(me)||(fe=D(me))||de&&me&&typeof me.length=="number"){fe&&(me=fe);var ee=0;return function(){return ee>=me.length?{done:!0}:{done:!1,value:me[ee++]}}}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 fe=me[Symbol.iterator](),fe.next.bind(fe)}function P(me,de){return de={exports:{}},me(de,de.exports),de.exports}var H=P(function(me){function de(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function fe(ee){me.exports.defaults=ee}me.exports={defaults:de(),getDefaults:de,changeDefaults:fe}}),F=H.defaults,M=H.getDefaults,O=H.changeDefaults,b=/[&<>"']/,C=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,A={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(de){return A[de]};function u(me,de){if(de){if(b.test(me))return me.replace(C,y)}else if(k.test(me))return me.replace(_,y);return me}var a=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(me){return me.replace(a,function(de,fe){return fe=fe.toLowerCase(),fe==="colon"?":":fe.charAt(0)==="#"?fe.charAt(1)==="x"?String.fromCharCode(parseInt(fe.substring(2),16)):String.fromCharCode(+fe.substring(1)):""})}var h=/(^|[^\[])\^/g;function w(me,de){me=me.source||me,de=de||"";var fe={replace:function(te,ae){return ae=ae.source||ae,ae=ae.replace(h,"$1"),me=me.replace(te,ae),fe},getRegex:function(){return new RegExp(me,de)}};return fe}var g=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(me,de,fe){if(me){var ee;try{ee=decodeURIComponent(l(fe)).replace(g,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}de&&!m.test(fe)&&(fe=o(de,fe));try{fe=encodeURI(fe).replace(/%25/g,"%")}catch(te){return null}return fe}var x={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(me,de){x[" "+me]||(f.test(me)?x[" "+me]=me+"/":x[" "+me]=I(me,"/",!0)),me=x[" "+me];var fe=me.indexOf(":")===-1;return de.substring(0,2)==="//"?fe?de:me.replace(p,"$1")+de:de.charAt(0)==="/"?fe?de:me.replace(d,"$1")+de:me+de}var E={exec:function(){}};function v(me){for(var de=1,fe,ee;de<arguments.length;de++){fe=arguments[de];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(me[ee]=fe[ee])}return me}function T(me,de){var fe=me.replace(/\|/g,function(ae,ue,pe){for(var Se=!1,Oe=ue;--Oe>=0&&pe[Oe]==="\\";)Se=!Se;return Se?"|":" |"}),ee=fe.split(/ \|/),te=0;if(ee.length>de)ee.splice(de);else for(;ee.length<de;)ee.push("");for(;te<ee.length;te++)ee[te]=ee[te].trim().replace(/\\\|/g,"|");return ee}function I(me,de,fe){var ee=me.length;if(ee===0)return"";for(var te=0;te<ee;){var ae=me.charAt(ee-te-1);if(ae===de&&!fe)te++;else if(ae!==de&&fe)te++;else break}return me.substr(0,ee-te)}function G(me,de){if(me.indexOf(de[1])===-1)return-1;for(var fe=me.length,ee=0,te=0;te<fe;te++)if(me[te]==="\\")te++;else if(me[te]===de[0])ee++;else if(me[te]===de[1]&&(ee--,ee<0))return te;return-1}function X(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 J={escape:u,unescape:l,edit:w,cleanUrl:L,resolveUrl:o,noopTest:E,merge:v,splitCells:T,rtrim:I,findClosingBracket:G,checkSanitizeDeprecation:X},z=H.defaults,W=J.rtrim,q=J.splitCells,ne=J.escape,ce=J.findClosingBracket;function ve(me,de,fe){var ee=de.href,te=de.title?ne(de.title):null,ae=me[1].replace(/\\([\[\]])/g,"$1");return me[0].charAt(0)!=="!"?{type:"link",raw:fe,href:ee,title:te,text:ae}:{type:"image",raw:fe,href:ee,title:te,text:ne(ae)}}function De(me,de){var fe=me.match(/^(\s+)(?:```)/);if(fe===null)return de;var ee=fe[1];return de.split(`
|
|
`).map(function(te){var ae=te.match(/^\s+/);if(ae===null)return te;var ue=ae[0];return ue.length>=ee.length?te.slice(ee.length):te}).join(`
|
|
`)}var xe=function(){function me(fe){this.options=fe||z}var de=me.prototype;return de.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},de.code=function(ee,te){var ae=this.rules.block.code.exec(ee);if(ae){var ue=te[te.length-1];if(ue&&ue.type==="paragraph")return{raw:ae[0],text:ae[0].trimRight()};var pe=ae[0].replace(/^ {4}/gm,"");return{type:"code",raw:ae[0],codeBlockStyle:"indented",text:this.options.pedantic?pe:W(pe,`
|
|
`)}}},de.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ae=te[0],ue=De(ae,te[3]||"");return{type:"code",raw:ae,lang:te[2]?te[2].trim():te[2],text:ue}}},de.heading=function(ee){var te=this.rules.block.heading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},de.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ae={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(ae.header.length===ae.align.length){var ue=ae.align.length,pe;for(pe=0;pe<ue;pe++)/^ *-+: *$/.test(ae.align[pe])?ae.align[pe]="right":/^ *:-+: *$/.test(ae.align[pe])?ae.align[pe]="center":/^ *:-+ *$/.test(ae.align[pe])?ae.align[pe]="left":ae.align[pe]=null;for(ue=ae.cells.length,pe=0;pe<ue;pe++)ae.cells[pe]=q(ae.cells[pe],ae.header.length);return ae}}},de.hr=function(ee){var te=this.rules.block.hr.exec(ee);if(te)return{type:"hr",raw:te[0]}},de.blockquote=function(ee){var te=this.rules.block.blockquote.exec(ee);if(te){var ae=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ae}}},de.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ae=te[0],ue=te[2],pe=ue.length>1,Se=ue[ue.length-1]===")",Oe={type:"list",raw:ae,ordered:pe,start:pe?+ue.slice(0,-1):"",loose:!1,items:[]},qe=te[0].match(this.rules.block.item),pt=!1,dt,Lt,Tt,ut,Bt,Ct,_t,Dt=qe.length,mt=0;mt<Dt;mt++)dt=qe[mt],ae=dt,Lt=dt.length,dt=dt.replace(/^ *([*+-]|\d+[.)]) */,""),~dt.indexOf(`
|
|
`)&&(Lt-=dt.length,dt=this.options.pedantic?dt.replace(/^ {1,4}/gm,""):dt.replace(new RegExp("^ {1,"+Lt+"}","gm"),"")),mt!==Dt-1&&(Tt=this.rules.block.bullet.exec(qe[mt+1])[0],(pe?Tt.length===1||!Se&&Tt[Tt.length-1]===")":Tt.length>1||this.options.smartLists&&Tt!==ue)&&(ut=qe.slice(mt+1).join(`
|
|
`),Oe.raw=Oe.raw.substring(0,Oe.raw.length-ut.length),mt=Dt-1)),Bt=pt||/\n\n(?!\s*$)/.test(dt),mt!==Dt-1&&(pt=dt.charAt(dt.length-1)===`
|
|
`,Bt||(Bt=pt)),Bt&&(Oe.loose=!0),Ct=/^\[[ xX]\] /.test(dt),_t=void 0,Ct&&(_t=dt[1]!==" ",dt=dt.replace(/^\[[ xX]\] +/,"")),Oe.items.push({type:"list_item",raw:ae,task:Ct,checked:_t,loose:Bt,text:dt});return Oe}},de.html=function(ee){var te=this.rules.block.html.exec(ee);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):ne(te[0]):te[0]}},de.def=function(ee){var te=this.rules.block.def.exec(ee);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ae=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ae,raw:te[0],href:te[2],title:te[3]}}},de.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ae={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ae.header.length===ae.align.length){ae.raw=te[0];var ue=ae.align.length,pe;for(pe=0;pe<ue;pe++)/^ *-+: *$/.test(ae.align[pe])?ae.align[pe]="right":/^ *:-+: *$/.test(ae.align[pe])?ae.align[pe]="center":/^ *:-+ *$/.test(ae.align[pe])?ae.align[pe]="left":ae.align[pe]=null;for(ue=ae.cells.length,pe=0;pe<ue;pe++)ae.cells[pe]=q(ae.cells[pe].replace(/^ *\| *| *\| *$/g,""),ae.header.length);return ae}}},de.lheading=function(ee){var te=this.rules.block.lheading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},de.paragraph=function(ee){var te=this.rules.block.paragraph.exec(ee);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},de.text=function(ee,te){var ae=this.rules.block.text.exec(ee);if(ae){var ue=te[te.length-1];return ue&&ue.type==="text"?{raw:ae[0],text:ae[0]}:{type:"text",raw:ae[0],text:ae[0]}}},de.escape=function(ee){var te=this.rules.inline.escape.exec(ee);if(te)return{type:"escape",raw:te[0],text:ne(te[1])}},de.tag=function(ee,te,ae){var ue=this.rules.inline.tag.exec(ee);if(ue)return!te&&/^<a /i.test(ue[0])?te=!0:te&&/^<\/a>/i.test(ue[0])&&(te=!1),!ae&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?ae=!0:ae&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(ae=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:te,inRawBlock:ae,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ne(ue[0]):ue[0]}},de.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ae=ce(te[2],"()");if(ae>-1){var ue=te[0].indexOf("!")===0?5:4,pe=ue+te[1].length+ae;te[2]=te[2].substring(0,ae),te[0]=te[0].substring(0,pe).trim(),te[3]=""}var Se=te[2],Oe="";if(this.options.pedantic){var qe=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Se);qe?(Se=qe[1],Oe=qe[3]):Oe=""}else Oe=te[3]?te[3].slice(1,-1):"";Se=Se.trim().replace(/^<([\s\S]*)>$/,"$1");var pt=ve(te,{href:Se&&Se.replace(this.rules.inline._escapes,"$1"),title:Oe&&Oe.replace(this.rules.inline._escapes,"$1")},te[0]);return pt}},de.reflink=function(ee,te){var ae;if((ae=this.rules.inline.reflink.exec(ee))||(ae=this.rules.inline.nolink.exec(ee))){var ue=(ae[2]||ae[1]).replace(/\s+/g," ");if(ue=te[ue.toLowerCase()],!ue||!ue.href){var pe=ae[0].charAt(0);return{type:"text",raw:pe,text:pe}}var Se=ve(ae,ue,ae[0]);return Se}},de.strong=function(ee,te,ae){ae===void 0&&(ae="");var ue=this.rules.inline.strong.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ae===""||this.rules.inline.punctuation.exec(ae)))){te=te.slice(-1*ee.length);var pe=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;pe.lastIndex=0;for(var Se;(ue=pe.exec(te))!=null;)if(Se=this.rules.inline.strong.middle.exec(te.slice(0,ue.index+3)),Se)return{type:"strong",raw:ee.slice(0,Se[0].length),text:ee.slice(2,Se[0].length-2)}}},de.em=function(ee,te,ae){ae===void 0&&(ae="");var ue=this.rules.inline.em.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ae===""||this.rules.inline.punctuation.exec(ae)))){te=te.slice(-1*ee.length);var pe=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;pe.lastIndex=0;for(var Se;(ue=pe.exec(te))!=null;)if(Se=this.rules.inline.em.middle.exec(te.slice(0,ue.index+2)),Se)return{type:"em",raw:ee.slice(0,Se[0].length),text:ee.slice(1,Se[0].length-1)}}},de.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ae=te[2].replace(/\n/g," "),ue=/[^ ]/.test(ae),pe=ae.startsWith(" ")&&ae.endsWith(" ");return ue&&pe&&(ae=ae.substring(1,ae.length-1)),ae=ne(ae,!0),{type:"codespan",raw:te[0],text:ae}}},de.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},de.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},de.autolink=function(ee,te){var ae=this.rules.inline.autolink.exec(ee);if(ae){var ue,pe;return ae[2]==="@"?(ue=ne(this.options.mangle?te(ae[1]):ae[1]),pe="mailto:"+ue):(ue=ne(ae[1]),pe=ue),{type:"link",raw:ae[0],text:ue,href:pe,tokens:[{type:"text",raw:ue,text:ue}]}}},de.url=function(ee,te){var ae;if(ae=this.rules.inline.url.exec(ee)){var ue,pe;if(ae[2]==="@")ue=ne(this.options.mangle?te(ae[0]):ae[0]),pe="mailto:"+ue;else{var Se;do Se=ae[0],ae[0]=this.rules.inline._backpedal.exec(ae[0])[0];while(Se!==ae[0]);ue=ne(ae[0]),ae[1]==="www."?pe="http://"+ue:pe=ue}return{type:"link",raw:ae[0],text:ue,href:pe,tokens:[{type:"text",raw:ue,text:ue}]}}},de.inlineText=function(ee,te,ae){var ue=this.rules.inline.text.exec(ee);if(ue){var pe;return te?pe=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ne(ue[0]):ue[0]:pe=ne(this.options.smartypants?ae(ue[0]):ue[0]),{type:"text",raw:ue[0],text:pe}}},me}(),Ce=J.noopTest,Te=J.edit,Ee=J.merge,ge={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ge._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ge._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ge.def=Te(ge.def).replace("label",ge._label).replace("title",ge._title).getRegex(),ge.bullet=/(?:[*+-]|\d{1,9}[.)])/,ge.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ge.item=Te(ge.item,"gm").replace(/bull/g,ge.bullet).getRegex(),ge.list=Te(ge.list).replace(/bull/g,ge.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ge.def.source+")").getRegex(),ge._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ge._comment=/<!--(?!-?>)[\s\S]*?-->/,ge.html=Te(ge.html,"i").replace("comment",ge._comment).replace("tag",ge._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge.paragraph=Te(ge._paragraph).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.blockquote=Te(ge.blockquote).replace("paragraph",ge.paragraph).getRegex(),ge.normal=Ee({},ge),ge.gfm=Ee({},ge.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ge.gfm.nptable=Te(ge.gfm.nptable).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.gfm.table=Te(ge.gfm.table).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.pedantic=Ee({},ge.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ge._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Ce,paragraph:Te(ge.normal._paragraph).replace("hr",ge.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",ge.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ce,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:Ce,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Te(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Te(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Te(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Te(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Te(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Te(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Te(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Te(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Te(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Te(se._blockSkip,"g").getRegex(),se.overlapSkip=Te(se._overlapSkip,"g").getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,se.autolink=Te(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Te(se.tag).replace("comment",ge._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Te(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Te(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Te(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal=Ee({},se),se.pedantic=Ee({},se.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Te(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=Ee({},se.normal,{escape:Te(se.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),se.gfm.url=Te(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=Ee({},se.gfm,{br:Te(se.br).replace("{2,}","*").getRegex(),text:Te(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var ke={block:ge,inline:se},Ve=H.defaults,He=ke.block,tt=ke.inline;function Ke(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 Le(me){var de="",fe,ee,te=me.length;for(fe=0;fe<te;fe++)ee=me.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var Me=function(){function me(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||Ve,this.options.tokenizer=this.options.tokenizer||new xe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:He.normal,inline:tt.normal};this.options.pedantic?(ee.block=He.pedantic,ee.inline=tt.pedantic):this.options.gfm&&(ee.block=He.gfm,this.options.breaks?ee.inline=tt.breaks:ee.inline=tt.gfm),this.tokenizer.rules=ee}me.lex=function(ee,te){var ae=new me(te);return ae.lex(ee)};var de=me.prototype;return de.lex=function(ee){return ee=ee.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(ee,this.tokens,!0),this.inline(this.tokens),this.tokens},de.blockTokens=function(ee,te,ae){te===void 0&&(te=[]),ae===void 0&&(ae=!0),ee=ee.replace(/^ +$/gm,"");for(var ue,pe,Se,Oe;ee;){if(ue=this.tokenizer.space(ee)){ee=ee.substring(ue.raw.length),ue.type&&te.push(ue);continue}if(ue=this.tokenizer.code(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Oe=te[te.length-1],Oe.raw+=`
|
|
`+ue.raw,Oe.text+=`
|
|
`+ue.text);continue}if(ue=this.tokenizer.fences(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.heading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.nptable(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.hr(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.blockquote(ee)){ee=ee.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],ae),te.push(ue);continue}if(ue=this.tokenizer.list(ee)){for(ee=ee.substring(ue.raw.length),Se=ue.items.length,pe=0;pe<Se;pe++)ue.items[pe].tokens=this.blockTokens(ue.items[pe].text,[],!1);te.push(ue);continue}if(ue=this.tokenizer.html(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ae&&(ue=this.tokenizer.def(ee))){ee=ee.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(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.lheading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ae&&(ue=this.tokenizer.paragraph(ee))){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.text(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Oe=te[te.length-1],Oe.raw+=`
|
|
`+ue.raw,Oe.text+=`
|
|
`+ue.text);continue}if(ee){var qe="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(qe);break}else throw new Error(qe)}}return te},de.inline=function(ee){var te,ae,ue,pe,Se,Oe,qe=ee.length;for(te=0;te<qe;te++){Oe=ee[te];switch(Oe.type){case"paragraph":case"text":case"heading":{Oe.tokens=[],this.inlineTokens(Oe.text,Oe.tokens);break}case"table":{for(Oe.tokens={header:[],cells:[]},pe=Oe.header.length,ae=0;ae<pe;ae++)Oe.tokens.header[ae]=[],this.inlineTokens(Oe.header[ae],Oe.tokens.header[ae]);for(pe=Oe.cells.length,ae=0;ae<pe;ae++)for(Se=Oe.cells[ae],Oe.tokens.cells[ae]=[],ue=0;ue<Se.length;ue++)Oe.tokens.cells[ae][ue]=[],this.inlineTokens(Se[ue],Oe.tokens.cells[ae][ue]);break}case"blockquote":{this.inline(Oe.tokens);break}case"list":{for(pe=Oe.items.length,ae=0;ae<pe;ae++)this.inline(Oe.items[ae].tokens);break}}}return ee},de.inlineTokens=function(ee,te,ae,ue,pe){te===void 0&&(te=[]),ae===void 0&&(ae=!1),ue===void 0&&(ue=!1),pe===void 0&&(pe="");var Se,Oe=ee,qe;if(this.tokens.links){var pt=Object.keys(this.tokens.links);if(pt.length>0)for(;(qe=this.tokenizer.rules.inline.reflinkSearch.exec(Oe))!=null;)pt.includes(qe[0].slice(qe[0].lastIndexOf("[")+1,-1))&&(Oe=Oe.slice(0,qe.index)+"["+"a".repeat(qe[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(qe=this.tokenizer.rules.inline.blockSkip.exec(Oe))!=null;)Oe=Oe.slice(0,qe.index)+"["+"a".repeat(qe[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(Se=this.tokenizer.escape(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.tag(ee,ae,ue)){ee=ee.substring(Se.raw.length),ae=Se.inLink,ue=Se.inRawBlock,te.push(Se);continue}if(Se=this.tokenizer.link(ee)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,ue)),te.push(Se);continue}if(Se=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,ue)),te.push(Se);continue}if(Se=this.tokenizer.strong(ee,Oe,pe)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.em(ee,Oe,pe)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.codespan(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.br(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.del(ee)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.autolink(ee,Le)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(!ae&&(Se=this.tokenizer.url(ee,Le))){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.inlineText(ee,ue,Ke)){ee=ee.substring(Se.raw.length),pe=Se.raw.slice(-1),te.push(Se);continue}if(ee){var dt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(dt);break}else throw new Error(dt)}}return te},$(me,null,[{key:"rules",get:function(){return{block:He,inline:tt}}}]),me}(),We=H.defaults,Xe=J.cleanUrl,Ge=J.escape,Fe=function(){function me(fe){this.options=fe||We}var de=me.prototype;return de.code=function(ee,te,ae){var ue=(te||"").match(/\S*/)[0];if(this.options.highlight){var pe=this.options.highlight(ee,ue);pe!=null&&pe!==ee&&(ae=!0,ee=pe)}return ue?'<pre><code class="'+this.options.langPrefix+Ge(ue,!0)+'">'+(ae?ee:Ge(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ae?ee:Ge(ee,!0))+`</code></pre>
|
|
`},de.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},de.html=function(ee){return ee},de.heading=function(ee,te,ae,ue){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+ue.slug(ae)+'">'+ee+"</h"+te+`>
|
|
`:"<h"+te+">"+ee+"</h"+te+`>
|
|
`},de.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},de.list=function(ee,te,ae){var ue=te?"ol":"ul",pe=te&&ae!==1?' start="'+ae+'"':"";return"<"+ue+pe+`>
|
|
`+ee+"</"+ue+`>
|
|
`},de.listitem=function(ee){return"<li>"+ee+`</li>
|
|
`},de.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},de.paragraph=function(ee){return"<p>"+ee+`</p>
|
|
`},de.table=function(ee,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+ee+`</thead>
|
|
`+te+`</table>
|
|
`},de.tablerow=function(ee){return`<tr>
|
|
`+ee+`</tr>
|
|
`},de.tablecell=function(ee,te){var ae=te.header?"th":"td",ue=te.align?"<"+ae+' align="'+te.align+'">':"<"+ae+">";return ue+ee+"</"+ae+`>
|
|
`},de.strong=function(ee){return"<strong>"+ee+"</strong>"},de.em=function(ee){return"<em>"+ee+"</em>"},de.codespan=function(ee){return"<code>"+ee+"</code>"},de.br=function(){return this.options.xhtml?"<br/>":"<br>"},de.del=function(ee){return"<del>"+ee+"</del>"},de.link=function(ee,te,ae){if(ee=Xe(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ae;var ue='<a href="'+Ge(ee)+'"';return te&&(ue+=' title="'+te+'"'),ue+=">"+ae+"</a>",ue},de.image=function(ee,te,ae){if(ee=Xe(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ae;var ue='<img src="'+ee+'" alt="'+ae+'"';return te&&(ue+=' title="'+te+'"'),ue+=this.options.xhtml?"/>":">",ue},de.text=function(ee){return ee},me}(),Be=function(){function me(){}var de=me.prototype;return de.strong=function(ee){return ee},de.em=function(ee){return ee},de.codespan=function(ee){return ee},de.del=function(ee){return ee},de.html=function(ee){return ee},de.text=function(ee){return ee},de.link=function(ee,te,ae){return""+ae},de.image=function(ee,te,ae){return""+ae},de.br=function(){return""},me}(),ot=function(){function me(){this.seen={}}var de=me.prototype;return de.slug=function(ee){var te=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ae=te;do this.seen[ae]++,te=ae+"-"+this.seen[ae];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},me}(),et=H.defaults,Ze=J.unescape,rt=function(){function me(fe){this.options=fe||et,this.options.renderer=this.options.renderer||new Fe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Be,this.slugger=new ot}me.parse=function(ee,te){var ae=new me(te);return ae.parse(ee)};var de=me.prototype;return de.parse=function(ee,te){te===void 0&&(te=!0);var ae="",ue,pe,Se,Oe,qe,pt,dt,Lt,Tt,ut,Bt,Ct,_t,Dt,mt,or,Zt,vt,vr=ee.length;for(ue=0;ue<vr;ue++){ut=ee[ue];switch(ut.type){case"space":continue;case"hr":{ae+=this.renderer.hr();continue}case"heading":{ae+=this.renderer.heading(this.parseInline(ut.tokens),ut.depth,Ze(this.parseInline(ut.tokens,this.textRenderer)),this.slugger);continue}case"code":{ae+=this.renderer.code(ut.text,ut.lang,ut.escaped);continue}case"table":{for(Lt="",dt="",Oe=ut.header.length,pe=0;pe<Oe;pe++)dt+=this.renderer.tablecell(this.parseInline(ut.tokens.header[pe]),{header:!0,align:ut.align[pe]});for(Lt+=this.renderer.tablerow(dt),Tt="",Oe=ut.cells.length,pe=0;pe<Oe;pe++){for(pt=ut.tokens.cells[pe],dt="",qe=pt.length,Se=0;Se<qe;Se++)dt+=this.renderer.tablecell(this.parseInline(pt[Se]),{header:!1,align:ut.align[Se]});Tt+=this.renderer.tablerow(dt)}ae+=this.renderer.table(Lt,Tt);continue}case"blockquote":{Tt=this.parse(ut.tokens),ae+=this.renderer.blockquote(Tt);continue}case"list":{for(Bt=ut.ordered,Ct=ut.start,_t=ut.loose,Oe=ut.items.length,Tt="",pe=0;pe<Oe;pe++)mt=ut.items[pe],or=mt.checked,Zt=mt.task,Dt="",mt.task&&(vt=this.renderer.checkbox(or),_t?mt.tokens.length>0&&mt.tokens[0].type==="text"?(mt.tokens[0].text=vt+" "+mt.tokens[0].text,mt.tokens[0].tokens&&mt.tokens[0].tokens.length>0&&mt.tokens[0].tokens[0].type==="text"&&(mt.tokens[0].tokens[0].text=vt+" "+mt.tokens[0].tokens[0].text)):mt.tokens.unshift({type:"text",text:vt}):Dt+=vt),Dt+=this.parse(mt.tokens,_t),Tt+=this.renderer.listitem(Dt,Zt,or);ae+=this.renderer.list(Tt,Bt,Ct);continue}case"html":{ae+=this.renderer.html(ut.text);continue}case"paragraph":{ae+=this.renderer.paragraph(this.parseInline(ut.tokens));continue}case"text":{for(Tt=ut.tokens?this.parseInline(ut.tokens):ut.text;ue+1<vr&&ee[ue+1].type==="text";)ut=ee[++ue],Tt+=`
|
|
`+(ut.tokens?this.parseInline(ut.tokens):ut.text);ae+=te?this.renderer.paragraph(Tt):Tt;continue}default:{var sr='Token with "'+ut.type+'" type was not found.';if(this.options.silent){console.error(sr);return}else throw new Error(sr)}}}return ae},de.parseInline=function(ee,te){te=te||this.renderer;var ae="",ue,pe,Se=ee.length;for(ue=0;ue<Se;ue++){pe=ee[ue];switch(pe.type){case"escape":{ae+=te.text(pe.text);break}case"html":{ae+=te.html(pe.text);break}case"link":{ae+=te.link(pe.href,pe.title,this.parseInline(pe.tokens,te));break}case"image":{ae+=te.image(pe.href,pe.title,pe.text);break}case"strong":{ae+=te.strong(this.parseInline(pe.tokens,te));break}case"em":{ae+=te.em(this.parseInline(pe.tokens,te));break}case"codespan":{ae+=te.codespan(pe.text);break}case"br":{ae+=te.br();break}case"del":{ae+=te.del(this.parseInline(pe.tokens,te));break}case"text":{ae+=te.text(pe.text);break}default:{var Oe='Token with "'+pe.type+'" type was not found.';if(this.options.silent){console.error(Oe);return}else throw new Error(Oe)}}}return ae},me}(),ht=J.merge,Qe=J.checkSanitizeDeprecation,Je=J.escape,we=H.getDefaults,lt=H.changeDefaults,it=H.defaults;function Ae(me,de,fe){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 de=="function"&&(fe=de,de=null),de=ht({},Ae.defaults,de||{}),Qe(de),fe){var ee=de.highlight,te;try{te=Me.lex(me,de)}catch(Se){return fe(Se)}var ae=function(Oe){var qe;if(!Oe)try{qe=rt.parse(te,de)}catch(pt){Oe=pt}return de.highlight=ee,Oe?fe(Oe):fe(null,qe)};if(!ee||ee.length<3)return ae();if(delete de.highlight,!te.length)return ae();var ue=0;Ae.walkTokens(te,function(Se){Se.type==="code"&&(ue++,setTimeout(function(){ee(Se.text,Se.lang,function(Oe,qe){if(Oe)return ae(Oe);qe!=null&&qe!==Se.text&&(Se.text=qe,Se.escaped=!0),ue--,ue===0&&ae()})},0))}),ue===0&&ae();return}try{var pe=Me.lex(me,de);return de.walkTokens&&Ae.walkTokens(pe,de.walkTokens),rt.parse(pe,de)}catch(Se){if(Se.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+Je(Se.message+"",!0)+"</pre>";throw Se}}Ae.options=Ae.setOptions=function(me){return ht(Ae.defaults,me),lt(Ae.defaults),Ae},Ae.getDefaults=we,Ae.defaults=it,Ae.use=function(me){var de=ht({},me);if(me.renderer&&function(){var ee=Ae.defaults.renderer||new Fe,te=function(pe){var Se=ee[pe];ee[pe]=function(){for(var Oe=arguments.length,qe=new Array(Oe),pt=0;pt<Oe;pt++)qe[pt]=arguments[pt];var dt=me.renderer[pe].apply(ee,qe);return dt===!1&&(dt=Se.apply(ee,qe)),dt}};for(var ae in me.renderer)te(ae);de.renderer=ee}(),me.tokenizer&&function(){var ee=Ae.defaults.tokenizer||new xe,te=function(pe){var Se=ee[pe];ee[pe]=function(){for(var Oe=arguments.length,qe=new Array(Oe),pt=0;pt<Oe;pt++)qe[pt]=arguments[pt];var dt=me.tokenizer[pe].apply(ee,qe);return dt===!1&&(dt=Se.apply(ee,qe)),dt}};for(var ae in me.tokenizer)te(ae);de.tokenizer=ee}(),me.walkTokens){var fe=Ae.defaults.walkTokens;de.walkTokens=function(ee){me.walkTokens(ee),fe&&fe(ee)}}Ae.setOptions(de)},Ae.walkTokens=function(me,de){for(var fe=N(me),ee;!(ee=fe()).done;){var te=ee.value;de(te);switch(te.type){case"table":{for(var ae=N(te.tokens.header),ue;!(ue=ae()).done;){var pe=ue.value;Ae.walkTokens(pe,de)}for(var Se=N(te.tokens.cells),Oe;!(Oe=Se()).done;)for(var qe=Oe.value,pt=N(qe),dt;!(dt=pt()).done;){var Lt=dt.value;Ae.walkTokens(Lt,de)}break}case"list":{Ae.walkTokens(te.items,de);break}default:te.tokens&&Ae.walkTokens(te.tokens,de)}}},Ae.Parser=rt,Ae.parser=rt.parse,Ae.Renderer=Fe,Ae.TextRenderer=Be,Ae.Lexer=Me,Ae.lexer=Me.lex,Ae.Tokenizer=xe,Ae.Slugger=ot,Ae.parse=Ae;var Ne=Ae;return Ne})},ELLl:function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=ie.Pos;ie.defineOption("autoCloseBrackets",!1,function(A,y,u){u&&u!=ie.Init&&(A.removeKeyMap(N),A.state.closeBrackets=null),y&&(P(V(y,"pairs")),A.state.closeBrackets=y,A.addKeyMap(N))});function V(A,y){return y=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[y]!=null?A[y]:$[y]}var N={Backspace:M,Enter:O};function P(A){for(var y=0;y<A.length;y++){var u=A.charAt(y),a="'"+u+"'";N[a]||(N[a]=H(u))}}P($.pairs+"`");function H(A){return function(y){return C(y,A)}}function F(A){var y=A.state.closeBrackets;if(!y||y.override)return y;var u=A.getModeAt(A.getCursor());return u.closeBrackets||y}function M(A){var y=F(A);if(!y||A.getOption("disableInput"))return ie.Pass;for(var u=V(y,"pairs"),a=A.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=k(A,a[l].head);if(!h||u.indexOf(h)%2!=0)return ie.Pass}for(var l=a.length-1;l>=0;l--){var w=a[l].head;A.replaceRange("",D(w.line,w.ch-1),D(w.line,w.ch+1),"+delete")}}function O(A){var y=F(A),u=y&&V(y,"explode");if(!u||A.getOption("disableInput"))return ie.Pass;for(var a=A.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=k(A,a[l].head);if(!h||u.indexOf(h)%2!=0)return ie.Pass}A.operation(function(){var w=A.lineSeparator()||`
|
|
`;A.replaceSelection(w+w,null),A.execCommand("goCharLeft"),a=A.listSelections();for(var g=0;g<a.length;g++){var m=a[g].head.line;A.indentLine(m,null,!0),A.indentLine(m+1,null,!0)}})}function b(A){var y=ie.cmpPos(A.anchor,A.head)>0;return{anchor:new D(A.anchor.line,A.anchor.ch+(y?-1:1)),head:new D(A.head.line,A.head.ch+(y?1:-1))}}function C(A,y){var u=F(A);if(!u||A.getOption("disableInput"))return ie.Pass;var a=V(u,"pairs"),l=a.indexOf(y);if(l==-1)return ie.Pass;for(var h=V(u,"closeBefore"),w=V(u,"triples"),g=a.charAt(l+1)==y,m=A.listSelections(),L=l%2==0,x,f=0;f<m.length;f++){var p=m[f],d=p.head,o,E=A.getRange(d,D(d.line,d.ch+1));if(L&&!p.empty())o="surround";else if((g||!L)&&E==y)g&&_(A,d)?o="both":w.indexOf(y)>=0&&A.getRange(d,D(d.line,d.ch+3))==y+y+y?o="skipThree":o="skip";else if(g&&d.ch>1&&w.indexOf(y)>=0&&A.getRange(D(d.line,d.ch-2),d)==y+y){if(d.ch>2&&/\bstring/.test(A.getTokenTypeAt(D(d.line,d.ch-2))))return ie.Pass;o="addFour"}else if(g){var v=d.ch==0?" ":A.getRange(D(d.line,d.ch-1),d);if(!ie.isWordChar(E)&&v!=y&&!ie.isWordChar(v))o="both";else return ie.Pass}else if(L&&(E.length===0||/\s/.test(E)||h.indexOf(E)>-1))o="both";else return ie.Pass;if(!x)x=o;else if(x!=o)return ie.Pass}var T=l%2?a.charAt(l-1):y,I=l%2?y:a.charAt(l+1);A.operation(function(){if(x=="skip")A.execCommand("goCharRight");else if(x=="skipThree")for(var G=0;G<3;G++)A.execCommand("goCharRight");else if(x=="surround"){for(var X=A.getSelections(),G=0;G<X.length;G++)X[G]=T+X[G]+I;A.replaceSelections(X,"around"),X=A.listSelections().slice();for(var G=0;G<X.length;G++)X[G]=b(X[G]);A.setSelections(X)}else x=="both"?(A.replaceSelection(T+I,null),A.triggerElectric(T+I),A.execCommand("goCharLeft")):x=="addFour"&&(A.replaceSelection(T+T+T+T,"before"),A.execCommand("goCharRight"))})}function k(A,y){var u=A.getRange(D(y.line,y.ch-1),D(y.line,y.ch+1));return u.length==2?u:null}function _(A,y){var u=A.getTokenAt(D(y.line,y.ch+1));return/\bstring/.test(u.type)&&u.start==y.ch&&(y.ch==0||!/\bstring/.test(A.getTokenTypeAt(y)))}})},F8wB:function(Et,nt,re){Et.exports={loading:"loading___1SIOG"}},Gytx:function(Et,nt){Et.exports=function(ie,$,D,V){var N=D?D.call(V,ie,$):void 0;if(N!==void 0)return!!N;if(ie===$)return!0;if(typeof ie!="object"||!ie||typeof $!="object"||!$)return!1;var P=Object.keys(ie),H=Object.keys($);if(P.length!==H.length)return!1;for(var F=Object.prototype.hasOwnProperty.bind($),M=0;M<P.length;M++){var O=P[M];if(!F(O))return!1;var b=ie[O],C=$[O];if(N=D?D.call(V,b,C,O):void 0,N===!1||N===void 0&&b!==C)return!1}return!0}},HV1I:function(Et,nt,re){Et.exports={flex_box_center:"flex_box_center___1nEOe",flex_space_between:"flex_space_between___21gJ7",flex_box_vertical_center:"flex_box_vertical_center___2iHIq",flex_box_center_end:"flex_box_center_end___19LSZ",flex_box_column:"flex_box_column___2zG50",bg:"bg___u_uqy",formWrap:"formWrap___3rl8w"}},HmJG:function(Et,nt,re){},LdHM:function(Et,nt,re){"use strict";re.d(nt,"b",function(){return h}),re.d(nt,"a",function(){return g});var ie=re("1OyB"),$=re("vuIU"),D=re("Ji7U"),V=re("LK+K"),N=re("q1tI"),P=re("rePB"),H=re("Ff2n"),F=re("ODXe"),M=re("4IlW"),O=re("bX4T"),b=re("YrtM"),C=re("TSYQ"),k=re.n(C),_=re("+nKL"),A=re("8OUc"),y=function(q,ne){var ce=q.prefixCls,ve=q.id,De=q.flattenOptions,xe=q.childrenAsData,Ce=q.values,Te=q.searchValue,Ee=q.multiple,ge=q.defaultActiveFirstOption,se=q.height,ke=q.itemHeight,Ve=q.notFoundContent,He=q.open,tt=q.menuItemSelectedIcon,Ke=q.virtual,Le=q.onSelect,Me=q.onToggleOpen,We=q.onActiveValue,Xe=q.onScroll,Ge=q.onMouseEnter,Fe="".concat(ce,"-item"),Be=Object(b.a)(function(){return De},[He,De],function(Ne,me){return me[0]&&Ne[1]!==me[1]}),ot=N.useRef(null),et=function(me){me.preventDefault()},Ze=function(me){ot.current&&ot.current.scrollTo({index:me})},rt=function(me){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Be.length,ee=0;ee<fe;ee+=1){var te=(me+ee*de+fe)%fe,ae=Be[te],ue=ae.group,pe=ae.data;if(!ue&&!pe.disabled)return te}return-1},ht=N.useState(function(){return rt(0)}),Qe=Object(F.a)(ht,2),Je=Qe[0],we=Qe[1],lt=function(me){we(me);var de=Be[me];if(!de){We(null,-1);return}We(de.data.value,me)};N.useEffect(function(){lt(ge!==!1?rt(0):-1)},[Be.length,Te]),N.useEffect(function(){var Ne=setTimeout(function(){if(!Ee&&He&&Ce.size===1){var me=Array.from(Ce)[0],de=Be.findIndex(function(fe){var ee=fe.data;return ee.value===me});lt(de),Ze(de)}});return function(){return clearTimeout(Ne)}},[He]);var it=function(me){me!==void 0&&Le(me,{selected:!Ce.has(me)}),Ee||Me(!1)};if(N.useImperativeHandle(ne,function(){return{onKeyDown:function(me){var de=me.which;switch(de){case M.a.UP:case M.a.DOWN:{var fe=0;if(de===M.a.UP?fe=-1:de===M.a.DOWN&&(fe=1),fe!==0){var ee=rt(Je+fe,fe);Ze(ee),lt(ee)}break}case M.a.ENTER:{var te=Be[Je];te&&!te.data.disabled?it(te.data.value):it(void 0),He&&me.preventDefault();break}case M.a.ESC:Me(!1)}},onKeyUp:function(){},scrollTo:function(me){Ze(me)}}}),Be.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Fe,"-empty"),onMouseDown:et},Ve);function Ae(Ne){var me=Be[Ne];if(!me)return null;var de=me.data||{},fe=de.value,ee=de.label,te=de.children,ae=Object(O.a)(de,!0),ue=xe?te:ee;return me?N.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},ae,{key:Ne,role:"option",id:"".concat(ve,"_list_").concat(Ne),"aria-selected":Ce.has(fe)}),fe):null}return N.createElement(N.Fragment,null,N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ae(Je-1),Ae(Je),Ae(Je+1)),N.createElement(_.a,{itemKey:"key",ref:ot,data:Be,height:se,itemHeight:ke,fullHeight:!1,onMouseDown:et,onScroll:Xe,virtual:Ke,onMouseEnter:Ge},function(Ne,me){var de,fe=Ne.group,ee=Ne.groupOption,te=Ne.data,ae=te.label,ue=te.key;if(fe)return N.createElement("div",{className:k()(Fe,"".concat(Fe,"-group"))},ae!==void 0?ae:ue);var pe=te.disabled,Se=te.value,Oe=te.title,qe=te.children,pt=te.style,dt=te.className,Lt=Object(H.a)(te,["disabled","value","title","children","style","className"]),Tt=Ce.has(Se),ut="".concat(Fe,"-option"),Bt=k()(Fe,ut,dt,(de={},Object(P.a)(de,"".concat(ut,"-grouped"),ee),Object(P.a)(de,"".concat(ut,"-active"),Je===me&&!pe),Object(P.a)(de,"".concat(ut,"-disabled"),pe),Object(P.a)(de,"".concat(ut,"-selected"),Tt),de)),Ct=xe?qe:ae,_t=!tt||typeof tt=="function"||Tt;return N.createElement("div",Object.assign({},Lt,{"aria-selected":Tt,className:Bt,title:Oe,onMouseMove:function(){if(Je===me||pe)return;lt(me)},onClick:function(){pe||it(Se)},style:pt}),N.createElement("div",{className:"".concat(ut,"-content")},Ct||Se),N.isValidElement(tt)||Tt,_t&&N.createElement(A.a,{className:"".concat(Fe,"-option-state"),customizeIcon:tt,customizeIconProps:{isSelected:Tt}},Tt?"\u2713":null))}))},u=N.forwardRef(y);u.displayName="OptionList";var a=u,l=function(){return null};l.isSelectOption=!0;var h=l,w=function(){return null};w.isSelectOptGroup=!0;var g=w,m=re("VTBJ"),L=re("Zm9Q");function x(W){var q=W.key,ne=W.props,ce=ne.children,ve=ne.value,De=Object(H.a)(ne,["children","value"]);return Object(m.a)({key:q,value:ve!==void 0?ve:q,children:ce},De)}function f(W){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(W).map(function(ne,ce){if(!N.isValidElement(ne)||!ne.type)return null;var ve=ne.type.isSelectOptGroup,De=ne.key,xe=ne.props,Ce=xe.children,Te=Object(H.a)(xe,["children"]);return q||!ve?x(ne):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(De===null?ce:De,"__"),label:De},Te),{},{options:f(Ce)})}).filter(function(ne){return ne})}var p=re("2Qr1"),d=re("qNPg"),o=re("U8pU"),E=re("Kwbf"),v=re("WKfj");function T(W){var q=W.mode,ne=W.options,ce=W.children,ve=W.backfill,De=W.allowClear,xe=W.placeholder,Ce=W.getInputElement,Te=W.showSearch,Ee=W.onSearch,ge=W.defaultOpen,se=W.autoFocus,ke=W.labelInValue,Ve=W.value,He=W.inputValue,tt=W.optionLabelProp,Ke=q==="multiple"||q==="tags",Le=Te!==void 0?Te:Ke||q==="combobox",Me=ne||f(ce);if(Object(E.a)(q!=="tags"||Me.every(function(Fe){return!Fe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var We=Me.some(function(Fe){return Fe.options?Fe.options.some(function(Be){return typeof("value"in Be?Be.value:Be.key)=="number"}):typeof("value"in Fe?Fe.value:Fe.key)=="number"});Object(E.a)(!We,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(E.a)(q!=="combobox"||!tt,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(E.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(E.a)(q==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(E.b)(q!=="combobox"||!Ce||!De||!xe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ee&&!Le&&q!=="combobox"&&q!=="tags"&&Object(E.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(E.b)(!ge||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Ve!=null){var Xe=Object(v.d)(Ve);Object(E.a)(!ke||Xe.every(function(Fe){return Object(o.a)(Fe)==="object"&&("key"in Fe||"value"in Fe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(E.a)(!Ke||Array.isArray(Ve),"`value` should be array when `mode` is `multiple` or `tags`")}if(ce){var Ge=null;Object(L.a)(ce).some(function(Fe){if(!N.isValidElement(Fe)||!Fe.type)return!1;var Be=Fe.type;if(Be.isSelectOption)return!1;if(Be.isSelectOptGroup){var ot=Object(L.a)(Fe.props.children).every(function(et){return!N.isValidElement(et)||!Fe.type||et.type.isSelectOption?!0:(Ge=et.type,!1)});return!ot}return Ge=Be,!0}),Ge&&Object(E.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Ge.displayName||Ge.name||Ge,"`.")),Object(E.a)(He===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var I=T,G=Object(d.a)({prefixCls:"rc-select",components:{optionList:a},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:I,fillOptionsWithMissingValue:p.a}),X=function(W){Object(D.a)(ne,W);var q=Object(V.a)(ne);function ne(){var ce;return Object(ie.a)(this,ne),ce=q.apply(this,arguments),ce.selectRef=N.createRef(),ce.focus=function(){ce.selectRef.current.focus()},ce.blur=function(){ce.selectRef.current.blur()},ce}return Object($.a)(ne,[{key:"render",value:function(){return N.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ne}(N.Component);X.Option=h,X.OptGroup=g;var J=X,z=nt.c=J},Ly88:function(Et,nt,re){"use strict";re.r(nt);var ie=re("14J3"),$=re("BMrR"),D=re("jCWc"),V=re("kPKH"),N=re("OaEy"),P=re("2fM7"),H=re("7Kak"),F=re("9yH6"),M=re("5NDa"),O=re("5rEg"),b=re("2qtc"),C=re("kLXV"),k=re("miYZ"),_=re("tsqr"),A=re("9og8"),y=re("k1fw"),u=re("y8nQ"),a=re("Vl3Y"),l=re("tJVT"),h=re("PpiC"),w=re("WmNS"),g=re.n(w),m=re("q1tI"),L=re.n(m),x=re("9kvl"),f=re("Ot1p"),p=re("HBuW"),d=re("HV1I"),o=re.n(d),E=re("LvDl"),v=re.n(E),T=re("9ZNV"),I=re("nuEh"),G=re("fnXi"),X=re("UqFu"),J=re("2RCv"),z={1:[100,200],2:[300,400,500,600],3:[700,800,900,1e3]},W=function(ne){var ce,ve,De,xe=ne.shixunsDetail,Ce=ne.dispatch,Te=ne.match,Ee=ne.practiceSetting,ge=Object(h.a)(ne,["shixunsDetail","dispatch","match","practiceSetting"]),se=a.a.useForm(),ke=Object(l.a)(se,1),Ve=ke[0],He=Object(m.useState)({}),tt=Object(l.a)(He,2),Ke=tt[0],Le=tt[1],Me=Object(m.useState)([100,200]),We=Object(l.a)(Me,2),Xe=We[0],Ge=We[1],Fe=xe.challengesNew,Be=Object(m.useState)(),ot=Object(l.a)(Be,2),et=ot[0],Ze=ot[1],rt=Object(m.useState)(),ht=Object(l.a)(rt,2),Qe=ht[0],Je=ht[1],we=Object(m.useState)(!0),lt=Object(l.a)(we,2),it=lt[0],Ae=lt[1],Ne=Object(m.useState)(1),me=Object(l.a)(Ne,2),de=me[0],fe=me[1],ee=Object(m.useRef)({subject:"",difficulty:1,score:100,task_pass:Object(X.a)(Fe.task_pass_default)}),te=Object(m.useRef)(null),ae=Ee.selectQuestionParams,ue=Ee.id,pe=Ee.newQuestion;Object(m.useEffect)(function(){Te.params.challengesId?(Je(!0),Se()):(Ae(!0),Je(!1),Ce({type:"shixunsDetail/getChallengesNew",payload:Object(y.a)({},Te.params)}),Ae(!1)),setTimeout(function(){document.getElementById("practice-scroll").scrollTo(0,0)},300)},[Te.params]),Object(m.useEffect)(function(){return Tt(),function(){clearTimeout(te.current)}},[Ke]);var Se=function(){var Ct=Object(A.a)(g.a.mark(function _t(){var Dt,mt;return g.a.wrap(function(Zt){for(;;)switch(Zt.prev=Zt.next){case 0:return Ae(!0),Zt.next=3,Object(p.H)({id:Te.params.id,challengeId:Te.params.challengesId,tab:0});case 3:Dt=Zt.sent,Dt&&(mt=Object(y.a)(Object(y.a)({},Dt),{},{task_pass:Object(X.a)(Dt.task_pass)}),Ze(mt),Oe(mt),Ae(!1),ee.current={subject:mt.subject,difficulty:mt.difficulty,score:mt.score,task_pass:mt.task_pass});case 5:case"end":return Zt.stop()}},_t)}));return function(){return Ct.apply(this,arguments)}}(),Oe=function(_t){var Dt={subject:_t.name,difficulty:_t.difficulty,score:_t.score,challenge_tag:_t.tags,task_pass:_t.task_pass},mt=z[_t.difficulty];Ge(mt),Ve.setFieldsValue(Object(y.a)({},Dt)),Le(Object(y.a)({},Dt))},qe=function(_t){var Dt=z[_t],mt=Dt==null?void 0:Dt[0];Ge(Dt),Ve.setFieldsValue({score:mt}),Le(Object(y.a)(Object(y.a)({},Ve.getFieldsValue()),{score:mt}))},pt=function(_t,Dt){Le(Object(y.a)({},Ve.getFieldsValue())),"difficulty"in _t&&qe(_t.difficulty)},dt=function(){var Ct=Object(A.a)(g.a.mark(function _t(){var Dt,mt,or,Zt,vt,vr=arguments;return g.a.wrap(function(Kt){for(;;)switch(Kt.prev=Kt.next){case 0:if(mt=vr.length>0&&vr[0]!==void 0?vr[0]:{},!(!Qe&&((Dt=xe.detail)===null||Dt===void 0?void 0:Dt.shixun_status)===2)){Kt.next=4;break}return _.b.info("\u8BE5\u5B9E\u8BAD\u5DF2\u7ECF\u53D1\u5E03\u4E0D\u80FD\u65B0\u5EFA"),Kt.abrupt("return");case 4:if(!Qe){Kt.next=10;break}return Kt.next=7,Object(p.Mb)(Object(y.a)(Object(y.a)({},Te.params),{},{tab:0,challenge:Object(y.a)({},mt),challenge_tag:mt.challenge_tag}));case 7:return or=Kt.sent,or&&(Ce({type:"practiceSetting/setUpdateIndex"}),x.d.replace("/shixuns/".concat(Te.params.id,"/edit/").concat(Te.params.challengesId,"/tab=2"))),Kt.abrupt("return");case 10:return Zt=Object(y.a)({},Ke),Zt.identifier=Te.params.id,Zt.st=0,Kt.next=15,Object(p.b)(Object(y.a)({},Zt));case 15:vt=Kt.sent,vt.status===1&&(x.d.replace("/shixuns/".concat(Te.params.id,"/edit/").concat(vt.challenge_id,"/tab=2")),setTimeout(function(){Ce({type:"practiceSetting/setParams",payload:{newQuestion:null}}),Ce({type:"practiceSetting/setUpdateIndex"})},200));case 17:case"end":return Kt.stop()}},_t)}));return function(){return Ct.apply(this,arguments)}}(),Lt=function(){Bt()},Tt=function(){clearTimeout(te.current),te.current=setTimeout(ut,500)},ut=function(){"subject"in Ke&&pe&&Ce({type:"practiceSetting/setParams",payload:{newQuestion:{st:0,name:Ke==null?void 0:Ke.subject}}});var _t=["subject","difficulty","score","task_pass"],Dt=_t.some(function(mt){var or=Object(E.isNumber)(Ke[mt])?String(Ke[mt]):Ke[mt],Zt=Object(E.isNumber)(ee.current[mt])?String(ee.current[mt]):ee.current[mt];return!Object(E.isEqual)(or,Zt)});Ce(Dt?{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}:{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},Bt=function(){var _t,Dt=function(){x.d.push("/shixuns/".concat(ue,"/challenges")),Ce({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};Ee!=null&&(_t=Ee.sideBar)!==null&&_t!==void 0&&_t.confirmLeave?C.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){Dt()}}):Dt()};return L.a.createElement(L.a.Fragment,null,L.a.createElement("section",{key:1,className:o.a.bg,id:"practice-scroll"},L.a.createElement(a.a,{key:de,form:Ve,className:o.a.formWrap,scrollToFirstError:!0,layout:"vertical",onValuesChange:pt,onFinish:dt},L.a.createElement(G.a,{activeIndex:0,isEdit:Qe}),L.a.createElement(a.a.Item,{initialValue:"",name:"subject",label:"\u4EFB\u52A1\u540D\u79F0:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EFB\u52A1\u540D\u79F0"}]},L.a.createElement(O.a,{bordered:!1,maxLength:60,suffix:"".concat(((ce=Ke.subject)===null||ce===void 0?void 0:ce.length)||0,"/60"),placeholder:"\u4F8B\u5982\uFF1A\u4ECEPython\u7A0B\u5E8F\u8BBE\u8BA1-\u5165\u95E8\u7CBE\u901A"})),L.a.createElement(a.a.Item,{name:"task_pass",label:"\u4EFB\u52A1\u8981\u6C42:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F5C\u4E1A\u7684\u7B80\u4ECB"},{max:35e3,message:"\u8FC7\u5173\u4EFB\u52A1\u7B80\u4ECB\u6700\u5927\u9650\u523635000\u4E2A\u5B57\u7B26"}]},L.a.createElement(f.a,{key:Te.params.challengesId||"3",watch:!0,defaultValue:Qe?et==null?void 0:et.task_pass:Fe.task_pass_default})),L.a.createElement(a.a.Item,{initialValue:1,name:"difficulty",label:"\u96BE\u5EA6\u7CFB\u6570:",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u96BE\u5EA6\u7CFB\u6570"}]},L.a.createElement(F.a.Group,{disabled:((ve=xe.detail)===null||ve===void 0?void 0:ve.shixun_status)===2},L.a.createElement(F.a,{value:1},"\u7B80\u5355"),L.a.createElement(F.a,{style:{marginLeft:70},value:2},"\u4E2D\u7B49"),L.a.createElement(F.a,{style:{marginLeft:70},value:3},"\u56F0\u96BE"))),L.a.createElement(a.a.Item,{name:"challenge_tag",label:L.a.createElement("div",null,"\u6280\u80FD\u6807\u7B7E ",L.a.createElement("span",{className:"pl20 font12 c-light-black"},"\u5B66\u5458\u7B54\u9898\u6B63\u786E\u5C06\u83B7\u5F97\u6280\u80FD\uFF0C\u5426\u5219\u4E0D\u80FD\u83B7\u5F97\u6280\u80FD\uFF08\u56DE\u8F66\u6DFB\u52A0\u6807\u7B7E\uFF09")),rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6280\u80FD\u6807\u7B7E"}]},L.a.createElement(J.a,{placeholder:"\u6DFB\u52A0\u6807\u7B7E",style:{width:"260px"},InputRight:L.a.createElement("span",{className:"ml5"},"(\u56DE\u8F66\u6DFB\u52A0\u6807\u7B7E)")})),L.a.createElement($.a,{className:"customItemSelect"},L.a.createElement(V.a,null,L.a.createElement(a.a.Item,{name:"score",initialValue:100,label:"\u5956\u52B1\u91D1\u5E01:",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u5956\u52B1\u7ECF\u9A8C\u503C"}]},L.a.createElement(P.a,{disabled:((De=xe.detail)===null||De===void 0?void 0:De.shixun_status)===2,bordered:!1,style:{width:260}},Xe==null?void 0:Xe.map(function(Ct,_t){return L.a.createElement(P.a.Option,{key:_t,value:Ct},Ct)})))),L.a.createElement(V.a,{flex:1},L.a.createElement("div",{style:{marginTop:88},className:"font12 c-light-black ml10"}," \u5B66\u5458\u6B63\u786E\u7B54\u9898\u65F6\u83B7\u5F97\u91D1\u5E01\uFF0C\u5E76\u4E14\u83B7\u5F97\u7B49\u91CF\u7684\u7ECF\u9A8C\u503C\u3002\u5982\uFF1A+100\u91D1\u5E01\u3001+100\u7ECF\u9A8C\u503C"))))),L.a.createElement(T.a,{key:2,onOk:function(){return Ve.submit()},className:"customFixedButton",onCancel:Lt}),L.a.createElement(I.a,{loading:it}))};nt.default=Object(x.a)(function(q){var ne=q.shixunsDetail,ce=q.newCourse,ve=q.globalSetting,De=q.practiceSetting;return{shixunsDetail:ne,newCourse:ce,globalSetting:ve,practiceSetting:De}})(W)},M8RZ:function(Et,nt,re){"use strict";re.d(nt,"a",function(){return M});var ie=re("fWQN"),$=re("mtLc"),D=re("yKVA"),V=re("879j"),N=re("q1tI"),P=re.n(N),H=re("i8i4"),F=re.n(H),M=function(O){Object(D.a)(C,O);var b=Object(V.a)(C);function C(k){var _;Object(ie.a)(this,C),_=b.call(this,k);var A=window.document;return _.node=A.createElement("div"),A.body.appendChild(_.node),_}return Object($.a)(C,[{key:"render",value:function(){var _=this.props.children;return Object(H.createPortal)(_,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),C}(P.a.Component)},OLES:function(Et,nt,re){"use strict";var ie=re("U8pU"),$=re("VTBJ"),D=re("Ff2n"),V=re("q1tI"),N=re("uciX"),P=re("7ixt"),H=function(k){var _=k.overlay,A=k.prefixCls,y=k.id,u=k.overlayInnerStyle;return V.createElement("div",{className:"".concat(A,"-inner"),id:y,role:"tooltip",style:u},typeof _=="function"?_():_)},F=H,M=function(k,_){var A=k.overlayClassName,y=k.trigger,u=y===void 0?["hover"]:y,a=k.mouseEnterDelay,l=a===void 0?0:a,h=k.mouseLeaveDelay,w=h===void 0?.1:h,g=k.overlayStyle,m=k.prefixCls,L=m===void 0?"rc-tooltip":m,x=k.children,f=k.onVisibleChange,p=k.afterVisibleChange,d=k.transitionName,o=k.animation,E=k.placement,v=E===void 0?"right":E,T=k.align,I=T===void 0?{}:T,G=k.destroyTooltipOnHide,X=G===void 0?!1:G,J=k.defaultVisible,z=k.getTooltipContainer,W=k.overlayInnerStyle,q=Object(D.a)(k,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ne=Object(V.useRef)(null);Object(V.useImperativeHandle)(_,function(){return ne.current});var ce=Object($.a)({},q);"visible"in k&&(ce.popupVisible=k.visible);var ve=function(){var Ee=k.arrowContent,ge=Ee===void 0?null:Ee,se=k.overlay,ke=k.id;return[V.createElement("div",{className:"".concat(L,"-arrow"),key:"arrow"},ge),V.createElement(F,{key:"content",prefixCls:L,id:ke,overlay:se,overlayInnerStyle:W})]},De=!1,xe=!1;if(typeof X=="boolean")De=X;else if(X&&Object(ie.a)(X)==="object"){var Ce=X.keepParent;De=Ce===!0,xe=Ce===!1}return V.createElement(N.a,Object.assign({popupClassName:A,prefixCls:L,popup:ve,action:u,builtinPlacements:P.a,popupPlacement:v,ref:ne,popupAlign:I,getPopupContainer:z,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:d,popupAnimation:o,defaultPopupVisible:J,destroyPopupOnHide:De,autoDestroy:xe,mouseLeaveDelay:w,popupStyle:g,mouseEnterDelay:l},ce),x)},O=Object(V.forwardRef)(M),b=nt.a=O},Ot1p:function(Et,nt,re){"use strict";var ie=re("2qtc"),$=re("kLXV"),D=re("rAM+"),V=re("miYZ"),N=re("tsqr"),P=re("9og8"),H=re("tJVT"),F=re("jrin"),M=re("WmNS"),O=re.n(M),b=re("q1tI"),C=re.n(b),k=re("VrN/"),_=re.n(k),A=re("bdgK"),y=re("p77/"),u=re("Bd2K"),a=re("ELLl"),l=re("19Vz"),h=re("lZu9"),w=re("+NIl"),g=re("kSUc"),m=re("9Bee"),L=function(pe){var Se=pe.value,Oe=Se===void 0?"":Se,qe=pe.className,pt=pe.showTextOnly,dt=pe.showLines,Lt=pe.style,Tt=Lt===void 0?{}:Lt,ut=Object(b.useMemo)(function(){return""},[Oe]);return C.a.createElement(C.a.Fragment,null,C.a.createElement("div",{dangerouslySetInnerHTML:{__html:ut}}))},x=re("0Owb"),f=re("dejd"),p=re("C+DQ"),d=re("1vsH"),o=re("m3rI"),E=[{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 v(pe){var Se=pe.onActionCallback,Oe=pe.title,qe=pe.icon,pt=pe.actionName,dt=pe.className,Lt=dt===void 0?"":dt,Tt=pe.children;function ut(){Se(pt)}return C.a.createElement("a",{title:Oe,className:Lt,onClick:ut},C.a.createElement("i",{className:"md-iconfont ".concat(qe)}),Tt)}var T=function(pe){var Se=pe.watch,Oe=pe.showNullButton,qe=pe.onActionCallback,pt=pe.fullScreen,dt=pe.insertTemp,Lt=pe.hidetoolBar,Tt=pe.uuid,ut=pe.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(d.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(d.F)("_educoder_session"),"&key=").concat(Tt,"&api=").concat(encodeURIComponent(o.a.PROXY_SERVER)));var Bt=[].concat(E,[{title:"".concat(Se?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Se?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return C.a.createElement("ul",{className:"markdown-toolbar-container"},!Lt&&Bt.map(function(Ct,_t){return C.a.createElement("li",{key:_t},Ct.actionName?C.a.createElement(v,Object(x.a)({},Ct,{onActionCallback:qe})):C.a.createElement("span",{className:"v-line"}))}),Oe?C.a.createElement("li",null,C.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:qe},C.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,dt&&C.a.createElement("li",null,C.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(dt),onActionCallback:qe},C.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),C.a.createElement("li",{className:"btn-full-screen"},C.a.createElement(v,{icon:"".concat(pt?"icon-shrink":"icon-enlarge"),title:pt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:qe})))},I=re("M8RZ"),G=re("+L6B"),X=re("2/Rp"),J=re("y8nQ"),z=re("Vl3Y"),W=re("5NDa"),q=re("5rEg"),ne={labelCol:{span:4},wrapperCol:{span:20}},ce=function(pe){var Se=pe.callback,Oe=pe.onCancel;function qe(pt){Se(pt)}return C.a.createElement(z.a,Object(x.a)({},ne,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:qe}),C.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},C.a.createElement(q.a,null)),C.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},C.a.createElement(q.a,null)),C.a.createElement("div",{className:"flex-container flex-end"},C.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(X.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))},ve=re("7ahc"),De=re("HmJG"),xe=re("BjJ7"),Ce=z.a.useForm,Te={width:280,marginRight:10},Ee={labelCol:{span:5},wrapperCol:{span:19}},ge=function(pe){var Se=pe.callback,Oe=pe.onCancel,qe=Ce(),pt=Object(H.a)(qe,1),dt=pt[0];function Lt(Bt){Se(Bt)}function Tt(Bt,Ct){if(Bt.status===-1){N.b.error(Bt.message);return}dt.setFieldsValue({src:"/api/attachments/".concat(Bt.id),type:Ct.type})}function ut(Bt){var Ct=Bt.target.files[0];ke(Ct,Tt)}return C.a.createElement(z.a,Object(x.a)({form:dt},Ee,{className:"upload-image-panel",onFinish:Lt}),C.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},C.a.createElement("div",{className:"flex-container"},C.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},C.a.createElement(q.a,{style:Te})),C.a.createElement(se,{onFileChange:ut}))),C.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},C.a.createElement(q.a,{style:{width:264}})),C.a.createElement(z.a.Item,{style:{textAlign:"right"}},C.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(X.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))};function se(pe){var Se=pe.onFileChange;return C.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",C.a.createElement("input",{type:"file",onChange:Se}))}function ke(pe,Se){if(!pe)throw new String("\u6CA1\u6709\u6587\u4EF6");var Oe=new FormData;Oe.append("editormd-image-file",pe),Oe.append("file_param_name","editormd-image-file"),Oe.append("byxhr","true");var qe=new window.XMLHttpRequest;qe.withCredentials=!0,qe.addEventListener("load",function(pt){Se(JSON.parse(pt.target.responseText),pe)},!1),qe.addEventListener("error",function(pt){console.error(pt)},!1),qe.open("POST","".concat(xe.a,"/api/attachments.json")),qe.send(Oe)}var Ve=re("giR+"),He=re("fyUT"),tt=re("7Kak"),Ke=re("9yH6"),Le=Ke.a.Group,Me={margin:"0 8px"},We=function(pe){var Se=pe.callback,Oe=pe.onCancel;function qe(pt){Se(pt)}return C.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:qe},C.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},C.a.createElement("span",{style:Me},"\u5355\u5143\u683C\u6570\uFF1A"),C.a.createElement("span",{style:Me},"\u884C\u6570"),C.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},C.a.createElement(He.a,null)),C.a.createElement("span",{style:Me},"\u5217\u6570"),C.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},C.a.createElement(He.a,null))),C.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},C.a.createElement("span",{style:Me},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),C.a.createElement(z.a.Item,{name:"align"},C.a.createElement(Le,null,C.a.createElement(Ke.a,{value:"default"},C.a.createElement("i",{className:"fa fa-align-justify"})),C.a.createElement(Ke.a,{value:"left"},C.a.createElement("i",{className:"fa fa-align-left"})),C.a.createElement(Ke.a,{value:"center"},C.a.createElement("i",{className:"fa fa-align-center"})),C.a.createElement(Ke.a,{value:"right"},C.a.createElement("i",{className:"fa fa-align-right"}))))),C.a.createElement("div",{className:"flex-container flex-end"},C.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(X.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))},Xe=re("ErOA"),Ge=re("7Cbv"),Fe="link",Be="upload-image",ot="code-block",et="add-table",Ze="------------",rt={default:Ze,left:":".concat(Ze),center:":".concat(Ze,":"),right:"".concat(Ze,":")},ht=re("9VGf"),Qe,Je;function we(){}var lt=0,it=1e4,Ae="\u2581",Ne=`
|
|
**\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(pe){return/^\d+$/.test(pe)?"".concat(pe,"px"):pe}var de=navigator.platform.toUpperCase().indexOf("MAC")>=0,fe=de?"Cmd":"Ctrl",ee=["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"],te=(Qe={},Object(F.a)(Qe,fe+"-B","bold"),Object(F.a)(Qe,fe+"-I","italic"),Qe),ae=(Je={},Object(F.a)(Je,Fe,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Je,ot,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Je,Be,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Je,et,"\u6DFB\u52A0\u8868\u683C"),Je),ue=nt.a=function(pe){var Se=pe.defaultValue,Oe=Se===void 0?"":Se,qe=pe.onChange,pt=pe.width,dt=pt===void 0?"100%":pt,Lt=pe.height,Tt=Lt===void 0?400:Lt,ut=pe.miniToolbar,Bt=ut===void 0?!1:ut,Ct=pe.isFocus,_t=Ct===void 0?!1:Ct,Dt=pe.watch,mt=pe.insertTemp,or=pe.mode,Zt=or===void 0?"markdown":or,vt=pe.id,vr=vt===void 0?"markdown-editor-id":vt,sr=pe.showResizeBar,Kt=sr===void 0?!1:sr,Fr=pe.noStorage,ci=Fr===void 0?!1:Fr,qr=pe.showNullButton,Ft=qr===void 0?!1:qr,ct=pe.hidetoolBar,Gr=ct===void 0?!1:ct,ei=pe.fullScreen,yr=ei===void 0?!1:ei,Ot=pe.onBlur,Ur=pe.onCMBeforeChange,Vr=pe.onFullScreen,fi=pe.className,Ue=fi===void 0?"":fi,wt=pe.disablePaste,pi=wt===void 0?!1:wt,mi=pe.placeholder,gi=mi===void 0?"":mi,vi=pe.values,j=vi===void 0?"":vi,s=Object(b.useState)(null),c=Object(H.a)(s,2),R=c[0],Z=c[1],U=Object(b.useState)(Oe),he=Object(H.a)(U,2),Re=he[0],ze=he[1],ft=Object(b.useState)(Dt),Pe=Object(H.a)(ft,2),bt=Pe[0],Ut=Pe[1],Yt=Object(b.useState)(yr),Mr=Object(H.a)(Yt,2),br=Mr[0],xr=Mr[1],Xr=Object(b.useState)(""),Ri=Object(H.a)(Xr,2),lr=Ri[0],jr=Ri[1],oi=Object(b.useState)(0),si=Object(H.a)(oi,2),Ir=si[0],Oi=si[1],yi=Object(b.useState)(Tt),zi=Object(H.a)(yi,2),Ki=zi[0],Yr=zi[1],zr=Object(b.useState)(!1),bi=Object(H.a)(zr,2),dn=bi[0],xi=bi[1],qt=Object(b.useRef)(Object(Ge.a)()),jt=Object(b.useRef)(!1),pr=Object(b.useRef)(),Pt=Object(b.useRef)(),tr=Object(b.useRef)(),Gt=Object(b.useRef)(),ti=Object(b.useRef)(),ur=function(){var gt=Object(P.a)(O.a.mark(function At(){var xt,Rt;return O.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:return Vt.next=2,Object(Xe.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:qt.current}});case 2:Rt=Vt.sent,Rt!=null&&(xt=Rt.attachments)!==null&&xt!==void 0&&xt.length&&(console.log("cm:",R,Pt),Rt.attachments.map(function(It){It.content_type.indexOf("image")>-1?R.replaceSelection(".concat(It.content_type,")")):It.content_type.indexOf("video")>-1?R.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):It.content_type.indexOf("pdf")>-1?R.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):R.replaceSelection("[".concat(It.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,")"))}));case 4:case"end":return Vt.stop()}},At)}));return function(){return gt.apply(this,arguments)}}();Object(b.useEffect)(function(){ze(j),R==null||R.setValue(j)},[j]),Object(b.useEffect)(function(){Vr==null||Vr(br)},[br]),Object(b.useEffect)(function(){if(Pt.current){var gt=_.a.fromTextArea(Pt.current,{mode:Zt,lineNumbers:!Bt,lineWrapping:!0,value:Oe,autoCloseTags:!0,autoCloseBrackets:!0});_t&>.focus();function At(xt,Rt){if(pi){Rt.preventDefault();return}var Nt=Rt.clipboardData;if(Nt){var Vt=Nt.types.toString(),It=Nt.items;if(Vt==="Files"||Nt.types.indexOf("Files")>-1){if(Rt.preventDefault(),Zt=="stex")return;try{var nr,Lr=It[1];((nr=It[0])===null||nr===void 0?void 0:nr.kind)==="file"&&(Lr=It[0]);var Mt=Lr.getAsFile(),li=Mt.name.split(".").pop();ke(Mt,function(Wt){if(Wt.id){var _r,Er,Kr;(Mt==null||((_r=Mt.type)===null||_r===void 0)?void 0:_r.indexOf("image"))>-1?gt.replaceSelection(".concat(Wt.content_type,")")):(Mt==null||((Er=Mt.type)===null||Er===void 0)?void 0:Er.indexOf("video"))>-1?gt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Mt==null||((Kr=Mt.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?gt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Mt.type,'&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):ee.includes(li)?gt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})}catch(Wt){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return gt.on("paste",At),gt.on("dragleave",function(xt,Rt){tr.current.classList.remove("mouse-hover-md")}),gt.on("dragover",function(xt,Rt){tr.current.classList.add("mouse-hover-md")}),gt.on("drop",function(xt,Rt){tr.current.classList.add("mouse-hover-md");var Nt;if(Nt=Rt.dataTransfer.files,Nt.length>0){Rt.preventDefault(),Rt.stopPropagation();for(var Vt=function(Lr){var Mt=Nt[Lr],li=Mt.name.split(".").pop();ke(Mt,function(Wt){if(Wt.id){var _r,Er,Kr;(Mt==null||((_r=Mt.type)===null||_r===void 0)?void 0:_r.indexOf("image"))>-1?gt.replaceSelection(".concat(Wt.content_type,")")):(Mt==null||((Er=Mt.type)===null||Er===void 0)?void 0:Er.indexOf("video"))>-1?gt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Mt==null||((Kr=Mt.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?gt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Mt.type,'&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):ee.includes(li)?gt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})},It=0;It<Nt.length;It++)Vt(It)}}),Z(gt),function(){gt.off("paste",At)}}},[]);var Cr=Object(b.useCallback)(function(){if(tr.current)try{}catch(gt){console.log(gt,"---- to set md editor body height")}},[Ki,tr,br]);Object(b.useEffect)(function(){function gt(){var xt=new A.default(function(Rt){var Nt=Object(D.a)(Rt),Vt;try{for(Nt.s();!(Vt=Nt.n()).done;){var It=Vt.value;(It.target.offsetHeight>0||It.target.offsetWidth>0)&&(Cr(),R.setSize("100%","100%"),R.refresh())}}catch(nr){Nt.e(nr)}finally{Nt.f()}});return xt.observe(Pt.current.parentElement),xt}if(R){var At=gt();return function(){At.unobserve(Pt.current.parentElement)}}},[R,Cr]),Object(b.useEffect)(function(){if(R){for(var gt=[],At=function(){var It=Rt[xt];Nt=Object(H.a)(It,2);var nr=Nt[0],Lr=Nt[1],Mt=Object(F.a)({},nr,function(){Vi(Lr)});gt.push(Mt),R.addKeyMap(Mt)},xt=0,Rt=Object.entries(te);xt<Rt.length;xt++){var Nt;At()}return pr.current=setInterval(function(){jt.current&&ur()},4e3),function(){clearInterval(pr.current);var Vt=Object(D.a)(gt),It;try{for(Vt.s();!(It=Vt.n()).done;){var nr=It.value;R.removeKeyMap(nr)}}catch(Lr){Vt.e(Lr)}finally{Vt.f()}}}},[R]),Object(b.useEffect)(function(){yr!==br&&xr(yr)},[yr]),Object(ht.a)(function(){if(!ci&&Ir>0){var gt=new Date().getTime(),At=window.sessionStorage.getItem(vr);gt>=Ir+it&&(!At||At!==Re)&&(window.sessionStorage.setItem(vr,Re),xi(!0))}},it),Object(b.useEffect)(function(){Ut(Dt)},[R,Dt]),Object(b.useEffect)(function(){R&&(_t&&R.focus())},[R,_t]),Object(b.useEffect)(function(){if(bt&&R){var gt=R.getScrollerElement();function At(xt){var Rt=xt.target;if(ti.current){var Nt=Rt.scrollTop/Rt.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Nt}}return gt.addEventListener("scroll",At),function(){gt.removeEventListener("scroll",At)}}},[R,bt]),Object(b.useEffect)(function(){if(R&&Ur){function gt(At,xt){Ur(At,xt)}return R.on("beforeChange",gt),function(){R.off("beforeChange",gt)}}},[R,Ur]),Object(b.useEffect)(function(){if(R&&Ot){function gt(){Ot(R.getValue())}return R.on("blur",gt),function(){R.off("blur",gt)}}},[R,Ot]),Object(b.useEffect)(function(){if(R){function gt(At){var xt=At.getValue();ze(xt),Oi(new Date().getTime()),At.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),qe&&qe(xt)}return R.on("change",gt),function(){R.off("change",gt)}}},[R,qe]),Object(b.useEffect)(function(){R&&(Oe==null?(R.setValue(""),ze("")):Oe!==R.getValue()&&(R.setValue(Oe),ze(Oe),R.setCursor(R.lineCount(),0)))},[R,Oe]);var Vi=Object(b.useCallback)(function(gt){var At=R.getCursor(),xt=R.getSelection(),Rt=xt.split(`
|
|
`);switch(gt){case"bold":return R.replaceSelection("**"+xt+"**"),xt===""&&R.setCursor(At.line,At.ch+2),R.focus();case"italic":return R.replaceSelection("*"+xt+"*"),xt===""&&R.setCursor(At.line,At.ch+1),R.focus();case"code":return R.replaceSelection("`"+xt+"`"),xt===""&&R.setCursor(At.line,At.ch+1),R.focus();case"inline-latex":return R.replaceSelection("`$$"+xt+"$$`"),xt===""&&R.setCursor(At.line,At.ch+3),R.focus();case"latex":return R.replaceSelection("```latex\n"+xt+"\n```"),R.setCursor(At.line+1,xt.length+1),R.focus();case"line-break":return R.replaceSelection(`<br/>
|
|
`),R.focus();case"list-ul":return xt===""?R.replaceSelection("- "+xt):R.replaceSelection(Rt.map(function(Nt){return Nt===""?"":"- ".concat(Nt)}).join(`
|
|
`)),R.focus();case"list-ol":return xt===""?R.replaceSelection("1. "+xt):R.replaceSelection(Rt.map(function(Nt,Vt){return Nt===""?"":"".concat(Vt+1,". ").concat(Nt)}).join(`
|
|
`)),R.focus();case"add-null-ch":return xt===""&&R.setCursor(At.line,At.ch+1),R.replaceSelection(Ae),R.focus();case"inster-template-1":return xt===""&&R.setCursor(At.line,At.ch),R.replaceSelection(Ne),R.focus();case"eraser":return R.setValue(""),R.focus();case"trigger-watch":return Ut(!bt),R.focus();case"trigger-full-screen":return xr(!br),R.focus();case Fe:jr(Fe);return;case ot:jr(ot);return;case Be:jr(Be);return;case et:jr(et);return;default:throw new Error}},[R,bt,br]),Ei=Object(b.useCallback)(function(gt){jr("");switch(lr){case Fe:var At=gt.title,xt=gt.link;return R.replaceSelection("[".concat(At,"](").concat(xt,")")),R.focus();case ot:var Rt=gt.language,Nt=gt.content;return R.replaceSelection(["```"+Rt,Nt,"```"].join(`
|
|
`)),R.focus();case Be:var Vt=gt.src,It=gt.alt;return It?R.replaceSelection(".concat(Vt,' "').concat(It,'" )')):R.replaceSelection("")),R.focus();case et:for(var nr=gt.row,Lr=gt.col,Mt=gt.align,li=`
|
|
`,Wt=0;Wt<nr;Wt++){for(var _r=[],Er=[],Kr=0;Kr<Lr;Kr++)Wt===1&&Er.push(rt[Mt]),_r.push(" ");Wt===1&&(li+="| ".concat(Er.join(" | "),` |
|
|
`)),li+="| ".concat(_r.join(Lr===1?"":" | "),` |
|
|
`)}return R.replaceSelection(li+`
|
|
`),R.focus();default:throw new Error}},[R,lr]),cn=Object(b.useMemo)(function(){switch(lr){case Fe:return C.a.createElement(ce,{callback:Ei,onCancel:Si});case ot:return C.a.createElement(ve.b,{callback:Ei,onCancel:Si});case Be:return C.a.createElement(ge,{callback:Ei,onCancel:Si});case et:return C.a.createElement(We,{callback:Ei,onCancel:Si});default:return null}},[lr]);function Si(){jr("")}Object(b.useEffect)(function(){if(Gt.current){var gt=Gt.current,At=!1,xt=0;function Rt(It){At=!0,xt=It.pageY}function Nt(){At=!1}function Vt(It){if(At){var nr=It.pageY-xt;nr<0&&(nr=0),nr>300&&(nr=300);var Lr=Tt+nr+"px";Yr(Lr)}}return gt.addEventListener("mousedown",Rt),document.addEventListener("mousemove",Vt),document.addEventListener("mouseup",Nt),function(){gt.removeEventListener("mousedown",Rt),document.removeEventListener("mousemove",Vt),document.removeEventListener("mouseup",Nt)}}},[R,Gt]),Object(b.useEffect)(function(){Yr(Tt)},[Tt]);var ri=me(dt),fn=me(Ki),$r={width:ri,height:fn},pn=Object(b.useMemo)(function(){if(Ir){var gt=new Date(Ir),At=gt.getHours(),xt=gt.getMinutes(),Rt=gt.getSeconds();return At=At<10?"0"+At:At,xt=xt<10?"0"+xt:xt,Rt=Rt<10?"0"+Rt:Rt,"".concat(At,":").concat(xt,":").concat(Rt)}return 0},[Ir]);function jn(){window.sessionStorage.removeItem(vr),xi(!1),Oi(0)}function Pi(){xi(!1),Oi(0),R.setValue(window.sessionStorage.getItem(vr))}function ua(gt,At){var xt=R.getValue();xt=xt.replace(gt,At),ze(xt),R==null||R.setValue(xt)}return C.a.createElement(b.Fragment,null,C.a.createElement("div",{className:"markdown-editor-wrapper",ref:tr},C.a.createElement("div",{className:"markdown-editor-container ".concat(Ue," ").concat(bt?"on-preview":""," ").concat(Bt?"mini":""," ").concat(br?"full-screen":""),style:$r},C.a.createElement(T,{insertTemp:mt,watch:bt,fullScreen:br,showNullButton:Ft,onActionCallback:Vi,hidetoolBar:Gr,uuid:qt.current,setOpenPhones:function(){jt.current=!0}}),C.a.createElement("div",{className:"markdown-editor-body"},C.a.createElement("div",{className:"codemirror-container"},C.a.createElement("textarea",{ref:Pt,placeholder:gi})),bt?C.a.createElement("div",{ref:ti,className:"preview-container"},Zt==="stex"&&C.a.createElement(L,{value:Re}),Zt!=="stex"&&C.a.createElement(m.a,{edit:!0,value:Re,replaces:ua})):null))),Kt?C.a.createElement("a",{ref:Gt,className:"editor-resize"}):null,C.a.createElement(I.a,null,ae[lr]?C.a.createElement($.a,{centered:!0,title:ae[lr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(Et,nt){/**
|
|
* @license
|
|
* Copyright (C) 2006 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/var re,ie,$,D=!1,V,N;window.PR_SHOULD_USE_CONTINUATION=!0;var P,H;(function(){var F=window,M=["break,continue,do,else,for,if,return,while"],O=[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"],b=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],C=[b,"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"],k=[b,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],_=[b,"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",y=[b,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",a=[M,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[M,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],h=[M,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],w=[C,_,k,y,u,a,l,h],g=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,m="str",L="kwd",x="com",f="typ",p="lit",d="pun",o="pln",E="tag",v="dec",T="src",I="atn",G="atv",X="nocode",J="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(Le){for(var Me=0,We=!1,Xe=!1,Ge=0,Fe=Le.length;Ge<Fe;++Ge){var Be=Le[Ge];if(Be.ignoreCase)Xe=!0;else if(/[a-z]/i.test(Be.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){We=!0,Xe=!1;break}}var ot={b:8,t:9,n:10,v:11,f:12,r:13};function et(Je){var we=Je.charCodeAt(0);if(we!==92)return we;var lt=Je.charAt(1);return we=ot[lt],we||("0"<=lt&<<="7"?parseInt(Je.substring(1),8):lt==="u"||lt==="x"?parseInt(Je.substring(2),16):Je.charCodeAt(1))}function Ze(Je){if(Je<32)return(Je<16?"\\x0":"\\x")+Je.toString(16);var we=String.fromCharCode(Je);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function rt(Je){var we=Je.substring(1,Je.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")),lt=[],it=we[0]==="^",Ae=["["];it&&Ae.push("^");for(var Ne=it?1:0,me=we.length;Ne<me;++Ne){var de=we[Ne];if(/\\[bdsw]/i.test(de))Ae.push(de);else{var fe=et(de),ee;Ne+2<me&&we[Ne+1]==="-"?(ee=et(we[Ne+2]),Ne+=2):ee=fe,lt.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||lt.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||lt.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}lt.sort(function(pe,Se){return pe[0]-Se[0]||Se[1]-pe[1]});for(var te=[],ae=[],Ne=0;Ne<lt.length;++Ne){var ue=lt[Ne];ue[0]<=ae[1]+1?ae[1]=Math.max(ae[1],ue[1]):te.push(ae=ue)}for(var Ne=0;Ne<te.length;++Ne){var ue=te[Ne];Ae.push(Ze(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Ae.push("-"),Ae.push(Ze(ue[1])))}return Ae.push("]"),Ae.join("")}function ht(Je){for(var we=Je.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")),lt=we.length,it=[],Ae=0,Ne=0;Ae<lt;++Ae){var me=we[Ae];if(me==="(")++Ne;else if(me.charAt(0)==="\\"){var de=+me.substring(1);de&&(de<=Ne?it[de]=-1:we[Ae]=Ze(de))}}for(var Ae=1;Ae<it.length;++Ae)it[Ae]===-1&&(it[Ae]=++Me);for(var Ae=0,Ne=0;Ae<lt;++Ae){var me=we[Ae];if(me==="(")++Ne,it[Ne]||(we[Ae]="(?:");else if(me.charAt(0)==="\\"){var de=+me.substring(1);de&&de<=Ne&&(we[Ae]="\\"+it[de])}}for(var Ae=0;Ae<lt;++Ae)we[Ae]==="^"&&we[Ae+1]!=="^"&&(we[Ae]="");if(Je.ignoreCase&&We)for(var Ae=0;Ae<lt;++Ae){var me=we[Ae],fe=me.charAt(0);me.length>=2&&fe==="["?we[Ae]=rt(me):fe!=="\\"&&(we[Ae]=me.replace(/[a-zA-Z]/g,function(ae){var ue=ae.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return we.join("")}for(var Qe=[],Ge=0,Fe=Le.length;Ge<Fe;++Ge){var Be=Le[Ge];if(Be.global||Be.multiline)throw new Error(""+Be);Qe.push("(?:"+ht(Be)+")")}return new RegExp(Qe.join("|"),Xe?"gi":"g")}function W(Le,Me){var We=/(?:^|\s)nocode(?:\s|$)/,Xe=[],Ge=0,Fe=[],Be=0;function ot(et){var Ze=et.nodeType;if(Ze==1){if(We.test(et.className))return;for(var rt=et.firstChild;rt;rt=rt.nextSibling)ot(rt);var ht=et.nodeName.toLowerCase();(ht==="br"||ht==="li")&&(Xe[Be]=`
|
|
`,Fe[Be<<1]=Ge++,Fe[Be++<<1|1]=et)}else if(Ze==3||Ze==4){var Qe=et.nodeValue;Qe.length&&(Me?Qe=Qe.replace(/\r\n?/g,`
|
|
`):Qe=Qe.replace(/[ \t\r\n]+/g," "),Xe[Be]=Qe,Fe[Be<<1]=Ge,Ge+=Qe.length,Fe[Be++<<1|1]=et)}}return ot(Le),{sourceCode:Xe.join("").replace(/\n$/,""),spans:Fe}}function q(Le,Me,We,Xe,Ge){if(!We)return;var Fe={sourceNode:Le,pre:1,langExtension:null,numberLines:null,sourceCode:We,spans:null,basePos:Me,decorations:null};Xe(Fe),Ge.push.apply(Ge,Fe.decorations)}var ne=/\S/;function ce(Le){for(var Me=void 0,We=Le.firstChild;We;We=We.nextSibling){var Xe=We.nodeType;Me=Xe===1?Me?Le:We:Xe===3&&ne.test(We.nodeValue)?Le:Me}return Me===Le?void 0:Me}function ve(Le,Me){var We={},Xe;(function(){for(var Be=Le.concat(Me),ot=[],et={},Ze=0,rt=Be.length;Ze<rt;++Ze){var ht=Be[Ze],Qe=ht[3];if(Qe)for(var Je=Qe.length;--Je>=0;)We[Qe.charAt(Je)]=ht;var we=ht[1],lt=""+we;et.hasOwnProperty(lt)||(ot.push(we),et[lt]=null)}ot.push(/[\0-\uffff]/),Xe=z(ot)})();var Ge=Me.length,Fe=function(Be){for(var ot=Be.sourceCode,et=Be.basePos,Ze=Be.sourceNode,rt=[et,o],ht=0,Qe=ot.match(Xe)||[],Je={},we=0,lt=Qe.length;we<lt;++we){var it=Qe[we],Ae=Je[it],Ne=void 0,me;if(typeof Ae=="string")me=!1;else{var de=We[it.charAt(0)];if(de)Ne=it.match(de[1]),Ae=de[0];else{for(var fe=0;fe<Ge;++fe)if(de=Me[fe],Ne=it.match(de[1]),Ne){Ae=de[0];break}Ne||(Ae=o)}me=Ae.length>=5&&Ae.substring(0,5)==="lang-",me&&!(Ne&&typeof Ne[1]=="string")&&(me=!1,Ae=T),me||(Je[it]=Ae)}var ee=ht;if(ht+=it.length,!me)rt.push(et+ee,Ae);else{var te=Ne[1],ae=it.indexOf(te),ue=ae+te.length;Ne[2]&&(ue=it.length-Ne[2].length,ae=ue-te.length);var pe=Ae.substring(5);q(Ze,et+ee,it.substring(0,ae),Fe,rt),q(Ze,et+ee+ae,te,se(pe,te),rt),q(Ze,et+ee+ue,it.substring(ue),Fe,rt)}}Be.decorations=rt};return Fe}function De(Le){var Me=[],We=[];Le.tripleQuotedStrings?Me.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Le.multiLineStrings?Me.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Me.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Le.verbatimStrings&&We.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Xe=Le.hashComments;Xe&&(Le.cStyleComments?(Xe>1?Me.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),We.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([x,/^#[^\r\n]*/,null,"#"])),Le.cStyleComments&&(We.push([x,/^\/\/[^\r\n]*/,null]),We.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ge=Le.regexLiterals;if(Ge){var Fe=Ge>1?"":`
|
|
\r`,Be=Fe?".":"[\\S\\s]",ot="/(?=[^/*"+Fe+"])(?:[^/\\x5B\\x5C"+Fe+"]|\\x5C"+Be+"|\\x5B(?:[^\\x5C\\x5D"+Fe+"]|\\x5C"+Be+")*(?:\\x5D|$))+/";We.push(["lang-regex",RegExp("^"+J+"("+ot+")")])}var et=Le.types;et&&We.push([f,et]);var Ze=(""+Le.keywords).replace(/^ | $/g,"");Ze.length&&We.push([L,new RegExp("^(?:"+Ze.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([o,/^\s+/,null,` \r
|
|
\xA0`]);var rt="^.[^\\s\\w.$@'\"`/\\\\]*";return Le.regexLiterals&&(rt+="(?!s*/)"),We.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[o,/^[a-z_$][a-z_$@0-9]*/i,null],[p,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[o,/^\\[\s\S]?/,null],[d,new RegExp(rt),null]),ve(Me,We)}var xe=De({keywords:w,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(Le,Me,We){for(var Xe=/(?:^|\s)nocode(?:\s|$)/,Ge=/\r\n?|\n/,Fe=Le.ownerDocument,Be=Fe.createElement("li");Le.firstChild;)Be.appendChild(Le.firstChild);var ot=[Be];function et(we){var lt=we.nodeType;if(lt==1&&!Xe.test(we.className))if(we.nodeName==="br")Ze(we),we.parentNode&&we.parentNode.removeChild(we);else for(var it=we.firstChild;it;it=it.nextSibling)et(it);else if((lt==3||lt==4)&&We){var Ae=we.nodeValue,Ne=Ae.match(Ge);if(Ne){var me=Ae.substring(0,Ne.index);we.nodeValue=me;var de=Ae.substring(Ne.index+Ne[0].length);if(de){var fe=we.parentNode;fe.insertBefore(Fe.createTextNode(de),we.nextSibling)}Ze(we),me||we.parentNode.removeChild(we)}}}function Ze(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function lt(Ne,me){var de=me?Ne.cloneNode(!1):Ne,fe=Ne.parentNode;if(fe){var ee=lt(fe,1),te=Ne.nextSibling;ee.appendChild(de);for(var ae=te;ae;ae=te)te=ae.nextSibling,ee.appendChild(ae)}return de}for(var it=lt(we.nextSibling,0),Ae;(Ae=it.parentNode)&&Ae.nodeType===1;)it=Ae;ot.push(it)}for(var rt=0;rt<ot.length;++rt)et(ot[rt]);Me===(Me|0)&&ot[0].setAttribute("value",Me);var ht=Fe.createElement("ol");ht.className="linenums";for(var Qe=Math.max(0,Me-1|0)||0,rt=0,Je=ot.length;rt<Je;++rt)Be=ot[rt],Be.className="L"+(rt+Qe)%10,Be.firstChild||Be.appendChild(Fe.createTextNode("\xA0")),ht.appendChild(Be);Le.appendChild(ht)}function Te(Le){var Me=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Me=Me&&+Me[1]<=8;var We=/\n/g,Xe=Le.sourceCode,Ge=Xe.length,Fe=0,Be=Le.spans,ot=Be.length,et=0,Ze=Le.decorations,rt=Ze.length,ht=0;Ze[rt]=Ge;var Qe,Je;for(Je=Qe=0;Je<rt;)Ze[Je]!==Ze[Je+2]?(Ze[Qe++]=Ze[Je++],Ze[Qe++]=Ze[Je++]):Je+=2;for(rt=Qe,Je=Qe=0;Je<rt;){for(var we=Ze[Je],lt=Ze[Je+1],it=Je+2;it+2<=rt&&Ze[it+1]===lt;)it+=2;Ze[Qe++]=we,Ze[Qe++]=lt,Je=it}rt=Ze.length=Qe;var Ae=Le.sourceNode,Ne="";Ae&&(Ne=Ae.style.display,Ae.style.display="none");try{for(var me=null;et<ot;){var de=Be[et],fe=Be[et+2]||Ge,ee=Ze[ht+2]||Ge,it=Math.min(fe,ee),te=Be[et+1],ae;if(te.nodeType!==1&&(ae=Xe.substring(Fe,it))){Me&&(ae=ae.replace(We,"\r")),te.nodeValue=ae;var ue=te.ownerDocument,pe=ue.createElement("span");pe.className=Ze[ht+1];var Se=te.parentNode;Se.replaceChild(pe,te),pe.appendChild(te),Fe<fe&&(Be[et+1]=te=ue.createTextNode(Xe.substring(it,fe)),Se.insertBefore(te,pe.nextSibling))}Fe=it,Fe>=fe&&(et+=2),Fe>=ee&&(ht+=2)}}finally{Ae&&(Ae.style.display=Ne)}}var Ee={};function ge(Le,Me){for(var We=Me.length;--We>=0;){var Xe=Me[We];Ee.hasOwnProperty(Xe)?F.console&&console.warn("cannot override language handler %s",Xe):Ee[Xe]=Le}}function se(Le,Me){return Le&&Ee.hasOwnProperty(Le)||(Le=/^\s*</.test(Me)?"default-markup":"default-code"),Ee[Le]}ge(xe,["default-code"]),ge(ve([],[[o,/^[^<?]+/],[v,/^<!\w[^>]*(?:>|$)/],[x,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[d,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),ge(ve([[o,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[E,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[I,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[d,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),ge(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),ge(De({keywords:C,hashComments:!0,cStyleComments:!0,types:g}),["c","cc","cpp","cxx","cyc","m"]),ge(De({keywords:"null,true,false"}),["json"]),ge(De({keywords:_,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:g}),["cs"]),ge(De({keywords:k,cStyleComments:!0}),["java"]),ge(De({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ge(De({keywords:a,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ge(De({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ge(De({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ge(De({keywords:y,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ge(De({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ge(ve([],[[m,/^[\s\S]+/]]),["regex"]);function ke(Le){var Me=Le.langExtension;try{var We=W(Le.sourceNode,Le.pre),Xe=We.sourceCode;Le.sourceCode=Xe,Le.spans=We.spans,Le.basePos=0,se(Me,Xe)(Le),Te(Le)}catch(Ge){F.console&&console.log(Ge&&Ge.stack||Ge)}}function Ve(Le,Me,We){var Xe=We||!1,Ge=Me||null,Fe=document.createElement("div");Fe.innerHTML="<pre>"+Le+"</pre>",Fe=Fe.firstChild,Xe&&Ce(Fe,Xe,!0);var Be={langExtension:Ge,numberLines:Xe,sourceNode:Fe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return ke(Be),Fe.innerHTML}function He(Le,Me){var We=Me||document.body,Xe=We.ownerDocument||document;function Ge(de){return We.getElementsByTagName(de)}for(var Fe=[Ge("pre"),Ge("code"),Ge("xmp")],Be=[],ot=0;ot<Fe.length;++ot)for(var et=0,Ze=Fe[ot].length;et<Ze;++et)Be.push(Fe[ot][et]);Fe=null;var rt=Date;rt.now||(rt={now:function(){return+new Date}});var ht=0,Qe=/\blang(?:uage)?-([\w.]+)(?!\S)/,Je=/\bprettyprint\b/,we=/\bprettyprinted\b/,lt=/pre|xmp/i,it=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Ne={};function me(){for(var de=F.PR_SHOULD_USE_CONTINUATION?rt.now()+250:Infinity;ht<Be.length&&rt.now()<de;ht++){for(var fe=Be[ht],ee=Ne,te=fe;te=te.previousSibling;){var ae=te.nodeType,ue=(ae===7||ae===8)&&te.nodeValue;if(ue?!/^\??prettify\b/.test(ue):ae!==3||/\S/.test(te.nodeValue))break;if(ue){ee={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Dt,mt,or){ee[mt]=or});break}}var pe=fe.className;if((ee!==Ne||Je.test(pe))&&!we.test(pe)){for(var Se=!1,Oe=fe.parentNode;Oe;Oe=Oe.parentNode){var qe=Oe.tagName;if(Ae.test(qe)&&Oe.className&&Je.test(Oe.className)){Se=!0;break}}if(!Se){fe.className+=" prettyprinted";var pt=ee.lang;if(!pt){pt=pe.match(Qe);var dt;!pt&&(dt=ce(fe))&&it.test(dt.tagName)&&(pt=dt.className.match(Qe)),pt&&(pt=pt[1])}var Lt;if(lt.test(fe.tagName))Lt=1;else{var Tt=fe.currentStyle,ut=Xe.defaultView,Bt=Tt?Tt.whiteSpace:ut&&ut.getComputedStyle?ut.getComputedStyle(fe,null).getPropertyValue("white-space"):0;Lt=Bt&&Bt.substring(0,3)==="pre"}var Ct=ee.linenums;(Ct=Ct==="true"||+Ct)||(Ct=pe.match(/\blinenums\b(?::(\d+))?/),Ct=Ct?Ct[1]&&Ct[1].length?+Ct[1]:!0:!1),Ct&&Ce(fe,Ct,Lt);var _t={langExtension:pt,sourceNode:fe,numberLines:Ct,pre:Lt,sourceCode:null,basePos:null,spans:null,decorations:null};ke(_t)}}}ht<Be.length?F.setTimeout(me,250):typeof Le=="function"&&Le()}me()}var tt=F.PR={createSimpleLexer:ve,registerLangHandler:ge,sourceDecorator:De,PR_ATTRIB_NAME:I,PR_ATTRIB_VALUE:G,PR_COMMENT:x,PR_DECLARATION:v,PR_KEYWORD:L,PR_LITERAL:p,PR_NOCODE:X,PR_PLAIN:o,PR_PUNCTUATION:d,PR_SOURCE:T,PR_STRING:m,PR_TAG:E,PR_TYPE:f,prettyPrintOne:D?F.prettyPrintOne=Ve:P=Ve,prettyPrint:H=D?F.prettyPrint=He:H=He},Ke=F.define;typeof Ke=="function"&&Ke.amd&&Ke("google-code-prettify",[],function(){return tt})})()},UUDw:function(Et,nt,re){Et.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(Et,nt,re){"use strict";re.d(nt,"a",function(){return ie});var ie=function(D){var V=document.createElement("textarea");return V.value=D,V.value}},"VrN/":function(Et,nt,re){(function(ie,$){Et.exports=$()})(this,function(){"use strict";var ie=navigator.userAgent,$=navigator.platform,D=/gecko\/\d/i.test(ie),V=/MSIE \d/.test(ie),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ie),P=/Edge\/(\d+)/.exec(ie),H=V||N||P,F=H&&(V?document.documentMode||6:+(P||N)[1]),M=!P&&/WebKit\//.test(ie),O=M&&/Qt\/\d+\.\d+/.test(ie),b=!P&&/Chrome\//.test(ie),C=/Opera\//.test(ie),k=/Apple Computer/.test(navigator.vendor),_=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ie),A=/PhantomJS/.test(ie),y=!P&&/AppleWebKit/.test(ie)&&/Mobile\/\w+/.test(ie),u=/Android/.test(ie),a=y||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ie),l=y||/Mac/.test($),h=/\bCrOS\b/.test(ie),w=/win/i.test($),g=C&&ie.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(C=!1,M=!0);var m=l&&(O||C&&(g==null||g<12.11)),L=D||H&&F>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var i=e.className,r=x(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return p(e).appendChild(t)}function o(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var S=0;S<t.length;++S)n.appendChild(t[S]);return n}function E(e,t,i,r){var n=o(e,t,i,r);return n.setAttribute("role","presentation"),n}var v;document.createRange?v=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:v=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function T(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 I(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;x(t).test(i)||(e.className+=(i?" ":"")+t)}function X(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!x(i[r]).test(t)&&(t+=" "+i[r]);return t}var J=function(e){e.select()};y?J=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:H&&(J=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function W(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function q(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var S=r||0,B=n||0;;){var K=e.indexOf(" ",S);if(K<0||K>=t)return B+(t-S);B+=K-S,B+=i-B%i,S=K+1}}var ne=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ne.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ne.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ce(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ve=50,De={toString:function(){return"CodeMirror.Pass"}},xe={scroll:!1},Ce={origin:"*mouse"},Te={origin:"+move"};function Ee(e,t,i){for(var r=0,n=0;;){var S=e.indexOf(" ",r);S==-1&&(S=e.length);var B=S-r;if(S==e.length||n+B>=t)return r+Math.min(B,t-n);if(n+=S-r,n+=i-n%i,r=S+1,n>=t)return r}}var ge=[""];function se(e){for(;ge.length<=e;)ge.push(ke(ge)+" ");return ge[e]}function ke(e){return e[e.length-1]}function Ve(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function He(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function tt(){}function Ke(e,t){var i;return Object.create?i=Object.create(e):(tt.prototype=e,i=new tt),t&&W(t,i),i}var Le=/[\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()||Le.test(e))}function We(e,t){return t?t.source.indexOf("\\w")>-1&&Me(e)?!0:t.test(e):Me(e)}function Xe(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Ge=/[\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 Fe(e){return e.charCodeAt(0)>=768&&Ge.test(e)}function Be(e,t,i){for(;(i<0?t>0:t<e.length)&&Fe(e.charAt(t));)t+=i;return t}function ot(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,S=r<0?Math.ceil(n):Math.floor(n);if(S==t)return e(S)?t:i;e(S)?i=S:t=S+r}}function et(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,S=0;S<e.length;++S){var B=e[S];(B.from<i&&B.to>t||t==i&&B.to==t)&&(r(Math.max(B.from,t),Math.min(B.to,i),B.level==1?"rtl":"ltr",S),n=!0)}n||r(t,i,"ltr")}var Ze=null;function rt(e,t,i){var r;Ze=null;for(var n=0;n<e.length;++n){var S=e[n];if(S.from<t&&S.to>t)return n;S.to==t&&(S.from!=S.to&&i=="before"?r=n:Ze=n),S.from==t&&(S.from!=S.to&&i!="before"?r=n:Ze=n)}return r!=null?r:Ze}var ht=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(Q){return Q<=247?e.charAt(Q):1424<=Q&&Q<=1524?"R":1536<=Q&&Q<=1785?t.charAt(Q-1536):1774<=Q&&Q<=2220?"r":8192<=Q&&Q<=8203?"w":Q==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,S=/[LRr]/,B=/[Lb1n]/,K=/[1n]/;function Y(Q,oe,le){this.level=Q,this.from=oe,this.to=le}return function(Q,oe){var le=oe=="ltr"?"L":"R";if(Q.length==0||oe=="ltr"&&!r.test(Q))return!1;for(var be=Q.length,ye=[],_e=0;_e<be;++_e)ye.push(i(Q.charCodeAt(_e)));for(var Ie=0,je=le;Ie<be;++Ie){var Ye=ye[Ie];Ye=="m"?ye[Ie]=je:je=Ye}for(var at=0,$e=le;at<be;++at){var st=ye[at];st=="1"&&$e=="r"?ye[at]="n":S.test(st)&&($e=st,st=="r"&&(ye[at]="R"))}for(var St=1,yt=ye[0];St<be-1;++St){var kt=ye[St];kt=="+"&&yt=="1"&&ye[St+1]=="1"?ye[St]="1":kt==","&&yt==ye[St+1]&&(yt=="1"||yt=="n")&&(ye[St]=yt),yt=kt}for(var Xt=0;Xt<be;++Xt){var cr=ye[Xt];if(cr==",")ye[Xt]="N";else if(cr=="%"){var Qt=void 0;for(Qt=Xt+1;Qt<be&&ye[Qt]=="%";++Qt);for(var Br=Xt&&ye[Xt-1]=="!"||Qt<be&&ye[Qt]=="1"?"1":"N",Rr=Xt;Rr<Qt;++Rr)ye[Rr]=Br;Xt=Qt-1}}for(var rr=0,Or=le;rr<be;++rr){var gr=ye[rr];Or=="L"&&gr=="1"?ye[rr]="L":S.test(gr)&&(Or=gr)}for(var ar=0;ar<be;++ar)if(n.test(ye[ar])){var ir=void 0;for(ir=ar+1;ir<be&&n.test(ye[ir]);++ir);for(var Jt=(ar?ye[ar-1]:le)=="L",Pr=(ir<be?ye[ir]:le)=="L",un=Jt==Pr?Jt?"L":"R":le,ki=ar;ki<ir;++ki)ye[ki]=un;ar=ir-1}for(var Tr=[],ai,fr=0;fr<be;)if(B.test(ye[fr])){var Va=fr;for(++fr;fr<be&&B.test(ye[fr]);++fr);Tr.push(new Y(0,Va,fr))}else{var di=fr,Hi=Tr.length,Gi=oe=="rtl"?1:0;for(++fr;fr<be&&ye[fr]!="L";++fr);for(var Ar=di;Ar<fr;)if(K.test(ye[Ar])){di<Ar&&(Tr.splice(Hi,0,new Y(1,di,Ar)),Hi+=Gi);var hn=Ar;for(++Ar;Ar<fr&&K.test(ye[Ar]);++Ar);Tr.splice(Hi,0,new Y(2,hn,Ar)),Hi+=Gi,di=Ar}else++Ar;di<fr&&Tr.splice(Hi,0,new Y(1,di,fr))}return oe=="ltr"&&(Tr[0].level==1&&(ai=Q.match(/^\s+/))&&(Tr[0].from=ai[0].length,Tr.unshift(new Y(0,0,ai[0].length))),ke(Tr).level==1&&(ai=Q.match(/\s+$/))&&(ke(Tr).to-=ai[0].length,Tr.push(new Y(0,be-ai[0].length,be)))),oe=="rtl"?Tr.reverse():Tr}}();function Qe(e,t){var i=e.order;return i==null&&(i=e.order=ht(e.text,t)),i}var Je=[],we=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Je).concat(i)}};function lt(e,t){return e._handlers&&e._handlers[t]||Je}function it(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var S=ce(n,i);S>-1&&(r[t]=n.slice(0,S).concat(n.slice(S+1)))}}}function Ae(e,t){var i=lt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function Ne(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,i||t.type,e,t),ae(t)||t.codemirrorIgnore}function me(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ce(i,t[r])==-1&&i.push(t[r])}function de(e,t){return lt(e,t).length>0}function fe(e){e.prototype.on=function(t,i){we(this,t,i)},e.prototype.off=function(t,i){it(this,t,i)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ae(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){ee(e),te(e)}function pe(e){return e.target||e.srcElement}function Se(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 Oe=function(){if(H&&F<9)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),qe;function pt(e){if(qe==null){var t=o("span","\u200B");d(e,o("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(qe=t.offsetWidth<=1&&t.offsetHeight>2&&!(H&&F<8))}var i=qe?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var dt;function Lt(e){if(dt!=null)return dt;var t=d(e,document.createTextNode("A\u062EA")),i=v(t,0,1).getBoundingClientRect(),r=v(t,1,2).getBoundingClientRect();return p(e),!i||i.left==i.right?!1:dt=r.right-i.right<3}var Tt=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
|
|
`,t);n==-1&&(n=e.length);var S=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),B=S.indexOf("\r");B!=-1?(i.push(S.slice(0,B)),t+=B+1):(i.push(S),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},ut=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Bt=function(){var e=o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ct=null;function _t(e){if(Ct!=null)return Ct;var t=d(e,o("span","x")),i=t.getBoundingClientRect(),r=v(t,0,1).getBoundingClientRect();return Ct=Math.abs(i.left-r.left)>1}var Dt={},mt={};function or(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Dt[e]=t}function Zt(e,t){mt[e]=t}function vt(e){if(typeof e=="string"&&mt.hasOwnProperty(e))e=mt[e];else if(e&&typeof e.name=="string"&&mt.hasOwnProperty(e.name)){var t=mt[e.name];typeof t=="string"&&(t={name:t}),e=Ke(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return vt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return vt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function vr(e,t){t=vt(t);var i=Dt[t.name];if(!i)return vr(e,"text/plain");var r=i(e,t);if(sr.hasOwnProperty(t.name)){var n=sr[t.name];for(var S in n){if(!n.hasOwnProperty(S))continue;r.hasOwnProperty(S)&&(r["_"+S]=r[S]),r[S]=n[S]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var B in t.modeProps)r[B]=t.modeProps[B];return r}var sr={};function Kt(e,t){var i=sr.hasOwnProperty(e)?sr[e]:sr[e]={};W(t,i)}function Fr(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function ci(e,t){for(var i;e.innerMode&&!(i=e.innerMode(t),!i||i.mode==e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function qr(e,t,i){return e.startState?e.startState(t,i):!0}var Ft=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};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),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)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=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Ft.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Ft.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(B){return i?B.toLowerCase():B},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var S=this.string.slice(this.pos).match(e);return S&&S.index>0?null:(S&&t!==!1&&(this.pos+=S[0].length),S)}},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 ct(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],S=n.chunkSize();if(t<S){i=n;break}t-=S}return i.lines[t]}function Gr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(S){var B=S.text;n==i.line&&(B=B.slice(0,i.ch)),n==t.line&&(B=B.slice(t.ch)),r.push(B),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function yr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Ot(e){if(e.parent==null)return null;for(var t=e.parent,i=ce(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function Ur(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],S=n.height;if(t<S){e=n;continue e}t-=S,i+=n.chunkSize()}return i}while(!e.lines);for(var B=0;B<e.lines.length;++B){var K=e.lines[B],Y=K.height;if(t<Y)break;t-=Y}return i+B}function Vr(e,t){return t>=e.first&&t<e.first+e.size}function fi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ue(e,t,i){if(i===void 0&&(i=null),!(this instanceof Ue))return new Ue(e,t,i);this.line=e,this.ch=t,this.sticky=i}function wt(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&wt(e,t)==0}function mi(e){return Ue(e.line,e.ch)}function gi(e,t){return wt(e,t)<0?t:e}function vi(e,t){return wt(e,t)<0?e:t}function j(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return Ue(e.first,0);var i=e.first+e.size-1;return t.line>i?Ue(i,ct(e,i).text.length):c(t,ct(e,t.line).text.length)}function c(e,t){var i=e.ch;return i==null||i>t?Ue(e.line,t):i<0?Ue(e.line,0):e}function R(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Z=function(e,t){this.state=e,this.lookAhead=t},U=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};U.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},U.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}},U.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},U.fromSaved=function(e,t,i){return t instanceof Z?new U(e,Fr(e.mode,t.state),i,t.lookAhead):new U(e,Fr(e.mode,t),i)},U.prototype.save=function(e){var t=e!==!1?Fr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Z(t,this.maxLookAhead):t};function he(e,t,i,r){var n=[e.state.modeGen],S={};br(e,t.text,e.doc.mode,i,function(Q,oe){return n.push(Q,oe)},S,r);for(var B=i.state,K=function(Q){i.baseTokens=n;var oe=e.state.overlays[Q],le=1,be=0;i.state=!0,br(e,t.text,oe.mode,i,function(ye,_e){for(var Ie=le;be<ye;){var je=n[le];je>ye&&n.splice(le,1,ye,n[le+1],je),le+=2,be=Math.min(ye,je)}if(!_e)return;if(oe.opaque)n.splice(Ie,le-Ie,ye,"overlay "+_e),le=Ie+2;else for(;Ie<le;Ie+=2){var Ye=n[Ie+1];n[Ie+1]=(Ye?Ye+" ":"")+"overlay "+_e}},S),i.state=B,i.baseTokens=null,i.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:n,classes:S.bgClass||S.textClass?S:null}}function Re(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=ze(e,Ot(t)),n=t.text.length>e.options.maxHighlightLength&&Fr(e.doc.mode,r.state),S=he(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=S.styles,S.classes?t.styleClasses=S.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function ze(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new U(r,!0,t);var S=xr(e,t,i),B=S>r.first&&ct(r,S-1).stateAfter,K=B?U.fromSaved(r,B,S):new U(r,qr(r.mode),S);return r.iter(S,t,function(Y){ft(e,Y.text,K);var Q=K.line;Y.stateAfter=Q==t-1||Q%5==0||Q>=n.viewFrom&&Q<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function ft(e,t,i,r){var n=e.doc.mode,S=new Ft(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&Pe(n,i.state);!S.eol();)bt(n,S,i.state),S.start=S.pos}function Pe(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function bt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var S=e.token(t,i);if(t.pos>t.start)return S}throw new Error("Mode "+e.name+" failed to advance stream.")}var Ut=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Yt(e,t,i,r){var n=e.doc,S=n.mode,B;t=s(n,t);var K=ct(n,t.line),Y=ze(e,t.line,i),Q=new Ft(K.text,e.options.tabSize,Y),oe;for(r&&(oe=[]);(r||Q.pos<t.ch)&&!Q.eol();)Q.start=Q.pos,B=bt(S,Q,Y.state),r&&oe.push(new Ut(Q,B,Fr(n.mode,Y.state)));return r?oe:new Ut(Q,B,Y.state)}function Mr(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function br(e,t,i,r,n,S,B){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,Q=null,oe=new Ft(t,e.options.tabSize,r),le,be=e.options.addModeClass&&[null];for(t==""&&Mr(Pe(i,r.state),S);!oe.eol();){if(oe.pos>e.options.maxHighlightLength?(K=!1,B&&ft(e,t,r,oe.pos),oe.pos=t.length,le=null):le=Mr(bt(i,oe,r.state,be),S),be){var ye=be[0].name;ye&&(le="m-"+(le?ye+" "+le:ye))}if(!K||Q!=le){for(;Y<oe.start;)Y=Math.min(oe.start,Y+5e3),n(Y,Q);Q=le}oe.start=oe.pos}for(;Y<oe.pos;){var _e=Math.min(oe.pos,Y+5e3);n(_e,Q),Y=_e}}function xr(e,t,i){for(var r,n,S=e.doc,B=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>B;--K){if(K<=S.first)return S.first;var Y=ct(S,K-1),Q=Y.stateAfter;if(Q&&(!i||K+(Q instanceof Z?Q.lookAhead:0)<=S.modeFrontier))return K;var oe=q(Y.text,null,e.options.tabSize);(n==null||r>oe)&&(n=K-1,r=oe)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=ct(e,r).stateAfter;if(n&&(!(n instanceof Z)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Ri=!1,lr=!1;function jr(){Ri=!0}function oi(){lr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function Ir(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Oi(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function yi(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function zi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],B=S.marker,K=S.from==null||(B.inclusiveLeft?S.from<=t:S.from<t);if(K||S.from==t&&B.type=="bookmark"&&(!i||!S.marker.insertLeft)){var Y=S.to==null||(B.inclusiveRight?S.to>=t:S.to>t);(r||(r=[])).push(new si(B,S.from,Y?null:S.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],B=S.marker,K=S.to==null||(B.inclusiveRight?S.to>=t:S.to>t);if(K||S.from==t&&B.type=="bookmark"&&(!i||S.marker.insertLeft)){var Y=S.from==null||(B.inclusiveLeft?S.from<=t:S.from<t);(r||(r=[])).push(new si(B,Y?null:S.from-t,S.to==null?null:S.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&ct(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&ct(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,S=t.to.ch,B=wt(t.from,t.to)==0,K=zi(i,n,B),Y=Ki(r,S,B),Q=t.text.length==1,oe=ke(t.text).length+(Q?n:0);if(K)for(var le=0;le<K.length;++le){var be=K[le];if(be.to==null){var ye=Ir(Y,be.marker);ye?Q&&(be.to=ye.to==null?null:ye.to+oe):be.to=n}}if(Y)for(var _e=0;_e<Y.length;++_e){var Ie=Y[_e];if(Ie.to!=null&&(Ie.to+=oe),Ie.from==null){var je=Ir(K,Ie.marker);je||(Ie.from=oe,Q&&(K||(K=[])).push(Ie))}else Ie.from+=oe,Q&&(K||(K=[])).push(Ie)}K&&(K=zr(K)),Y&&Y!=K&&(Y=zr(Y));var Ye=[K];if(!Q){var at=t.text.length-2,$e;if(at>0&&K)for(var st=0;st<K.length;++st)K[st].to==null&&($e||($e=[])).push(new si(K[st].marker,null,null));for(var St=0;St<at;++St)Ye.push($e);Ye.push(Y)}return Ye}function zr(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function bi(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ye){if(ye.markedSpans)for(var _e=0;_e<ye.markedSpans.length;++_e){var Ie=ye.markedSpans[_e].marker;Ie.readOnly&&(!r||ce(r,Ie)==-1)&&(r||(r=[])).push(Ie)}}),!r)return null;for(var n=[{from:t,to:i}],S=0;S<r.length;++S)for(var B=r[S],K=B.find(0),Y=0;Y<n.length;++Y){var Q=n[Y];if(wt(Q.to,K.from)<0||wt(Q.from,K.to)>0)continue;var oe=[Y,1],le=wt(Q.from,K.from),be=wt(Q.to,K.to);(le<0||!B.inclusiveLeft&&!le)&&oe.push({from:Q.from,to:K.from}),(be>0||!B.inclusiveRight&&!be)&&oe.push({from:K.to,to:Q.to}),n.splice.apply(n,oe),Y+=oe.length-3}return n}function dn(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function xi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function qt(e){return e.inclusiveLeft?-1:0}function jt(e){return e.inclusiveRight?1:0}function pr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),S=wt(r.from,n.from)||qt(e)-qt(t);if(S)return-S;var B=wt(r.to,n.to)||jt(e)-jt(t);return B||t.id-e.id}function Pt(e,t){var i=lr&&e.markedSpans,r;if(i)for(var n=void 0,S=0;S<i.length;++S)n=i[S],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||pr(r,n.marker)<0)&&(r=n.marker);return r}function tr(e){return Pt(e,!0)}function Gt(e){return Pt(e,!1)}function ti(e,t){var i=lr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var S=i[n];S.marker.collapsed&&(S.from==null||S.from<t)&&(S.to==null||S.to>t)&&(!r||pr(r,S.marker)<0)&&(r=S.marker)}return r}function ur(e,t,i,r,n){var S=ct(e,t),B=lr&&S.markedSpans;if(B)for(var K=0;K<B.length;++K){var Y=B[K];if(!Y.marker.collapsed)continue;var Q=Y.marker.find(0),oe=wt(Q.from,i)||qt(Y.marker)-qt(n),le=wt(Q.to,r)||jt(Y.marker)-jt(n);if(oe>=0&&le<=0||oe<=0&&le>=0)continue;if(oe<=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?wt(Q.to,i)>=0:wt(Q.to,i)>0)||oe>=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?wt(Q.from,r)<=0:wt(Q.from,r)<0))return!0}}function Cr(e){for(var t;t=tr(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Gt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=Gt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=ct(e,t),r=Cr(i);return i==r?t:Ot(r)}function Si(e,t){if(t>e.lastLine())return t;var i=ct(e,t),r;if(!ri(e,i))return t;for(;r=Gt(i);)i=r.find(1,!0).line;return Ot(i)+1}function ri(e,t){var i=lr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,Ir(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,S=0;S<t.markedSpans.length;++S)if(n=t.markedSpans[S],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function $r(e){e=Cr(e);for(var t=0,i=e.parent,r=0;r<i.lines.length;++r){var n=i.lines[r];if(n==e)break;t+=n.height}for(var S=i.parent;S;i=S,S=i.parent)for(var B=0;B<S.children.length;++B){var K=S.children[B];if(K==i)break;t+=K.height}return t}function pn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=tr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Gt(r);){var S=i.find(0,!0);t-=r.text.length-S.from.ch,r=S.to.line,t+=r.text.length-S.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=ct(i,i.first),t.maxLineLength=pn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=pn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Pi=function(e,t,i){this.text=e,xi(this,t),this.height=i?i(this):1};Pi.prototype.lineNo=function(){return Ot(this)},fe(Pi);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),dn(e),xi(e,i);var n=r?r(e):1;n!=e.height&&yr(e,n)}function gt(e){e.parent=null,dn(e)}var At={},xt={};function Rt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?xt:At;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Nt(e,t){var i=E("span",null,null,M?"padding-right: .1px":null),r={pre:E("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var S=n?t.rest[n-1]:t.line,B=void 0;r.pos=0,r.addToken=It,Lt(e.display.measure)&&(B=Qe(S,e.doc.direction))&&(r.addToken=Lr(r.addToken,B)),r.map=[];var K=t!=e.display.externalMeasured&&Ot(S);li(S,r,Re(e,S,K)),S.styleClasses&&(S.styleClasses.bgClass&&(r.bgClass=X(S.styleClasses.bgClass,r.bgClass||"")),S.styleClasses.textClass&&(r.textClass=X(S.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(pt(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(M){var Y=r.content.lastChild;(/\bcm-tab\b/.test(Y.className)||Y.querySelector&&Y.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=X(r.pre.className,r.textClass||"")),r}function Vt(e){var t=o("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function It(e,t,i,r,n,S,B){if(!t)return;var K=e.splitSpaces?nr(t,e.trailingSpace):t,Y=e.cm.state.specialChars,Q=!1,oe;if(!Y.test(t))e.col+=t.length,oe=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,oe),H&&F<9&&(Q=!0),e.pos+=t.length;else{oe=document.createDocumentFragment();for(var le=0;;){Y.lastIndex=le;var be=Y.exec(t),ye=be?be.index-le:t.length-le;if(ye){var _e=document.createTextNode(K.slice(le,le+ye));H&&F<9?oe.appendChild(o("span",[_e])):oe.appendChild(_e),e.map.push(e.pos,e.pos+ye,_e),e.col+=ye,e.pos+=ye}if(!be)break;le+=ye+1;var Ie=void 0;if(be[0]==" "){var je=e.cm.options.tabSize,Ye=je-e.col%je;Ie=oe.appendChild(o("span",se(Ye),"cm-tab")),Ie.setAttribute("role","presentation"),Ie.setAttribute("cm-text"," "),e.col+=Ye}else be[0]=="\r"||be[0]==`
|
|
`?(Ie=oe.appendChild(o("span",be[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ie.setAttribute("cm-text",be[0]),e.col+=1):(Ie=e.cm.options.specialCharPlaceholder(be[0]),Ie.setAttribute("cm-text",be[0]),H&&F<9?oe.appendChild(o("span",[Ie])):oe.appendChild(Ie),e.col+=1);e.map.push(e.pos,e.pos+1,Ie),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||Q||S||B){var at=i||"";r&&(at+=r),n&&(at+=n);var $e=o("span",[oe],at,S);if(B)for(var st in B)B.hasOwnProperty(st)&&st!="style"&&st!="class"&&$e.setAttribute(st,B[st]);return e.content.appendChild($e)}e.content.appendChild(oe)}function nr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var S=e.charAt(n);S==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(S="\xA0"),r+=S,i=S==" "}return r}function Lr(e,t){return function(i,r,n,S,B,K,Y){n=n?n+" cm-force-border":"cm-force-border";for(var Q=i.pos,oe=Q+r.length;;){for(var le=void 0,be=0;be<t.length&&!(le=t[be],le.to>Q&&le.from<=Q);be++);if(le.to>=oe)return e(i,r,n,S,B,K,Y);e(i,r.slice(0,le.to-Q),n,S,null,K,Y),S=null,r=r.slice(le.to-Q),Q=le.to}}}function Mt(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function li(e,t,i){var r=e.markedSpans,n=e.text,S=0;if(!r){for(var B=1;B<i.length;B+=2)t.addToken(t,n.slice(S,S=i[B]),Rt(i[B+1],t.cm.options));return}for(var K=n.length,Y=0,Q=1,oe="",le,be,ye=0,_e,Ie,je,Ye,at;;){if(ye==Y){_e=Ie=je=be="",at=null,Ye=null,ye=Infinity;for(var $e=[],st=void 0,St=0;St<r.length;++St){var yt=r[St],kt=yt.marker;if(kt.type=="bookmark"&&yt.from==Y&&kt.widgetNode)$e.push(kt);else if(yt.from<=Y&&(yt.to==null||yt.to>Y||kt.collapsed&&yt.to==Y&&yt.from==Y)){if(yt.to!=null&&yt.to!=Y&&ye>yt.to&&(ye=yt.to,Ie=""),kt.className&&(_e+=" "+kt.className),kt.css&&(be=(be?be+";":"")+kt.css),kt.startStyle&&yt.from==Y&&(je+=" "+kt.startStyle),kt.endStyle&&yt.to==ye&&(st||(st=[])).push(kt.endStyle,yt.to),kt.title&&((at||(at={})).title=kt.title),kt.attributes)for(var Xt in kt.attributes)(at||(at={}))[Xt]=kt.attributes[Xt];kt.collapsed&&(!Ye||pr(Ye.marker,kt)<0)&&(Ye=yt)}else yt.from>Y&&ye>yt.from&&(ye=yt.from)}if(st)for(var cr=0;cr<st.length;cr+=2)st[cr+1]==ye&&(Ie+=" "+st[cr]);if(!Ye||Ye.from==Y)for(var Qt=0;Qt<$e.length;++Qt)Mt(t,0,$e[Qt]);if(Ye&&(Ye.from||0)==Y){if(Mt(t,(Ye.to==null?K+1:Ye.to)-Y,Ye.marker,Ye.from==null),Ye.to==null)return;Ye.to==Y&&(Ye=!1)}}if(Y>=K)break;for(var Br=Math.min(K,ye);;){if(oe){var Rr=Y+oe.length;if(!Ye){var rr=Rr>Br?oe.slice(0,Br-Y):oe;t.addToken(t,rr,le?le+_e:_e,je,Y+rr.length==ye?Ie:"",be,at)}if(Rr>=Br){oe=oe.slice(Br-Y),Y=Br;break}Y=Rr,je=""}oe=n.slice(S,S=i[Q++]),le=Rt(i[Q++],t.cm.options)}}}function Wt(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?Ot(ke(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function _r(e,t,i){for(var r=[],n,S=t;S<i;S=n){var B=new Wt(e.doc,ct(e.doc,S),S);n=S+B.size,r.push(B)}return r}var Er=null;function Kr(e){Er?Er.ops.push(e):e.ownsGroup=Er={ops:[e],delayedCallbacks:[]}}function ks(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function Rs(e,t){var i=e.ownsGroup;if(!i)return;try{ks(i)}finally{Er=null,t(i)}}var mn=null;function mr(e,t){var i=lt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;Er?n=Er.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(Os,0));for(var S=function(K){n.push(function(){return i[K].apply(null,r)})},B=0;B<i.length;++B)S(B)}function Os(){var e=mn;mn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var S=t.changes[n];S=="text"?Ms(e,t):S=="gutter"?Za(e,t,i,r):S=="class"?ha(e,t):S=="widget"&&Is(e,t,r)}t.changes=null}function gn(e){return e.node==e.text&&(e.node=o("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),H&&F<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(o("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Nt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(e,t),t.line.wrapClass?gn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=gn(t);t.gutterBackground=o("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var S=t.line.gutterMarkers;if(e.options.lineNumbers||S){var B=gn(t),K=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(o("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),S)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Q=e.display.gutterSpecs[Y].className,oe=S.hasOwnProperty(Q)&&S[Q];oe&&K.appendChild(o("div",[oe],"CodeMirror-gutter-elt","left: "+r.gutterLeft[Q]+"px; width: "+r.gutterWidth[Q]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=x("CodeMirror-linewidget"),n=t.node.firstChild,S=void 0;n;n=S)S=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Qa(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ha(e,t),Za(e,t,i,r),Qa(e,t,r),t.node}function Qa(e,t,i){if(Ja(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Ja(e,t.rest[r],t,i,!1)}function Ja(e,t,i,r,n){if(!t.widgets)return;for(var S=gn(i),B=0,K=t.widgets;B<K.length;++B){var Y=K[B],Q=o("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||Q.setAttribute("cm-ignore-events","true"),Bs(Y,Q,i,r),e.display.input.setUneditable(Q),n&&Y.above?S.insertBefore(Q,i.gutter||i.text):S.appendChild(Q),mr(Y,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function vn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!T(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),d(t.display.measure,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=pe(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Wn(e){return e.lineSpace.offsetTop}function da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,o("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return ve-e.display.nativeBarWidth}function Mi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var S=t.measure.heights=[];if(r){t.measure.width=n;for(var B=t.text.firstChild.getClientRects(),K=0;K<B.length-1;K++){var Y=B[K],Q=B[K+1];Math.abs(Y.bottom-Q.bottom)>2&&S.push((Y.bottom+Q.top)/2-i.top)}}S.push(i.bottom-i.top)}}function eo(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(Ot(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=Cr(t);var i=Ot(t),r=e.display.externalMeasured=new Wt(e.doc,t,i);r.lineN=i;var n=r.built=Nt(e,r);return r.text=n.pre,d(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return ni(e,Xi(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Bi(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=Ot(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ni(e,t,i,r,n){t.before&&(i=-1);var S=i+(r||""),B;return t.cache.hasOwnProperty(S)?B=t.cache[S]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),B=Ws(e,t,i,r),B.bogus||(t.cache[S]=B)),{left:B.left,right:B.right,top:n?B.rtop:B.top,bottom:n?B.rbottom:B.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,S,B,K,Y,Q=0;Q<e.length;Q+=3)if(K=e[Q],Y=e[Q+1],t<K?(n=0,S=1,B="left"):t<Y?(n=t-K,S=n+1):(Q==e.length-3||t==Y&&e[Q+3]>t)&&(S=Y-K,n=S-1,t>=Y&&(B="right")),n!=null){if(r=e[Q+2],K==Y&&i==(r.insertLeft?"left":"right")&&(B=i),i=="left"&&n==0)for(;Q&&e[Q-2]==e[Q-3]&&e[Q-1].insertLeft;)r=e[(Q-=3)+2],B="left";if(i=="right"&&n==Y-K)for(;Q<e.length-3&&e[Q+3]==e[Q+4]&&!e[Q+5].insertLeft;)r=e[(Q+=3)+2],B="right";break}return{node:r,start:n,end:S,collapse:B,coverStart:K,coverEnd:Y}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),S=n.node,B=n.start,K=n.end,Y=n.collapse,Q;if(S.nodeType==3){for(var oe=0;oe<4;oe++){for(;B&&Fe(t.line.text.charAt(n.coverStart+B));)--B;for(;n.coverStart+K<n.coverEnd&&Fe(t.line.text.charAt(n.coverStart+K));)++K;if(H&&F<9&&B==0&&K==n.coverEnd-n.coverStart?Q=S.parentNode.getBoundingClientRect():Q=js(v(S,B,K).getClientRects(),r),Q.left||Q.right||B==0)break;K=B,B=B-1,Y="right"}H&&F<11&&(Q=Hs(e.display.measure,Q))}else{B>0&&(Y=r="right");var le;e.options.lineWrapping&&(le=S.getClientRects()).length>1?Q=le[r=="right"?le.length-1:0]:Q=S.getBoundingClientRect()}if(H&&F<9&&!B&&(!Q||!Q.left&&!Q.right)){var be=S.parentNode.getClientRects()[0];be?Q={left:be.left,right:be.left+$i(e.display),top:be.top,bottom:be.bottom}:Q=ro}for(var ye=Q.top-t.rect.top,_e=Q.bottom-t.rect.top,Ie=(ye+_e)/2,je=t.view.measure.heights,Ye=0;Ye<je.length-1&&!(Ie<je[Ye]);Ye++);var at=Ye?je[Ye-1]:0,$e=je[Ye],st={left:(Y=="right"?Q.right:Q.left)-t.rect.left,right:(Y=="left"?Q.left:Q.right)-t.rect.left,top:at,bottom:$e};return!Q.left&&!Q.right&&(st.bogus=!0),e.options.singleCursorHeightPerLine||(st.rtop=ye,st.rbottom=_e),st}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!_t(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,p(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function yn(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return b&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return b&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=vn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var S=pa(t);i.top+=S,i.bottom+=S}if(r=="line")return i;r||(r="local");var B=$r(t);if(r=="local"?B+=Wn(e.display):B-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();B+=K.top+(r=="window"?0:so());var Y=K.left+(r=="window"?0:oo());i.left+=Y,i.right+=Y}return i.top+=B,i.bottom+=B,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var S=e.display.sizer.getBoundingClientRect();r+=S.left,n+=S.top}var B=e.display.lineSpace.getBoundingClientRect();return{left:r-B.left,top:n-B.top}}function ma(e,t,i,r,n){return r||(r=ct(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,S){r=r||ct(e.doc,t.line),n||(n=Xi(e,r));function B(_e,Ie){var je=ni(e,n,_e,Ie?"right":"left",S);return Ie?je.left=je.right:je.right=je.left,Hn(e,r,je,i)}var K=Qe(r,e.doc.direction),Y=t.ch,Q=t.sticky;if(Y>=r.text.length?(Y=r.text.length,Q="before"):Y<=0&&(Y=0,Q="after"),!K)return B(Q=="before"?Y-1:Y,Q=="before");function oe(_e,Ie,je){var Ye=K[Ie],at=Ye.level==1;return B(je?_e-1:_e,at!=je)}var le=rt(K,Y,Q),be=Ze,ye=oe(Y,le,Q=="before");return be!=null&&(ye.other=oe(Y,be,Q!="before")),ye}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=ct(e.doc,t.line),n=$r(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var S=Ue(e,t,i);return S.xRel=n,r&&(S.outside=r),S}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=Ur(r,i),S=r.first+r.size-1;if(n>S)return ga(r.first+r.size-1,ct(r,S).text.length,null,1,1);t<0&&(t=0);for(var B=ct(r,n);;){var K=Gs(e,B,n,t,i),Y=ti(B,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var Q=Y.find(1);if(Q.line==n)return Q;B=ct(r,n=Q.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,S=ot(function(B){return ni(e,i,B-1).bottom<=r},n,0);return n=ot(function(B){return ni(e,i,B).top>r},S,n),{begin:S,end:n}}function co(e,t,i,r){i||(i=Xi(e,t));var n=Hn(e,t,ni(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=$r(t);var S=Xi(e,t),B=pa(t),K=0,Y=t.text.length,Q=!0,oe=Qe(t,e.doc.direction);if(oe){var le=(e.options.lineWrapping?Ks:zs)(e,t,i,S,oe,r,n);Q=le.level!=1,K=Q?le.from:le.to-1,Y=Q?le.to:le.from-1}var be=null,ye=null,_e=ot(function(St){var yt=ni(e,S,St);return yt.top+=B,yt.bottom+=B,ya(yt,r,n,!1)?(yt.top<=n&&yt.left<=r&&(be=St,ye=yt),!0):!1},K,Y),Ie,je,Ye=!1;if(ye){var at=r-ye.left<ye.right-r,$e=at==Q;_e=be+($e?0:1),je=$e?"after":"before",Ie=at?ye.left:ye.right}else{!Q&&(_e==Y||_e==K)&&_e++,je=_e==0?"after":_e==t.text.length?"before":ni(e,S,_e-(Q?1:0)).bottom+B<=n==Q?"after":"before";var st=Zr(e,Ue(i,_e,je),"line",t,S);Ie=st.left,Ye=n<st.top?-1:n>=st.bottom?1:0}return _e=Be(t.text,_e,1),ga(i,_e,je,Ye,r-Ie)}function zs(e,t,i,r,n,S,B){var K=ot(function(le){var be=n[le],ye=be.level!=1;return ya(Zr(e,Ue(i,ye?be.to:be.from,ye?"before":"after"),"line",t,r),S,B,!0)},0,n.length-1),Y=n[K];if(K>0){var Q=Y.level!=1,oe=Zr(e,Ue(i,Q?Y.from:Y.to,Q?"after":"before"),"line",t,r);ya(oe,S,B,!0)&&oe.top>B&&(Y=n[K-1])}return Y}function Ks(e,t,i,r,n,S,B){var K=ho(e,t,r,B),Y=K.begin,Q=K.end;/\s/.test(t.text.charAt(Q-1))&&Q--;for(var oe=null,le=null,be=0;be<n.length;be++){var ye=n[be];if(ye.from>=Q||ye.to<=Y)continue;var _e=ye.level!=1,Ie=ni(e,r,_e?Math.min(Q,ye.to)-1:Math.max(Y,ye.from)).right,je=Ie<S?S-Ie+1e9:Ie-S;(!oe||le>je)&&(oe=ye,le=je)}return oe||(oe=n[n.length-1]),oe.from<Y&&(oe={from:Y,to:oe.to,level:oe.level}),oe.to>Q&&(oe={from:oe.from,to:Q,level:oe.level}),oe}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=o("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(o("br"));Ii.appendChild(document.createTextNode("x"))}d(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),p(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=o("span","xxxxxxxxxx"),i=o("pre",[t],"CodeMirror-line-like");d(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,S=t.gutters.firstChild,B=0;S;S=S.nextSibling,++B){var K=e.display.gutterSpecs[B].className;i[K]=S.offsetLeft+S.clientLeft+n,r[K]=S.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(ri(e.doc,n))return 0;var S=0;if(n.widgets)for(var B=0;B<n.widgets.length;B++)n.widgets[B].height&&(S+=n.widgets[B].height);return i?S+(Math.ceil(n.text.length/r)||1)*t:S+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&yr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&pe(t).getAttribute("cm-not-content")=="true")return null;var S,B,K=n.lineSpace.getBoundingClientRect();try{S=t.clientX-K.left,B=t.clientY-K.top}catch(le){return null}var Y=va(e,S,B),Q;if(r&&Y.xRel>0&&(Q=ct(e.doc,Y.line).text).length==Y.ch){var oe=q(Q,Q.length,e.options.tabSize)-Q.length;Y=Ue(Y.line,Math.max(0,Math.round((S-qa(e.display).left)/$i(e.display))-oe))}return Y}function Bi(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function Dr(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)lr&&cn(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)lr&&Si(e.doc,i+r)>n.viewFrom?Ci(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ci(e);else if(t<=n.viewFrom){var S=Gn(e,i,i+r,1);S?(n.view=n.view.slice(S.index),n.viewFrom=S.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var B=Gn(e,t,t,-1);B?(n.view=n.view.slice(0,B.index),n.viewTo=B.lineN):Ci(e)}else{var K=Gn(e,t,t,-1),Y=Gn(e,i,i+r,1);K&&Y?(n.view=n.view.slice(0,K.index).concat(_r(e,K.lineN,Y.lineN)).concat(n.view.slice(Y.index)),n.viewTo+=r):Ci(e)}var Q=n.externalMeasured;Q&&(i<Q.lineN?Q.lineN+=r:t<Q.lineN+Q.size&&(n.externalMeasured=null))}function Ti(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var S=r.view[Bi(e,t)];if(S.node==null)return;var B=S.changes||(S.changes=[]);ce(B,i)==-1&&B.push(i)}function Ci(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gn(e,t,i,r){var n=Bi(e,t),S,B=e.display.view;if(!lr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,Y=0;Y<n;Y++)K+=B[Y].size;if(K!=t){if(r>0){if(n==B.length-1)return null;S=K+B[n].size-t,n++}else S=K-t;t+=S,i+=S}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:B.length-1))return null;i+=r*B[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=_r(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=_r(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Bi(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(_r(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Bi(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function bn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),S=r.selection=document.createDocumentFragment(),B=0;B<i.sel.ranges.length;B++){if(!t&&B==i.sel.primIndex)continue;var K=i.sel.ranges[B];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var Y=K.empty();(Y||e.options.showCursorWhenSelecting)&&go(e,K.head,n),Y||Xs(e,K,S)}return r}function go(e,t,i){var r=Zr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(o("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var S=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));S.style.display="",S.style.left=r.other.left+"px",S.style.top=r.other.top+"px",S.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,S=document.createDocumentFragment(),B=qa(e.display),K=B.left,Y=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-B.right,Q=n.direction=="ltr";function oe($e,st,St,yt){st<0&&(st=0),st=Math.round(st),yt=Math.round(yt),S.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+$e+`px;
|
|
top: `+st+"px; width: "+(St==null?Y-$e:St)+`px;
|
|
height: `+(yt-st)+"px"))}function le($e,st,St){var yt=ct(n,$e),kt=yt.text.length,Xt,cr;function Qt(rr,Or){return ma(e,Ue($e,rr),"div",yt,Or)}function Br(rr,Or,gr){var ar=co(e,yt,null,rr),ir=Or=="ltr"==(gr=="after")?"left":"right",Jt=gr=="after"?ar.begin:ar.end-(/\s/.test(yt.text.charAt(ar.end-1))?2:1);return Qt(Jt,ir)[ir]}var Rr=Qe(yt,n.direction);return et(Rr,st||0,St==null?kt:St,function(rr,Or,gr,ar){var ir=gr=="ltr",Jt=Qt(rr,ir?"left":"right"),Pr=Qt(Or-1,ir?"right":"left"),un=st==null&&rr==0,ki=St==null&&Or==kt,Tr=ar==0,ai=!Rr||ar==Rr.length-1;if(Pr.top-Jt.top<=3){var fr=(Q?un:ki)&&Tr,Va=(Q?ki:un)&&ai,di=fr?K:(ir?Jt:Pr).left,Hi=Va?Y:(ir?Pr:Jt).right;oe(di,Jt.top,Hi-di,Jt.bottom)}else{var Gi,Ar,hn,Xa;ir?(Gi=Q&&un&&Tr?K:Jt.left,Ar=Q?Y:Br(rr,gr,"before"),hn=Q?K:Br(Or,gr,"after"),Xa=Q&&ki&&ai?Y:Pr.right):(Gi=Q?Br(rr,gr,"before"):K,Ar=!Q&&un&&Tr?Y:Jt.right,hn=!Q&&ki&&ai?K:Pr.left,Xa=Q?Br(Or,gr,"after"):Y),oe(Gi,Jt.top,Ar-Gi,Jt.bottom),Jt.bottom<Pr.top&&oe(K,Jt.bottom,null,Pr.top),oe(hn,Pr.top,Xa-hn,Pr.bottom)}(!Xt||zn(Jt,Xt)<0)&&(Xt=Jt),zn(Pr,Xt)<0&&(Xt=Pr),(!cr||zn(Jt,cr)<0)&&(cr=Jt),zn(Pr,cr)<0&&(cr=Pr)}),{start:Xt,end:cr}}var be=t.from(),ye=t.to();if(be.line==ye.line)le(be.line,be.ch,ye.ch);else{var _e=ct(n,be.line),Ie=ct(n,ye.line),je=Cr(_e)==Cr(Ie),Ye=le(be.line,be.ch,je?_e.text.length+1:null).end,at=le(ye.line,je?0:null,ye.ch).start;je&&(Ye.top<at.top-2?(oe(Ye.right,Ye.top,null,Ye.bottom),oe(K,at.top,at.left,at.bottom)):oe(Ye.right,Ye.top,at.left-Ye.right,Ye.bottom)),Ye.bottom<at.top&&oe(K,Ye.bottom,null,at.top)}i.appendChild(S)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),M&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,f(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],S=e.options.lineWrapping,B=void 0,K=0;if(n.hidden)continue;if(H&&F<8){var Y=n.node.offsetTop+n.node.offsetHeight;B=Y-i,i=Y}else{var Q=n.node.getBoundingClientRect();B=Q.bottom-Q.top,!S&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-Q.left-1)}var oe=n.line.height-B;if((oe>.005||oe<-.005)&&(yr(n.line,B),bo(n.line),n.rest))for(var le=0;le<n.rest.length;le++)bo(n.rest[le]);if(K>e.display.sizerWidth){var be=Math.ceil(K/$i(e.display));be>e.display.maxLineLength&&(e.display.maxLineLength=be,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,S=Ur(t,r),B=Ur(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<S?(S=K,B=Ur(t,$r(ct(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=B&&(S=Ur(t,$r(ct(t,Y))-e.wrapper.clientHeight),B=Y)}return{from:S,to:Math.max(B,S+1)}}function Ys(e,t){if(Ne(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!A){var S=o("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(S),S.scrollIntoView(n),e.display.lineSpace.removeChild(S)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Ue(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Ue(t.line,t.ch+1,"before"):t);for(var S=0;S<5;S++){var B=!1,K=Zr(e,t),Y=!i||i==t?K:Zr(e,i);n={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var Q=Ca(e,n),oe=e.doc.scrollTop,le=e.doc.scrollLeft;if(Q.scrollTop!=null&&(En(e,Q.scrollTop),Math.abs(e.doc.scrollTop-oe)>1&&(B=!0)),Q.scrollLeft!=null&&(Fi(e,Q.scrollLeft),Math.abs(e.doc.scrollLeft-le)>1&&(B=!0)),!B)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&En(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,S=ca(e),B={};t.bottom-t.top>S&&(t.bottom=t.top+S);var K=e.doc.height+da(i),Y=t.top<r,Q=t.bottom>K-r;if(t.top<n)B.scrollTop=Y?0:t.top;else if(t.bottom>n+S){var oe=Math.min(t.top,(Q?K:t.bottom)-S);oe!=n&&(B.scrollTop=oe)}var le=e.options.fixedGutter?0:i.gutters.offsetWidth,be=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-le,ye=Mi(e)-i.gutters.offsetWidth,_e=t.right-t.left>ye;return _e&&(t.right=t.left+ye),t.left<10?B.scrollLeft=0:t.left<be?B.scrollLeft=Math.max(0,t.left+le-(_e?0:10)):t.right>ye+be-3&&(B.scrollLeft=t.right+(_e?0:10)-ye),B}function wa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Qi(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function xn(e,t,i){(t!=null||i!=null)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Qs(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});xn(e,n.scrollLeft,n.scrollTop)}function En(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||La(e,{top:t}),Eo(e,t,!0),D&&La(e),Cn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Fi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=function(e,t,i){this.cm=i;var r=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,H&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var S=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+S)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.prototype.zeroWidthHack=function(){var e=l&&!_?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ne,this.disableVert=new ne},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),S=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);S!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Tn=function(){};Tn.prototype.update=function(){return{bottom:0,right:0}},Tn.prototype.setScrollLeft=function(){},Tn.prototype.setScrollTop=function(){},Tn.prototype.clear=function(){};function Ji(e,t){t||(t=Sn(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),So(e,Sn(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var To={native:Ui,null:Tn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&f(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),we(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?Fi(e,t):En(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Js=0;function ji(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Js},Kr(e.curOp)}function Wi(e){var t=e.curOp;t&&Rs(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var S=0;S<t.length;S++)il(t[S]);for(var B=0;B<t.length;B++)nl(t[B])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Mi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==I();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Ji(t,e.barMeasure),e.updatedDisplay&&Da(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var S=e.maybeHiddenMarkers,B=e.maybeUnhiddenMarkers;if(S)for(var K=0;K<S.length;++K)S[K].lines.length||Ae(S[K],"hide");if(B)for(var Y=0;Y<B.length;++Y)B[Y].lines.length&&Ae(B[Y],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Nr(e,t){if(e.curOp)return t();ji(e);try{return t()}finally{Wi(e)}}function hr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);ji(e);try{return t.apply(e,arguments)}finally{Wi(e)}}}function wr(e){return function(){if(this.curOp)return e.apply(this,arguments);ji(this);try{return e.apply(this,arguments)}finally{Wi(this)}}}function dr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);ji(t);try{return e.apply(this,arguments)}finally{Wi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=ze(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(S){if(r.line>=e.display.viewFrom){var B=S.styles,K=S.text.length>e.options.maxHighlightLength?Fr(t.mode,r.state):null,Y=he(e,S,r,!0);K&&(r.state=K),S.styles=Y.styles;var Q=S.styleClasses,oe=Y.classes;oe?S.styleClasses=oe:Q&&(S.styleClasses=null);for(var le=!B||B.length!=S.styles.length||Q!=oe&&(!Q||!oe||Q.bgClass!=oe.bgClass||Q.textClass!=oe.textClass),be=0;!le&&be<B.length;++be)le=B[be]!=S.styles[be];le&&n.push(r.line),S.stateAfter=r.save(),r.nextLine()}else S.text.length<=e.options.maxHighlightLength&&ft(e,S.text,r),S.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Nr(e,function(){for(var S=0;S<n.length;S++)Ti(e,n[S],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Mi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){de(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ae.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=I();if(!t||!T(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&T(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==I())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&T(document.body,e.anchorNode)&&T(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ci(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Lo(e)&&(Ci(e),t.dims=ba(e));var n=r.first+r.size,S=Math.max(t.visible.from-e.options.viewportMargin,r.first),B=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<S&&S-i.viewFrom<20&&(S=Math.max(r.first,i.viewFrom)),i.viewTo>B&&i.viewTo-B<20&&(B=Math.min(n,i.viewTo)),lr&&(S=cn(e.doc,S),B=Si(e.doc,B));var K=S!=i.viewFrom||B!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,S,B),i.viewOffset=$r(ct(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var Q=sl(e);return Y>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),Y>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(Q),p(i.cursorDiv),p(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Mi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!Aa(e,t))break;Kn(e);var n=Sn(e);bn(e),Ji(e,n),Da(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function La(e,t){var i=new Yn(e,t);if(Aa(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Ji(e,r),Da(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,S=r.lineDiv,B=S.firstChild;function K(_e){var Ie=_e.nextSibling;return M&&l&&e.display.currentWheelTarget==_e?_e.style.display="none":_e.parentNode.removeChild(_e),Ie}for(var Y=r.view,Q=r.viewFrom,oe=0;oe<Y.length;oe++){var le=Y[oe];if(!le.hidden)if(!le.node||le.node.parentNode!=S){var be=Ns(e,le,Q,i);S.insertBefore(be,B)}else{for(;B!=le.node;)B=K(B);var ye=n&&t!=null&&t<=Q&&le.lineNumber;le.changes&&(ce(le.changes,"gutter")>-1&&(ye=!1),Ya(e,le,Q,i)),ye&&(p(le.lineNumber),le.lineNumber.appendChild(document.createTextNode(fi(e.options,Q)))),B=le.node.nextSibling}Q+=le.size}for(;B;)B=K(B)}function _a(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Da(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+ii(e)+"px"}function Ao(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,S=r+"px",B=0;B<i.length;B++)if(!i[B].hidden){e.options.fixedGutter&&(i[B].gutter&&(i[B].gutter.style.left=S),i[B].gutterBackground&&(i[B].gutterBackground.style.left=S));var K=i[B].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=S}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),S=n.firstChild.offsetWidth,B=n.offsetWidth-S;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(S,r.lineGutter.offsetWidth-B)+1,r.lineNumWidth=r.lineNumInnerWidth+B,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_a(e.display),!0}return!1}function ka(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var S=e[n],B=null;if(typeof S!="string"&&(B=S.style,S=S.className),S=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:S,style:B})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function _o(e){var t=e.gutters,i=e.gutterSpecs;p(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],S=n.className,B=n.style,K=t.appendChild(o("div",null,"CodeMirror-gutter "+S));B&&(K.style.cssText=B),S=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",_a(e)}function wn(e){_o(e.display),Dr(e),Ao(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=E("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=E("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=E("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[S],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),H&&F<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!M&&!(D&&a)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=ka(r.gutters,r.lineNumbers),_o(n),i.init(n)}var $n=0,Wr=null;H?Wr=-.53:D?Wr=15:b?Wr=-.7:k&&(Wr=-1/3);function Do(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function dl(e){var t=Do(e);return t.x*=Wr,t.y*=Wr,t}function ko(e,t){var i=Do(t),r=i.x,n=i.y,S=e.display,B=S.scroller,K=B.scrollWidth>B.clientWidth,Y=B.scrollHeight>B.clientHeight;if(!(r&&K||n&&Y))return;if(n&&l&&M){e:for(var Q=t.target,oe=S.view;Q!=B;Q=Q.parentNode)for(var le=0;le<oe.length;le++)if(oe[le].node==Q){e.display.currentWheelTarget=Q;break e}}if(r&&!D&&!C&&Wr!=null){n&&Y&&En(e,Math.max(0,B.scrollTop+n*Wr)),Fi(e,Math.max(0,B.scrollLeft+r*Wr)),(!n||n&&Y)&&ee(t),S.wheelStartX=null;return}if(n&&Wr!=null){var be=n*Wr,ye=e.doc.scrollTop,_e=ye+S.wrapper.clientHeight;be<0?ye=Math.max(0,ye+be-50):_e=Math.min(e.doc.height,_e+be+50),La(e,{top:ye,bottom:_e})}$n<20&&(S.wheelStartX==null?(S.wheelStartX=B.scrollLeft,S.wheelStartY=B.scrollTop,S.wheelDX=r,S.wheelDY=n,setTimeout(function(){if(S.wheelStartX==null)return;var Ie=B.scrollLeft-S.wheelStartX,je=B.scrollTop-S.wheelStartY,Ye=je&&S.wheelDY&&je/S.wheelDY||Ie&&S.wheelDX&&Ie/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!Ye)return;Wr=(Wr*$n+Ye)/($n+1),++$n},200)):(S.wheelDX+=r,S.wheelDY+=n))}var Hr=function(e,t){this.ranges=e,this.primIndex=t};Hr.prototype.primary=function(){return this.ranges[this.primIndex]},Hr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var i=this.ranges[t],r=e.ranges[t];if(!pi(i.anchor,r.anchor)||!pi(i.head,r.head))return!1}return!0},Hr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Ht(mi(this.ranges[t].anchor),mi(this.ranges[t].head));return new Hr(e,this.primIndex)},Hr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Hr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(wt(t,r.from())>=0&&wt(e,r.to())<=0)return i}return-1};var Ht=function(e,t){this.anchor=e,this.head=t};Ht.prototype.from=function(){return vi(this.anchor,this.head)},Ht.prototype.to=function(){return gi(this.anchor,this.head)},Ht.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Qr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(be,ye){return wt(be.from(),ye.from())}),i=ce(t,n);for(var S=1;S<t.length;S++){var B=t[S],K=t[S-1],Y=wt(K.to(),B.from());if(r&&!B.empty()?Y>0:Y>=0){var Q=vi(K.from(),B.from()),oe=gi(K.to(),B.to()),le=K.empty()?B.from()==B.head:K.from()==K.head;S<=i&&--i,t.splice(--S,2,new Ht(le?oe:Q,le?Q:oe))}}return new Hr(t,i)}function wi(e,t){return new Hr([new Ht(e,t||e)],0)}function Ai(e){return e.text?Ue(e.from.line+e.text.length-1,ke(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(wt(e,t.from)<0)return e;if(wt(e,t.to)<=0)return Ai(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Ai(t).ch-t.to.ch),Ue(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Ht(Ro(n.anchor,t),Ro(n.head,t)))}return Qr(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?Ue(i.line,e.ch-t.ch+i.ch):Ue(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Ue(e.first,0),S=n,B=0;B<t.length;B++){var K=t[B],Y=Oo(K.from,n,S),Q=Oo(Ai(K),n,S);if(n=K.to,S=Q,i=="around"){var oe=e.sel.ranges[B],le=wt(oe.head,oe.anchor)<0;r[B]=new Ht(le?Q:Y,le?Y:Q)}else r[B]=new Ht(Y,Y)}return new Hr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=vr(e.options,e.doc.modeOption),An(e)}function An(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Cn(e,100),e.state.modeGen++,e.curOp&&Dr(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&ke(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(at){return i?i[at]:null}function S(at,$e,st){ua(at,$e,st,r),mr(at,"change",at,t)}function B(at,$e){for(var st=[],St=at;St<$e;++St)st.push(new Pi(Q[St],n(St),r));return st}var K=t.from,Y=t.to,Q=t.text,oe=ct(e,K.line),le=ct(e,Y.line),be=ke(Q),ye=n(Q.length-1),_e=Y.line-K.line;if(t.full)e.insert(0,B(0,Q.length)),e.remove(Q.length,e.size-Q.length);else if(Po(e,t)){var Ie=B(0,Q.length-1);S(le,le.text,ye),_e&&e.remove(K.line,_e),Ie.length&&e.insert(K.line,Ie)}else if(oe==le)if(Q.length==1)S(oe,oe.text.slice(0,K.ch)+be+oe.text.slice(Y.ch),ye);else{var je=B(1,Q.length-1);je.push(new Pi(be+oe.text.slice(Y.ch),ye,r)),S(oe,oe.text.slice(0,K.ch)+Q[0],n(0)),e.insert(K.line+1,je)}else if(Q.length==1)S(oe,oe.text.slice(0,K.ch)+Q[0]+le.text.slice(Y.ch),n(0)),e.remove(K.line+1,_e);else{S(oe,oe.text.slice(0,K.ch)+Q[0],n(0)),S(le,be+le.text.slice(Y.ch),ye);var Ye=B(1,Q.length-1);_e>1&&e.remove(K.line+1,_e-1),e.insert(K.line+1,Ye)}mr(e,"change",e,t)}function Li(e,t,i){function r(n,S,B){if(n.linked)for(var K=0;K<n.linked.length;++K){var Y=n.linked[K];if(Y.doc==S)continue;var Q=B&&Y.sharedHist;if(i&&!Q)continue;t(Y.doc,Q),r(Y.doc,n,Q)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Oa(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Dr(e)}function Io(e){(e.doc.direction=="rtl"?G:f)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Nr(e,function(){Io(e),Dr(e)})}function Zn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var i={from:mi(t.from),to:Ai(t),text:Gr(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=ke(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),ke(e.done);if(e.done.length&&!ke(e.done).ranges)return ke(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),ke(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var S=+new Date,B,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>S-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(B=pl(n,n.lastOp==r)))K=ke(B.changes),wt(t.from,t.to)==0&&wt(t.from,K.to)==0?K.to=Ai(t):B.changes.push(Ma(e,t));else{var Y=ke(n.done);for((!Y||!Y.ranges)&&Qn(e.sel,n.done),B={changes:[Ma(e,t)],generation:n.generation},n.done.push(B);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=S,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||Ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,S=r&&r.origin;i==n.lastSelOp||S&&n.lastSelOrigin==S&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==S||ml(e,S,ke(n.done),t))?n.done[n.done.length-1]=t:Qn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=S,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Qn(e,t){var i=ke(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],S=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(B){B.markedSpans&&((n||(n=t["spans_"+e.id]={}))[S]=B.markedSpans),++S})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var S=i[n],B=r[n];if(S&&B){e:for(var K=0;K<B.length;++K){for(var Y=B[K],Q=0;Q<S.length;++Q)if(S[Q].marker==Y.marker)continue e;S.push(Y)}}else B&&(i[n]=B)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var S=e[n];if(S.ranges){r.push(i?Hr.prototype.deepCopy.call(S):S);continue}var B=S.changes,K=[];r.push({changes:K});for(var Y=0;Y<B.length;++Y){var Q=B[Y],oe=void 0;if(K.push({from:Q.from,to:Q.to,text:Q.text}),t)for(var le in Q)(oe=le.match(/^spans_(\d+)$/))&&(ce(t,Number(oe[1]))>-1&&(ke(K)[le]=Q[le],delete Q[le]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var S=wt(t,n)<0;S!=wt(i,n)<0?(n=t,t=i):S!=wt(t,i)<0&&(t=i)}return new Ht(n,t)}else return new Ht(i||t,t)}function Jn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Sr(e,new Hr([Ia(e.sel.primary(),t,i,n)],0),r)}function jo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),S=0;S<e.sel.ranges.length;S++)r[S]=Ia(e.sel.ranges[S],t[S],null,n);var B=Qr(e.cm,r,e.sel.primIndex);Sr(e,B,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,Sr(e,Qr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){Sr(e,wi(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var S=0;S<n.length;S++)this.ranges[S]=new Ht(s(e,n[S].anchor),s(e,n[S].head))},origin:i&&i.origin};return Ae(e,"beforeSelectionChange",e,r),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Qr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=ke(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):Sr(e,t,i)}function Sr(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(de(e,"beforeSelectionChange")||e.cm&&de(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(wt(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Qi(e.cm)}function Go(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,me(e.cm)),mr(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,S=0;S<t.ranges.length;S++){var B=t.ranges[S],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[S],Y=ea(e,B.anchor,K&&K.anchor,i,r),Q=ea(e,B.head,K&&K.head,i,r);(n||Y!=B.anchor||Q!=B.head)&&(n||(n=t.ranges.slice(0,S)),n[S]=new Ht(Y,Q))}return n?Qr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var S=ct(e,t.line);if(S.markedSpans)for(var B=0;B<S.markedSpans.length;++B){var K=S.markedSpans[B],Y=K.marker,Q="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,oe="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(Q?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(oe?K.to>=t.ch:K.to>t.ch))){if(n&&(Ae(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(S.markedSpans){--B;continue}else break;if(!Y.atomic)continue;if(i){var le=Y.find(r<0?1:-1),be=void 0;if((r<0?oe:Q)&&(le=Vo(e,le,-r,le&&le.line==t.line?S:null)),le&&le.line==t.line&&(be=wt(le,i))&&(r<0?be<0:be>0))return en(e,le,t,r,n)}var ye=Y.find(r<0?-1:1);return(r<0?Q:oe)&&(ye=Vo(e,ye,r,ye.line==t.line?S:null)),ye?en(e,ye,t,r,n):null}}return t}function ea(e,t,i,r,n){var S=r||1,B=en(e,t,i,S,n)||!n&&en(e,t,i,S,!0)||en(e,t,i,-S,n)||!n&&en(e,t,i,-S,!0);return B||(e.cantEdit=!0,Ue(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Ue(t.line-1)):null:i>0&&t.ch==(r||ct(e,t.line)).text.length?t.line<e.first+e.size-1?Ue(t.line+1,0):null:new Ue(t.line,t.ch+i)}function Xo(e){e.setSelection(Ue(e.firstLine(),0),Ue(e.lastLine()),xe)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,S,B,K){n&&(r.from=s(e,n)),S&&(r.to=s(e,S)),B&&(r.text=B),K!==void 0&&(r.origin=K)}),Ae(e,"beforeChange",e,r),e.cm&&Ae(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function tn(e,t,i){if(e.cm){if(!e.cm.curOp)return hr(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Ri&&!i&&bi(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&wt(t.from,t.to)==0)return;var i=Ra(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Yr(e,t));var r=[];Li(e,function(n,S){!S&&ce(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),Ln(n,t,null,Yr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,S,B=e.sel,K=t=="undo"?n.done:n.undone,Y=t=="undo"?n.undone:n.done,Q=0;Q<K.length&&!(S=K[Q],i?S.ranges&&!S.equals(e.sel):!S.ranges);Q++);if(Q==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(S=K.pop(),S.ranges){if(Qn(S,Y),i&&!S.equals(e.sel)){Sr(e,S,{clearRedo:!1});return}B=S}else if(r){K.push(S);return}else break;var oe=[];Qn(B,Y),Y.push({changes:oe,generation:n.generation}),n.generation=S.generation||++n.maxGeneration;for(var le=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),be=function(Ie){var je=S.changes[Ie];if(je.origin=t,le&&!Yo(e,je,!1))return K.length=0,{};oe.push(Ma(e,je));var Ye=Ie?Ra(e,je):ke(K);Ln(e,je,Ye,Uo(e,je)),!Ie&&e.cm&&e.cm.scrollIntoView({from:je.from,to:Ai(je)});var at=[];Li(e,function($e,st){!st&&ce(at,$e.history)==-1&&(qo($e.history,je),at.push($e.history)),Ln($e,je,null,Uo($e,je))})},ye=S.changes.length-1;ye>=0;--ye){var _e=be(ye);if(_e)return _e.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Hr(Ve(e.sel.ranges,function(n){return new Ht(Ue(n.anchor.line+t,n.anchor.ch),Ue(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Dr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ti(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return hr(e.cm,Ln)(e,t,i,r);if(t.to.line<e.first){Zo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:Ue(e.first,0),to:Ue(t.to.line+n,t.to.ch),text:[ke(t.text)],origin:t.origin}}var S=e.lastLine();t.to.line>S&&(t={from:t.from,to:Ue(S,ct(e,S).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Gr(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),qn(e,i,xe),e.cantEdit&&ea(e,Ue(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,S=t.from,B=t.to,K=!1,Y=S.line;e.options.lineWrapping||(Y=Ot(Cr(ct(r,S.line))),r.iter(Y,B.line+1,function(ye){if(ye==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&me(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(Y,S.line+t.text.length,function(ye){var _e=pn(ye);_e>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=_e,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),Xr(r,S.line),Cn(e,400);var Q=t.text.length-(B.line-S.line)-1;t.full?Dr(e):S.line==B.line&&t.text.length==1&&!Po(e.doc,t)?Ti(e,S.line,"text"):Dr(e,S.line,B.line+1,Q);var oe=de(e,"changes"),le=de(e,"change");if(le||oe){var be={from:S,to:B,text:t.text,removed:t.removed,origin:t.origin};le&&mr(e,"change",e,be),oe&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(be)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var S;r||(r=i),wt(r,i)<0&&(S=[r,i],i=S[0],r=S[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function Qo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Jo(e,t,i,r){for(var n=0;n<e.length;++n){var S=e[n],B=!0;if(S.ranges){S.copied||(S=e[n]=S.deepCopy(),S.copied=!0);for(var K=0;K<S.ranges.length;K++)Qo(S.ranges[K].anchor,t,i,r),Qo(S.ranges[K].head,t,i,r);continue}for(var Y=0;Y<S.changes.length;++Y){var Q=S.changes[Y];if(i<Q.from.line)Q.from=Ue(Q.from.line+r,Q.from.ch),Q.to=Ue(Q.to.line+r,Q.to.ch);else if(t<=Q.to.line){B=!1;break}}B||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Jo(e.done,i,r,n),Jo(e.undone,i,r,n)}function _n(e,t,i,r){var n=t,S=t;return typeof t=="number"?S=ct(e,j(e,t)):n=Ot(t),n==null?null:(r(S,n)&&e.cm&&Ti(e.cm,n,i),S)}function Dn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}Dn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,gt(n),mr(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function kn(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}kn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var S=Math.min(t,n-e),B=r.height;if(r.removeInner(e,S),this.height-=B-r.height,n==S&&(this.children.splice(i--,1),r.parent=null),(t-=S)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var K=[];this.collapse(K),this.children=[new Dn(K)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],S=n.chunkSize();if(e<=S){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var B=n.lines.length%25+25,K=B;K<n.lines.length;){var Y=new Dn(n.lines.slice(K,K+=25));n.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}n.lines=n.lines.slice(0,B),this.maybeSpill()}break}e-=S}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new kn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ce(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new kn(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],S=n.chunkSize();if(e<S){var B=Math.min(t,S-e);if(n.iterN(e,B,i))return!0;if((t-=B)==0)break;e=0}else e-=S}}};var Rn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};Rn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=Ot(i);if(r==null||!t)return;for(var n=0;n<t.length;++n)t[n]==this&&t.splice(n--,1);t.length||(i.widgets=null);var S=vn(this);yr(i,Math.max(0,i.height-S)),e&&(Nr(e,function(){es(e,i,-S),Ti(e,r,"widget")}),mr(e,"lineWidgetCleared",e,this,r))},Rn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=vn(this)-t;if(!n)return;ri(this.doc,r)||yr(r,r.height+n),i&&Nr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),mr(i,"lineWidgetChanged",i,e,Ot(r))})},fe(Rn);function es(e,t,i){$r(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new Rn(e,i,r),S=e.cm;return S&&n.noHScroll&&(S.display.alignWidgets=!0),_n(e,t,"widget",function(B){var K=B.widgets||(B.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=B,S&&!ri(e,B)){var Y=$r(B)<e.scrollTop;yr(B,B.height+vn(n)),Y&&wa(S,n.height),S.curOp.forceUpdate=!0}return!0}),S&&mr(S,"lineWidgetAdded",S,n,typeof t=="number"?t:Ot(t)),n}var ts=0,_i=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};_i.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&ji(e),de(this,"clear")){var i=this.find();i&&mr(this,"clear",i.from,i.to)}for(var r=null,n=null,S=0;S<this.lines.length;++S){var B=this.lines[S],K=Ir(B.markedSpans,this);e&&!this.collapsed?Ti(e,Ot(B),"text"):e&&(K.to!=null&&(n=Ot(B)),K.from!=null&&(r=Ot(B))),B.markedSpans=Oi(B.markedSpans,K),K.from==null&&this.collapsed&&!ri(this.doc,B)&&e&&yr(B,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Y=0;Y<this.lines.length;++Y){var Q=Cr(this.lines[Y]),oe=pn(Q);oe>e.display.maxLineLength&&(e.display.maxLine=Q,e.display.maxLineLength=oe,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Dr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&zo(e.doc)),e&&mr(e,"markerCleared",e,this,r,n),t&&Wi(e),this.parent&&this.parent.clear()},_i.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var S=this.lines[n],B=Ir(S.markedSpans,this);if(B.from!=null&&(i=Ue(t?S:Ot(S),B.from),e==-1))return i;if(B.to!=null&&(r=Ue(t?S:Ot(S),B.to),e==1))return r}return i&&{from:i,to:r}},_i.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Nr(r,function(){var n=t.line,S=Ot(t.line),B=fa(r,S);if(B&&(no(B),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var Y=vn(i)-K;Y&&yr(n,n.height+Y)}mr(r,"markerChanged",r,e)})},_i.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ce(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},_i.prototype.detachLine=function(e){if(this.lines.splice(ce(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},fe(_i);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return hr(e.cm,nn)(e,t,i,r,n);var S=new _i(e,n),B=wt(t,i);if(r&&W(r,S,!1),B>0||B==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=E("span",[S.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||S.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(S.widgetNode.insertLeft=!0)),S.collapsed){if(ur(e,t.line,t,i,S)||t.line!=i.line&&ur(e,i.line,t,i,S))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}S.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,Q;if(e.iter(K,i.line+1,function(le){Y&&S.collapsed&&!Y.options.lineWrapping&&Cr(le)==Y.display.maxLine&&(Q=!0),S.collapsed&&K!=t.line&&yr(le,0),yi(le,new si(S,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),S.collapsed&&e.iter(t.line,i.line+1,function(le){ri(e,le)&&yr(le,0)}),S.clearOnEnter&&we(S,"beforeCursorEnter",function(){return S.clear()}),S.readOnly&&(jr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),S.collapsed&&(S.id=++ts,S.atomic=!0),Y){if(Q&&(Y.curOp.updateMaxLine=!0),S.collapsed)Dr(Y,t.line,i.line+1);else if(S.className||S.startStyle||S.endStyle||S.css||S.attributes||S.title)for(var oe=t.line;oe<=i.line;oe++)Ti(Y,oe,"text");S.atomic&&zo(Y.doc),mr(Y,"markerAdded",Y,S)}return S}var On=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};On.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();mr(this,"clear")},On.prototype.find=function(e,t){return this.primary.find(e,t)},fe(On);function Sl(e,t,i,r,n){r=W(r),r.shared=!1;var S=[nn(e,t,i,r,n)],B=S[0],K=r.widgetNode;return Li(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),S.push(nn(Y,s(Y,t),s(Y,i),r,n));for(var Q=0;Q<Y.linked.length;++Q)if(Y.linked[Q].isParent)return;B=ke(S)}),new On(S,B)}function rs(e){return e.findMarks(Ue(e.first,0),e.clipPos(Ue(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),S=e.clipPos(n.from),B=e.clipPos(n.to);if(wt(S,B)){var K=nn(e,S,B,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],S=[n.primary.doc];Li(n.primary.doc,function(Y){return S.push(Y)});for(var B=0;B<n.markers.length;B++){var K=n.markers[B];ce(S,K.doc)==-1&&(K.parent=null,n.markers.splice(B--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,kr=function(e,t,i,r,n){if(!(this instanceof kr))return new kr(e,t,i,r,n);i==null&&(i=0),kn.call(this,[new Dn([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var S=Ue(i,0);this.sel=wi(S),this.history=new Zn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:S,to:S,text:e}),Sr(this,wi(S),xe)};kr.prototype=Ke(kn.prototype,{constructor:kr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:dr(function(e){var t=Ue(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Ue(i,ct(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&xn(this.cm,0,0),Sr(this,wi(t),xe)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=Gr(this,s(this,e),s(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Vr(this,e))return ct(this,e)},getLineNumber:function(e){return Ot(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ct(this,e)),Cr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return s(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:dr(function(e,t,i){Wo(this,s(this,typeof e=="number"?Ue(e,t||0):e),null,i)}),setSelection:dr(function(e,t,i){Wo(this,s(this,e),s(this,t||e),i)}),extendSelection:dr(function(e,t,i){Jn(this,s(this,e),t&&s(this,t),i)}),extendSelections:dr(function(e,t){jo(this,R(this,e),t)}),extendSelectionsBy:dr(function(e,t){var i=Ve(this.sel.ranges,e);jo(this,R(this,i),t)}),setSelections:dr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new Ht(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Sr(this,Qr(this.cm,r,t),i)}),addSelection:dr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Ht(s(this,e),s(this,t||e))),Sr(this,Qr(this.cm,r,r.length-1),i)}),getSelection:function(e){for(var t=this.sel.ranges,i,r=0;r<t.length;r++){var n=Gr(this,t[r].from(),t[r].to());i=i?i.concat(n):n}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],i=this.sel.ranges,r=0;r<i.length;r++){var n=Gr(this,i[r].from(),i[r].to());e!==!1&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){for(var r=[],n=0;n<this.sel.ranges.length;n++)r[n]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:dr(function(e,t,i){for(var r=[],n=this.sel,S=0;S<n.ranges.length;S++){var B=n.ranges[S];r[S]={from:B.from(),to:B.to(),text:this.splitLines(e[S]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),Y=r.length-1;Y>=0;Y--)tn(this,r[Y]);K?Ho(this,K):this.cm&&Qi(this.cm)}),undo:dr(function(){ta(this,"undo")}),redo:dr(function(){ta(this,"redo")}),undoSelection:dr(function(){ta(this,"undo",!0)}),redoSelection:dr(function(){ta(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Zn(this.history.maxGeneration),Li(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Zn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:dr(function(e,t,i){return _n(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Xe(n)&&(r.gutterMarkers=null),!0})}),clearGutter:dr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&_n(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Xe(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Vr(this,e))return null;if(t=e,e=ct(this,e),!e)return null}else if(t=Ot(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:dr(function(e,t,i){return _n(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[n])r[n]=i;else{if(x(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:dr(function(e,t,i){return _n(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",S=r[n];if(S)if(i==null)r[n]=null;else{var B=S.match(x(i));if(!B)return!1;var K=B.index+B[0].length;r[n]=S.slice(0,B.index)+(!B.index||K==S.length?"":" ")+S.slice(K)||null}else return!1;return!0})}),addLineWidget:dr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(this,s(this,e),s(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=s(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=ct(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(S){var B=S.markedSpans;if(B)for(var K=0;K<B.length;K++){var Y=B[K];!(Y.to!=null&&n==e.line&&e.ch>=Y.to||Y.from==null&&n!=e.line||Y.from!=null&&n==t.line&&Y.from>=t.ch)&&(!i||i(Y.marker))&&r.push(Y.marker.parent||Y.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var S=n.text.length+r;if(S>e)return t=e,!0;e-=S,++i}),s(this,Ue(i,t))},indexFromPos:function(e){e=s(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new kr(ei(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new kr(ei(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof $t&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Li(e,function(n){return r.push(n.id)},!0),e.history=new Zn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Li(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Tt(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:dr(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)})}),kr.prototype.eachLine=kr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),Ne(t,e)||ui(t.display,e))return;ee(e),H&&(is=+new Date);var i=Ni(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,S=Array(n),B=0,K=function(){++B==n&&hr(t,function(){i=s(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(S.filter(function(_e){return _e!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,ye),Ho(t.doc,wi(s(t.doc,i),s(t.doc,Ai(ye))))})()},Y=function(ye,_e){if(t.options.allowDropFileTypes&&ce(t.options.allowDropFileTypes,ye.type)==-1){K();return}var Ie=new FileReader;Ie.onerror=function(){return K()},Ie.onload=function(){var je=Ie.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(je)){K();return}S[_e]=je,K()},Ie.readAsText(ye)},Q=0;Q<r.length;Q++)Y(r[Q],Q);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var oe=e.dataTransfer.getData("Text");if(oe){var le;if(t.state.draggingText&&!t.state.draggingText.copy&&(le=t.listSelections()),qn(t.doc,wi(i,i)),le)for(var be=0;be<le.length;++be)rn(t.doc,"",le[be].anchor,le[be].head,"drag");t.replaceSelection(oe,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Ll(e,t){if(H&&(!e.state.draggingText||+new Date-is<100)){ue(t);return}if(Ne(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!k){var i=o("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",C&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),C&&i.parentNode.removeChild(i)}}function _l(e,t){var i=Ni(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),d(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var S=0;S<i.length;S++)e(i[S])})}var os=!1;function Dl(){if(os)return;kl(),os=!0}function kl(){var e;we(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),we(window,"blur",function(){return as(Zi)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Pn=0;Pn<10;Pn++)Di[Pn+48]=Di[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[Mn+63235]="F"+Mn;var hi={};hi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},hi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},hi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},hi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},hi.default=l?hi.macDefault:hi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,S,B=0;B<t.length-1;B++){var K=t[B];if(/^(cmd|meta|m)$/i.test(K))S=!0;else if(/^a(lt)?$/i.test(K))i=!0;else if(/^(c|ctrl|control)$/i.test(K))r=!0;else if(/^s(hift)?$/i.test(K))n=!0;else throw new Error("Unrecognized modifier name: "+K)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),S&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=Ve(i.split(" "),Ol),S=0;S<n.length;S++){var B=void 0,K=void 0;S==n.length-1?(K=n.join(" "),B=r):(K=n.slice(0,S+1).join(" "),B="...");var Y=t[K];if(!Y)t[K]=B;else if(Y!=B)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var Q in t)e[Q]=t[Q];return e}function an(e,t,i,r){t=ia(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var S=0;S<t.fallthrough.length;S++){var B=an(e,t.fallthrough[S],i,r);if(B)return B}}}function ss(e){var t=typeof e=="string"?e:Di[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(m?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(m?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(C&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?hi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var S=t(i[n]);r.length&&wt(S.from,ke(r).to)<=0;){var B=r.pop();if(wt(B.from,S.from)<0){S.from=B.from;break}}r.push(S)}Nr(e,function(){for(var K=r.length-1;K>=0;K--)rn(e.doc,"",r[K].from,r[K].to,"+delete");Qi(e)})}function Ba(e,t,i){var r=Be(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Ue(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=Qe(i,t.doc.direction);if(S){var B=n<0?ke(S):S[0],K=n<0==(B.level==1),Y=K?"after":"before",Q;if(B.level>0||t.doc.direction=="rtl"){var oe=Xi(t,i);Q=n<0?i.text.length-1:0;var le=ni(t,oe,Q).top;Q=ot(function(be){return ni(t,oe,be).top==le},n<0==(B.level==1)?B.from:B.to-1,Q),Y=="before"&&(Q=Ba(i,Q,1))}else Q=n<0?B.to:B.from;return new Ue(r,Q,Y)}}return new Ue(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=Qe(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var S=rt(n,i.ch,i.sticky),B=n[S];if(e.doc.direction=="ltr"&&B.level%2==0&&(r>0?B.to>i.ch:B.from<i.ch))return Fa(t,i,r);var K=function(Ye,at){return Ba(t,Ye instanceof Ue?Ye.ch:Ye,at)},Y,Q=function(Ye){return e.options.lineWrapping?(Y=Y||Xi(e,t),co(e,t,Y,Ye)):{begin:0,end:t.text.length}},oe=Q(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||B.level==1){var le=B.level==1==r<0,be=K(i,le?1:-1);if(be!=null&&(le?be<=B.to&&be<=oe.end:be>=B.from&&be>=oe.begin)){var ye=le?"before":"after";return new Ue(i.line,be,ye)}}var _e=function(Ye,at,$e){for(var st=function(Xt,cr){return cr?new Ue(i.line,K(Xt,1),"before"):new Ue(i.line,Xt,"after")};Ye>=0&&Ye<n.length;Ye+=at){var St=n[Ye],yt=at>0==(St.level!=1),kt=yt?$e.begin:K($e.end,-1);if(St.from<=kt&&kt<St.to)return st(kt,yt);if(kt=yt?St.from:K(St.to,-1),$e.begin<=kt&&kt<$e.end)return st(kt,yt)}},Ie=_e(S+r,r,oe);if(Ie)return Ie;var je=r>0?oe.end:K(oe.begin,-1);return je!=null&&!(r>0&&je==t.text.length)&&(Ie=_e(r>0?0:n.length-1,r,Q(je)),Ie)?Ie:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),xe)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=ct(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Ue(t.head.line+1,0)}:{from:t.head,to:Ue(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:s(e.doc,Ue(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Ue(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ue(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Te)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Te)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?ds(e,t.head):r},Te)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var S=i[n].from(),B=q(e.getLine(S.line),S.ch,r);t.push(se(r-B%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Nr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,S=ct(e.doc,n.line).text;if(S){if(n.ch==S.length&&(n=new Ue(n.line,n.ch-1)),n.ch>0)n=new Ue(n.line,n.ch+1),e.replaceRange(S.charAt(n.ch-1)+S.charAt(n.ch-2),Ue(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var B=ct(e.doc,n.line-1).text;B&&(n=new Ue(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),Ue(n.line-1,B.length-1),n,"+transpose"))}}i.push(new Ht(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Nr(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Qi(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=ct(e.doc,t),r=Cr(i);return r!=i&&(t=Ot(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=ct(e.doc,t),r=Vi(i);return r!=i&&(t=Ot(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=ct(e.doc,i.line),n=Qe(r,e.doc.direction);if(!n||n[0].level==0){var S=Math.max(i.ch,r.text.search(/\S/)),B=t.line==i.line&&t.ch<=S&&t.ch;return Ue(i.line,B?0:S,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=De}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Bl=new ne;function Nn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&mr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(ee(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Fl(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=I(),Ne(t,e))return;H&&F<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);C&&(ja=r?i:null,!r&&i==88&&!Bt&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),D&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),it(document,"keyup",i),it(document,"mouseover",i))}we(document,"keyup",i),we(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ne(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Ne(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(C&&i==ja){ja=null,ee(e);return}if(C&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&wt(t,this.pos)==0&&i==this.button};var Bn,Fn;function Wl(e,t){var i=+new Date;return Fn&&Fn.compare(i,e,t)?(Bn=Fn=null,"triple"):Bn&&Bn.compare(i,e,t)?(Fn=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Fn=null,"single")}function vs(e){var t=this,i=t.display;if(Ne(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){M||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=Se(e),S=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,S,e))return;n==1?r?zl(t,r,S,e):pe(e)==i.scroller&&ee(e):n==2?(r&&Jn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(L?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var S="Click";return r=="double"?S="Double"+S:r=="triple"&&(S="Triple"+S),S=(t==1?"Left":t==2?"Middle":"Right")+S,Nn(e,ls(S,n),n,function(B){if(typeof B=="string"&&(B=In[B]),!B)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=B(e,i)!=De}finally{e.state.suppressEdits=!1}return K})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var S=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=S?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){H?setTimeout(z(vo,e),0):e.curOp.focus=I();var n=Gl(e,i,r),S=e.doc.sel,B;e.options.dragDrop&&Oe&&!e.isReadOnly()&&i=="single"&&(B=S.contains(t))>-1&&(wt((B=S.ranges[B]).from(),t)<0||t.xRel>0)&&(wt(B.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,S=!1,B=hr(e,function(Q){M&&(n.scroller.draggable=!1),e.state.draggingText=!1,it(n.wrapper.ownerDocument,"mouseup",B),it(n.wrapper.ownerDocument,"mousemove",K),it(n.scroller,"dragstart",Y),it(n.scroller,"drop",B),S||(ee(Q),r.addNew||Jn(e.doc,i,null,null,r.extend),M&&!k||H&&F==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(Q){S=S||Math.abs(t.clientX-Q.clientX)+Math.abs(t.clientY-Q.clientY)>=10},Y=function(){return S=!0};M&&(n.scroller.draggable=!0),e.state.draggingText=B,B.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),we(n.wrapper.ownerDocument,"mouseup",B),we(n.wrapper.ownerDocument,"mousemove",K),we(n.scroller,"dragstart",Y),we(n.scroller,"drop",B),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new Ht(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Ht(Ue(t.line,0),s(e.doc,Ue(t.line+1,0)));var r=i(e,t);return new Ht(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,S=e.doc;ee(t);var B,K,Y=S.sel,Q=Y.ranges;if(r.addNew&&!r.extend?(K=S.sel.contains(i),K>-1?B=Q[K]:B=new Ht(i,i)):(B=S.sel.primary(),K=S.sel.primIndex),r.unit=="rectangle")r.addNew||(B=new Ht(i,i)),i=Ni(e,t,!0,!0),K=-1;else{var oe=ys(e,i,r.unit);r.extend?B=Ia(B,oe.anchor,oe.head,r.extend):B=oe}r.addNew?K==-1?(K=Q.length,Sr(S,Qr(e,Q.concat([B]),K),{scroll:!1,origin:"*mouse"})):Q.length>1&&Q[K].empty()&&r.unit=="char"&&!r.extend?(Sr(S,Qr(e,Q.slice(0,K).concat(Q.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=S.sel):Na(S,K,B,Ce):(K=0,Sr(S,new Hr([B],0),Ce),Y=S.sel);var le=i;function be($e){if(wt(le,$e)==0)return;if(le=$e,r.unit=="rectangle"){for(var st=[],St=e.options.tabSize,yt=q(ct(S,i.line).text,i.ch,St),kt=q(ct(S,$e.line).text,$e.ch,St),Xt=Math.min(yt,kt),cr=Math.max(yt,kt),Qt=Math.min(i.line,$e.line),Br=Math.min(e.lastLine(),Math.max(i.line,$e.line));Qt<=Br;Qt++){var Rr=ct(S,Qt).text,rr=Ee(Rr,Xt,St);Xt==cr?st.push(new Ht(Ue(Qt,rr),Ue(Qt,rr))):Rr.length>rr&&st.push(new Ht(Ue(Qt,rr),Ue(Qt,Ee(Rr,cr,St))))}st.length||st.push(new Ht(i,i)),Sr(S,Qr(e,Y.ranges.slice(0,K).concat(st),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView($e)}else{var Or=B,gr=ys(e,$e,r.unit),ar=Or.anchor,ir;wt(gr.anchor,ar)>0?(ir=gr.head,ar=vi(Or.from(),gr.anchor)):(ir=gr.anchor,ar=gi(Or.to(),gr.head));var Jt=Y.ranges.slice(0);Jt[K]=Xl(e,new Ht(s(S,ar),ir)),Sr(S,Qr(e,Jt,K),Ce)}}var ye=n.wrapper.getBoundingClientRect(),_e=0;function Ie($e){var st=++_e,St=Ni(e,$e,!0,r.unit=="rectangle");if(!St)return;if(wt(St,le)!=0){e.curOp.focus=I(),be(St);var yt=Vn(n,S);(St.line>=yt.to||St.line<yt.from)&&setTimeout(hr(e,function(){_e==st&&Ie($e)}),150)}else{var kt=$e.clientY<ye.top?-20:$e.clientY>ye.bottom?20:0;kt&&setTimeout(hr(e,function(){if(_e!=st)return;n.scroller.scrollTop+=kt,Ie($e)}),50)}}function je($e){e.state.selectingText=!1,_e=Infinity,$e&&(ee($e),n.input.focus()),it(n.wrapper.ownerDocument,"mousemove",Ye),it(n.wrapper.ownerDocument,"mouseup",at),S.history.lastSelOrigin=null}var Ye=hr(e,function($e){$e.buttons===0||!Se($e)?je($e):Ie($e)}),at=hr(e,je);e.state.selectingText=at,we(n.wrapper.ownerDocument,"mousemove",Ye),we(n.wrapper.ownerDocument,"mouseup",at)}function Xl(e,t){var i=t.anchor,r=t.head,n=ct(e.doc,i.line);if(wt(i,r)==0&&i.sticky==r.sticky)return t;var S=Qe(n);if(!S)return t;var B=rt(S,i.ch,i.sticky),K=S[B];if(K.from!=i.ch&&K.to!=i.ch)return t;var Y=B+(K.from==i.ch==(K.level!=1)?0:1);if(Y==0||Y==S.length)return t;var Q;if(r.line!=i.line)Q=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var oe=rt(S,r.ch,r.sticky),le=oe-B||(r.ch-i.ch)*(K.level==1?-1:1);oe==Y-1||oe==Y?Q=le<0:Q=le>0}var be=S[Y+(Q?-1:0)],ye=Q==(be.level==1),_e=ye?be.from:be.to,Ie=ye?"after":"before";return i.ch==_e&&i.sticky==Ie?t:new Ht(new Ue(i.line,_e,Ie),r)}function bs(e,t,i,r){var n,S;if(t.touches)n=t.touches[0].clientX,S=t.touches[0].clientY;else try{n=t.clientX,S=t.clientY}catch(be){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var B=e.display,K=B.lineDiv.getBoundingClientRect();if(S>K.bottom||!de(e,i))return ae(t);S-=K.top-B.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Q=B.gutters.childNodes[Y];if(Q&&Q.getBoundingClientRect().right>=n){var oe=Ur(e.doc,S),le=e.display.gutterSpecs[Y];return Ae(e,i,e,oe,le.className,t),ae(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Ne(e,t,"contextmenu"))return;L||e.display.input.onContextMenu(t)}function Yl(e,t){return de(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,S,B){e.defaults[r]=n,S&&(t[r]=B?function(K,Y,Q){Q!=sn&&S(K,Y,Q)}:S)}e.defineOption=i,e.Init=sn,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){An(r),yn(r),Dr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var S=[],B=r.doc.first;r.doc.iter(function(Y){for(var Q=0;;){var oe=Y.text.indexOf(n,Q);if(oe==-1)break;Q=oe+n.length,S.push(Ue(B,oe))}B++});for(var K=S.length-1;K>=0;K--)rn(r.doc,n,S[K],Ue(S[K].line,S[K].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,S){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),S!=sn&&r.refresh()}),i("specialCharPlaceholder",Vt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",a?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!w),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,S){var B=ia(n),K=S!=sn&&ia(S);K&&K.detach&&K.detach(r,B),B.attach&&B.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Ql,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=ka(n,r.options.lineNumbers),wn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Ji(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Ji(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=ka(r.options.gutters,n),wn(r)},!0),i("firstLineNumber",1,wn,!0),i("lineNumberFormatter",function(r){return r},wn,!0),i("showCursorWhenSelecting",!1,bn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,bn,!0),i("singleCursorHeightPerLine",!0,bn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,An,!0),i("addModeClass",!1,An,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,An,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,S=t?we:it;S(e.display.scroller,"dragstart",n.start),S(e.display.scroller,"dragenter",n.enter),S(e.display.scroller,"dragover",n.over),S(e.display.scroller,"dragleave",n.leave),S(e.display.scroller,"drop",n.drop)}}function Ql(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(f(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Ea(e),Dr(e),yn(e),setTimeout(function(){return Ji(e)},100)}function $t(e,t){var i=this;if(!(this instanceof $t))return new $t(e,t);this.options=t=t?W(t):{},W(Ss,t,!1);var r=t.value;typeof r=="string"?r=new kr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new $t.inputStyles[t.inputStyle](this),S=this.display=new hl(e,r,n,t);S.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Co(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new ne,keySeq:null,specialChars:null},t.autofocus&&!a&&S.input.focus(),H&&F<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Jl(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!a||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var B in aa)aa.hasOwnProperty(B)&&aa[B](this,t[B],sn);Lo(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);Wi(this),M&&t.lineWrapping&&getComputedStyle(S.lineDiv).textRendering=="optimizelegibility"&&(S.lineDiv.style.textRendering="auto")}$t.defaults=Ss,$t.optionHandlers=aa;function Jl(e){var t=e.display;we(t.scroller,"mousedown",hr(e,vs)),H&&F<11?we(t.scroller,"dblclick",hr(e,function(Y){if(Ne(e,Y))return;var Q=Ni(e,Y);if(!Q||Ha(e,Y)||ui(e.display,Y))return;ee(Y);var oe=e.findWordAt(Q);Jn(e.doc,oe.anchor,oe.head)})):we(t.scroller,"dblclick",function(Y){return Ne(e,Y)||ee(Y)}),we(t.scroller,"contextmenu",function(Y){return xs(e,Y)}),we(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||xs(e,Y)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function S(Y){if(Y.touches.length!=1)return!1;var Q=Y.touches[0];return Q.radiusX<=1&&Q.radiusY<=1}function B(Y,Q){if(Q.left==null)return!0;var oe=Q.left-Y.left,le=Q.top-Y.top;return oe*oe+le*le>20*20}we(t.scroller,"touchstart",function(Y){if(!Ne(e,Y)&&!S(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(i);var Q=+new Date;t.activeTouch={start:Q,moved:!1,prev:Q-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),we(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),we(t.scroller,"touchend",function(Y){var Q=t.activeTouch;if(Q&&!ui(t,Y)&&Q.left!=null&&!Q.moved&&new Date-Q.start<300){var oe=e.coordsChar(t.activeTouch,"page"),le;!Q.prev||B(Q,Q.prev)?le=new Ht(oe,oe):!Q.prev.prev||B(Q,Q.prev.prev)?le=e.findWordAt(oe):le=new Ht(Ue(oe.line,0),s(e.doc,Ue(oe.line+1,0))),e.setSelection(le.anchor,le.head),e.focus(),ee(Y)}n()}),we(t.scroller,"touchcancel",n),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),we(t.scroller,"mousewheel",function(Y){return ko(e,Y)}),we(t.scroller,"DOMMouseScroll",function(Y){return ko(e,Y)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){Ne(e,Y)||ue(Y)},over:function(Y){Ne(e,Y)||(_l(e,Y),ue(Y))},start:function(Y){return Ll(e,Y)},drop:hr(e,Al),leave:function(Y){Ne(e,Y)||ns(e)}};var K=t.input.getField();we(K,"keyup",function(Y){return ms.call(e,Y)}),we(K,"keydown",hr(e,ps)),we(K,"keypress",hr(e,gs)),we(K,"focus",function(Y){return Ta(e,Y)}),we(K,"blur",function(Y){return Zi(e,Y)})}var Ga=[];$t.defineInitHook=function(e){return Ga.push(e)};function Un(e,t,i,r){var n=e.doc,S;i==null&&(i="add"),i=="smart"&&(n.mode.indent?S=ze(e,t).state:i="prev");var B=e.options.tabSize,K=ct(n,t),Y=q(K.text,null,B);K.stateAfter&&(K.stateAfter=null);var Q=K.text.match(/^\s*/)[0],oe;if(!r&&!/\S/.test(K.text))oe=0,i="not";else if(i=="smart"&&(oe=n.mode.indent(S,K.text.slice(Q.length),K.text),oe==De||oe>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?oe=q(ct(n,t-1).text,null,B):oe=0:i=="add"?oe=Y+e.options.indentUnit:i=="subtract"?oe=Y-e.options.indentUnit:typeof i=="number"&&(oe=Y+i),oe=Math.max(0,oe);var le="",be=0;if(e.options.indentWithTabs)for(var ye=Math.floor(oe/B);ye;--ye)be+=B,le+=" ";if(be<oe&&(le+=se(oe-be)),le!=Q)return rn(n,le,Ue(t,0),Ue(t,Q.length),"+input"),K.stateAfter=null,!0;for(var _e=0;_e<n.sel.ranges.length;_e++){var Ie=n.sel.ranges[_e];if(Ie.head.line==t&&Ie.head.ch<Q.length){var je=Ue(t,Q.length);Na(n,_e,new Ht(je,je));break}}}var Jr=null;function oa(e){Jr=e}function za(e,t,i,r,n){var S=e.doc;e.display.shift=!1,r||(r=S.sel);var B=+new Date-200,K=n=="paste"||e.state.pasteIncoming>B,Y=Tt(t),Q=null;if(K&&r.ranges.length>1)if(Jr&&Jr.text.join(`
|
|
`)==t){if(r.ranges.length%Jr.text.length==0){Q=[];for(var oe=0;oe<Jr.text.length;oe++)Q.push(S.splitLines(Jr.text[oe]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Q=Ve(Y,function(Ye){return[Ye]}));for(var le=e.curOp.updateInput,be=r.ranges.length-1;be>=0;be--){var ye=r.ranges[be],_e=ye.from(),Ie=ye.to();ye.empty()&&(i&&i>0?_e=Ue(_e.line,_e.ch-i):e.state.overwrite&&!K?Ie=Ue(Ie.line,Math.min(ct(S,Ie.line).text.length,Ie.ch+ke(Y).length)):K&&Jr&&Jr.lineWise&&Jr.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(_e=Ie=Ue(_e.line,0)));var je={from:_e,to:Ie,text:Q?Q[be%Q.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};tn(e.doc,je),mr(e,"inputRead",e,je)}t&&!K&&Cs(e,t),Qi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=le),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ts(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Nr(t,function(){return za(t,i,0,null,"paste")}),!0}function Cs(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var S=e.getModeAt(n.head),B=!1;if(S.electricChars){for(var K=0;K<S.electricChars.length;K++)if(t.indexOf(S.electricChars.charAt(K))>-1){B=Un(e,n.head.line,"smart");break}}else S.electricInput&&(S.electricInput.test(ct(e.doc,n.head.line).text.slice(0,n.head.ch))&&(B=Un(e,n.head.line,"smart")));B&&mr(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,S={anchor:Ue(n,0),head:Ue(n+1,0)};i.push(S),t.push(e.getRange(S.anchor,S.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),y&&(e.style.border="1px solid black"),As(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var S=this.options,B=S[r];if(S[r]==n&&r!="mode")return;S[r]=n,t.hasOwnProperty(r)&&hr(this,t[r])(this,n,B),Ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,S=0;S<n.length;++S)if(n[S]==r||n[S].name==r)return n.splice(S,1),!0},addOverlay:wr(function(r,n){var S=r.token?r:e.getMode(this.options,r);if(S.startState)throw new Error("Overlays may not be stateful.");He(this.state.overlays,{mode:S,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(B){return B.priority}),this.state.modeGen++,Dr(this)}),removeOverlay:wr(function(r){for(var n=this.state.overlays,S=0;S<n.length;++S){var B=n[S].modeSpec;if(B==r||typeof r=="string"&&B.name==r){n.splice(S,1),this.state.modeGen++,Dr(this);return}}}),indentLine:wr(function(r,n,S){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Un(this,r,n,S)}),indentSelection:wr(function(r){for(var n=this.doc.sel.ranges,S=-1,B=0;B<n.length;B++){var K=n[B];if(K.empty())K.head.line>S&&(Un(this,K.head.line,r,!0),S=K.head.line,B==this.doc.sel.primIndex&&Qi(this));else{var Y=K.from(),Q=K.to(),oe=Math.max(S,Y.line);S=Math.min(this.lastLine(),Q.line-(Q.ch?0:1))+1;for(var le=oe;le<S;++le)Un(this,le,r);var be=this.doc.sel.ranges;Y.ch==0&&n.length==be.length&&be[B].from().ch>0&&Na(this.doc,B,new Ht(Y,be[B].to()),xe)}}}),getTokenAt:function(r,n){return Yt(this,r,n)},getLineTokens:function(r,n){return Yt(this,Ue(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Re(this,ct(this.doc,r.line)),S=0,B=(n.length-1)/2,K=r.ch,Y;if(K==0)Y=n[2];else for(;;){var Q=S+B>>1;if((Q?n[Q*2-1]:0)>=K)B=Q;else if(n[Q*2+1]<K)S=Q+1;else{Y=n[Q*2+2];break}}var oe=Y?Y.indexOf("overlay "):-1;return oe<0?Y:oe==0?null:Y.slice(0,oe-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var S=[];if(!i.hasOwnProperty(n))return S;var B=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")B[K[n]]&&S.push(B[K[n]]);else if(K[n])for(var Y=0;Y<K[n].length;Y++){var Q=B[K[n][Y]];Q&&S.push(Q)}else K.helperType&&B[K.helperType]?S.push(B[K.helperType]):B[K.name]&&S.push(B[K.name]);for(var oe=0;oe<B._global.length;oe++){var le=B._global[oe];le.pred(K,this)&&ce(S,le.val)==-1&&S.push(le.val)}return S},getStateAfter:function(r,n){var S=this.doc;return r=j(S,r==null?S.first+S.size-1:r),ze(this,r+1,n).state},cursorCoords:function(r,n){var S,B=this.doc.sel.primary();return r==null?S=B.head:typeof r=="object"?S=s(this.doc,r):S=r?B.from():B.to(),Zr(this,S,n||"page")},charCoords:function(r,n){return ma(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,Ur(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,S){var B=!1,K;if(typeof r=="number"){var Y=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>Y&&(r=Y,B=!0),K=ct(this.doc,r)}else K=r;return Hn(this,K,{top:0,left:0},n||"page",S||B).top+(B?this.doc.height-$r(K):0)},defaultTextHeight:function(){return Yi(this.display)},defaultCharWidth:function(){return $i(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,S,B,K){var Y=this.display;r=Zr(this,s(this.doc,r));var Q=r.bottom,oe=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),Y.sizer.appendChild(n),B=="over")Q=r.top;else if(B=="above"||B=="near"){var le=Math.max(Y.wrapper.clientHeight,this.doc.height),be=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(B=="above"||r.bottom+n.offsetHeight>le)&&r.top>n.offsetHeight?Q=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=le&&(Q=r.bottom),oe+n.offsetWidth>be&&(oe=be-n.offsetWidth)}n.style.top=Q+"px",n.style.left=n.style.right="",K=="right"?(oe=Y.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?oe=0:K=="middle"&&(oe=(Y.sizer.clientWidth-n.offsetWidth)/2),n.style.left=oe+"px"),S&&Zs(this,{left:oe,top:Q,right:oe+n.offsetWidth,bottom:Q+n.offsetHeight})},triggerOnKeyDown:wr(ps),triggerOnKeyPress:wr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:wr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:wr(function(r){Cs(this,r)}),findPosH:function(r,n,S,B){var K=1;n<0&&(K=-1,n=-n);for(var Y=s(this.doc,r),Q=0;Q<n&&!(Y=Ka(this.doc,Y,K,S,B),Y.hitSide);++Q);return Y},moveH:wr(function(r,n){var S=this;this.extendSelectionsBy(function(B){return S.display.shift||S.doc.extend||B.empty()?Ka(S.doc,B.head,r,n,S.options.rtlMoveVisually):r<0?B.from():B.to()},Te)}),deleteH:wr(function(r,n){var S=this.doc.sel,B=this.doc;S.somethingSelected()?B.replaceSelection("",null,"+delete"):on(this,function(K){var Y=Ka(B,K.head,r,n,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,n,S,B){var K=1,Y=B;n<0&&(K=-1,n=-n);for(var Q=s(this.doc,r),oe=0;oe<n;++oe){var le=Zr(this,Q,"div");if(Y==null?Y=le.left:le.left=Y,Q=_s(this,le,K,S),Q.hitSide)break}return Q},moveV:wr(function(r,n){var S=this,B=this.doc,K=[],Y=!this.display.shift&&!B.extend&&B.sel.somethingSelected();if(B.extendSelectionsBy(function(oe){if(Y)return r<0?oe.from():oe.to();var le=Zr(S,oe.head,"div");oe.goalColumn!=null&&(le.left=oe.goalColumn),K.push(le.left);var be=_s(S,le,r,n);return n=="page"&&oe==B.sel.primary()&&wa(S,ma(S,be,"div").top-le.top),be},Te),K.length)for(var Q=0;Q<B.sel.ranges.length;Q++)B.sel.ranges[Q].goalColumn=K[Q]}),findWordAt:function(r){var n=this.doc,S=ct(n,r.line).text,B=r.ch,K=r.ch;if(S){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==S.length)&&B?--B:++K;for(var Q=S.charAt(B),oe=We(Q,Y)?function(le){return We(le,Y)}:/\s/.test(Q)?function(le){return/\s/.test(le)}:function(le){return!/\s/.test(le)&&!We(le)};B>0&&oe(S.charAt(B-1));)--B;for(;K<S.length&&oe(S.charAt(K));)++K}return new Ht(Ue(r.line,B),Ue(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):f(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==I()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:wr(function(r,n){xn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ii(this)-this.display.barHeight,width:r.scrollWidth-ii(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Mi(this)}},scrollIntoView:wr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Ue(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Qs(this,r):xo(this,r.from,r.to,r.margin)}),setSize:wr(function(r,n){var S=this,B=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=B(r)),n!=null&&(this.display.wrapper.style.height=B(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(Y){if(Y.widgets){for(var Q=0;Q<Y.widgets.length;Q++)if(Y.widgets[Q].noHScroll){Ti(S,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(r){return Nr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:wr(function(){var r=this.display.cachedTextHeight;Dr(this),this.curOp.forceUpdate=!0,yn(this),xn(this,this.doc.scrollLeft,this.doc.scrollTop),_a(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Ea(this),Ae(this,"refresh",this)}),swapDoc:wr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yn(this),this.display.input.reset(),xn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,mr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},fe(e),e.registerHelper=function(r,n,S){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=S},e.registerGlobalHelper=function(r,n,S,B){e.registerHelper(r,n,B),i[r]._global.push({pred:S,val:B})}}function Ka(e,t,i,r,n){var S=t,B=i,K=ct(e,t.line),Y=n&&e.direction=="rtl"?-i:i;function Q(){var at=t.line+Y;return at<e.first||at>=e.first+e.size?!1:(t=new Ue(at,t.ch,t.sticky),K=ct(e,at))}function oe(at){var $e;if(r=="codepoint"){var st=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(st)?$e=null:$e=new Ue(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(st>=55296&&st<56320?2:1))),-i)}else n?$e=Ml(e.cm,K,t,i):$e=Fa(K,t,i);if($e==null)if(!at&&Q())t=Ua(n,e.cm,K,t.line,Y);else return!1;else t=$e;return!0}if(r=="char"||r=="codepoint")oe();else if(r=="column")oe(!0);else if(r=="word"||r=="group")for(var le=null,be=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),_e=!0;!(i<0&&!oe(!_e));_e=!1){var Ie=K.text.charAt(t.ch)||`
|
|
`,je=We(Ie,ye)?"w":be&&Ie==`
|
|
`?"n":!be||/\s/.test(Ie)?null:"p";if(be&&!_e&&!je&&(je="s"),le&&le!=je){i<0&&(i=1,oe(),t.sticky="after");break}if(je&&(le=je),i>0&&!oe(!_e))break}var Ye=ea(e,t,S,B,!0);return pi(S,Ye)&&(Ye.hitSide=!0),Ye}function _s(e,t,i,r){var n=e.doc,S=t.left,B;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*Yi(e.display),3);B=(i>0?t.bottom:t.top)+i*Y}else r=="line"&&(B=i>0?t.bottom+3:t.top-3);for(var Q;!(Q=va(e,S,B),!Q.outside);){if(i<0?B<=0:B>=n.height){Q.hitSide=!0;break}B+=i*5}return Q}var zt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ne,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};zt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function S(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}we(n,"paste",function(K){if(!S(K)||Ne(r,K)||Ts(K,r))return;F<=11&&setTimeout(hr(r,function(){return t.updateFromDOM()}),20)}),we(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),we(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),we(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(n,"touchstart",function(){return i.forceCompositionEnd()}),we(n,"input",function(){t.composing||t.readFromDOMSoon()});function B(K){if(!S(K)||Ne(r,K))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var Y=ws(r);oa({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,xe),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var Q=Jr.text.join(`
|
|
`);if(K.clipboardData.setData("Text",Q),K.clipboardData.getData("Text")==Q){K.preventDefault();return}}var oe=Ls(),le=oe.firstChild;r.display.lineSpace.insertBefore(oe,r.display.lineSpace.firstChild),le.value=Jr.text.join(`
|
|
`);var be=document.activeElement;J(le),setTimeout(function(){r.display.lineSpace.removeChild(oe),be.focus(),be==n&&i.showPrimarySelection()},50)}we(n,"copy",B),we(n,"cut",B)},zt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},zt.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},zt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},zt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},zt.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line<t.display.viewFrom){e.removeAllRanges();return}var S=sa(t,e.anchorNode,e.anchorOffset),B=sa(t,e.focusNode,e.focusOffset);if(S&&!S.bad&&B&&!B.bad&&wt(vi(S,B),r)==0&&wt(gi(S,B),n)==0)return;var K=t.display.view,Y=r.line>=t.display.viewFrom&&Ds(t,r)||{node:K[0].measure.map[2],offset:0},Q=n.line<t.display.viewTo&&Ds(t,n);if(!Q){var oe=K[K.length-1].measure,le=oe.maps?oe.maps[oe.maps.length-1]:oe.map;Q={node:le[le.length-1],offset:le[le.length-2]-le[le.length-3]}}if(!Y||!Q){e.removeAllRanges();return}var be=e.rangeCount&&e.getRangeAt(0),ye;try{ye=v(Y.node,Y.offset,Q.offset,Q.node)}catch(_e){}ye&&(!D&&t.state.focused?(e.collapse(Y.node,Y.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),be&&e.anchorNode==null?e.addRange(be):D&&this.startGracePeriod()),this.rememberSelection()},zt.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)},zt.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},zt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},zt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return T(this.div,t)},zt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},zt.prototype.blur=function(){this.div.blur()},zt.prototype.getField=function(){return this.div},zt.prototype.supportsTouch=function(){return!0},zt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Nr(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)},zt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},zt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&b&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Nr(t,function(){Sr(t.doc,wi(i,r),xe),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},zt.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,i=e.doc.sel.primary(),r=i.from(),n=i.to();if(r.ch==0&&r.line>e.firstLine()&&(r=Ue(r.line-1,ct(e.doc,r.line-1).length)),n.ch==ct(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Ue(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var S,B,K;r.line==t.viewFrom||(S=Bi(e,r.line))==0?(B=Ot(t.view[0].line),K=t.view[0].node):(B=Ot(t.view[S].line),K=t.view[S-1].node.nextSibling);var Y=Bi(e,n.line),Q,oe;if(Y==t.view.length-1?(Q=t.viewTo-1,oe=t.lineDiv.lastChild):(Q=Ot(t.view[Y+1].line)-1,oe=t.view[Y+1].node.previousSibling),!K)return!1;for(var le=e.doc.splitLines(tu(e,K,oe,B,Q)),be=Gr(e.doc,Ue(B,0),Ue(Q,ct(e.doc,Q).text.length));le.length>1&&be.length>1;)if(ke(le)==ke(be))le.pop(),be.pop(),Q--;else if(le[0]==be[0])le.shift(),be.shift(),B++;else break;for(var ye=0,_e=0,Ie=le[0],je=be[0],Ye=Math.min(Ie.length,je.length);ye<Ye&&Ie.charCodeAt(ye)==je.charCodeAt(ye);)++ye;for(var at=ke(le),$e=ke(be),st=Math.min(at.length-(le.length==1?ye:0),$e.length-(be.length==1?ye:0));_e<st&&at.charCodeAt(at.length-_e-1)==$e.charCodeAt($e.length-_e-1);)++_e;if(le.length==1&&be.length==1&&B==r.line)for(;ye&&ye>r.ch&&at.charCodeAt(at.length-_e-1)==$e.charCodeAt($e.length-_e-1);)ye--,_e++;le[le.length-1]=at.slice(0,at.length-_e).replace(/^\u200b+/,""),le[0]=le[0].slice(ye).replace(/\u200b+$/,"");var St=Ue(B,ye),yt=Ue(Q,be.length?ke(be).length-_e:0);if(le.length>1||le[0]||wt(St,yt))return rn(e.doc,le,St,yt,"+input"),!0},zt.prototype.ensurePolled=function(){this.forceCompositionEnd()},zt.prototype.reset=function(){this.forceCompositionEnd()},zt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},zt.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)},zt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Nr(this.cm,function(){return Dr(e.cm)})},zt.prototype.setUneditable=function(e){e.contentEditable="false"},zt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||hr(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},zt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},zt.prototype.onContextMenu=function(){},zt.prototype.resetPosition=function(){},zt.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=ct(e.doc,t.line),n=eo(i,r,t.line),S=Qe(r,e.doc.direction),B="left";if(S){var K=rt(S,t.ch);B=K%2?"right":"left"}var Y=io(n.map,t.ch,B);return Y.offset=Y.collapse=="right"?Y.end:Y.start,Y}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var S="",B=!1,K=e.doc.lineSeparator(),Y=!1;function Q(ye){return function(_e){return _e.id==ye}}function oe(){B&&(S+=K,Y&&(S+=K),B=Y=!1)}function le(ye){ye&&(oe(),S+=ye)}function be(ye){if(ye.nodeType==1){var _e=ye.getAttribute("cm-text");if(_e){le(_e);return}var Ie=ye.getAttribute("cm-marker"),je;if(Ie){var Ye=e.findMarks(Ue(r,0),Ue(n+1,0),Q(+Ie));Ye.length&&(je=Ye[0].find(0))&&le(Gr(e.doc,je.from,je.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var at=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;at&&oe();for(var $e=0;$e<ye.childNodes.length;$e++)be(ye.childNodes[$e]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),at&&(B=!0)}else ye.nodeType==3&&le(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(be(t),t==i);)t=t.nextSibling,Y=!1;return S}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(Ue(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var n=0;n<e.display.view.length;n++){var S=e.display.view[n];if(S.node==r)return ru(S,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!T(r,t))return ln(Ue(Ot(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var S=e.rest?ke(e.rest):e.line;return ln(Ue(Ot(S),S.text.length),n)}var B=t.nodeType==3?t:null,K=t;for(!B&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(B=t.firstChild,i&&(i=B.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,Q=Y.maps;function oe(je,Ye,at){for(var $e=-1;$e<(Q?Q.length:0);$e++)for(var st=$e<0?Y.map:Q[$e],St=0;St<st.length;St+=3){var yt=st[St+2];if(yt==je||yt==Ye){var kt=Ot($e<0?e.line:e.rest[$e]),Xt=st[St]+at;return(at<0||yt!=je)&&(Xt=st[St+(at?1:0)]),Ue(kt,Xt)}}}var le=oe(B,K,i);if(le)return ln(le,n);for(var be=K.nextSibling,ye=B?B.nodeValue.length-i:0;be;be=be.nextSibling){if(le=oe(be,be.firstChild,0),le)return ln(Ue(le.line,le.ch-ye),n);ye+=be.textContent.length}for(var _e=K.previousSibling,Ie=i;_e;_e=_e.previousSibling){if(le=oe(_e,_e.firstChild,-1),le)return ln(Ue(le.line,le.ch+Ie),n);Ie+=_e.textContent.length}}var er=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ne,this.hasSelection=!1,this.composing=null};er.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),y&&(n.style.width="0px"),we(n,"input",function(){H&&F>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),we(n,"paste",function(B){if(Ne(r,B)||Ts(B,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(B){if(Ne(r,B))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);oa({lineWise:!0,text:K.text}),B.type=="cut"?r.setSelections(K.ranges,null,xe):(i.prevInput="",n.value=K.text.join(`
|
|
`),J(n))}else return;B.type=="cut"&&(r.state.cutIncoming=+new Date)}we(n,"cut",S),we(n,"copy",S),we(e.scroller,"paste",function(B){if(ui(e,B)||Ne(r,B))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=B.clipboardData,n.dispatchEvent(K)}),we(e.lineSpace,"selectstart",function(B){ui(e,B)||ee(B)}),we(n,"compositionstart",function(){var B=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:B,range:r.markText(B,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},er.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},er.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},er.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Zr(e,i.sel.primary().head,"div"),S=t.wrapper.getBoundingClientRect(),B=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+B.top-S.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+B.left-S.left))}return r},er.prototype.showSelection=function(e){var t=this.cm,i=t.display;d(i.cursorDiv,e.cursors),d(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},er.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&J(this.textarea),H&&F>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",H&&F>=9&&(this.hasSelection=null))},er.prototype.getField=function(){return this.textarea},er.prototype.supportsTouch=function(){return!1},er.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!a||I()!=this.textarea))try{this.textarea.focus()}catch(e){}},er.prototype.blur=function(){this.textarea.blur()},er.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},er.prototype.receivedFocus=function(){this.slowPoll()},er.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()})},er.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},er.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ut(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(H&&F>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var S=n.charCodeAt(0);if(S==8203&&!r&&(r="\u200B"),S==8666)return this.reset(),this.cm.execCommand("undo")}for(var B=0,K=Math.min(r.length,n.length);B<K&&r.charCodeAt(B)==n.charCodeAt(B);)++B;return Nr(t,function(){za(t,n.slice(B),r.length-B,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
|
|
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},er.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},er.prototype.onKeyPress=function(){H&&F>=9&&(this.hasSelection=null),this.fastPoll()},er.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var S=Ni(i,e),B=r.scroller.scrollTop;if(!S||C)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(S)==-1&&hr(i,Sr)(i.doc,wi(S),xe);var Y=n.style.cssText,Q=t.wrapper.style.cssText,oe=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-oe.top-5)+"px; left: "+(e.clientX-oe.left-5)+`px;
|
|
z-index: 1000; background: `+(H?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var le;M&&(le=window.scrollY),r.input.focus(),M&&window.scrollTo(null,le),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function be(){if(n.selectionStart!=null){var Ie=i.somethingSelected(),je="\u200B"+(Ie?n.value:"");n.value="\u21DA",n.value=je,t.prevInput=Ie?"":"\u200B",n.selectionStart=1,n.selectionEnd=je.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Q,n.style.cssText=Y,H&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),n.selectionStart!=null){(!H||H&&F<9)&&be();var Ie=0,je=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?hr(i,Xo)(i):Ie++<10?r.detectingSelectAll=setTimeout(je,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(je,200)}}if(H&&F>=9&&be(),L){ue(e);var _e=function(){it(window,"mouseup",_e),setTimeout(ye,20)};we(window,"mouseup",_e)}else setTimeout(ye,50)},er.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},er.prototype.setUneditable=function(){},er.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?W(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=I();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(we(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var S=e.form;n=S.submit;try{var B=S.submit=function(){r(),S.submit=n,S.submit(),S.submit=B}}catch(Y){}}t.finishInit=function(Y){Y.save=r,Y.getTextArea=function(){return e},Y.toTextArea=function(){Y.toTextArea=isNaN,r(),e.parentNode.removeChild(Y.getWrapperElement()),e.style.display="",e.form&&(it(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=$t(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function nu(e){e.off=it,e.on=we,e.wheelEventPixels=dl,e.Doc=kr,e.splitLines=Tt,e.countColumn=q,e.findColumn=Ee,e.isWordChar=Me,e.Pass=De,e.signal=Ae,e.Line=Pi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Ue,e.cmpPos=wt,e.modes=Dt,e.mimeModes=mt,e.resolveMode=vt,e.getMode=vr,e.modeExtensions=sr,e.extendMode=Kt,e.copyState=Fr,e.startState=qr,e.innerMode=ci,e.commands=In,e.keyMap=hi,e.keyName=us,e.isModifierKey=ss,e.lookupKey=an,e.normalizeKeyMap=Pl,e.StringStream=Ft,e.SharedTextMarker=On,e.TextMarker=_i,e.LineWidget=Rn,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=ue,e.addClass=G,e.contains=T,e.rmClass=f,e.keyNames=Di}$l($t),ql($t);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in kr.prototype)kr.prototype.hasOwnProperty(la)&&ce(au,la)<0&&($t.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(kr.prototype[la]));return fe(kr),$t.inputStyles={textarea:er,contenteditable:zt},$t.defineMode=function(e){!$t.defaults.mode&&e!="null"&&($t.defaults.mode=e),or.apply(this,arguments)},$t.defineMIME=Zt,$t.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),$t.defineMIME("text/plain","null"),$t.defineExtension=function(e,t){$t.prototype[e]=t},$t.defineDocExtension=function(e,t){kr.prototype[e]=t},$t.fromTextArea=iu,nu($t),$t.version="5.58.2",$t})},Y1PL:function(Et,nt,re){"use strict";re.r(nt),re.d(nt,"ResizableTextArea",function(){return ce});var ie=re("wx14"),$=re("1OyB"),D=re("vuIU"),V=re("Ji7U"),N=re("LK+K"),P=re("q1tI"),H=re("VTBJ"),F=re("rePB"),M=re("Zm9Q"),O=re("Kwbf"),b=re("c+Xe"),C=re("m+aA"),k=re("bdgK"),_=new Map;function A(xe){xe.forEach(function(Ce){var Te,Ee=Ce.target;(Te=_.get(Ee))===null||Te===void 0||Te.forEach(function(ge){return ge(Ee)})})}var y=new k.default(A),u=null,a=null;function l(xe,Ce){_.has(xe)||(_.set(xe,new Set),y.observe(xe)),_.get(xe).add(Ce)}function h(xe,Ce){_.has(xe)&&(_.get(xe).delete(Ce),_.get(xe).size||(y.unobserve(xe),_.delete(xe)))}var w=function(xe){Object(V.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(){return Object($.a)(this,Te),Ce.apply(this,arguments)}return Object(D.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(P.Component),g=P.createContext(null);function m(xe){var Ce=xe.children,Te=xe.onBatchResize,Ee=P.useRef(0),ge=P.useRef([]),se=P.useContext(g),ke=P.useCallback(function(Ve,He,tt){Ee.current+=1;var Ke=Ee.current;ge.current.push({size:Ve,element:He,data:tt}),Promise.resolve().then(function(){Ke===Ee.current&&(Te==null||Te(ge.current),ge.current=[])}),se==null||se(Ve,He,tt)},[Te,se]);return P.createElement(g.Provider,{value:ke},Ce)}function L(xe){var Ce=xe.children,Te=xe.disabled,Ee=P.useRef(null),ge=P.useRef(null),se=P.useContext(g),ke=P.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ve=P.isValidElement(Ce)&&Object(b.c)(Ce),He=Ve?Ce.ref:null,tt=P.useMemo(function(){return Object(b.a)(He,Ee)},[He,Ee]),Ke=P.useRef(xe);Ke.current=xe;var Le=P.useCallback(function(Me){var We=Ke.current,Xe=We.onResize,Ge=We.data,Fe=Me.getBoundingClientRect(),Be=Fe.width,ot=Fe.height,et=Me.offsetWidth,Ze=Me.offsetHeight,rt=Math.floor(Be),ht=Math.floor(ot);if(ke.current.width!==rt||ke.current.height!==ht||ke.current.offsetWidth!==et||ke.current.offsetHeight!==Ze){var Qe={width:rt,height:ht,offsetWidth:et,offsetHeight:Ze};ke.current=Qe;var Je=et===Math.round(Be)?Be:et,we=Ze===Math.round(ot)?ot:Ze,lt=Object(H.a)(Object(H.a)({},Qe),{},{offsetWidth:Je,offsetHeight:we});se==null||se(lt,Me,Ge),Xe&&Promise.resolve().then(function(){Xe(lt,Me)})}},[]);return P.useEffect(function(){var Me=Object(C.a)(Ee.current)||Object(C.a)(ge.current);return Me&&!Te&&l(Me,Le),function(){return h(Me,Le)}},[Ee.current,Te]),P.createElement(w,{ref:ge},Ve?P.cloneElement(Ce,{ref:tt}):Ce)}var x="rc-observer-key";function f(xe){var Ce=xe.children,Te=Object(M.a)(Ce);return Te.map(function(Ee,ge){var se=(Ee==null?void 0:Ee.key)||"".concat(x,"-").concat(ge);return P.createElement(L,Object(ie.a)({},xe,{key:se}),Ee)})}f.Collection=m;var p=f,d=re("bT9E"),o=re("TSYQ"),E=re.n(o),v=`
|
|
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
|
|
`,T=["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"],I={},G;function X(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=xe.getAttribute("id")||xe.getAttribute("data-reactid")||xe.getAttribute("name");if(Ce&&I[Te])return I[Te];var Ee=window.getComputedStyle(xe),ge=Ee.getPropertyValue("box-sizing")||Ee.getPropertyValue("-moz-box-sizing")||Ee.getPropertyValue("-webkit-box-sizing"),se=parseFloat(Ee.getPropertyValue("padding-bottom"))+parseFloat(Ee.getPropertyValue("padding-top")),ke=parseFloat(Ee.getPropertyValue("border-bottom-width"))+parseFloat(Ee.getPropertyValue("border-top-width")),Ve=T.map(function(tt){return"".concat(tt,":").concat(Ee.getPropertyValue(tt))}).join(";"),He={sizingStyle:Ve,paddingSize:se,borderSize:ke,boxSizing:ge};return Ce&&Te&&(I[Te]=He),He}function J(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ee=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;G||(G=document.createElement("textarea"),G.setAttribute("tab-index","-1"),G.setAttribute("aria-hidden","true"),document.body.appendChild(G)),xe.getAttribute("wrap")?G.setAttribute("wrap",xe.getAttribute("wrap")):G.removeAttribute("wrap");var ge=X(xe,Ce),se=ge.paddingSize,ke=ge.borderSize,Ve=ge.boxSizing,He=ge.sizingStyle;G.setAttribute("style","".concat(He,";").concat(v)),G.value=xe.value||xe.placeholder||"";var tt=Number.MIN_SAFE_INTEGER,Ke=Number.MAX_SAFE_INTEGER,Le=G.scrollHeight,Me;if(Ve==="border-box"?Le+=ke:Ve==="content-box"&&(Le-=se),Te!==null||Ee!==null){G.value=" ";var We=G.scrollHeight-se;Te!==null&&(tt=We*Te,Ve==="border-box"&&(tt=tt+se+ke),Le=Math.max(tt,Le)),Ee!==null&&(Ke=We*Ee,Ve==="border-box"&&(Ke=Ke+se+ke),Me=Le>Ke?"":"hidden",Le=Math.min(Ke,Le))}return{height:Le,minHeight:tt,maxHeight:Ke,overflowY:Me,resize:"none"}}var z=re("Gytx"),W=re.n(z),q;(function(xe){xe[xe.NONE=0]="NONE",xe[xe.RESIZING=1]="RESIZING",xe[xe.RESIZED=2]="RESIZED"})(q||(q={}));var ne=function(xe){Object(V.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(Ee){var ge;return Object($.a)(this,Te),ge=Ce.call(this,Ee),ge.nextFrameActionId=void 0,ge.resizeFrameId=void 0,ge.textArea=void 0,ge.saveTextArea=function(se){ge.textArea=se},ge.handleResize=function(se){var ke=ge.state.resizeStatus,Ve=ge.props,He=Ve.autoSize,tt=Ve.onResize;if(ke!==q.NONE)return;typeof tt=="function"&&tt(se),He&&ge.resizeOnNextFrame()},ge.resizeOnNextFrame=function(){cancelAnimationFrame(ge.nextFrameActionId),ge.nextFrameActionId=requestAnimationFrame(ge.resizeTextarea)},ge.resizeTextarea=function(){var se=ge.props.autoSize;if(!se||!ge.textArea)return;var ke=se.minRows,Ve=se.maxRows,He=J(ge.textArea,!1,ke,Ve);ge.setState({textareaStyles:He,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(ge.resizeFrameId),ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:q.RESIZED},function(){ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:q.NONE}),ge.fixFirefoxAutoScroll()})})})})},ge.renderTextArea=function(){var se=ge.props,ke=se.prefixCls,Ve=ke===void 0?"rc-textarea":ke,He=se.autoSize,tt=se.onResize,Ke=se.className,Le=se.disabled,Me=ge.state,We=Me.textareaStyles,Xe=Me.resizeStatus,Ge=Object(d.a)(ge.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Fe=E()(Ve,Ke,Object(F.a)({},"".concat(Ve,"-disabled"),Le));"value"in Ge&&(Ge.value=Ge.value||"");var Be=Object(H.a)(Object(H.a)(Object(H.a)({},ge.props.style),We),Xe===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return P.createElement(p,{onResize:ge.handleResize,disabled:!(He||tt)},P.createElement("textarea",Object(ie.a)({},Ge,{className:Fe,style:Be,ref:ge.saveTextArea})))},ge.state={textareaStyles:{},resizeStatus:q.NONE},ge}return Object(D.a)(Te,[{key:"componentDidUpdate",value:function(ge){(ge.value!==this.props.value||!W()(ge.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ge=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(ge,se)}}catch(ke){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(P.Component),ce=ne,ve=function(xe){Object(V.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(Ee){var ge;Object($.a)(this,Te),ge=Ce.call(this,Ee),ge.resizableTextArea=void 0,ge.focus=function(){ge.resizableTextArea.textArea.focus()},ge.saveTextArea=function(ke){ge.resizableTextArea=ke},ge.handleChange=function(ke){var Ve=ge.props.onChange;ge.setValue(ke.target.value,function(){ge.resizableTextArea.resizeTextarea()}),Ve&&Ve(ke)},ge.handleKeyDown=function(ke){var Ve=ge.props,He=Ve.onPressEnter,tt=Ve.onKeyDown;ke.keyCode===13&&He&&He(ke),tt&&tt(ke)};var se=typeof Ee.value=="undefined"||Ee.value===null?Ee.defaultValue:Ee.value;return ge.state={value:se},ge}return Object(D.a)(Te,[{key:"setValue",value:function(ge,se){"value"in this.props||this.setState({value:ge},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return P.createElement(ce,Object(ie.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ge){return"value"in ge?{value:ge.value}:null}}]),Te}(P.Component),De=nt.default=ve},ZpRC:function(Et,nt,re){"use strict";function ie(b){return typeof b=="object"&&b!=null&&b.nodeType===1}function $(b,C){return(!C||b!=="hidden")&&b!=="visible"&&b!=="clip"}function D(b,C){if(b.clientHeight<b.scrollHeight||b.clientWidth<b.scrollWidth){var k=getComputedStyle(b,null);return $(k.overflowY,C)||$(k.overflowX,C)||function(_){var A=function(y){if(!y.ownerDocument||!y.ownerDocument.defaultView)return null;try{return y.ownerDocument.defaultView.frameElement}catch(u){return null}}(_);return!!A&&(A.clientHeight<_.scrollHeight||A.clientWidth<_.scrollWidth)}(b)}return!1}function V(b,C,k,_,A,y,u,a){return y<b&&u>C||y>b&&u<C?0:y<=b&&a<=k||u>=C&&a>=k?y-b-_:u>C&&a<k||y<b&&a>k?u-C+A:0}var N=function(b,C){var k=window,_=C.scrollMode,A=C.block,y=C.inline,u=C.boundary,a=C.skipOverflowHiddenElements,l=typeof u=="function"?u:function(We){return We!==u};if(!ie(b))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,w=[],g=b;ie(g)&&l(g);){if((g=g.parentElement)===h){w.push(g);break}g!=null&&g===document.body&&D(g)&&!D(document.documentElement)||g!=null&&D(g,a)&&w.push(g)}for(var m=k.visualViewport?k.visualViewport.width:innerWidth,L=k.visualViewport?k.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=b.getBoundingClientRect(),d=p.height,o=p.width,E=p.top,v=p.right,T=p.bottom,I=p.left,G=A==="start"||A==="nearest"?E:A==="end"?T:E+d/2,X=y==="center"?I+o/2:y==="end"?v:I,J=[],z=0;z<w.length;z++){var W=w[z],q=W.getBoundingClientRect(),ne=q.height,ce=q.width,ve=q.top,De=q.right,xe=q.bottom,Ce=q.left;if(_==="if-needed"&&E>=0&&I>=0&&T<=L&&v<=m&&E>=ve&&T<=xe&&I>=Ce&&v<=De)return J;var Te=getComputedStyle(W),Ee=parseInt(Te.borderLeftWidth,10),ge=parseInt(Te.borderTopWidth,10),se=parseInt(Te.borderRightWidth,10),ke=parseInt(Te.borderBottomWidth,10),Ve=0,He=0,tt="offsetWidth"in W?W.offsetWidth-W.clientWidth-Ee-se:0,Ke="offsetHeight"in W?W.offsetHeight-W.clientHeight-ge-ke:0;if(h===W)Ve=A==="start"?G:A==="end"?G-L:A==="nearest"?V(f,f+L,L,ge,ke,f+G,f+G+d,d):G-L/2,He=y==="start"?X:y==="center"?X-m/2:y==="end"?X-m:V(x,x+m,m,Ee,se,x+X,x+X+o,o),Ve=Math.max(0,Ve+f),He=Math.max(0,He+x);else{Ve=A==="start"?G-ve-ge:A==="end"?G-xe+ke+Ke:A==="nearest"?V(ve,xe,ne,ge,ke+Ke,G,G+d,d):G-(ve+ne/2)+Ke/2,He=y==="start"?X-Ce-Ee:y==="center"?X-(Ce+ce/2)+tt/2:y==="end"?X-De+se+tt:V(Ce,De,ce,Ee,se+tt,X,X+o,o);var Le=W.scrollLeft,Me=W.scrollTop;G+=Me-(Ve=Math.max(0,Math.min(Me+Ve,W.scrollHeight-ne+Ke))),X+=Le-(He=Math.max(0,Math.min(Le+He,W.scrollWidth-ce+tt)))}J.push({el:W,top:Ve,left:He})}return J};function P(b){return b===Object(b)&&Object.keys(b).length!==0}function H(b,C){C===void 0&&(C="auto");var k="scrollBehavior"in document.body.style;b.forEach(function(_){var A=_.el,y=_.top,u=_.left;A.scroll&&k?A.scroll({top:y,left:u,behavior:C}):(A.scrollTop=y,A.scrollLeft=u)})}function F(b){return b===!1?{block:"end",inline:"nearest"}:P(b)?b:{block:"start",inline:"nearest"}}function M(b,C){var k=!b.ownerDocument.documentElement.contains(b);if(P(C)&&typeof C.behavior=="function")return C.behavior(k?[]:N(b,C));if(k)return;var _=F(C);return H(N(b,_),_.behavior)}var O=nt.a=M},bT9E:function(Et,nt,re){"use strict";re.d(nt,"a",function(){return $});var ie=re("VTBJ");function $(D,V){var N=Object(ie.a)({},D);return Array.isArray(V)&&V.forEach(function(P){delete N[P]}),N}},c5Ni:function(Et,nt,re){},dejd:function(Et,nt,re){},dmUQ:function(Et,nt,re){"use strict";var ie=re("Ff2n"),$=re("rePB"),D=re("1OyB"),V=re("vuIU"),N=re("Ji7U"),P=re("md7G"),H=re("foSv"),F=re("q1tI"),M=re.n(F),O=re("TSYQ"),b=re.n(O),C=re("4IlW");function k(d,o){var E=Object.keys(d);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(d);o&&(v=v.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),E.push.apply(E,v)}return E}function _(d){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?k(Object(E),!0).forEach(function(v){Object($.a)(d,v,E[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(E)):k(Object(E)).forEach(function(v){Object.defineProperty(d,v,Object.getOwnPropertyDescriptor(E,v))})}return d}function A(d){var o=y();return function(){var v=Object(H.a)(d),T;if(o){var I=Object(H.a)(this).constructor;T=Reflect.construct(v,arguments,I)}else T=v.apply(this,arguments);return Object(P.a)(this,T)}}function y(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(d){return!1}}function u(){}function a(d){d.preventDefault()}var l=function(o){return o.replace(/[^\w.-]+/g,"")},h=200,w=600,g=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,m=function(o){return o!=null},L=function(o,E){return E===o||typeof E=="number"&&typeof o=="number"&&isNaN(E)&&isNaN(o)},x=function(d){Object(N.a)(E,d);var o=A(E);function E(v){var T;Object(D.a)(this,E),T=o.call(this,v),T.onKeyDown=function(X){var J=T.props,z=J.onKeyDown,W=J.onPressEnter;if(X.keyCode===C.a.UP){var q=T.getRatio(X);T.up(X,q,null),T.stop()}else if(X.keyCode===C.a.DOWN){var ne=T.getRatio(X);T.down(X,ne,null),T.stop()}else X.keyCode===C.a.ENTER&&W&&W(X);if(T.recordCursorPosition(),T.lastKeyCode=X.keyCode,z){for(var ce=arguments.length,ve=new Array(ce>1?ce-1:0),De=1;De<ce;De++)ve[De-1]=arguments[De];z.apply(void 0,[X].concat(ve))}},T.onKeyUp=function(X){var J=T.props.onKeyUp;if(T.stop(),T.recordCursorPosition(),J){for(var z=arguments.length,W=new Array(z>1?z-1:0),q=1;q<z;q++)W[q-1]=arguments[q];J.apply(void 0,[X].concat(W))}},T.onChange=function(X){var J=T.props.onChange;T.state.focused&&(T.inputting=!0),T.rawInput=T.props.parser(T.getValueFromEvent(X)),T.setState({inputValue:T.rawInput}),J(T.toNumber(T.rawInput))},T.onMouseUp=function(){var X=T.props.onMouseUp;T.recordCursorPosition(),X&&X.apply(void 0,arguments)},T.onFocus=function(){var X;T.setState({focused:!0}),(X=T.props).onFocus.apply(X,arguments)},T.onBlur=function(){var X=T.props.onBlur;T.inputting=!1,T.setState({focused:!1});var J=T.getCurrentValidValue(T.state.inputValue),z=T.setValue(J,u);if(X){var W=T.input.value,q=T.getInputDisplayValue({focus:!1,value:z});T.input.value=q&&Number(q),X.apply(void 0,arguments),T.input.value=W}},T.getRatio=function(X){var J=1;return X.metaKey||X.ctrlKey?J=.1:X.shiftKey&&(J=10),J},T.getFullNum=function(X){return isNaN(X)?X:/e/i.test(String(X))?Number(X).toFixed(18).replace(/\.?0+$/,""):X},T.getPrecision=function(X){if(m(T.props.precision))return T.props.precision;var J=String(X);if(J.indexOf("e-")>=0)return parseInt(J.slice(J.indexOf("e-")+2),10);var z=0;return J.indexOf(".")>=0&&(z=J.length-J.indexOf(".")-1),z},T.getInputDisplayValue=function(X){var J=X||T.state,z=J.focused,W=J.inputValue,q=J.value,ne;z?ne=W:ne=T.toPrecisionAsStep(q),ne==null&&(ne="");var ce=T.formatWrapper(ne);return m(T.props.decimalSeparator)&&(ce=ce.toString().replace(".",T.props.decimalSeparator)),ce},T.recordCursorPosition=function(){try{T.cursorStart=T.input.selectionStart,T.cursorEnd=T.input.selectionEnd,T.currentValue=T.input.value,T.cursorBefore=T.input.value.substring(0,T.cursorStart),T.cursorAfter=T.input.value.substring(T.cursorEnd)}catch(X){}},T.restoreByAfter=function(X){if(X===void 0)return!1;var J=T.input.value,z=J.lastIndexOf(X);if(z===-1)return!1;var W=T.cursorBefore.length;return T.lastKeyCode===C.a.DELETE&&T.cursorBefore.charAt(W-1)===X[0]?(T.fixCaret(W,W),!0):z+X.length===J.length?(T.fixCaret(z,z),!0):!1},T.partRestoreByAfter=function(X){return X===void 0?!1:Array.prototype.some.call(X,function(J,z){var W=X.substring(z);return T.restoreByAfter(W)})},T.isNotCompleteNumber=function(X){return isNaN(X)||X===""||X===null||X&&X.toString().indexOf(".")===X.toString().length-1},T.stop=function(){T.autoStepTimer&&clearTimeout(T.autoStepTimer)},T.down=function(X,J,z){T.pressingUpOrDown=!0,T.step("down",X,J,z)},T.up=function(X,J,z){T.pressingUpOrDown=!0,T.step("up",X,J,z)},T.saveInput=function(X){T.input=X};var I=v.value;I===void 0&&(I=v.defaultValue),T.state={focused:v.autoFocus};var G=T.getValidValue(T.toNumber(I));return T.state=_(_({},T.state),{},{inputValue:T.toPrecisionAsStep(G),value:G}),T}return Object(V.a)(E,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(T){var I=this.props,G=I.value,X=I.onChange,J=I.max,z=I.min,W=this.state.focused;if(T){if(!L(T.value,G)||!L(T.max,J)||!L(T.min,z)){var q=W?G:this.getValidValue(G),ne;this.pressingUpOrDown?ne=q:this.inputting?ne=this.rawInput:ne=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:ne})}var ce="value"in this.props?G:this.state.value;"max"in this.props&&T.max!==J&&typeof ce=="number"&&ce>J&&X&&X(J),"min"in this.props&&T.min!==z&&typeof ce=="number"&&ce<z&&X&&X(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ve=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===C.a.BACKSPACE?ve=this.cursorStart-1:this.lastKeyCode===C.a.DELETE&&(ve=this.cursorStart):ve=this.input.value.length,this.fixCaret(ve,ve)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case C.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case C.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(De){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(T){var I=T;return I===""?I="":this.isNotCompleteNumber(parseFloat(I))?I=this.state.value:I=this.getValidValue(I),this.toNumber(I)}},{key:"getValueFromEvent",value:function(T){var I=T.target.value.trim().replace(/。/g,".");return m(this.props.decimalSeparator)&&(I=I.replace(this.props.decimalSeparator,".")),I}},{key:"getValidValue",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,X=parseFloat(T);return isNaN(X)?T:(X<I&&(X=I),X>G&&(X=G),X)}},{key:"setValue",value:function(T,I){var G=this.props.precision,X=this.isNotCompleteNumber(parseFloat(T))?null:parseFloat(T),J=this.state.value,z=J===void 0?null:J,W=this.state.inputValue,q=W===void 0?null:W,ne=typeof X=="number"?X.toFixed(G):"".concat(X),ce=X!==z||ne!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},I)):this.setState({value:X,inputValue:this.toPrecisionAsStep(T)},I),ce&&this.props.onChange(X),X}},{key:"getMaxPrecision",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,X=G.precision,J=G.step;if(m(X))return X;var z=this.getPrecision(I),W=this.getPrecision(J),q=this.getPrecision(T);return T?Math.max(q,z+W):z+W}},{key:"getPrecisionFactor",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(T,I);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(T){return this.props.formatter?this.props.formatter(T):T}},{key:"toPrecisionAsStep",value:function(T){if(this.isNotCompleteNumber(T)||T==="")return T;var I=Math.abs(this.getMaxPrecision(T));return isNaN(I)?T.toString():Number(T).toFixed(I)}},{key:"toNumber",value:function(T){var I=this.props.precision,G=this.state.focused,X=T&&T.length>16&&G;return this.isNotCompleteNumber(T)||X?T:m(I)?Math.round(T*Math.pow(10,I))/Math.pow(10,I):Number(T)}},{key:"upStep",value:function(T,I){var G=this.props.step,X=this.getPrecisionFactor(T,I),J=Math.abs(this.getMaxPrecision(T,I)),z=((X*T+X*G*I)/X).toFixed(J);return this.toNumber(z)}},{key:"downStep",value:function(T,I){var G=this.props.step,X=this.getPrecisionFactor(T,I),J=Math.abs(this.getMaxPrecision(T,I)),z=((X*T-X*G*I)/X).toFixed(J);return this.toNumber(z)}},{key:"step",value:function(T,I){var G=this,X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,J=arguments.length>3?arguments[3]:void 0;this.stop(),I&&(I.persist(),I.preventDefault());var z=this.props;if(z.disabled)return;var W=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(W))return;var q=this["".concat(T,"Step")](W,X),ne=q>z.max||q<z.min;if(q>z.max?q=z.max:q<z.min&&(q=z.min),this.setValue(q,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ne)return;this.autoStepTimer=setTimeout(function(){G[T](I,X,!0)},J?h:w)}},{key:"fixCaret",value:function(T,I){if(T===void 0||I===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,X=this.input.selectionEnd;(T!==G||I!==X)&&this.input.setSelectionRange(T,I)}catch(J){}}},{key:"render",value:function(){var T,I=this.props,G=I.prefixCls,X=I.disabled,J=I.readOnly,z=I.useTouch,W=I.autoComplete,q=I.upHandler,ne=I.downHandler,ce=I.className,ve=I.max,De=I.min,xe=I.style,Ce=I.title,Te=I.onMouseEnter,Ee=I.onMouseLeave,ge=I.onMouseOver,se=I.onMouseOut,ke=I.required,Ve=I.onClick,He=I.tabIndex,tt=I.type,Ke=I.placeholder,Le=I.id,Me=I.inputMode,We=I.pattern,Xe=I.step,Ge=I.maxLength,Fe=I.autoFocus,Be=I.name,ot=I.onPaste,et=I.onInput,Ze=Object(ie.a)(I,["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"]),rt=this.state,ht=rt.value,Qe=rt.focused,Je=b()(G,(T={},Object($.a)(T,ce,!!ce),Object($.a)(T,"".concat(G,"-disabled"),X),Object($.a)(T,"".concat(G,"-focused"),Qe),T)),we={};Object.keys(Ze).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(we[ue]=Ze[ue])});var lt=!J&&!X,it=this.getInputDisplayValue(null),Ae=(ht||ht===0)&&(isNaN(ht)||Number(ht)>=ve),Ne=(ht||ht===0)&&(isNaN(ht)||Number(ht)<=De),me=Ae||X||J,de=Ne||X||J,fe=b()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object($.a)({},"".concat(G,"-handler-up-disabled"),me)),ee=b()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object($.a)({},"".concat(G,"-handler-down-disabled"),de)),te=z?{onTouchStart:me?u:this.up,onTouchEnd:this.stop}:{onMouseDown:me?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ae=z?{onTouchStart:de?u:this.down,onTouchEnd:this.stop}:{onMouseDown:de?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:Je,style:xe,title:Ce,onMouseEnter:Te,onMouseLeave:Ee,onMouseOver:ge,onMouseOut:se,onFocus:function(){return null},onBlur:function(){return null}},M.a.createElement("div",{className:"".concat(G,"-handler-wrap")},M.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":me,className:fe}),q||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:a})),M.a.createElement("span",Object.assign({unselectable:"on"},ae,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:ee}),ne||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:a}))),M.a.createElement("div",{className:"".concat(G,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":ve,"aria-valuenow":ht,required:ke,type:tt,placeholder:Ke,onPaste:ot,onClick:Ve,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:He,autoComplete:W,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:lt?this.onKeyDown:u,onKeyUp:lt?this.onKeyUp:u,autoFocus:Fe,maxLength:Ge,readOnly:J,disabled:X,max:ve,min:De,step:Xe,name:Be,title:Ce,id:Le,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(it),pattern:We,inputMode:Me,onInput:et},we))))}}]),E}(M.a.Component);x.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:g,min:-g,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var f=x,p=nt.a=f},fnXi:function(Et,nt,re){"use strict";var ie=re("2qtc"),$=re("kLXV"),D=re("q1tI"),V=re.n(D),N=re("Ty5D"),P=re("9kvl"),H=re("93VE"),F=re.n(H),M=function(b){var C=b.activeIndex,k=b.isEdit,_=k===void 0?!0:k,A=b.dispatch,y=b.practiceSetting,u=Object(N.i)(),a=u.id,l=u.challengesId,h=Object(D.useMemo)(function(){return[{name:"\u672C\u5173\u4EFB\u52A1",url:"/shixuns/".concat(a,"/edit/").concat(l,"/editcheckpoint")},{name:"\u8BC4\u6D4B\u8BBE\u7F6E",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=2")},{name:"\u53C2\u8003\u7B54\u6848",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=3")},{name:"\u5173\u5361\u6392\u884C\u699C",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=4")}]},[a,l]),w=function(m){var L,x=function(){P.d.push(m),A({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};y!=null&&(L=y.sideBar)!==null&&L!==void 0&&L.confirmLeave?$.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){x()}}):x()};return V.a.createElement("ul",{className:"challenge-nav"},_?h.map(function(g,m){return C===m?V.a.createElement("li",{key:g.url}," ",V.a.createElement("a",{className:"active"},g.name)," "):V.a.createElement("li",{key:g.url}," ",V.a.createElement("a",{onClick:function(){return w(g.url)}},g.name)," ")}):V.a.createElement("li",{key:h[0].url}," ",V.a.createElement("a",{className:"active"},h[0].name)," "))};nt.a=Object(P.a)(function(O){var b=O.globalSetting,C=O.practiceSetting;return{globalSetting:b,practiceSetting:C}})(M)},kSUc:function(Et,nt,re){},lZu9:function(Et,nt,re){(function(ie){ie(re("VrN/"),re("1eCo"),re("8EBN"))})(function(ie){"use strict";ie.defineMode("markdown",function($,D){var V=ie.getMode($,"text/html"),N=V.name=="null";function P(z){if(ie.findModeByName){var W=ie.findModeByName(z);W&&(z=W.mime||W.mimes[0])}var q=ie.getMode($,z);return q.name=="null"?null:q}D.highlightFormatting===void 0&&(D.highlightFormatting=!1),D.maxBlockquoteDepth===void 0&&(D.maxBlockquoteDepth=0),D.taskLists===void 0&&(D.taskLists=!1),D.strikethrough===void 0&&(D.strikethrough=!1),D.emoji===void 0&&(D.emoji=!1),D.fencedCodeBlockHighlighting===void 0&&(D.fencedCodeBlockHighlighting=!0),D.fencedCodeBlockDefaultMode===void 0&&(D.fencedCodeBlockDefaultMode="text/plain"),D.xml===void 0&&(D.xml=!0),D.tokenTypeOverrides===void 0&&(D.tokenTypeOverrides={});var H={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var F in H)H.hasOwnProperty(F)&&D.tokenTypeOverrides[F]&&(H[F]=D.tokenTypeOverrides[F]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,b=/^\[(x| )\](?=\s)/i,C=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,_=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,y=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,a=" ";function l(z,W,q){return W.f=W.inline=q,q(z,W)}function h(z,W,q){return W.f=W.block=q,q(z,W)}function w(z){return!z||!/\S/.test(z.string)}function g(z){if(z.linkTitle=!1,z.linkHref=!1,z.linkText=!1,z.em=!1,z.strong=!1,z.strikethrough=!1,z.quote=0,z.indentedCode=!1,z.f==L){var W=N;if(!W){var q=ie.innerMode(V,z.htmlState);W=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}W&&(z.f=d,z.block=m,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function m(z,W){var q=z.column()===W.indentation,ne=w(W.prevLine.stream),ce=W.indentedCode,ve=W.prevLine.hr,De=W.list!==!1,xe=(W.listStack[W.listStack.length-1]||0)+3;W.indentedCode=!1;var Ce=W.indentation;if(W.indentationDiff===null&&(W.indentationDiff=W.indentation,De)){for(W.list=null;Ce<W.listStack[W.listStack.length-1];)W.listStack.pop(),W.listStack.length?W.indentation=W.listStack[W.listStack.length-1]:W.list=!1;W.list!==!1&&(W.indentationDiff=Ce-W.listStack[W.listStack.length-1])}var Te=!ne&&!ve&&!W.prevLine.header&&(!De||!ce)&&!W.prevLine.fencedCodeEnd,Ee=(W.list===!1||ve||ne)&&W.indentation<=xe&&z.match(M),ge=null;if(W.indentationDiff>=4&&(ce||W.prevLine.fencedCodeEnd||W.prevLine.header||ne))return z.skipToEnd(),W.indentedCode=!0,H.code;if(z.eatSpace())return null;if(q&&W.indentation<=xe&&(ge=z.match(C))&&ge[1].length<=6)return W.quote=0,W.header=ge[1].length,W.thisLine.header=!0,D.highlightFormatting&&(W.formatting="header"),W.f=W.inline,f(W);if(W.indentation<=xe&&z.eat(">"))return W.quote=q?1:W.quote+1,D.highlightFormatting&&(W.formatting="quote"),z.eatSpace(),f(W);if(!Ee&&!W.setext&&q&&W.indentation<=xe&&(ge=z.match(O))){var se=ge[1]?"ol":"ul";return W.indentation=Ce+z.current().length,W.list=!0,W.quote=0,W.listStack.push(W.indentation),W.em=!1,W.strong=!1,W.code=!1,W.strikethrough=!1,D.taskLists&&z.match(b,!1)&&(W.taskList=!0),W.f=W.inline,D.highlightFormatting&&(W.formatting=["list","list-"+se]),f(W)}else{if(q&&W.indentation<=xe&&(ge=z.match(A,!0)))return W.quote=0,W.fencedEndRE=new RegExp(ge[1]+"+ *$"),W.localMode=D.fencedCodeBlockHighlighting&&P(ge[2]||D.fencedCodeBlockDefaultMode),W.localMode&&(W.localState=ie.startState(W.localMode)),W.f=W.block=x,D.highlightFormatting&&(W.formatting="code-block"),W.code=-1,f(W);if(W.setext||(!Te||!De)&&!W.quote&&W.list===!1&&!W.code&&!Ee&&!y.test(z.string)&&(ge=z.lookAhead(1))&&(ge=ge.match(k)))return W.setext?(W.header=W.setext,W.setext=0,z.skipToEnd(),D.highlightFormatting&&(W.formatting="header")):(W.header=ge[0].charAt(0)=="="?1:2,W.setext=W.header),W.thisLine.header=!0,W.f=W.inline,f(W);if(Ee)return z.skipToEnd(),W.hr=!0,W.thisLine.hr=!0,H.hr;if(z.peek()==="[")return l(z,W,I)}return l(z,W,W.inline)}function L(z,W){var q=V.token(z,W.htmlState);if(!N){var ne=ie.innerMode(V,W.htmlState);(ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText||W.md_inside&&z.current().indexOf(">")>-1)&&(W.f=d,W.block=m,W.htmlState=null)}return q}function x(z,W){var q=W.listStack[W.listStack.length-1]||0,ne=W.indentation<q,ce=q+3;if(W.fencedEndRE&&W.indentation<=ce&&(ne||z.match(W.fencedEndRE))){D.highlightFormatting&&(W.formatting="code-block");var ve;return ne||(ve=f(W)),W.localMode=W.localState=null,W.block=m,W.f=d,W.fencedEndRE=null,W.code=0,W.thisLine.fencedCodeEnd=!0,ne?h(z,W,W.block):ve}else return W.localMode?W.localMode.token(z,W.localState):(z.skipToEnd(),H.code)}function f(z){var W=[];if(z.formatting){W.push(H.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var q=0;q<z.formatting.length;q++)W.push(H.formatting+"-"+z.formatting[q]),z.formatting[q]==="header"&&W.push(H.formatting+"-"+z.formatting[q]+"-"+z.header),z.formatting[q]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?W.push(H.formatting+"-"+z.formatting[q]+"-"+z.quote):W.push("error"))}if(z.taskOpen)return W.push("meta"),W.length?W.join(" "):null;if(z.taskClosed)return W.push("property"),W.length?W.join(" "):null;if(z.linkHref?W.push(H.linkHref,"url"):(z.strong&&W.push(H.strong),z.em&&W.push(H.em),z.strikethrough&&W.push(H.strikethrough),z.emoji&&W.push(H.emoji),z.linkText&&W.push(H.linkText),z.code&&W.push(H.code),z.image&&W.push(H.image),z.imageAltText&&W.push(H.imageAltText,"link"),z.imageMarker&&W.push(H.imageMarker)),z.header&&W.push(H.header,H.header+"-"+z.header),z.quote&&(W.push(H.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?W.push(H.quote+"-"+z.quote):W.push(H.quote+"-"+D.maxBlockquoteDepth)),z.list!==!1){var ne=(z.listStack.length-1)%3;ne?ne===1?W.push(H.list2):W.push(H.list3):W.push(H.list1)}return z.trailingSpaceNewLine?W.push("trailing-space-new-line"):z.trailingSpace&&W.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),W.length?W.join(" "):null}function p(z,W){return z.match(_,!0)?f(W):void 0}function d(z,W){var q=W.text(z,W);if(typeof q!="undefined")return q;if(W.list)return W.list=null,f(W);if(W.taskList){var ne=z.match(b,!0)[1]===" ";return ne?W.taskOpen=!0:W.taskClosed=!0,D.highlightFormatting&&(W.formatting="task"),W.taskList=!1,f(W)}if(W.taskOpen=!1,W.taskClosed=!1,W.header&&z.match(/^#+$/,!0))return D.highlightFormatting&&(W.formatting="header"),f(W);var ce=z.next();if(W.linkTitle){W.linkTitle=!1;var ve=ce;ce==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(De),!0))return H.linkHref}if(ce==="`"){var xe=W.formatting;D.highlightFormatting&&(W.formatting="code"),z.eatWhile("`");var Ce=z.current().length;if(W.code==0&&(!W.quote||Ce==1))return W.code=Ce,f(W);if(Ce==W.code){var Te=f(W);return W.code=0,Te}else return W.formatting=xe,f(W)}else if(W.code)return f(W);if(ce==="\\"&&(z.next(),D.highlightFormatting)){var Ee=f(W),ge=H.formatting+"-escape";return Ee?Ee+" "+ge:ge}if(ce==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return W.imageMarker=!0,W.image=!0,D.highlightFormatting&&(W.formatting="image"),f(W);if(ce==="["&&W.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return W.imageMarker=!1,W.imageAltText=!0,D.highlightFormatting&&(W.formatting="image"),f(W);if(ce==="]"&&W.imageAltText){D.highlightFormatting&&(W.formatting="image");var Ee=f(W);return W.imageAltText=!1,W.image=!1,W.inline=W.f=E,Ee}if(ce==="["&&!W.image)return W.linkText&&z.match(/^.*?\]/)||(W.linkText=!0,D.highlightFormatting&&(W.formatting="link")),f(W);if(ce==="]"&&W.linkText){D.highlightFormatting&&(W.formatting="link");var Ee=f(W);return W.linkText=!1,W.inline=W.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?E:d,Ee}if(ce==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=o,D.highlightFormatting&&(W.formatting="link");var Ee=f(W);return Ee?Ee+=" ":Ee="",Ee+H.linkInline}if(ce==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=o,D.highlightFormatting&&(W.formatting="link");var Ee=f(W);return Ee?Ee+=" ":Ee="",Ee+H.linkEmail}if(D.xml&&ce==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var se=z.string.indexOf(">",z.pos);if(se!=-1){var ke=z.string.substring(z.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(ke)&&(W.md_inside=!0)}return z.backUp(1),W.htmlState=ie.startState(V),h(z,W,L)}if(D.xml&&ce==="<"&&z.match(/^\/\w*?>/))return W.md_inside=!1,"tag";if(ce==="*"||ce==="_"){for(var Ve=1,He=z.pos==1?" ":z.string.charAt(z.pos-2);Ve<3&&z.eat(ce);)Ve++;var tt=z.peek()||" ",Ke=!/\s/.test(tt)&&(!u.test(tt)||/\s/.test(He)||u.test(He)),Le=!/\s/.test(He)&&(!u.test(He)||/\s/.test(tt)||u.test(tt)),Me=null,We=null;if(Ve%2&&(!W.em&&Ke&&(ce==="*"||!Le||u.test(He))?Me=!0:W.em==ce&&Le&&(ce==="*"||!Ke||u.test(tt))&&(Me=!1)),Ve>1&&(!W.strong&&Ke&&(ce==="*"||!Le||u.test(He))?We=!0:W.strong==ce&&Le&&(ce==="*"||!Ke||u.test(tt))&&(We=!1)),We!=null||Me!=null){D.highlightFormatting&&(W.formatting=Me==null?"strong":We==null?"em":"strong em"),Me===!0&&(W.em=ce),We===!0&&(W.strong=ce);var Te=f(W);return Me===!1&&(W.em=!1),We===!1&&(W.strong=!1),Te}}else if(ce===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return f(W);z.backUp(1)}if(D.strikethrough){if(ce==="~"&&z.eatWhile(ce)){if(W.strikethrough){D.highlightFormatting&&(W.formatting="strikethrough");var Te=f(W);return W.strikethrough=!1,Te}else if(z.match(/^[^\s]/,!1))return W.strikethrough=!0,D.highlightFormatting&&(W.formatting="strikethrough"),f(W)}else if(ce===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return f(W);z.backUp(2)}}if(D.emoji&&ce===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){W.emoji=!0,D.highlightFormatting&&(W.formatting="emoji");var Xe=f(W);return W.emoji=!1,Xe}return ce===" "&&(z.match(/^ +$/,!1)?W.trailingSpace++:W.trailingSpace&&(W.trailingSpaceNewLine=!0)),f(W)}function o(z,W){var q=z.next();if(q===">"){W.f=W.inline=d,D.highlightFormatting&&(W.formatting="link");var ne=f(W);return ne?ne+=" ":ne="",ne+H.linkInline}return z.match(/^[^>]+/,!0),H.linkInline}function E(z,W){if(z.eatSpace())return null;var q=z.next();return q==="("||q==="["?(W.f=W.inline=T(q==="("?")":"]"),D.highlightFormatting&&(W.formatting="link-string"),W.linkHref=!0,f(W)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function T(z){return function(W,q){var ne=W.next();if(ne===z){q.f=q.inline=d,D.highlightFormatting&&(q.formatting="link-string");var ce=f(q);return q.linkHref=!1,ce}return W.match(v[z]),q.linkHref=!0,f(q)}}function I(z,W){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(W.f=G,z.next(),D.highlightFormatting&&(W.formatting="link"),W.linkText=!0,f(W)):l(z,W,d)}function G(z,W){if(z.match(/^\]:/,!0)){W.f=W.inline=X,D.highlightFormatting&&(W.formatting="link");var q=f(W);return W.linkText=!1,q}return z.match(/^([^\]\\]|\\.)+/,!0),H.linkText}function X(z,W){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?W.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),W.f=W.inline=d,H.linkHref+" url")}var J={startState:function(){return{f:m,prevLine:{stream:null},thisLine:{stream:null},block:m,htmlState:null,indentation:0,inline:d,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&ie.copyState(V,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?ie.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,W){if(W.formatting=!1,z!=W.thisLine.stream){if(W.header=0,W.hr=!1,z.match(/^\s*$/,!0))return g(W),null;if(W.prevLine=W.thisLine,W.thisLine={stream:z},W.taskList=!1,W.trailingSpace=0,W.trailingSpaceNewLine=!1,!W.localState&&(W.f=W.block,W.f!=L)){var q=z.match(/^\s*/,!0)[0].replace(/\t/g,a).length;if(W.indentation=q,W.indentationDiff=null,q>0)return null}}return W.f(z,W)},innerMode:function(z){return z.block==L?{state:z.htmlState,mode:V}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:J}},indent:function(z,W,q){return z.block==L&&V.indent?V.indent(z.htmlState,W,q):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,W,q):ie.Pass},blankLine:g,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J},"xml"),ie.defineMIME("text/markdown","markdown"),ie.defineMIME("text/x-markdown","markdown")})},nuEh:function(Et,nt,re){"use strict";var ie=re("T2oS"),$=re("W9HT"),D=re("q1tI"),V=re.n(D),N=re("F8wB"),P=re.n(N),H=function(M){var O=M.loading;return O?V.a.createElement("div",{className:P.a.loading},V.a.createElement($.a,null)):V.a.createElement(V.a.Fragment,null)};nt.a=H},osHv:function(Et,nt,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";var $=ie.Pos;function D(u,a){return u.line-a.line||u.ch-a.ch}var V="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",N=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",P=new RegExp("<(/?)(["+V+"]["+N+"]*)","g");function H(u,a,l,h){this.line=a,this.ch=l,this.cm=u,this.text=u.getLine(a),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function F(u,a){var l=u.cm.getTokenTypeAt($(u.line,a));return l&&/\btag\b/.test(l)}function M(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function O(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function b(u){for(;;){var a=u.text.indexOf(">",u.ch);if(a==-1){if(M(u))continue;return}if(!F(u,a+1)){u.ch=a+1;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function C(u){for(;;){var a=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(a==-1){if(O(u))continue;return}if(!F(u,a+1)){u.ch=a;continue}P.lastIndex=a,u.ch=a;var l=P.exec(u.text);if(l&&l.index==a)return l}}function k(u){for(;;){P.lastIndex=u.ch;var a=P.exec(u.text);if(!a){if(M(u))continue;return}if(!F(u,a.index+1)){u.ch=a.index+1;continue}return u.ch=a.index+a[0].length,a}}function _(u){for(;;){var a=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(a==-1){if(O(u))continue;return}if(!F(u,a+1)){u.ch=a;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function A(u,a){for(var l=[];;){var h=k(u),w,g=u.line,m=u.ch-(h?h[0].length:0);if(!h||!(w=b(u)))return;if(w=="selfClose")continue;if(h[1]){for(var L=l.length-1;L>=0;--L)if(l[L]==h[2]){l.length=L;break}if(L<0&&(!a||a==h[2]))return{tag:h[2],from:$(g,m),to:$(u.line,u.ch)}}else l.push(h[2])}}function y(u,a){for(var l=[];;){var h=_(u);if(!h)return;if(h=="selfClose"){C(u);continue}var w=u.line,g=u.ch,m=C(u);if(!m)return;if(m[1])l.push(m[2]);else{for(var L=l.length-1;L>=0;--L)if(l[L]==m[2]){l.length=L;break}if(L<0&&(!a||a==m[2]))return{tag:m[2],from:$(u.line,u.ch),to:$(w,g)}}}}ie.registerHelper("fold","xml",function(u,a){for(var l=new H(u,a.line,0);;){var h=k(l);if(!h||l.line!=a.line)return;var w=b(l);if(!w)return;if(!h[1]&&w!="selfClose"){var g=$(l.line,l.ch),m=A(l,h[2]);return m&&D(m.from,g)>0?{from:g,to:m.from}:null}}}),ie.findMatchingTag=function(u,a,l){var h=new H(u,a.line,a.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var w=b(h),g=w&&$(h.line,h.ch),m=w&&C(h);if(!w||!m||D(h,a)>0)return;var L={from:$(h.line,h.ch),to:g,tag:m[2]};return w=="selfClose"?{open:L,close:null,at:"open"}:m[1]?{open:y(h,m[2]),close:L,at:"close"}:(h=new H(u,g.line,g.ch,l),{open:L,close:A(h,m[2]),at:"open"})},ie.findEnclosingTag=function(u,a,l,h){for(var w=new H(u,a.line,a.ch,l);;){var g=y(w,h);if(!g)break;var m=new H(u,a.line,a.ch,l),L=A(m,g.tag);if(L)return{open:g,close:L}}},ie.scanForClosingTag=function(u,a,l,h){var w=new H(u,a.line,a.ch,h?{from:0,to:h}:null);return A(w,l)}})},p5ED:function(Et,nt,re){"use strict";var ie=re("+L6B"),$=re("2/Rp"),D=re("5Dmo"),V=re("3S7+"),N=re("k1fw"),P=re("tJVT"),H=re("q1tI"),F=re.n(H),M=re("vHTk"),O=re.n(M),b=re("yEEn"),C=re("ZW9T"),k=re("1vsH");nt.a=function(_){var A=_.name,y=_.data,u=_.theme,a=_.type,l=_.filename,h=_.monacoEditor,w=_.className,g=_.style,m=_.close,L=_.onClose,x=_.hasMask,f=Object(H.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),p=Object(P.a)(f,2),d=p[0],o=p[1],E=Object(H.useState)(""),v=Object(P.a)(E,2),T=v[0],I=v[1],G,X=1024*1024,J=10*X,z=Object(H.useRef)();a==="office"&&(G=Object(k.T)(y).filesize,G>J&&(a="other")),l&&(h.filename=l),Object(H.useEffect)(function(){var ne,ce,ve=(ne=document.cookie)===null||ne===void 0||((ce=ne.replace(/\s/g,""))===null||ce===void 0)?void 0:ce.split(";");ve==null||ve.map(function(De){var xe=De.split("=");xe[0]==="_educoder_session"&&I(xe[1])})},[]);var W=function(){if(y.startsWith("http")||y.startsWith("/")){q();return}Object(k.z)(l||"educoder",y,l)},q=function(){Object(k.x)(l||A,y)};return console.log("data:",y,"fileanme:",l," name:",A),F.a.createElement("div",{style:Object(N.a)({},g||{}),className:"".concat(x&&O.a.bgBlack," ").concat(a?O.a.wrp:"hide")},m&&F.a.createElement("div",{className:O.a.close,ref:z},F.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return z.current}},F.a.createElement("span",{onClick:q},F.a.createElement("i",{className:"icon-quxiaozhiding"}))),F.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return z.current}},F.a.createElement("span",{className:"",onClick:L},F.a.createElement("i",{className:"icon-guanbi1"})))),F.a.createElement("div",{className:"".concat(O.a[w]," ").concat(w," ").concat(O.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&F.a.createElement(C.b,h)),a==="audio"&&F.a.createElement("audio",{src:"".concat(y!=null&&y.startsWith("/")||(y==null?void 0:y.indexOf("https://"))>-1?y:"data:audio/mp3;base64,").concat(y),autoPlay:!0}),a==="video"&&F.a.createElement(F.a.Fragment,null,y!=null&&y.startsWith("/")?F.a.createElement("video",{controls:!0,src:"".concat(y),autoPlay:!0}):F.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(y),autoPlay:!0})),a==="html"&&F.a.createElement("iframe",{src:y+"&disposition=inline"}),a==="pdf"&&F.a.createElement("embed",{className:O.a.embed,src:y}),a==="image"&&F.a.createElement(F.a.Fragment,null,F.a.createElement("img",{src:"".concat(y!=null&&y.startsWith("/")||(y==null?void 0:y.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(y)})),a==="other"&&F.a.createElement("div",null,F.a.createElement($.a,{type:"primary",size:"large",onClick:W},F.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(a==="download"||a==="office")&&F.a.createElement($.a,{type:"primary",size:"large",onClick:W},F.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(Et,nt,re){},rUJ1:function(Et,nt){const re=/[&<>"']/,ie=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,V={"&":"&","<":"<",">":">",'"':""","'":"'"},N=x=>V[x];function P(x,f){if(f){if(re.test(x))return x.replace(ie,N)}else if($.test(x))return x.replace(D,N);return x}const H=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(x){return x.replace(H,(f,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const M=/(^|[^\[])\^/g;function O(x,f){x=x.source||x,f=f||"";const p={replace:(d,o)=>(o=o.source||o,o=o.replace(M,"$1"),x=x.replace(d,o),p),getRegex:()=>new RegExp(x,f)};return p}const b=/[^\w:]/g,C=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(x,f,p){if(x){let d;try{d=decodeURIComponent(F(p)).replace(b,"").toLowerCase()}catch(o){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}f&&!C.test(p)&&(p=a(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(d){return null}return p}const _={},A=/^[^:]+:\/*[^/]*$/,y=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(x,f){_[" "+x]||(A.test(x)?_[" "+x]=x+"/":_[" "+x]=g(x,"/",!0)),x=_[" "+x];const p=x.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:x.replace(y,"$1")+f:f.charAt(0)==="/"?p?f:x.replace(u,"$1")+f:x+f}const l={exec:function(){}};function h(x){let f=1,p,d;for(;f<arguments.length;f++){p=arguments[f];for(d in p)Object.prototype.hasOwnProperty.call(p,d)&&(x[d]=p[d])}return x}function w(x,f){const p=x.replace(/\|/g,(E,v,T)=>{let I=!1,G=v;for(;--G>=0&&T[G]==="\\";)I=!I;return I?"|":" |"}),d=p.split(/ \|/);let o=0;if(d.length>f)d.splice(f);else for(;d.length<f;)d.push("");for(;o<d.length;o++)d[o]=d[o].trim().replace(/\\\|/g,"|");return d}function g(x,f,p){const d=x.length;if(d===0)return"";let o=0;for(;o<d;){const E=x.charAt(d-o-1);if(E===f&&!p)o++;else if(E!==f&&p)o++;else break}return x.substr(0,d-o)}function m(x,f){if(x.indexOf(f[1])===-1)return-1;const p=x.length;let d=0,o=0;for(;o<p;o++)if(x[o]==="\\")o++;else if(x[o]===f[0])d++;else if(x[o]===f[1]&&(d--,d<0))return o;return-1}function L(x){x&&x.sanitize&&!x.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")}Et.exports={escape:P,unescape:F,edit:O,cleanUrl:k,resolveUrl:a,noopTest:l,merge:h,splitCells:w,rtrim:g,findClosingBracket:m,checkSanitizeDeprecation:L}},ulZh:function(Et,nt,re){typeof window!="undefined"&&function($,D){Et.exports=D()}(this,function(){return function(ie){var $={};function D(V){if($[V])return $[V].exports;var N=$[V]={i:V,l:!1,exports:{}};return ie[V].call(N.exports,N,N.exports,D),N.l=!0,N.exports}return D.m=ie,D.c=$,D.d=function(V,N,P){D.o(V,N)||Object.defineProperty(V,N,{enumerable:!0,get:P})},D.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},D.t=function(V,N){if(N&1&&(V=D(V)),N&8)return V;if(N&4&&typeof V=="object"&&V&&V.__esModule)return V;var P=Object.create(null);if(D.r(P),Object.defineProperty(P,"default",{enumerable:!0,value:V}),N&2&&typeof V!="string")for(var H in V)D.d(P,H,function(F){return V[F]}.bind(null,H));return P},D.n=function(V){var N=V&&V.__esModule?function(){return V.default}:function(){return V};return D.d(N,"a",N),N},D.o=function(V,N){return Object.prototype.hasOwnProperty.call(V,N)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ie,$,D){"use strict";var V=Object.prototype.hasOwnProperty,N="~";function P(){}Object.create&&(P.prototype=Object.create(null),new P().__proto__||(N=!1));function H(b,C,k){this.fn=b,this.context=C,this.once=k||!1}function F(b,C,k,_,A){if(typeof k!="function")throw new TypeError("The listener must be a function");var y=new H(k,_||b,A),u=N?N+C:C;return b._events[u]?b._events[u].fn?b._events[u]=[b._events[u],y]:b._events[u].push(y):(b._events[u]=y,b._eventsCount++),b}function M(b,C){--b._eventsCount===0?b._events=new P:delete b._events[C]}function O(){this._events=new P,this._eventsCount=0}O.prototype.eventNames=function(){var C=[],k,_;if(this._eventsCount===0)return C;for(_ in k=this._events)V.call(k,_)&&C.push(N?_.slice(1):_);return Object.getOwnPropertySymbols?C.concat(Object.getOwnPropertySymbols(k)):C},O.prototype.listeners=function(C){var k=N?N+C:C,_=this._events[k];if(!_)return[];if(_.fn)return[_.fn];for(var A=0,y=_.length,u=new Array(y);A<y;A++)u[A]=_[A].fn;return u},O.prototype.listenerCount=function(C){var k=N?N+C:C,_=this._events[k];return _?_.fn?1:_.length:0},O.prototype.emit=function(C,k,_,A,y,u){var a=N?N+C:C;if(!this._events[a])return!1;var l=this._events[a],h=arguments.length,w,g;if(l.fn){l.once&&this.removeListener(C,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,k),!0;case 3:return l.fn.call(l.context,k,_),!0;case 4:return l.fn.call(l.context,k,_,A),!0;case 5:return l.fn.call(l.context,k,_,A,y),!0;case 6:return l.fn.call(l.context,k,_,A,y,u),!0}for(g=1,w=new Array(h-1);g<h;g++)w[g-1]=arguments[g];l.fn.apply(l.context,w)}else{var m=l.length,L;for(g=0;g<m;g++){l[g].once&&this.removeListener(C,l[g].fn,void 0,!0);switch(h){case 1:l[g].fn.call(l[g].context);break;case 2:l[g].fn.call(l[g].context,k);break;case 3:l[g].fn.call(l[g].context,k,_);break;case 4:l[g].fn.call(l[g].context,k,_,A);break;default:if(!w)for(L=1,w=new Array(h-1);L<h;L++)w[L-1]=arguments[L];l[g].fn.apply(l[g].context,w)}}}return!0},O.prototype.on=function(C,k,_){return F(this,C,k,_,!1)},O.prototype.once=function(C,k,_){return F(this,C,k,_,!0)},O.prototype.removeListener=function(C,k,_,A){var y=N?N+C:C;if(!this._events[y])return this;if(!k)return M(this,y),this;var u=this._events[y];if(u.fn)u.fn===k&&(!A||u.once)&&(!_||u.context===_)&&M(this,y);else{for(var a=0,l=[],h=u.length;a<h;a++)(u[a].fn!==k||A&&!u[a].once||_&&u[a].context!==_)&&l.push(u[a]);l.length?this._events[y]=l.length===1?l[0]:l:M(this,y)}return this},O.prototype.removeAllListeners=function(C){var k;return C?(k=N?N+C:C,this._events[k]&&M(this,k)):(this._events=new P,this._eventsCount=0),this},O.prototype.off=O.prototype.removeListener,O.prototype.addListener=O.prototype.on,O.prefixed=N,O.EventEmitter=O,ie.exports=O},"./node_modules/url-toolkit/src/url-toolkit.js":function(ie,$,D){(function(V){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,P=/^([^\/?#]*)([^]*)$/,H=/(?:\/|^)\.(?=\/)/g,F=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(O,b,C){if(C=C||{},O=O.trim(),b=b.trim(),!b){if(!C.alwaysNormalize)return O;var k=M.parseURL(O);if(!k)throw new Error("Error trying to parse base URL.");return k.path=M.normalizePath(k.path),M.buildURLFromParts(k)}var _=M.parseURL(b);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return C.alwaysNormalize?(_.path=M.normalizePath(_.path),M.buildURLFromParts(_)):b;var A=M.parseURL(O);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var y=P.exec(A.path);A.netLoc=y[1],A.path=y[2]}A.netLoc&&!A.path&&(A.path="/");var u={scheme:A.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(u.netLoc=A.netLoc,_.path[0]!=="/"))if(!_.path)u.path=A.path,_.params||(u.params=A.params,_.query||(u.query=A.query));else{var a=A.path,l=a.substring(0,a.lastIndexOf("/")+1)+_.path;u.path=M.normalizePath(l)}return u.path===null&&(u.path=C.alwaysNormalize?M.normalizePath(_.path):_.path),M.buildURLFromParts(u)},parseURL:function(O){var b=N.exec(O);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(H,"");O.length!==(O=O.replace(F,"")).length;);return O.split("").reverse().join("")},buildURLFromParts:function(O){return O.scheme+O.netLoc+O.path+O.params+O.query+O.fragment}};ie.exports=M})(this)},"./node_modules/webworkify-webpack/index.js":function(ie,$,D){function V(C){var k={};function _(y){if(k[y])return k[y].exports;var u=k[y]={i:y,l:!1,exports:{}};return C[y].call(u.exports,u,u.exports,_),u.l=!0,u.exports}_.m=C,_.c=k,_.i=function(y){return y},_.d=function(y,u,a){_.o(y,u)||Object.defineProperty(y,u,{configurable:!1,enumerable:!0,get:a})},_.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},_.n=function(y){var u=y&&y.__esModule?function(){return y.default}:function(){return y};return _.d(u,"a",u),u},_.o=function(y,u){return Object.prototype.hasOwnProperty.call(y,u)},_.p="/",_.oe=function(y){throw console.error(y),y};var A=_(_.s=ENTRY_MODULE);return A.default||A}var N="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function H(C){return(C+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function F(C){return!isNaN(1*C)}function M(C,k,_){var A={};A[_]=[];var y=k.toString(),u=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return A;for(var a=u[1],l=new RegExp("(\\\\n|\\W)"+H(a)+P,"g"),h;h=l.exec(y);){if(h[3]==="dll-reference")continue;A[_].push(h[3])}for(l=new RegExp("\\("+H(a)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+P,"g");h=l.exec(y);)C[h[2]]||(A[_].push(h[1]),C[h[2]]=D(h[1]).m),A[h[2]]=A[h[2]]||[],A[h[2]].push(h[4]);for(var w=Object.keys(A),g=0;g<w.length;g++)for(var m=0;m<A[w[g]].length;m++)F(A[w[g]][m])&&(A[w[g]][m]=1*A[w[g]][m]);return A}function O(C){var k=Object.keys(C);return k.reduce(function(_,A){return _||C[A].length>0},!1)}function b(C,k){for(var _={main:[k]},A={main:[]},y={main:{}};O(_);)for(var u=Object.keys(_),a=0;a<u.length;a++){var l=u[a],h=_[l],w=h.pop();if(y[l]=y[l]||{},y[l][w]||!C[l][w])continue;y[l][w]=!0,A[l]=A[l]||[],A[l].push(w);for(var g=M(C,C[l][w],l),m=Object.keys(g),L=0;L<m.length;L++)_[m[L]]=_[m[L]]||[],_[m[L]]=_[m[L]].concat(g[m[L]])}return A}ie.exports=function(C,k){k=k||{};var _={main:D.m},A=k.all?{main:Object.keys(_.main)}:b(_,C),y="";Object.keys(A).filter(function(w){return w!=="main"}).forEach(function(w){for(var g=0;A[w][g];)g++;A[w].push(g),_[w][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+w+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(g))+")({"+A[w].map(function(m){return""+JSON.stringify(m)+": "+_[w][m].toString()}).join(",")+`});
|
|
`}),y=y+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(C))+")({"+A.main.map(function(w){return""+JSON.stringify(w)+": "+_.main[w].toString()}).join(",")+"}))(self);";var u=new window.Blob([y],{type:"text/javascript"});if(k.bare)return u;var a=window.URL||window.webkitURL||window.mozURL||window.msURL,l=a.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(ie,$,D){"use strict";D.r($),D.d($,"hlsDefaultConfig",function(){return L}),D.d($,"mergeConfig",function(){return f}),D.d($,"enableStreamingMode",function(){return p});var V=D("./src/controller/abr-controller.ts"),N=D("./src/controller/audio-stream-controller.ts"),P=D("./src/controller/audio-track-controller.ts"),H=D("./src/controller/subtitle-stream-controller.ts"),F=D("./src/controller/subtitle-track-controller.ts"),M=D("./src/controller/buffer-controller.ts"),O=D("./src/controller/timeline-controller.ts"),b=D("./src/controller/cap-level-controller.ts"),C=D("./src/controller/fps-controller.ts"),k=D("./src/controller/eme-controller.ts"),_=D("./src/controller/cmcd-controller.ts"),A=D("./src/utils/xhr-loader.ts"),y=D("./src/utils/fetch-loader.ts"),u=D("./src/utils/cues.ts"),a=D("./src/utils/mediakeys-helper.ts"),l=D("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var o=1;o<arguments.length;o++){var E=arguments[o];for(var v in E)Object.prototype.hasOwnProperty.call(E,v)&&(d[v]=E[v])}return d},h.apply(this,arguments)}function w(d,o){var E=Object.keys(d);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(d);o&&(v=v.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),E.push.apply(E,v)}return E}function g(d){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?w(Object(E),!0).forEach(function(v){m(d,v,E[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(E)):w(Object(E)).forEach(function(v){Object.defineProperty(d,v,Object.getOwnPropertyDescriptor(E,v))})}return d}function m(d,o,E){return o in d?Object.defineProperty(d,o,{value:E,enumerable:!0,configurable:!0,writable:!0}):d[o]=E,d}var L=g(g({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:b.default,fpsController:C.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},x()),{},{subtitleStreamController:H.SubtitleStreamController,subtitleTrackController:F.default,timelineController:O.TimelineController,audioStreamController:N.default,audioTrackController:P.default,emeController:k.default,cmcdController:_.default});function x(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function f(d,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},d,o)}function p(d){var o=d.loader;if(o!==y.default&&o!==A.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var E=Object(y.fetchSupported)();E&&(d.loader=y.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/polyfills/number.ts"),N=D("./src/utils/ewma-bandwidth-estimator.ts"),P=D("./src/events.ts"),H=D("./src/utils/buffer-helper.ts"),F=D("./src/errors.ts"),M=D("./src/types/loader.ts"),O=D("./src/utils/logger.ts");function b(_,A){for(var y=0;y<A.length;y++){var u=A[y];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function C(_,A,y){return A&&b(_.prototype,A),y&&b(_,y),_}var k=function(){function _(y){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=y;var u=y.config;this.bwEstimator=new N.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var A=_.prototype;return A.registerListeners=function(){var u=this.hls;u.on(P.Events.FRAG_LOADING,this.onFragLoading,this),u.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(P.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var u=this.hls;u.off(P.Events.FRAG_LOADING,this.onFragLoading,this),u.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(P.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(u,a){var l=a.frag;if(l.type===M.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=a.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(u,a){var l=this.hls.config;a.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,w=l.config,g=l.media;if(!u||!g)return;var m=a?a.stats:u.stats,L=a?a.duration:u.duration;if(m.aborted){O.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||g.paused||!g.playbackRate||!g.readyState)return;var x=performance.now()-m.loading.start,f=Math.abs(g.playbackRate);if(x<=500*L/f)return;var p=l.levels,d=l.minAutoLevel,o=p[u.level],E=m.total||Math.max(m.loaded,Math.round(L*o.maxBitrate/8)),v=Math.max(1,m.bwEstimate?m.bwEstimate/8:m.loaded*1e3/x),T=(E-m.loaded)/v,I=g.currentTime,G=(H.BufferHelper.bufferInfo(g,I,w.maxBufferHole).end-I)/f;if(G>=2*L/f||T<=G)return;var X=Number.POSITIVE_INFINITY,J;for(J=u.level-1;J>d;J--){var z=p[J].maxBitrate;if(X=L*z/(8*.8*v),X<G)break}if(X>=T)return;var W=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+u.sn+(a?" part "+a.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+J+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+T.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+X.toFixed(3)+` s
|
|
Time to underbuffer: `+G.toFixed(3)+" s"),l.nextLoadLevel=J,this.bwEstimator.sample(x,m.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:a,stats:m})},A.onFragLoaded=function(u,a){var l=a.frag,h=a.part;if(l.type===M.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(l.sn)){var w=h?h.stats:l.stats,g=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[l.level],L=(m.loaded?m.loaded.bytes:0)+w.loaded,x=(m.loaded?m.loaded.duration:0)+g;m.loaded={bytes:L,duration:x},m.realBitrate=Math.round(8*L/x)}if(l.bitrateTest){var f={stats:w,frag:l,part:h,id:l.type};this.onFragBuffered(P.Events.FRAG_BUFFERED,f),l.bitrateTest=!1}}},A.onFragBuffered=function(u,a){var l=a.frag,h=a.part,w=h?h.stats:l.stats;if(w.aborted)return;if(l.type!==M.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var g=w.parsing.end-w.loading.start;this.bwEstimator.sample(g,w.loaded),w.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=g/1e3:this.bitrateTestDelay=0},A.onError=function(u,a){switch(a.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.maxAutoLevel,w=l.config,g=l.minAutoLevel,m=l.media,L=a?a.duration:u?u.duration:0,x=m?m.currentTime:0,f=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():w.abrEwmaDefaultEstimate,d=(H.BufferHelper.bufferInfo(m,x,w.maxBufferHole).end-x)/f,o=this.findBestLevel(p,g,h,d,w.abrBandWidthFactor,w.abrBandWidthUpFactor);if(o>=0)return o;O.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=L?Math.min(L,w.maxStarvationDelay):w.maxStarvationDelay,v=w.abrBandWidthFactor,T=w.abrBandWidthUpFactor;if(!d){var I=this.bitrateTestDelay;if(I){var G=L?Math.min(L,w.maxLoadingDelay):w.maxLoadingDelay;E=G-I,O.logger.trace("bitrate test took "+Math.round(1e3*I)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),v=T=1}}return o=this.findBestLevel(p,g,h,d+E,v,T),Math.max(o,0)},A.findBestLevel=function(u,a,l,h,w,g){for(var m,L=this.fragCurrent,x=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,d=p[f],o=!!(d!=null&&(m=d.details)!==null&&m!==void 0&&m.live),E=d==null?void 0:d.codecSet,v=x?x.duration:L?L.duration:0,T=l;T>=a;T--){var I=p[T];if(!I||E&&I.codecSet!==E)continue;var G=I.details,X=(x?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||v,J=void 0;T<=f?J=w*u:J=g*u;var z=p[T].maxBitrate,W=z*X/J;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(J)+"/"+z+"/"+X+"/"+h+"/"+W),J>z&&(!W||o&&!this.bitrateTestDelay||W<h))return T}return-1},C(_,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,a=this.bwEstimator;if(u!==-1&&(!a||!a.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),_}();$.default=k},"./src/controller/audio-stream-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),P=D("./src/events.ts"),H=D("./src/utils/buffer-helper.ts"),F=D("./src/controller/fragment-tracker.ts"),M=D("./src/types/level.ts"),O=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),C=D("./src/demux/chunk-cache.ts"),k=D("./src/demux/transmuxer-interface.ts"),_=D("./src/types/transmuxer.ts"),A=D("./src/controller/fragment-finders.ts"),y=D("./src/utils/discontinuities.ts"),u=D("./src/errors.ts"),a=D("./src/utils/logger.ts");function l(){return l=Object.assign||function(L){for(var x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(L[p]=f[p])}return L},l.apply(this,arguments)}function h(L,x){L.prototype=Object.create(x.prototype),L.prototype.constructor=L,w(L,x)}function w(L,x){return w=Object.setPrototypeOf||function(p,d){return p.__proto__=d,p},w(L,x)}var g=100,m=function(L){h(x,L);function x(p,d){var o;return o=L.call(this,p,d,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var f=x.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var d=this.hls;d.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(P.Events.ERROR,this.onError,this),d.on(P.Events.BUFFER_RESET,this.onBufferReset,this),d.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f._unregisterListeners=function(){var d=this.hls;d.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(P.Events.ERROR,this.onError,this),d.off(P.Events.BUFFER_RESET,this.onBufferReset,this),d.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f.onInitPtsFound=function(d,o){var E=o.frag,v=o.id,T=o.initPTS;if(v==="main"){var I=E.cc;this.initPTS[E.cc]=T,this.log("InitPTS for cc: "+I+" found from main: "+T),this.videoTrackCC=I,this.state===N.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=N.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,o>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=N.State.IDLE):(this.loadedmetadata=!1,this.state=N.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},f.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var d,o=this.levels,E=this.trackId,v=o==null||((d=o[E])===null||d===void 0)?void 0:d.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var T,I=performance.now(),G=this.retryDate;(!G||I>=G||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=N.State.IDLE);break}case N.State.WAITING_INIT_PTS:{var X=this.waitingData;if(X){var J=X.frag,z=X.part,W=X.cache,q=X.complete;if(this.initPTS[J.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var ne=W.flush(),ce={frag:J,part:z,payload:ne,networkDetails:null};this._handleFragmentLoadProgress(ce),q&&L.prototype._handleFragmentLoadComplete.call(this,ce)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+J.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),De=H.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),xe=Object(A.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,J);xe<0&&(a.logger.log("Waiting fragment cc ("+J.cc+") @ "+J.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},f.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var o=this.mediaBuffer?this.mediaBuffer:d,E=o.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},f.doTickIdle=function(){var d,o,E=this.hls,v=this.levels,T=this.media,I=this.trackId,G=E.config;if(!v||!v[I])return;if(!T&&(this.startFragRequested||!G.startFragPrefetch))return;var X=v[I],J=X.details;if(!J||J.live&&this.levelLastLoaded!==I||this.waitForCdnTuneIn(J)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,b.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var W=z.len,q=this.getMaxBufferLength(),ne=this.audioSwitch;if(W>=q&&!ne)return;if(!ne&&this._streamEnded(z,J)){E.trigger(P.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var ce=J.fragments,ve=ce[0].start,De=z.end;if(ne){var xe=this.getLoadPosition();De=xe,J.PTSKnown&&xe<ve&&((z.end>ve||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=ve+.05))}var Ce=this.getNextFragment(De,J);if(!Ce){this.bufferFlushed=!0;return}((d=Ce.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((o=Ce.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(Ce,J):this.loadFragment(Ce,J,De)},f.getMaxBufferLength=function(){var d=L.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return o===null?d:Math.max(d,o.len)},f.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(d,o){var E=o.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(v){return new M.Level(v)})},f.onAudioTrackSwitching=function(d,o){var E=!!o.url;this.trackId=o.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),E?this.setInterval(g):this.resetTransmuxer(),E?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(d,o){this.mainDetails=o.details},f.onAudioTrackLoaded=function(d,o){var E,v=this.levels,T=o.details,I=o.id;if(!v){this.warn("Audio tracks were reset while loading level "+I);return}this.log("Track "+I+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var G=v[I],X=0;if(T.live||(E=G.details)!==null&&E!==void 0&&E.live){var J=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!J)return;!G.details&&T.hasProgramDateTime&&J.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(T,J),X=T.fragments[0].start):X=this.alignPlaylists(T,G.details)}G.details=T,this.levelLastLoaded=I,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(G.details,X),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(d){var o,E=d.frag,v=d.part,T=d.payload,I=this.config,G=this.trackId,X=this.levels;if(!X){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+E.sn+" of level "+E.level+" will not be buffered");return}var J=X[G];console.assert(J,"Audio track is defined on fragment load progress");var z=J.details;console.assert(z,"Audio track details are defined on fragment load progress");var W=I.defaultAudioCodec||J.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new k.default(this.hls,O.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ne=this.initPTS[E.cc],ce=(o=E.initSegment)===null||o===void 0?void 0:o.data;if(ne!==void 0){var ve=!1,De=v?v.index:-1,xe=De!==-1,Ce=new _.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,T.byteLength,De,xe);q.push(T,ce,W,"",E,v,z.totalduration,ve,Ce,ne)}else{a.logger.log("Unknown video PTS for cc "+E.cc+", waiting for video PTS before demuxing audio frag "+E.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Te=this.waitingData=this.waitingData||{frag:E,part:v,cache:new C.default,complete:!1},Ee=Te.cache;Ee.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}L.prototype._handleFragmentLoadComplete.call(this,d)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(d,o){var E=o.tracks.audio;E&&(this.mediaBuffer=E.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},f.onFragBuffered=function(d,o){var E=o.frag,v=o.part;if(E.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(v?" p: "+v.index:"")+" of level "+E.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}E.sn!=="initSegment"&&(this.fragPrevious=E,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,v)},f.onError=function(d,o){switch(o.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,o);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=o.fatal?N.State.ERROR:N.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var E=!0,v=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);v&&v.len>.5&&(E=!this.reduceMaxBufferLength(v.len)),E&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},f.onBufferFlushed=function(d,o){var E=o.type;E===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(d){var o,E="audio",v=this.hls,T=d.remuxResult,I=d.chunkMeta,G=this.getCurrentContext(I);if(!G){this.warn("The loading context changed while buffering fragment "+I.sn+" of level "+I.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(I.level);return}var X=G.frag,J=G.part,z=T.audio,W=T.text,q=T.id3,ne=T.initSegment;if(this.fragContextChanged(X))return;if(this.state=N.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ne!=null&&ne.tracks&&(this._bufferInitSegment(ne.tracks,X,I),v.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:X,id:E,tracks:ne.tracks})),z){var ce=z.startPTS,ve=z.endPTS,De=z.startDTS,xe=z.endDTS;J&&(J.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:ce,endPTS:ve,startDTS:De,endDTS:xe}),X.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,ce,ve,De,xe),this.bufferFragmentData(z,X,J,I)}if(q!=null&&(o=q.samples)!==null&&o!==void 0&&o.length){var Ce=l({frag:X,id:E},q);v.trigger(P.Events.FRAG_PARSING_METADATA,Ce)}if(W){var Te=l({frag:X,id:E},W);v.trigger(P.Events.FRAG_PARSING_USERDATA,Te)}},f._bufferInitSegment=function(d,o,E){if(this.state!==N.State.PARSING)return;d.video&&delete d.video;var v=d.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,d);var T=v.initSegment;if(T!=null&&T.byteLength){var I={type:"audio",frag:o,part:null,chunkMeta:E,parent:o.type,data:T};this.hls.trigger(P.Events.BUFFER_APPENDING,I)}this.tick()},f.loadFragment=function(d,o,E){var v=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||v===F.FragmentState.NOT_LOADED||v===F.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):o.live&&!Object(V.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=N.State.WAITING_INIT_PTS):(this.startFragRequested=!0,L.prototype.loadFragment.call(this,d,o,E)))},f.completeAudioSwitch=function(){var d=this.hls,o=this.media,E=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:E})},x}(N.default);$.default=m},"./src/controller/audio-track-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts"),N=D("./src/errors.ts"),P=D("./src/controller/base-playlist-controller.ts"),H=D("./src/types/loader.ts");function F(k,_){for(var A=0;A<_.length;A++){var y=_[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(k,y.key,y)}}function M(k,_,A){return _&&F(k.prototype,_),A&&F(k,A),k}function O(k,_){k.prototype=Object.create(_.prototype),k.prototype.constructor=k,b(k,_)}function b(k,_){return b=Object.setPrototypeOf||function(y,u){return y.__proto__=u,y},b(k,_)}var C=function(k){O(_,k);function _(y){var u;return u=k.call(this,y,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var A=_.prototype;return A.registerListeners=function(){var u=this.hls;u.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(V.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var u=this.hls;u.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(V.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,k.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(u,a){this.tracks=a.audioTracks||[]},A.onAudioTrackLoaded=function(u,a){var l=a.id,h=a.details,w=this.tracksInGroup[l];if(!w){this.warn("Invalid audio track id "+l);return}var g=w.details;w.details=a.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,g))},A.onLevelLoading=function(u,a){this.switchLevel(a.level)},A.onLevelSwitching=function(u,a){this.switchLevel(a.level)},A.switchLevel=function(u){var a=this.hls.levels[u];if(!(a!=null&&a.audioGroupIds))return;var l=a.audioGroupIds[a.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!h.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var w={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,w),this.selectInitialTrack()}},A.onError=function(u,a){if(k.prototype.onError.call(this,u,a),a.fatal||!a.context)return;a.context.type===H.PlaylistContextType.AUDIO_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},A.setAudioTrack=function(u){var a=this.tracksInGroup;if(u<0||u>=a.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=a[this.trackId];this.log("Now switching to audio-track index "+u);var h=a[u],w=h.id,g=h.groupId,m=g===void 0?"":g,L=h.name,x=h.type,f=h.url;if(this.trackId=u,this.trackName=L,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:w,groupId:m,name:L,type:x,url:f}),h.details&&!h.details.live)return;var p=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(p)},A.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var a=this.trackName,l=this.findTrackId(a)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(u){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var h=a[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},A.loadPlaylist=function(u){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,h=a.groupId,w=a.url;if(u)try{w=u.addDirectives(w)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:w,id:l,groupId:h,deliveryDirectives:u||null})}},M(_,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),_}(P.default);$.default=C},"./src/controller/base-playlist-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return M});var V=D("./src/polyfills/number.ts"),N=D("./src/types/level.ts"),P=D("./src/controller/level-helper.ts"),H=D("./src/utils/logger.ts"),F=D("./src/errors.ts"),M=function(){function O(C,k){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=H.logger.log.bind(H.logger,k+":"),this.warn=H.logger.warn.bind(H.logger,k+":"),this.hls=C}var b=O.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(k,_){_.fatal&&_.type===F.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},b.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},b.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},b.stopLoad=function(){this.canLoad=!1,this.clearTimer()},b.switchParams=function(k,_){var A=_==null?void 0:_.renditionReports;if(A)for(var y=0;y<A.length;y++){var u=A[y],a=""+u.URI;if(a===k.substr(-a.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(_&&this.hls.config.lowLatencyMode){var w=Math.min(_.age-_.partTarget,_.targetduration);h!==void 0&&w>_.partTarget&&(h+=1)}if(Object(V.isFiniteNumber)(l))return new N.HlsUrlParameters(l,Object(V.isFiniteNumber)(h)?h:void 0,N.HlsSkip.No)}}},b.loadPlaylist=function(k){},b.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},b.playlistLoaded=function(k,_,A){var y=this,u=_.details,a=_.stats,l=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||A!=null&&A.live){if(u.reloaded(A),A&&this.log("live playlist "+k+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),A&&u.fragments.length>0&&Object(P.mergeDetails)(A,u),!this.canLoad||!u.live)return;var h,w=void 0,g=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var m=this.hls.config.lowLatencyMode,L=u.lastPartSn,x=u.endSN,f=u.lastPartIndex,p=f!==-1,d=L===x,o=m?0:f;p?(w=d?x+1:L,g=d?o:f+1):w=x+1;var E=u.age,v=E+u.ageHeader,T=Math.min(v-u.partTarget,u.targetduration*1.5);if(T>0){if(A&&T>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+T+" with playlist age: "+u.age),T=0;else{var I=Math.floor(T/u.targetduration);if(w+=I,g!==void 0){var G=Math.round(T%u.targetduration/u.partTarget);g+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+T+" skip sn "+I+" to part "+g)}u.tuneInGoal=T}if(h=this.getDeliveryDirectives(u,_.deliveryDirectives,w,g),m||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,_.deliveryDirectives,w,g);var X=Object(P.computeReloadInterval)(u,a);w!==void 0&&u.canBlockReload&&(X-=u.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(X)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(h)},X)}else this.clearTimer()},b.getDeliveryDirectives=function(k,_,A,y){var u=Object(N.getSkipValue)(k,A);return _!=null&&_.skip&&k.deltaUpdateFailed&&(A=_.msn,y=_.part,u=N.HlsSkip.No),new N.HlsUrlParameters(A,y,u)},b.retryLoadingOrFail=function(k){var _=this,A=this.hls.config,y=this.retryCount<A.levelLoadingMaxRetry;if(y){var u;if(this.retryCount++,k.details.indexOf("LoadTimeOut")>-1&&(u=k.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return _.loadPlaylist()},a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return y},O}()},"./src/controller/base-stream-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"State",function(){return x}),D.d($,"default",function(){return f});var V=D("./src/polyfills/number.ts"),N=D("./src/task-loop.ts"),P=D("./src/controller/fragment-tracker.ts"),H=D("./src/utils/buffer-helper.ts"),F=D("./src/utils/logger.ts"),M=D("./src/events.ts"),O=D("./src/errors.ts"),b=D("./src/types/transmuxer.ts"),C=D("./src/utils/mp4-tools.ts"),k=D("./src/utils/discontinuities.ts"),_=D("./src/controller/fragment-finders.ts"),A=D("./src/controller/level-helper.ts"),y=D("./src/loader/fragment-loader.ts"),u=D("./src/crypt/decrypter.ts"),a=D("./src/utils/time-ranges.ts"),l=D("./src/types/loader.ts");function h(p,d){for(var o=0;o<d.length;o++){var E=d[o];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(p,E.key,E)}}function w(p,d,o){return d&&h(p.prototype,d),o&&h(p,o),p}function g(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function m(p,d){p.prototype=Object.create(d.prototype),p.prototype.constructor=p,L(p,d)}function L(p,d){return L=Object.setPrototypeOf||function(E,v){return E.__proto__=v,E},L(p,d)}var x={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"},f=function(p){m(d,p);function d(E,v,T){var I;return I=p.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=x.STOPPED,I.media=void 0,I.mediaBuffer=void 0,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=T,I.log=F.logger.log.bind(F.logger,T+":"),I.warn=F.logger.warn.bind(F.logger,T+":"),I.hls=E,I.fragmentLoader=new y.default(E.config),I.fragmentTracker=v,I.config=E.config,I.decrypter=new u.default(E,E.config),E.on(M.Events.KEY_LOADED,I.onKeyLoaded,g(I)),I}var o=d.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(v){},o.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},o._streamEnded=function(v,T){var I=this.fragCurrent,G=this.fragmentTracker;if(!T.live&&I&&I.sn===T.endSN&&!v.nextStart){var X=G.getState(I);return X===P.FragmentState.PARTIAL||X===P.FragmentState.OK}return!1},o.onMediaAttached=function(v,T){var I=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),I.addEventListener("seeking",this.onvseeking),I.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===x.STOPPED&&this.startLoad(G.startPosition)},o.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var v=this.config,T=this.fragCurrent,I=this.media,G=this.mediaBuffer,X=this.state,J=I?I.currentTime:0,z=H.BufferHelper.bufferInfo(G||I,J,v.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(J)?J.toFixed(3):J)+", state: "+X),X===x.ENDED)this.resetLoadingState();else if(T&&!z.len){var W=v.maxFragLookUpTolerance,q=T.start-W,ne=T.start+T.duration+W,ce=J>ne;(J<q||ce)&&(ce&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}I&&(this.lastCurrentTime=J),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=J),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(v,T){if(this.state!==x.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=x.IDLE;var I=this.levels[T.frag.level].details;I&&this.loadFragment(T.frag,I,T.frag.start)},o.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=x.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,p.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(v,T){this.log("Loading key for "+v.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=x.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(M.Events.KEY_LOADING,{frag:v})},o.loadFragment=function(v,T,I){this._loadFragForPlayback(v,T,I)},o._loadFragForPlayback=function(v,T,I){var G=this,X=function(z){if(G.fragContextChanged(v)){G.warn("Fragment "+v.sn+(z.part?" p: "+z.part.index:"")+" of level "+v.level+" was dropped during download."),G.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(v,T,I,X).then(function(J){if(!J)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(v)){(z===x.FRAG_LOADING||z===x.BACKTRACKING||!G.fragCurrent&&z===x.PARSING)&&(G.fragmentTracker.removeFragment(v),G.state=x.IDLE);return}if("payload"in J&&(G.log("Loaded fragment "+v.sn+" of level "+v.level),G.hls.trigger(M.Events.FRAG_LOADED,J),G.state===x.BACKTRACKING)){G.fragmentTracker.backtrack(v,J),G.resetFragmentLoading(v);return}G._handleFragmentLoadComplete(J)}).catch(function(J){G.warn(J),G.resetFragmentLoading(v)})},o.flushMainBuffer=function(v,T,I){if(I===void 0&&(I=null),!(v-T))return;var G={startOffset:v,endOffset:T,type:I};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,G)},o._loadInitSegment=function(v){var T=this;this._doFragLoad(v).then(function(I){if(!I||T.fragContextChanged(v)||!T.levels)throw new Error("init load aborted");return I}).then(function(I){var G=T.hls,X=I.payload,J=v.decryptdata;if(X&&X.byteLength>0&&J&&J.key&&J.iv&&J.method==="AES-128"){var z=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(X),J.key.buffer,J.iv.buffer).then(function(W){var q=self.performance.now();return G.trigger(M.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:z,tdecrypt:q}}),I.payload=W,I})}return I}).then(function(I){var G=T.fragCurrent,X=T.hls,J=T.levels;if(!J)throw new Error("init load aborted, missing levels");var z=J[v.level].details;console.assert(z,"Level details are defined when init segment is loaded");var W=v.stats;T.state=x.IDLE,T.fragLoadError=0,v.data=new Uint8Array(I.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),I.frag===G&&X.trigger(M.Events.FRAG_BUFFERED,{stats:W,frag:G,part:null,id:v.type}),T.tick()}).catch(function(I){T.warn(I),T.resetFragmentLoading(v)})},o.fragContextChanged=function(v){var T=this.fragCurrent;return!v||!T||v.level!==T.level||v.sn!==T.sn||v.urlId!==T.urlId},o.fragBufferedComplete=function(v,T){var I=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+a.default.toString(H.BufferHelper.getBuffered(I))),this.state=x.IDLE,this.tick()},o._handleFragmentLoadComplete=function(v){var T=this.transmuxer;if(!T)return;var I=v.frag,G=v.part,X=v.partsLoaded,J=!X||X.length===0||X.some(function(W){return!W}),z=new b.ChunkMetadata(I.level,I.sn,I.stats.chunkCount+1,0,G?G.index:-1,!J);T.flush(z)},o._handleFragmentLoadProgress=function(v){},o._doFragLoad=function(v,T,I,G){var X=this;if(I===void 0&&(I=null),!this.levels)throw new Error("frag load aborted, missing levels");if(I=Math.max(v.start,I||0),this.config.lowLatencyMode&&T){var J=T.partList;if(J&&G){I>v.end&&T.fragmentHint&&(v=T.fragmentHint);var z=this.getNextPart(J,v,I);if(z>-1){var W=J[z];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(J.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(I.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=x.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:v,part:J[z],targetBufferTime:I}),this.doFragPartsLoad(v,J,z,G).catch(function(q){return X.handleFragLoadError(q)})}else if(!v.url||this.loadedEndOfParts(J,I))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(I.toFixed(3))),Object(V.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=x.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:v,targetBufferTime:I}),this.fragmentLoader.load(v,G).catch(function(q){return X.handleFragLoadError(q)})},o.doFragPartsLoad=function(v,T,I,G){var X=this;return new Promise(function(J,z){var W=[],q=function ne(ce){var ve=T[ce];X.fragmentLoader.loadPart(v,ve,G).then(function(De){W[ve.index]=De;var xe=De.part;X.hls.trigger(M.Events.FRAG_LOADED,De);var Ce=T[ce+1];if(Ce&&Ce.fragment===v)ne(ce+1);else return J({frag:v,part:xe,partsLoaded:W})}).catch(z)};q(I)})},o.handleFragLoadError=function(v){var T=v.data;return T&&T.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(M.Events.ERROR,T),null},o._handleTransmuxerFlush=function(v){var T=this.getCurrentContext(v);if(!T||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var I=T.frag,G=T.part,X=T.level,J=self.performance.now();I.stats.parsing.end=J,G&&(G.stats.parsing.end=J),this.updateLevelTiming(I,G,X,v.partial)},o.getCurrentContext=function(v){var T=this.levels,I=v.level,G=v.sn,X=v.part;if(!T||!T[I])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+I+". The current chunk will not be buffered."),null;var J=T[I],z=X>-1?Object(A.getPartWith)(J,G,X):null,W=z?z.fragment:Object(A.getFragmentWithSN)(J,G,this.fragCurrent);return W?{frag:W,part:z,level:J}:null},o.bufferFragmentData=function(v,T,I,G){if(!v||this.state!==x.PARSING)return;var X=v.data1,J=v.data2,z=X;if(X&&J&&(z=Object(C.appendUint8Array)(X,J)),!z||!z.length)return;var W={type:v.type,frag:T,part:I,chunkMeta:G,parent:T.type,data:z};this.hls.trigger(M.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!I&&this.flushBufferGap(T)},o.flushBufferGap=function(v){var T=this.media;if(!T)return;if(!H.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,v.start);return}var I=T.currentTime,G=H.BufferHelper.bufferInfo(T,I,0),X=v.duration,J=Math.min(this.config.maxFragLookUpTolerance*2,X*.25),z=Math.max(Math.min(v.start-J,G.end-J),I+J);v.start-z>J&&this.flushMainBuffer(z,v.start)},o.getFwdBufferInfo=function(v,T){var I=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var X=H.BufferHelper.bufferInfo(v,G,I.maxBufferHole);if(X.len===0&&X.nextStart!==void 0){var J=this.fragmentTracker.getBufferedFrag(G,T);if(J&&X.nextStart<J.end)return H.BufferHelper.bufferInfo(v,G,Math.max(X.nextStart,I.maxBufferHole))}return X},o.getMaxBufferLength=function(v){var T=this.config,I;return v?I=Math.max(8*T.maxBufferSize/v,T.maxBufferLength):I=T.maxBufferLength,Math.min(I,T.maxMaxBufferLength)},o.reduceMaxBufferLength=function(v){var T=this.config,I=v||T.maxBufferLength;return T.maxMaxBufferLength>=I?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(v,T){var I,G,X=T.fragments,J=X.length;if(!J)return null;var z=this.config,W=X[0].start,q;if(T.live){var ne=z.initialLiveManifestSize;if(J<ne)return this.warn("Not enough fragments to start playback (have: "+J+", need: "+ne+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(T,X),this.startPosition=q?this.hls.liveSyncPosition||q.start:v)}else v<=W&&(q=X[0]);if(!q){var ce=z.lowLatencyMode?T.partEnd:T.fragmentEnd;q=this.getFragmentAtPosition(v,ce,T)}return(I=q)!==null&&I!==void 0&&I.initSegment&&!((G=q)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},o.getNextPart=function(v,T,I){for(var G=-1,X=!1,J=!0,z=0,W=v.length;z<W;z++){var q=v[z];if(J=J&&!q.independent,G>-1&&I<q.start)break;var ne=q.loaded;!ne&&(X||q.independent||J)&&q.fragment===T&&(G=z),X=ne}return G},o.loadedEndOfParts=function(v,T){var I=v[v.length-1];return I&&T>I.start&&I.loaded},o.getInitialLiveFragment=function(v,T){var I=this.fragPrevious,G=null;if(I){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+I.programDateTime),G=Object(_.findFragmentByPDT)(T,I.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var X=I.sn+1;if(X>=v.startSN&&X<=v.endSN){var J=T[X-v.startSN];I.cc===J.cc&&(G=J,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(_.findFragWithCC)(T,I.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?v.fragmentEnd:v.edge,v))}return G},o.getFragmentAtPosition=function(v,T,I){var G=this.config,X=this.fragPrevious,J=I.fragments,z=I.endSN,W=I.fragmentHint,q=G.maxFragLookUpTolerance,ne=!!(G.lowLatencyMode&&I.partList&&W);ne&&W&&!this.bitrateTest&&(J=J.concat(W),z=W.sn);var ce;if(v<T){var ve=v>T-q?0:q;ce=Object(_.findFragmentByPTS)(X,J,v,ve)}else ce=J[J.length-1];if(ce){var De=ce.sn-I.startSN,xe=X&&ce.level===X.level,Ce=J[De+1],Te=this.fragmentTracker.getState(ce);if(Te===P.FragmentState.BACKTRACKED){ce=null;for(var Ee=De;J[Ee]&&this.fragmentTracker.getState(J[Ee])===P.FragmentState.BACKTRACKED;)X?ce=J[Ee--]:ce=J[--Ee];ce||(ce=Ce)}else X&&ce.sn===X.sn&&!ne&&(xe&&(ce.sn<z&&this.fragmentTracker.getState(Ce)!==P.FragmentState.OK?(this.log("SN "+ce.sn+" just loaded, load next one: "+Ce.sn),ce=Ce):ce=null))}return ce},o.synchronizeToLiveEdge=function(v){var T=this.config,I=this.media;if(!I)return;var G=this.hls.liveSyncPosition,X=I.currentTime,J=v.fragments[0].start,z=v.edge,W=X>=J-T.maxFragLookUpTolerance&&X<=z;if(G!==null&&I.duration>G&&(X<G||!W)){var q=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*v.targetduration;(!W&&I.readyState<4||X<z-q)&&(this.loadedmetadata||(this.nextLoadPosition=G),I.readyState&&(this.warn("Playback: "+X.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),I.currentTime=G))}},o.alignPlaylists=function(v,T){var I=this.levels,G=this.levelLastLoaded,X=this.fragPrevious,J=G!==null?I[G]:null,z=v.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,q=!T,ne=v.alignedSliding&&Object(V.isFiniteNumber)(W);if(q||!ne&&!W){Object(k.alignStream)(X,J,v);var ce=v.fragments[0].start;return this.log("Live playlist sliding: "+ce.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+v.startSN+" prev-sn: "+(X?X.sn:"na")+" fragments: "+z),ce}return W},o.waitForCdnTuneIn=function(v){var T=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*T)},o.setStartPosition=function(v,T){var I=this.startPosition;if(I<T&&(I=-1),I===-1||this.lastCurrentTime===-1){var G=v.startTimeOffset;Object(V.isFiniteNumber)(G)?(I=T+G,G<0&&(I+=v.totalduration),I=Math.min(Math.max(T,I),T+v.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+I),this.startPosition=I):v.live?I=this.hls.liveSyncPosition||T:this.startPosition=I=0,this.lastCurrentTime=I}this.nextLoadPosition=I},o.getLoadPosition=function(){var v=this.media,T=0;return this.loadedmetadata&&v?T=v.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},o.handleFragLoadAborted=function(v,T){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(T?" part"+T.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},o.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=x.IDLE)},o.onFragmentOrKeyLoadError=function(v,T){if(T.fatal)return;var I=T.frag;if(!I||I.type!==v)return;var G=this.fragCurrent;console.assert(G&&I.sn===G.sn&&I.level===G.level&&I.urlId===G.urlId,"Frag load error must match current frag to retry");var X=this.config;if(this.fragLoadError+1<=X.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(I.level))return;var J=Math.min(Math.pow(2,this.fragLoadError)*X.fragLoadingRetryDelay,X.fragLoadingMaxRetryTimeout);this.warn("Fragment "+I.sn+" of "+v+" "+I.level+" failed to load, retrying in "+J+"ms"),this.retryDate=self.performance.now()+J,this.fragLoadError++,this.state=x.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(v===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(F.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},o.afterBufferFlushed=function(v,T,I){if(!v)return;var G=H.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(T,G,I),this.state===x.ENDED&&this.resetLoadingState()},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},o.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[v].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(v,T,I,G){var X=this,J=I.details;console.assert(!!J,"level.details must be defined");var z=Object.keys(v.elementaryStreams).reduce(function(W,q){var ne=v.elementaryStreams[q];if(ne){var ce=ne.endPTS-ne.startPTS;if(ce<=0)return X.warn("Could not parse fragment "+v.sn+" "+q+" duration reliably ("+ce+") resetting transmuxer to fallback to playlist timing"),X.resetTransmuxer(),W||!1;var ve=G?0:Object(A.updateFragPTSDTS)(J,v,ne.startPTS,ne.endPTS,ne.startDTS,ne.endDTS);return X.hls.trigger(M.Events.LEVEL_PTS_UPDATED,{details:J,level:I,drift:ve,type:q,frag:v,start:ne.startPTS,end:ne.endPTS}),!0}return W},!1);z?(this.state=x.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:v,part:T})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},w(d,[{key:"state",get:function(){return this._state},set:function(v){var T=this._state;T!==v&&(this._state=v,this.log(T+"->"+v))}}]),d}(N.default)},"./src/controller/buffer-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return _});var V=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),P=D("./src/utils/logger.ts"),H=D("./src/errors.ts"),F=D("./src/utils/buffer-helper.ts"),M=D("./src/utils/mediasource-helper.ts"),O=D("./src/loader/fragment.ts"),b=D("./src/controller/buffer-operation-queue.ts"),C=Object(M.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,_=function(){function A(u){var a=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=a.hls,h=a.media,w=a.mediaSource;P.logger.log("[buffer-controller]: Media source opened"),h&&(a.updateMediaElementDuration(),l.trigger(N.Events.MEDIA_ATTACHED,{media:h})),w&&w.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){P.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var y=A.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var a=this.hls;a.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(N.Events.BUFFER_RESET,this.onBufferReset,this),a.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(N.Events.BUFFER_EOS,this.onBufferEos,this),a.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(N.Events.FRAG_PARSED,this.onFragParsed,this),a.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var a=this.hls;a.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(N.Events.BUFFER_RESET,this.onBufferReset,this),a.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(N.Events.BUFFER_EOS,this.onBufferEos,this),a.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(N.Events.FRAG_PARSED,this.onFragParsed,this),a.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(a,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,P.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(a,l){var h=this.media=l.media;if(h&&C){var w=this.mediaSource=new C;w.addEventListener("sourceopen",this._onMediaSourceOpen),w.addEventListener("sourceended",this._onMediaSourceEnded),w.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(w),this._objectUrl=h.src}},y.onMediaDetaching=function(){var a=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(P.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(w){P.logger.warn("[buffer-controller]: onMediaDetaching: "+w.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(h&&self.URL.revokeObjectURL(h),a.src===h?(a.removeAttribute("src"),a.load()):P.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(N.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];try{h&&(a.removeBufferListeners(l),a.mediaSource&&a.mediaSource.removeSourceBuffer(h),a.sourceBuffer[l]=void 0)}catch(w){P.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",w)}}),this._initSourceBuffer()},y.onBufferCodecs=function(a,l){var h=this,w=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(g){if(w){var m=h.tracks[g];if(m&&typeof m.buffer.changeType=="function"){var L=l[g],x=L.codec,f=L.levelCodec,p=L.container,d=(m.levelCodec||m.codec).replace(k,"$1"),o=(f||x).replace(k,"$1");if(d!==o){var E=p+";codecs="+(f||x);h.appendChangeType(g,E)}}}else h.pendingTracks[g]=l[g]}),w)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},y.appendChangeType=function(a,l){var h=this,w=this.operationQueue,g={execute:function(){var L=h.sourceBuffer[a];L&&(P.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+l),L.changeType(l)),w.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(L){P.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",L)}};w.append(g,a)},y.onBufferAppending=function(a,l){var h=this,w=this.hls,g=this.operationQueue,m=this.tracks,L=l.data,x=l.type,f=l.frag,p=l.part,d=l.chunkMeta,o=d.buffering[x],E=self.performance.now();o.start=E;var v=f.stats.buffering,T=p?p.stats.buffering:null;v.start===0&&(v.start=E),T&&T.start===0&&(T.start=E);var I=m.audio,G=x==="audio"&&d.id===1&&(I==null?void 0:I.container)==="audio/mpeg",X={execute:function(){if(o.executeStart=self.performance.now(),G){var z=h.sourceBuffer[x];if(z){var W=f.start-z.timestampOffset;Math.abs(W)>=.1&&(P.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+W+") sn: "+f.sn+")"),z.timestampOffset=f.start)}}h.appendExecutor(L,x)},onStart:function(){},onComplete:function(){var z=self.performance.now();o.executeEnd=o.end=z,v.first===0&&(v.first=z),T&&T.first===0&&(T.first=z);var W=h.sourceBuffer,q={};for(var ne in W)q[ne]=F.BufferHelper.getBuffered(W[ne]);h.appendError=0,h.hls.trigger(N.Events.BUFFER_APPENDED,{type:x,frag:f,part:p,chunkMeta:d,parent:f.type,timeRanges:q})},onError:function(z){P.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",z);var W={type:H.ErrorTypes.MEDIA_ERROR,parent:f.type,details:H.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=H.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=H.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>w.config.appendErrorMaxRetry&&(P.logger.error("[buffer-controller]: Failed "+w.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0)),w.trigger(N.Events.ERROR,W)}};g.append(X,x)},y.onBufferFlushing=function(a,l){var h=this,w=this.operationQueue,g=function(L){return{execute:h.removeExecutor.bind(h,L,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(N.Events.BUFFER_FLUSHED,{type:L})},onError:function(f){P.logger.warn("[buffer-controller]: Failed to remove from "+L+" SourceBuffer",f)}}};l.type?w.append(g(l.type),l.type):this.getSourceBufferTypes().forEach(function(m){w.append(g(m),m)})},y.onFragParsed=function(a,l){var h=this,w=l.frag,g=l.part,m=[],L=g?g.elementaryStreams:w.elementaryStreams;L[O.ElementaryStreamTypes.AUDIOVIDEO]?m.push("audiovideo"):(L[O.ElementaryStreamTypes.AUDIO]&&m.push("audio"),L[O.ElementaryStreamTypes.VIDEO]&&m.push("video"));var x=function(){var p=self.performance.now();w.stats.buffering.end=p,g&&(g.stats.buffering.end=p);var d=g?g.stats:w.stats;h.hls.trigger(N.Events.FRAG_BUFFERED,{frag:w,part:g,stats:d,id:w.type})};m.length===0&&P.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+w.type+" level: "+w.level+" sn: "+w.sn),this.blockBuffers(x,m)},y.onFragChanged=function(a,l){this.flushBackBuffer()},y.onBufferEos=function(a,l){var h=this,w=this.getSourceBufferTypes().reduce(function(g,m){var L=h.sourceBuffer[m];return(!l.type||l.type===m)&&(L&&!L.ended&&(L.ended=!0,P.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),g&&!!(!L||L.ended)},!0);w&&this.blockBuffers(function(){var g=h.mediaSource;if(!g||g.readyState!=="open")return;g.endOfStream()})},y.onLevelUpdated=function(a,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},y.flushBackBuffer=function(){var a=this.hls,l=this.details,h=this.media,w=this.sourceBuffer;if(!h||l===null)return;var g=this.getSourceBufferTypes();if(!g.length)return;var m=l.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!Object(V.isFiniteNumber)(m)||m<0)return;var L=h.currentTime,x=l.levelTargetDuration,f=Math.max(m,x),p=Math.floor(L/x)*x-f;g.forEach(function(d){var o=w[d];if(o){var E=F.BufferHelper.getBuffered(o);E.length>0&&p>E.start(0)&&(a.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),l.live&&a.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),a.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:d}))}})},y.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var a=this.details,l=this.hls,h=this.media,w=this.mediaSource,g=a.fragments[0].start+a.totalduration,m=h.duration,L=Object(V.isFiniteNumber)(w.duration)?w.duration:0;a.live&&l.config.liveDurationInfinity?(P.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),w.duration=Infinity,this.updateSeekableRange(a)):(g>L&&g>m||!Object(V.isFiniteNumber)(m))&&(P.logger.log("[buffer-controller]: Updating Media Source duration to "+g.toFixed(3)),w.duration=g)},y.updateSeekableRange=function(a){var l=this.mediaSource,h=a.fragments,w=h.length;if(w&&a.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var g=Math.max(0,h[0].start),m=Math.max(g,g+a.totalduration);l.setLiveSeekableRange(g,m)}},y.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,w=Object.keys(h).length;if(w&&!a||w===2){this.createSourceBuffers(h),this.pendingTracks={};var g=this.getSourceBufferTypes();if(g.length===0){this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}g.forEach(function(m){l.executeNext(m)})}},y.createSourceBuffers=function(a){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var w=0;for(var g in a)if(!l[g]){var m=a[g];if(!m)throw Error("source buffer exists for track "+g+", however track does not");var L=m.levelCodec||m.codec,x=m.container+";codecs="+L;P.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var f=l[g]=h.addSourceBuffer(x),p=g;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[g]={buffer:f,codec:L,container:m.container,levelCodec:m.levelCodec,id:m.id},w++}catch(d){P.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:x})}}w&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(a){var l=this.operationQueue,h=l.current(a);h.onStart()},y._onSBUpdateEnd=function(a){var l=this.operationQueue,h=l.current(a);h.onComplete(),l.shiftAndExecuteNext(a)},y._onSBUpdateError=function(a,l){P.logger.error("[buffer-controller]: "+a+" SourceBuffer error",l),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(a);h&&h.onError(l)},y.removeExecutor=function(a,l,h){var w=this.media,g=this.mediaSource,m=this.operationQueue,L=this.sourceBuffer,x=L[a];if(!w||!g||!x){P.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(a);return}var f=Object(V.isFiniteNumber)(w.duration)?w.duration:Infinity,p=Object(V.isFiniteNumber)(g.duration)?g.duration:Infinity,d=Math.max(0,l),o=Math.min(h,f,p);o>d?(P.logger.log("[buffer-controller]: Removing ["+d+","+o+"] from the "+a+" SourceBuffer"),console.assert(!x.updating,a+" sourceBuffer must not be updating"),x.remove(d,o)):m.shiftAndExecuteNext(a)},y.appendExecutor=function(a,l){var h=this.operationQueue,w=this.sourceBuffer,g=w[l];if(!g){P.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}g.ended=!1,console.assert(!g.updating,l+" sourceBuffer must not be updating"),g.appendBuffer(a)},y.blockBuffers=function(a,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){P.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(a);return}var w=this.operationQueue,g=l.map(function(m){return w.appendBlocker(m)});Promise.all(g).then(function(){a(),l.forEach(function(m){var L=h.sourceBuffer[m];(!L||!L.updating)&&w.shiftAndExecuteNext(m)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(a,l,h){var w=this.sourceBuffer[a];if(!w)return;var g=h.bind(this,a);this.listeners[a].push({event:l,listener:g}),w.addEventListener(l,g)},y.removeBufferListeners=function(a){var l=this.sourceBuffer[a];if(!l)return;this.listeners[a].forEach(function(h){l.removeEventListener(h.event,h.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return N});var V=D("./src/utils/logger.ts"),N=function(){function P(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var H=P.prototype;return H.append=function(M,O){var b=this.queues[O];b.push(M),b.length===1&&this.buffers[O]&&this.executeNext(O)},H.insertAbort=function(M,O){var b=this.queues[O];b.unshift(M),this.executeNext(O)},H.appendBlocker=function(M){var O,b=new Promise(function(k){O=k}),C={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(C,M),b},H.executeNext=function(M){var O=this.buffers,b=this.queues,C=O[M],k=b[M];if(k.length){var _=k[0];try{_.execute()}catch(A){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),_.onError(A),(!C||!C.updating)&&(k.shift(),this.executeNext(M))}}},H.shiftAndExecuteNext=function(M){this.queues[M].shift(),this.executeNext(M)},H.current=function(M){return this.queues[M][0]},P}()},"./src/controller/cap-level-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts");function N(F,M){for(var O=0;O<M.length;O++){var b=M[O];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(F,b.key,b)}}function P(F,M,O){return M&&N(F.prototype,M),O&&N(F,O),F}var H=function(){function F(O){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=O,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var M=F.prototype;return M.setStreamController=function(b){this.streamController=b},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 b=this.hls;b.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var b=this.hls;b.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(b,C){F.isLevelAllowed(C.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(C.droppedLevel)},M.onMediaAttaching=function(b,C){this.media=C.media instanceof HTMLVideoElement?C.media:null},M.onManifestParsed=function(b,C){var k=this.hls;this.restrictedLevels=[],this.firstLevel=C.firstLevel,k.config.capLevelToPlayerSize&&C.video&&this.startCapping()},M.onBufferCodecs=function(b,C){var k=this.hls;k.config.capLevelToPlayerSize&&C.video&&this.startCapping()},M.onMediaDetaching=function(){this.stopCapping()},M.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var b=this.hls.levels;if(b.length){var C=this.hls;C.autoLevelCapping=this.getMaxLevel(b.length-1),C.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=C.autoLevelCapping}}},M.getMaxLevel=function(b){var C=this,k=this.hls.levels;if(!k.length)return-1;var _=k.filter(function(A,y){return F.isLevelAllowed(y,C.restrictedLevels)&&y<=b});return this.clientRect=null,F.getMaxLevelByMediaSize(_,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 b=this.media,C={width:0,height:0};if(b){var k=b.getBoundingClientRect();C.width=k.width,C.height=k.height,!C.width&&!C.height&&(C.width=k.right-k.left||b.width||0,C.height=k.bottom-k.top||b.height||0)}return this.clientRect=C,C},F.isLevelAllowed=function(b,C){return C===void 0&&(C=[]),C.indexOf(b)===-1},F.getMaxLevelByMediaSize=function(b,C,k){if(!b||!b.length)return-1;for(var _=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},A=b.length-1,y=0;y<b.length;y+=1){var u=b[y];if((u.width>=C||u.height>=k)&&_(u,b[y+1])){A=y;break}}return A},P(F,[{key:"mediaWidth",get:function(){return this.getDimensions().width*F.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*F.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var b=1;try{b=self.devicePixelRatio}catch(C){}return b}}]),F}();$.default=H},"./src/controller/cmcd-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return _});var V=D("./src/events.ts"),N=D("./src/types/cmcd.ts"),P=D("./src/utils/buffer-helper.ts"),H=D("./src/utils/logger.ts");function F(A,y){for(var u=0;u<y.length;u++){var a=y[u];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(A,a.key,a)}}function M(A,y,u){return y&&F(A.prototype,y),u&&F(A,u),A}function O(A,y){var u=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(u)return(u=u.call(A)).next.bind(u);if(Array.isArray(A)||(u=b(A))||y&&A&&typeof A.length=="number"){u&&(A=u);var a=0;return function(){return a>=A.length?{done:!0}:{done:!1,value:A[a++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(A,y){if(!A)return;if(typeof A=="string")return C(A,y);var u=Object.prototype.toString.call(A).slice(8,-1);if(u==="Object"&&A.constructor&&(u=A.constructor.name),u==="Map"||u==="Set")return Array.from(A);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return C(A,y)}function C(A,y){(y==null||y>A.length)&&(y=A.length);for(var u=0,a=new Array(y);u<y;u++)a[u]=A[u];return a}function k(){return k=Object.assign||function(A){for(var y=1;y<arguments.length;y++){var u=arguments[y];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(A[a]=u[a])}return A},k.apply(this,arguments)}var _=function(){function A(u){var a=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){a.initialized&&(a.starved=!0),a.buffering=!0},this.onPlaying=function(){a.initialized||(a.initialized=!0),a.buffering=!1},this.applyPlaylistData=function(w){try{a.apply(w,{ot:N.CMCDObjectType.MANIFEST,su:!a.initialized})}catch(g){H.logger.warn("Could not generate manifest CMCD data.",g)}},this.applyFragmentData=function(w){try{var g=w.frag,m=a.hls.levels[g.level],L=a.getObjectType(g),x={d:g.duration*1e3,ot:L};(L===N.CMCDObjectType.VIDEO||L===N.CMCDObjectType.AUDIO||L==N.CMCDObjectType.MUXED)&&(x.br=m.bitrate/1e3,x.tb=a.getTopBandwidth(L),x.bl=a.getBufferLength(L)),a.apply(w,x)}catch(f){H.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=u;var l=this.config=u.config,h=l.cmcd;h!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||A.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var y=A.prototype;return y.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},y.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(a,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},y.onBufferCreated=function(a,l){var h,w;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(w=l.tracks.video)===null||w===void 0?void 0:w.buffer},y.createData=function(){var a;return{v:N.CMCDVersion,sf:N.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(a=this.media)===null||a===void 0?void 0:a.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},y.apply=function(a,l){l===void 0&&(l={}),k(l,this.createData());var h=l.ot===N.CMCDObjectType.INIT||l.ot===N.CMCDObjectType.VIDEO||l.ot===N.CMCDObjectType.MUXED;if(this.starved&&h&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var w=A.toHeaders(l);if(!Object.keys(w).length)return;a.headers||(a.headers={}),k(a.headers,w)}else{var g=A.toQuery(l);if(!g)return;a.url=A.appendQueryToUri(a.url,g)}},y.getObjectType=function(a){var l=a.type;return l==="subtitle"?N.CMCDObjectType.TIMED_TEXT:a.sn==="initSegment"?N.CMCDObjectType.INIT:l==="audio"?N.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},y.getTopBandwidth=function(a){for(var l=0,h=a===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,w=O(h),g;!(g=w()).done;){var m=g.value;m.bitrate>l&&(l=m.bitrate)}return l>0?l:NaN},y.getBufferLength=function(a){var l=this.hls.media,h=a===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var w=P.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return w.len*1e3},y.createPlaylistLoader=function(){var a=this.config.pLoader,l=this.applyPlaylistData,h=a||this.config.loader;return function(){function w(m){this.loader=void 0,this.loader=new h(m)}var g=w.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(L,x,f){l(L),this.loader.load(L,x,f)},M(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},y.createFragmentLoader=function(){var a=this.config.fLoader,l=this.applyFragmentData,h=a||this.config.loader;return function(){function w(m){this.loader=void 0,this.loader=new h(m)}var g=w.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(L,x,f){l(L),this.loader.load(L,x,f)},M(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},A.uuid=function(){var a=URL.createObjectURL(new Blob),l=a.toString();return URL.revokeObjectURL(a),l.substr(l.lastIndexOf("/")+1)},A.serialize=function(a){for(var l=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},w=function(G){return Math.round(G)},g=function(G){return w(G/100)*100},m=function(G){return encodeURIComponent(G)},L={br:w,d:w,bl:g,dl:g,mtp:g,nor:m,rtp:g,tb:w},x=Object.keys(a||{}).sort(),f=O(x),p;!(p=f()).done;){var d=p.value,o=a[d];if(!h(o))continue;if(d==="v"&&o===1)continue;if(d=="pr"&&o===1)continue;var E=L[d];E&&(o=E(o));var v=typeof o,T=void 0;d==="ot"||d==="sf"||d==="st"?T=d+"="+o:v==="boolean"?T=d:v==="number"?T=d+"="+o:T=d+"="+JSON.stringify(o),l.push(T)}return l.join(",")},A.toHeaders=function(a){for(var l=Object.keys(a),h={},w=["Object","Request","Session","Status"],g=[{},{},{},{}],m={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},L=0,x=l;L<x.length;L++){var f=x[L],p=m[f]!=null?m[f]:1;g[p][f]=a[f]}for(var d=0;d<g.length;d++){var o=A.serialize(g[d]);o&&(h["CMCD-"+w[d]]=o)}return h},A.toQuery=function(a){return"CMCD="+encodeURIComponent(A.serialize(a))},A.appendQueryToUri=function(a,l){if(!l)return a;var h=a.includes("?")?"&":"?";return""+a+h+l},A}()},"./src/controller/eme-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts"),N=D("./src/errors.ts"),P=D("./src/utils/logger.ts"),H=D("./src/utils/mediakeys-helper.ts");function F(_,A){for(var y=0;y<A.length;y++){var u=A[y];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function M(_,A,y){return A&&F(_.prototype,A),y&&F(_,y),_}var O=3,b=function(A,y,u){var a={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(l){a.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),y.forEach(function(l){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[a]},C=function(A,y,u,a){switch(A){case H.KeySystems.WIDEVINE:return b(y,u,a);default:throw new Error("Unknown key-system: "+A)}},k=function(){function _(y){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=y,this._config=y.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=_.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(u){switch(u){case H.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},A._attemptKeySystemAccess=function(u,a,l){var h=this,w=C(u,a,l,this._drmSystemOptions);P.logger.log("Requesting encrypted media key-system access");var g=this.requestMediaKeySystemAccess(u,w);this.mediaKeysPromise=g.then(function(m){return h._onMediaKeySystemAccessObtained(u,m)}),g.catch(function(m){P.logger.error('Failed to obtain key-system "'+u+'" access:',m)})},A._onMediaKeySystemAccessObtained=function(u,a){var l=this;P.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:a,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var w=Promise.resolve().then(function(){return a.createMediaKeys()}).then(function(g){return h.mediaKeys=g,P.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),g});return w.catch(function(g){P.logger.error("Failed to create media-keys:",g)}),w},A._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(a){a.mediaKeysSession||(a.mediaKeysSession=a.mediaKeys.createSession(),u._onNewMediaKeySession(a.mediaKeysSession))})},A._onNewMediaKeySession=function(u){var a=this;P.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){a._onKeySessionMessage(u,l.message)},!1)},A._onKeySessionMessage=function(u,a){P.logger.log("Got EME message event, creating license request"),this._requestLicense(a,function(l){P.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},A.onMediaEncrypted=function(u){var a=this;if(P.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(w){if(!a._media)return;a._attemptSetMediaKeys(w),a._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},A._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var a=this._mediaKeysList[0];if(!a||!a.mediaKeys){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}P.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(a.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(u,a){var l=this,h=this._mediaKeysList[0];if(!h){P.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){P.logger.warn("Key-Session already initialized but requested again");return}var w=h.mediaKeysSession;if(!w){P.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!a){P.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}P.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,w.generateRequest(u,a).then(function(){P.logger.debug("Key-session generation succeeded")}).catch(function(g){P.logger.error("Error generating key-session request:",g),l.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(u,a,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,a,l);var w=this._licenseXhrSetup;if(w)try{w.call(this.hls,h,u),w=void 0}catch(g){P.logger.error(g)}try{h.readyState||h.open("POST",u,!0),w&&w.call(this.hls,h,u)}catch(g){throw new Error("issue setting up KeySystem license XHR "+g)}return h},A._onLicenseRequestReadyStageChange=function(u,a,l,h){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,P.logger.log("License request succeeded");var w=u.response,g=this._licenseResponseCallback;if(g)try{w=g.call(this.hls,u,a)}catch(L){P.logger.error(L)}h(w)}else{if(P.logger.error("License Request XHR failed ("+a+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>O){this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var m=O-this._requestLicenseFailureCount+1;P.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(l,h)}break}},A._generateLicenseRequestChallenge=function(u,a){switch(u.mediaKeySystemDomain){case H.KeySystems.WIDEVINE:return a}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},A._requestLicense=function(u,a){P.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){P.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),w=this._createLicenseXhr(h,u,a);P.logger.log("Sending license request to URL: "+h);var g=this._generateLicenseRequestChallenge(l,u);w.send(g)}catch(m){P.logger.error("Failure requesting DRM license: "+m),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(u,a){if(!this._emeEnabled)return;var l=a.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},A.onMediaDetached=function(){var u=this._media,a=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(a.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(u,a){if(!this._emeEnabled)return;var l=a.levels.map(function(w){return w.audioCodec}).filter(function(w){return!!w}),h=a.levels.map(function(w){return w.videoCodec}).filter(function(w){return!!w});this._attemptKeySystemAccess(H.KeySystems.WIDEVINE,l,h)},M(_,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),_}();$.default=k},"./src/controller/fps-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts"),N=D("./src/utils/logger.ts"),P=function(){function H(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 F=H.prototype;return F.setStreamController=function(O){this.streamController=O},F.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(O,b){var C=this.hls.config;if(C.capLevelOnFPSDrop){var k=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=k,k&&typeof k.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),C.fpsDroppedMonitoringPeriod)}},F.checkFPS=function(O,b,C){var k=performance.now();if(b){if(this.lastTime){var _=k-this.lastTime,A=C-this.lastDroppedFrames,y=b-this.lastDecodedFrames,u=1e3*A/_,a=this.hls;if(a.trigger(V.Events.FPS_DROP,{currentDropped:A,currentDecoded:y,totalDroppedFrames:C}),u>0&&A>a.config.fpsDroppedMonitoringThreshold*y){var l=a.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(a.autoLevelCapping===-1||a.autoLevelCapping>=l)&&(l=l-1,a.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:a.currentLevel}),a.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=C,this.lastDecodedFrames=b}},F.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var b=O.getVideoPlaybackQuality();this.checkFPS(O,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},H}();$.default=P},"./src/controller/fragment-finders.ts":function(ie,$,D){"use strict";D.r($),D.d($,"findFragmentByPDT",function(){return P}),D.d($,"findFragmentByPTS",function(){return H}),D.d($,"fragmentWithinToleranceTest",function(){return F}),D.d($,"pdtWithinToleranceTest",function(){return M}),D.d($,"findFragWithCC",function(){return O});var V=D("./src/polyfills/number.ts"),N=D("./src/utils/binary-search.ts");function P(b,C,k){if(C===null||!Array.isArray(b)||!b.length||!Object(V.isFiniteNumber)(C))return null;var _=b[0].programDateTime;if(C<(_||0))return null;var A=b[b.length-1].endProgramDateTime;if(C>=(A||0))return null;k=k||0;for(var y=0;y<b.length;++y){var u=b[y];if(M(C,k,u))return u}return null}function H(b,C,k,_){k===void 0&&(k=0),_===void 0&&(_=0);var A=null;if(b?A=C[b.sn-C[0].sn+1]||null:k===0&&C[0].start===0&&(A=C[0]),A&&F(k,_,A)===0)return A;var y=N.default.search(C,F.bind(null,k,_));return y||A}function F(b,C,k){b===void 0&&(b=0),C===void 0&&(C=0);var _=Math.min(C,k.duration+(k.deltaPTS?k.deltaPTS:0));return k.start+k.duration-_<=b?1:k.start-_>b&&k.start?-1:0}function M(b,C,k){var _=Math.min(C,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,A=k.endProgramDateTime||0;return A-_>b}function O(b,C){return N.default.search(b,function(k){return k.cc<C?1:k.cc>C?-1:0})}},"./src/controller/fragment-tracker.ts":function(ie,$,D){"use strict";D.r($),D.d($,"FragmentState",function(){return P}),D.d($,"FragmentTracker",function(){return H});var V=D("./src/events.ts"),N=D("./src/types/loader.ts"),P;(function(O){O.NOT_LOADED="NOT_LOADED",O.BACKTRACKED="BACKTRACKED",O.APPENDING="APPENDING",O.PARTIAL="PARTIAL",O.OK="OK"})(P||(P={}));var H=function(){function O(C){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=C,this._registerListeners()}var b=O.prototype;return b._registerListeners=function(){var k=this.hls;k.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var k=this.hls;k.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(k,_){if(_===N.PlaylistLevelType.MAIN){var A=this.activeFragment,y=this.activeParts;if(!A)return null;if(y)for(var u=y.length;u--;){var a=y[u],l=a?a.end:A.appendedPTS;if(a.start<=k&&l!==void 0&&k<=l)return u>9&&(this.activeParts=y.slice(u-9)),a}else if(A.start<=k&&A.appendedPTS!==void 0&&k<=A.appendedPTS)return A}return this.getBufferedFrag(k,_)},b.getBufferedFrag=function(k,_){for(var A=this.fragments,y=Object.keys(A),u=y.length;u--;){var a=A[y[u]];if((a==null?void 0:a.body.type)===_&&a.buffered){var l=a.body;if(l.start<=k&&k<=l.end)return l}}return null},b.detectEvictedFragments=function(k,_,A){var y=this;Object.keys(this.fragments).forEach(function(u){var a=y.fragments[u];if(!a)return;if(!a.buffered){a.body.type===A&&y.removeFragment(a.body);return}var l=a.range[k];if(!l)return;l.time.some(function(h){var w=!y.isTimeBuffered(h.startPTS,h.endPTS,_);return w&&y.removeFragment(a.body),w})})},b.detectPartialFragments=function(k){var _=this,A=this.timeRanges,y=k.frag,u=k.part;if(!A||y.sn==="initSegment")return;var a=M(y),l=this.fragments[a];if(!l)return;Object.keys(A).forEach(function(h){var w=y.elementaryStreams[h];if(!w)return;var g=A[h],m=u!==null||w.partial===!0;l.range[h]=_.getBufferedTimes(y,u,m,g)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},b.fragBuffered=function(k){var _=M(k),A=this.fragments[_];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},b.getBufferedTimes=function(k,_,A,y){for(var u={time:[],partial:A},a=_?_.start:k.start,l=_?_.end:k.end,h=k.minEndPTS||l,w=k.maxStartPTS||a,g=0;g<y.length;g++){var m=y.start(g)-this.bufferPadding,L=y.end(g)+this.bufferPadding;if(w>=m&&h<=L){u.time.push({startPTS:Math.max(a,y.start(g)),endPTS:Math.min(l,y.end(g))});break}else if(a<L&&l>m)u.partial=!0,u.time.push({startPTS:Math.max(a,y.start(g)),endPTS:Math.min(l,y.end(g))});else if(l<=m)break}return u},b.getPartialFragment=function(k){var _=null,A,y,u,a=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(w){var g=h[w];if(!g)return;F(g)&&(y=g.body.start-l,u=g.body.end+l,k>=y&&k<=u&&(A=Math.min(k-y,u-k),a<=A&&(_=g.body,a=A)))}),_},b.getState=function(k){var _=M(k),A=this.fragments[_];return A?A.buffered?F(A)?P.PARTIAL:P.OK:A.backtrack?P.BACKTRACKED:P.APPENDING:P.NOT_LOADED},b.backtrack=function(k,_){var A=M(k),y=this.fragments[A];if(!y||y.backtrack)return null;var u=y.backtrack=_||y.loaded;return y.loaded=null,u},b.getBacktrackData=function(k){var _=M(k),A=this.fragments[_];if(A){var y,u=A.backtrack;if(u!=null&&(y=u.payload)!==null&&y!==void 0&&y.byteLength)return u;this.removeFragment(k)}return null},b.isTimeBuffered=function(k,_,A){for(var y,u,a=0;a<A.length;a++){if(y=A.start(a)-this.bufferPadding,u=A.end(a)+this.bufferPadding,k>=y&&_<=u)return!0;if(_<=y)return!1}return!1},b.onFragLoaded=function(k,_){var A=_.frag,y=_.part;if(A.sn==="initSegment"||A.bitrateTest||y)return;var u=M(A);this.fragments[u]={body:A,loaded:_,backtrack:null,buffered:!1,range:Object.create(null)}},b.onBufferAppended=function(k,_){var A=this,y=_.frag,u=_.part,a=_.timeRanges;if(y.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=y,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(h){var w=a[h];if(A.detectEvictedFragments(h,w),!u)for(var g=0;g<w.length;g++)y.appendedPTS=Math.max(w.end(g),y.appendedPTS||0)})},b.onFragBuffered=function(k,_){this.detectPartialFragments(_)},b.hasFragment=function(k){var _=M(k);return!!this.fragments[_]},b.removeFragmentsInRange=function(k,_,A){var y=this;Object.keys(this.fragments).forEach(function(u){var a=y.fragments[u];if(!a)return;if(a.buffered){var l=a.body;l.type===A&&l.start<_&&l.end>k&&y.removeFragment(l)}})},b.removeFragment=function(k){var _=M(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[_]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function F(O){var b,C;return O.buffered&&(((b=O.range.video)===null||b===void 0?void 0:b.partial)||((C=O.range.audio)===null||C===void 0?void 0:C.partial))}function M(O){return O.type+"_"+O.level+"_"+O.urlId+"_"+O.sn}},"./src/controller/gap-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"STALL_MINIMUM_DURATION_MS",function(){return F}),D.d($,"MAX_START_GAP_JUMP",function(){return M}),D.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),D.d($,"SKIP_BUFFER_RANGE_START",function(){return b}),D.d($,"default",function(){return C});var V=D("./src/utils/buffer-helper.ts"),N=D("./src/errors.ts"),P=D("./src/events.ts"),H=D("./src/utils/logger.ts"),F=250,M=2,O=.1,b=.05,C=function(){function k(A,y,u,a){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=A,this.media=y,this.fragmentTracker=u,this.hls=a}var _=k.prototype;return _.destroy=function(){this.hls=this.fragmentTracker=this.media=null},_.poll=function(y){var u=this.config,a=this.media,l=this.stalled,h=a.currentTime,w=a.seeking,g=this.seeking&&!w,m=!this.seeking&&w;if(this.seeking=w,h!==y){if(this.moved=!0,l!==null){if(this.stallReported){var L=self.performance.now()-l;H.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((m||g)&&(this.stalled=null),a.paused||a.ended||a.playbackRate===0||!V.BufferHelper.getBuffered(a).length)return;var x=V.BufferHelper.bufferInfo(a,h,0),f=x.len>0,p=x.nextStart||0;if(!f&&!p)return;if(w){var d=x.len>M,o=!p||p-h>M&&!this.fragmentTracker.getPartialFragment(h);if(d||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,v=Math.max(p,x.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||((E=T.details)===null||E===void 0)?void 0:E.live,G=I?T.details.targetduration*2:M;if(v>0&&v<=G){this._trySkipBufferHole(null);return}}var X=self.performance.now();if(l===null){this.stalled=X;return}var J=X-l;!w&&J>=F&&this._reportStall(x.len);var z=V.BufferHelper.bufferInfo(a,h,u.maxBufferHole);this._tryFixBufferStall(z,J)},_._tryFixBufferStall=function(y,u){var a=this.config,l=this.fragmentTracker,h=this.media,w=h.currentTime,g=l.getPartialFragment(w);if(g){var m=this._trySkipBufferHole(g);if(m)return}y.len>a.maxBufferHole&&u>a.highBufferWatchdogPeriod*1e3&&(H.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},_._reportStall=function(y){var u=this.hls,a=this.media,l=this.stallReported;l||(this.stallReported=!0,H.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer (buffer="+y+")"),u.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},_._trySkipBufferHole=function(y){for(var u=this.config,a=this.hls,l=this.media,h=l.currentTime,w=0,g=V.BufferHelper.getBuffered(l),m=0;m<g.length;m++){var L=g.start(m);if(h+u.maxBufferHole>=w&&h<L){var x=Math.max(L+b,l.currentTime+O);return H.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+x),this.moved=!0,this.stalled=null,l.currentTime=x,y&&a.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+x,frag:y}),x}w=g.end(m)}return 0},_._tryNudgeBuffer=function(){var y=this.config,u=this.hls,a=this.media,l=a.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<y.nudgeMaxRetry){var w=l+h*y.nudgeOffset;H.logger.warn("Nudging 'currentTime' from "+l+" to "+w),a.currentTime=w,u.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else H.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+y.nudgeMaxRetry+" nudges"),u.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},k}()},"./src/controller/id3-track-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),P=D("./src/demux/id3.ts"),H=.25,F=function(){function M(b){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=b,this._registerListeners()}var O=M.prototype;return O.destroy=function(){this._unregisterListeners()},O._registerListeners=function(){var C=this.hls;C.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),C.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),C.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),C.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O._unregisterListeners=function(){var C=this.hls;C.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),C.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),C.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),C.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O.onMediaAttached=function(C,k){this.media=k.media},O.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},O.getID3Track=function(C){if(!this.media)return;for(var k=0;k<C.length;k++){var _=C[k];if(_.kind==="metadata"&&_.label==="id3")return Object(N.sendAddTrackEvent)(_,this.media),_}return this.media.addTextTrack("metadata","id3")},O.onFragParsingMetadata=function(C,k){if(!this.media)return;var _=k.frag,A=k.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var y=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<A.length;u++){var a=P.getID3Frames(A[u].data);if(a){var l=A[u].pts,h=u<A.length-1?A[u+1].pts:_.end,w=h-l;w<=0&&(h=l+H);for(var g=0;g<a.length;g++){var m=a[g];if(!P.isTimeStampFrame(m)){var L=new y(l,h,"");L.value=m,this.id3Track.addCue(L)}}}}},O.onBufferFlushing=function(C,k){var _=k.startOffset,A=k.endOffset,y=k.type;if(!y||y==="audio"){var u=this.id3Track;u&&Object(N.removeCuesInRange)(u,_,A)}},M}();$.default=F},"./src/controller/latency-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return M});var V=D("./src/errors.ts"),N=D("./src/events.ts"),P=D("./src/utils/logger.ts");function H(O,b){for(var C=0;C<b.length;C++){var k=b[C];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(O,k.key,k)}}function F(O,b,C){return b&&H(O.prototype,b),C&&H(O,C),O}var M=function(){function O(C){var k=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 k.timeupdate()},this.hls=C,this.config=C.config,this.registerListeners()}var b=O.prototype;return b.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},b.registerListeners=function(){this.hls.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(N.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){this.hls.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(N.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(N.Events.ERROR,this.onError)},b.onMediaAttached=function(k,_){this.media=_.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},b.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},b.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},b.onLevelUpdated=function(k,_){var A=_.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},b.onError=function(k,_){if(_.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,P.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},b.timeupdate=function(){var k=this.media,_=this.levelDetails;if(!k||!_)return;this.currentTime=k.currentTime;var A=this.computeLatency();if(A===null)return;this._latency=A;var y=this.config,u=y.lowLatencyMode,a=y.maxLiveSyncPlaybackRate;if(!u||a===1)return;var l=this.targetLatency;if(l===null)return;var h=A-l,w=Math.min(this.maxLatency,l+_.targetduration),g=h<w;if(_.live&&g&&h>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,a)),L=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;k.playbackRate=Math.min(m,Math.max(1,L))}else k.playbackRate!==1&&k.playbackRate!==0&&(k.playbackRate=1)},b.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},b.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},F(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var k=this.config,_=this.levelDetails;return k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:_?k.liveMaxLatencyDurationCount*_.targetduration:0}},{key:"targetLatency",get:function(){var k=this.levelDetails;if(k===null)return null;var _=k.holdBack,A=k.partHoldBack,y=k.targetduration,u=this.config,a=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,w=this.hls.userConfig,g=h&&A||_;(w.liveSyncDuration||w.liveSyncDurationCount||g===0)&&(g=a!==void 0?a:l*y);var m=y,L=1;return g+Math.min(this.stallCount*L,m)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),_=this.targetLatency,A=this.levelDetails;if(k===null||_===null||A===null)return null;var y=A.edge,u=k-_-this.edgeStalled,a=y-A.totalduration,l=y-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(a,u),l)}},{key:"drift",get:function(){var k=this.levelDetails;return k===null?1:k.drift}},{key:"edgeStalled",get:function(){var k=this.levelDetails;if(k===null)return 0;var _=(this.config.lowLatencyMode&&k.partTarget||k.targetduration)*3;return Math.max(k.age-_,0)}},{key:"forwardBufferLength",get:function(){var k=this.media,_=this.levelDetails;if(!k||!_)return 0;var A=k.buffered.length;return A?k.buffered.end(A-1):_.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return u});var V=D("./src/types/level.ts"),N=D("./src/events.ts"),P=D("./src/errors.ts"),H=D("./src/utils/codecs.ts"),F=D("./src/controller/level-helper.ts"),M=D("./src/controller/base-playlist-controller.ts"),O=D("./src/types/loader.ts");function b(){return b=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var w in h)Object.prototype.hasOwnProperty.call(h,w)&&(a[w]=h[w])}return a},b.apply(this,arguments)}function C(a,l){for(var h=0;h<l.length;h++){var w=l[h];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(a,w.key,w)}}function k(a,l,h){return l&&C(a.prototype,l),h&&C(a,h),a}function _(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,A(a,l)}function A(a,l){return A=Object.setPrototypeOf||function(w,g){return w.__proto__=g,w},A(a,l)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(a){_(l,a);function l(w){var g;return g=a.call(this,w,"[level-controller]")||this,g._levels=[],g._firstLevel=-1,g._startLevel=void 0,g.currentLevelIndex=-1,g.manualLevelIndex=-1,g.onParsedComplete=void 0,g._registerListeners(),g}var h=l.prototype;return h._registerListeners=function(){var g=this.hls;g.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.on(N.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var g=this.hls;g.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(N.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,a.prototype.destroy.call(this)},h.startLoad=function(){var g=this._levels;g.forEach(function(m){m.loadError=0}),a.prototype.startLoad.call(this)},h.onManifestLoaded=function(g,m){var L=[],x=[],f=[],p,d={},o,E=!1,v=!1,T=!1;if(m.levels.forEach(function(J){var z=J.attrs;E=E||!!(J.width&&J.height),v=v||!!J.videoCodec,T=T||!!J.audioCodec,y&&J.audioCodec&&J.audioCodec.indexOf("mp4a.40.34")!==-1&&(J.audioCodec=void 0);var W=J.bitrate+"-"+J.attrs.RESOLUTION+"-"+J.attrs.CODECS;o=d[W],o?o.url.push(J.url):(o=new V.Level(J),d[W]=o,L.push(o)),z&&(z.AUDIO&&Object(F.addGroupId)(o,"audio",z.AUDIO),z.SUBTITLES&&Object(F.addGroupId)(o,"text",z.SUBTITLES))}),(E||v)&&T&&(L=L.filter(function(J){var z=J.videoCodec,W=J.width,q=J.height;return!!z||!!(W&&q)})),L=L.filter(function(J){var z=J.audioCodec,W=J.videoCodec;return(!z||Object(H.isCodecSupportedInMp4)(z,"audio"))&&(!W||Object(H.isCodecSupportedInMp4)(W,"video"))}),m.audioTracks&&(x=m.audioTracks.filter(function(J){return!J.audioCodec||Object(H.isCodecSupportedInMp4)(J.audioCodec,"audio")}),Object(F.assignTrackIdsByGroup)(x)),m.subtitles&&(f=m.subtitles,Object(F.assignTrackIdsByGroup)(f)),L.length>0){p=L[0].bitrate,L.sort(function(J,z){return J.bitrate-z.bitrate}),this._levels=L;for(var I=0;I<L.length;I++)if(L[I].bitrate===p){this._firstLevel=I,this.log("manifest loaded, "+L.length+" level(s) found, first bitrate: "+p);break}var G=T&&!v,X={levels:L,audioTracks:x,subtitleTracks:f,firstLevel:this._firstLevel,stats:m.stats,audio:T,video:v,altAudio:!G&&x.some(function(J){return!!J.url})};this.hls.trigger(N.Events.MANIFEST_PARSED,X),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:m.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(g,m){if(a.prototype.onError.call(this,g,m),m.fatal)return;var L=m.context,x=this._levels[this.currentLevelIndex];if(L&&(L.type===O.PlaylistContextType.AUDIO_TRACK&&x.audioGroupIds&&L.groupId===x.audioGroupIds[x.urlId]||L.type===O.PlaylistContextType.SUBTITLE_TRACK&&x.textGroupIds&&L.groupId===x.textGroupIds[x.urlId])){this.redundantFailover(this.currentLevelIndex);return}var f=!1,p=!0,d;switch(m.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:if(m.frag){var o=this._levels[m.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=m.frag.level)):d=m.frag.level}break;case P.ErrorDetails.LEVEL_LOAD_ERROR:case P.ErrorDetails.LEVEL_LOAD_TIMEOUT:L&&(L.deliveryDirectives&&(p=!1),d=L.level),f=!0;break;case P.ErrorDetails.REMUX_ALLOC_ERROR:d=m.level,f=!0;break}d!==void 0&&this.recoverLevel(m,d,f,p)},h.recoverLevel=function(g,m,L,x){var f=g.details,p=this._levels[m];if(p.loadError++,L){var d=this.retryLoadingOrFail(g);if(d)g.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var o=p.url.length;if(o>1&&p.loadError<o)g.levelRetry=!0,this.redundantFailover(m);else if(this.manualLevelIndex===-1){var E=m===0?this._levels.length-1:m-1;this.currentLevelIndex!==E&&this._levels[E].loadError===0&&(this.warn(f+": switch to "+E),g.levelRetry=!0,this.hls.nextAutoLevel=E)}}},h.redundantFailover=function(g){var m=this._levels[g],L=m.url.length;if(L>1){var x=(m.urlId+1)%L;this.warn("Switching to redundant URL-id "+x),this._levels.forEach(function(f){f.urlId=x}),this.level=g}},h.onFragLoaded=function(g,m){var L=m.frag;if(L!==void 0&&L.type===O.PlaylistLevelType.MAIN){var x=this._levels[L.level];x!==void 0&&(x.fragmentError=0,x.loadError=0)}},h.onLevelLoaded=function(g,m){var L,x=m.level,f=m.details,p=this._levels[x];if(!p){var d;this.warn("Invalid level index "+x),(d=m.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(f.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(x,m,p.details)):(L=m.deliveryDirectives)!==null&&L!==void 0&&L.skip&&(f.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(g,m){var L=this.hls.levels[this.currentLevelIndex];if(!L)return;if(L.audioGroupIds){for(var x=-1,f=this.hls.audioTracks[m.id].groupId,p=0;p<L.audioGroupIds.length;p++)if(L.audioGroupIds[p]===f){x=p;break}x!==L.urlId&&(L.urlId=x,this.startLoad())}},h.loadPlaylist=function(g){var m=this.currentLevelIndex,L=this._levels[m];if(this.canLoad&&L&&L.url.length>0){var x=L.urlId,f=L.url[x];if(g)try{f=g.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+m+(g?" at sn "+g.msn+" part "+g.part:"")+" with URL-id "+x+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:m,id:x,deliveryDirectives:g||null})}},h.removeLevel=function(g,m){var L=function(p,d){return d!==m},x=this._levels.filter(function(f,p){return p!==g?!0:f.url.length>1&&m!==void 0?(f.url=f.url.filter(L),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(L)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(L)),f.urlId=0,!0):!1}).map(function(f,p){var d=f.details;return d!=null&&d.fragments&&d.fragments.forEach(function(o){o.level=p}),f});this._levels=x,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:x})},k(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(g){var m,L=this._levels;if(L.length===0)return;if(this.currentLevelIndex===g&&(m=L[g])!==null&&m!==void 0&&m.details)return;if(g<0||g>=L.length){var x=g<0;if(this.hls.trigger(N.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.LEVEL_SWITCH_ERROR,level:g,fatal:x,reason:"invalid level idx"}),x)return;g=Math.min(g,L.length-1)}this.clearTimer();var f=this.currentLevelIndex,p=L[f],d=L[g];this.log("switching to level "+g+" from "+f),this.currentLevelIndex=g;var o=b({},d,{level:g,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete o._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,o);var E=d.details;if(!E||E.live){var v=this.switchParams(d.uri,p==null?void 0:p.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(g){this.manualLevelIndex=g,this._startLevel===void 0&&(this._startLevel=g),g!==-1&&(this.level=g)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(g){this._firstLevel=g}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var g=this.hls.config.startLevel;return g!==void 0?g:this._firstLevel}else return this._startLevel},set:function(g){this._startLevel=g}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(g){this.level=g,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=g)}}]),l}(M.default)},"./src/controller/level-helper.ts":function(ie,$,D){"use strict";D.r($),D.d($,"addGroupId",function(){return P}),D.d($,"assignTrackIdsByGroup",function(){return H}),D.d($,"updatePTS",function(){return F}),D.d($,"updateFragPTSDTS",function(){return O}),D.d($,"mergeDetails",function(){return b}),D.d($,"mapPartIntersection",function(){return C}),D.d($,"mapFragmentIntersection",function(){return k}),D.d($,"adjustSliding",function(){return _}),D.d($,"addSliding",function(){return A}),D.d($,"computeReloadInterval",function(){return y}),D.d($,"getFragmentWithSN",function(){return u}),D.d($,"getPartWith",function(){return a});var V=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts");function P(l,h,w){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(w);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(w);break}}function H(l){var h={};l.forEach(function(w){var g=w.groupId||"";w.id=h[g]=h[g]||0,h[g]++})}function F(l,h,w){var g=l[h],m=l[w];M(g,m)}function M(l,h){var w=h.startPTS;if(Object(V.isFiniteNumber)(w)){var g=0,m;h.sn>l.sn?(g=w-l.start,m=l):(g=l.start-w,m=h),m.duration!==g&&(m.duration=g)}else if(h.sn>l.sn){var L=l.cc===h.cc;L&&l.minEndPTS?h.start=l.start+(l.minEndPTS-l.start):h.start=l.start+l.duration}else h.start=Math.max(l.start-h.duration,0)}function O(l,h,w,g,m,L){var x=g-w;x<=0&&(N.logger.warn("Fragment should have a positive duration",h),g=w+h.duration,L=m+h.duration);var f=w,p=g,d=h.startPTS,o=h.endPTS;if(Object(V.isFiniteNumber)(d)){var E=Math.abs(d-w);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(E,h.deltaPTS):h.deltaPTS=E,f=Math.max(w,d),w=Math.min(w,d),m=Math.min(m,h.startDTS),p=Math.min(g,o),g=Math.max(g,o),L=Math.max(L,h.endDTS)}h.duration=g-w;var v=w-h.start;h.appendedPTS=g,h.start=h.startPTS=w,h.maxStartPTS=f,h.startDTS=m,h.endPTS=g,h.minEndPTS=p,h.endDTS=L;var T=h.sn;if(!l||T<l.startSN||T>l.endSN)return 0;var I,G=T-l.startSN,X=l.fragments;for(X[G]=h,I=G;I>0;I--)M(X[I],X[I-1]);for(I=G;I<X.length-1;I++)M(X[I],X[I+1]);return l.fragmentHint&&M(X[X.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,v}function b(l,h){for(var w=null,g=l.fragments,m=g.length-1;m>=0;m--){var L=g[m].initSegment;if(L){w=L;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var x=0,f;if(k(l,h,function(I,G){I.relurl&&(x=I.cc-G.cc),Object(V.isFiniteNumber)(I.startPTS)&&Object(V.isFiniteNumber)(I.endPTS)&&(G.start=G.startPTS=I.startPTS,G.startDTS=I.startDTS,G.appendedPTS=I.appendedPTS,G.maxStartPTS=I.maxStartPTS,G.endPTS=I.endPTS,G.endDTS=I.endDTS,G.minEndPTS=I.minEndPTS,G.duration=I.endPTS-I.startPTS,G.duration&&(f=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=I.elementaryStreams,G.loader=I.loader,G.stats=I.stats,G.urlId=I.urlId,I.initSegment&&(G.initSegment=I.initSegment,w=I.initSegment)}),w){var p=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;p.forEach(function(I){var G;(!I.initSegment||I.initSegment.relurl===((G=w)===null||G===void 0?void 0:G.relurl))&&(I.initSegment=w)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(I){return!I}),h.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=h.skippedSegments;d--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var o=h.fragments;if(x){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<o.length;E++)o[E].cc+=x}h.skippedSegments&&(h.startCC=h.fragments[0].cc),C(l.partList,h.partList,function(I,G){G.elementaryStreams=I.elementaryStreams,G.stats=I.stats}),f?O(h,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):_(l,h),o.length&&(h.totalduration=h.edge-o[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var v=h.advancedDateTime;if(h.advanced&&v){var T=h.edge;h.driftStart||(h.driftStartTime=v,h.driftStart=T),h.driftEndTime=v,h.driftEnd=T}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function C(l,h,w){if(l&&h)for(var g=0,m=0,L=l.length;m<=L;m++){var x=l[m],f=h[m+g];x&&f&&x.index===f.index&&x.fragment.sn===f.fragment.sn?w(x,f):g--}}function k(l,h,w){for(var g=h.skippedSegments,m=Math.max(l.startSN,h.startSN)-h.startSN,L=(l.fragmentHint?1:0)+(g?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,x=h.startSN-l.startSN,f=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=m;d<=L;d++){var o=p[x+d],E=f[d];g&&!E&&d<g&&(E=h.fragments[d]=o),o&&E&&w(o,E)}}function _(l,h){var w=h.startSN+h.skippedSegments-l.startSN,g=l.fragments;if(w<0||w>=g.length)return;A(h,g[w].start)}function A(l,h){if(h){for(var w=l.fragments,g=l.skippedSegments;g<w.length;g++)w[g].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function y(l,h){var w=1e3*l.levelTargetDuration,g=w/2,m=l.age,L=m>0&&m<w*3,x=h.loading.end-h.loading.start,f,p=l.availabilityDelay;if(l.updated===!1)if(L){var d=333*l.misses;f=Math.max(Math.min(g,x*2),d),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=g;else L?(p=Math.min(p||w/2,m),l.availabilityDelay=p,f=p+w-m):f=w-x;return Math.round(f)}function u(l,h,w){if(!l||!l.details)return null;var g=l.details,m=g.fragments[h-g.startSN];return m||(m=g.fragmentHint,m&&m.sn===h?m:h<g.startSN&&w&&w.sn===h?w:null)}function a(l,h,w){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var m=g.length;m--;){var L=g[m];if(L.index===w&&L.fragment.sn===h)return L}return null}},"./src/controller/stream-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return g});var V=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),P=D("./src/is-supported.ts"),H=D("./src/events.ts"),F=D("./src/utils/buffer-helper.ts"),M=D("./src/controller/fragment-tracker.ts"),O=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),C=D("./src/demux/transmuxer-interface.ts"),k=D("./src/types/transmuxer.ts"),_=D("./src/controller/gap-controller.ts"),A=D("./src/errors.ts"),y=D("./src/utils/logger.ts");function u(m,L){for(var x=0;x<L.length;x++){var f=L[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function a(m,L,x){return L&&u(m.prototype,L),x&&u(m,x),m}function l(m,L){m.prototype=Object.create(L.prototype),m.prototype.constructor=m,h(m,L)}function h(m,L){return h=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},h(m,L)}var w=100,g=function(m){l(L,m);function L(f,p){var d;return d=m.call(this,f,p,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var x=L.prototype;return x._registerListeners=function(){var p=this.hls;p.on(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(H.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(H.Events.ERROR,this.onError,this),p.on(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(H.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x._unregisterListeners=function(){var p=this.hls;p.off(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(H.Events.ERROR,this.onError,this),p.off(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(H.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},x.startLoad=function(p){if(this.levels){var d=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=o.startLevel;E===-1&&(o.config.testBandwidth?(E=0,this.bitrateTest=!0):E=o.nextAutoLevel),this.level=o.nextLoadLevel=E,this.loadedmetadata=!1}d>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),p=d),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var p,d=this.levels,o=this.level,E=d==null||((p=d[o])===null||p===void 0)?void 0:p.details;if(E&&(!E.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(E))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var v,T=self.performance.now(),I=this.retryDate;(!I||T>=I||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var p,d,o=this.hls,E=this.levelLastLoaded,v=this.levels,T=this.media,I=o.config,G=o.nextLoadLevel;if(E===null||!T&&(this.startFragRequested||!I.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[G])return;var X=v[G];this.level=o.nextLoadLevel=G;var J=X.details;if(!J||this.state===N.State.WAITING_LEVEL||J.live&&this.levelLastLoaded!==G){this.state=N.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,O.PlaylistLevelType.MAIN);if(z===null)return;var W=z.len,q=this.getMaxBufferLength(X.maxBitrate);if(W>=q)return;if(this._streamEnded(z,J)){var ne={};this.altAudio&&(ne.type="video"),this.hls.trigger(H.Events.BUFFER_EOS,ne),this.state=N.State.ENDED;return}var ce=z.end,ve=this.getNextFragment(ce,J);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var De=ve.sn-J.startSN;De>1&&(ve=J.fragments[De-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===M.FragmentState.OK&&this.nextLoadPosition>ce){var xe=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,xe,O.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,J)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((p=ve.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((d=ve.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ve,J):this.loadFragment(ve,J,ce)},x.loadFragment=function(p,d,o){var E,v=this.fragmentTracker.getState(p);if(this.fragCurrent=p,v===M.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(p);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else v=M.FragmentState.NOT_LOADED}v===M.FragmentState.NOT_LOADED||v===M.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,p,d,o)):v===M.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((E=this.media)===null||E===void 0?void 0:E.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(p){var d=this.fragmentTracker.getAppendedFrag(p,O.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},x.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,O.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var p=this.levels,d=this.media;if(d!=null&&d.readyState){var o,E=this.getAppendedFrag(d.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!d.paused&&p){var v=this.hls.nextLoadLevel,T=p[v],I=this.fragLastKbps;I&&this.fragCurrent?o=this.fragCurrent.duration*T.maxBitrate/(1e3*I)+1:o=0}else o=0;var G=this.getBufferedFrag(d.currentTime+o);if(G){var X=this.followingBufferedFrag(G);if(X){this.abortCurrentFrag();var J=X.maxStartPTS?X.maxStartPTS:X.start,z=X.duration,W=Math.max(G.end,J+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(p,d){m.prototype.flushMainBuffer.call(this,p,d,this.altAudio?"video":null)},x.onMediaAttached=function(p,d){m.prototype.onMediaAttached.call(this,p,d);var o=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new _.default(this.config,o,this.fragmentTracker,this.hls)},x.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),m.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var p=this.media,d=p?p.currentTime:null;Object(V.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},x.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(H.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},x.onManifestParsed=function(p,d){var o=!1,E=!1,v;d.levels.forEach(function(T){v=T.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(o=!0),v.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=o&&E&&!Object(P.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},x.onLevelLoading=function(p,d){var o=this.levels;if(!o||this.state!==N.State.IDLE)return;var E=o[d.level];(!E.details||E.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(E.details))&&(this.state=N.State.WAITING_LEVEL)},x.onLevelLoaded=function(p,d){var o,E=this.levels,v=d.level,T=d.details,I=T.totalduration;if(!E){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+I);var G=this.fragCurrent;G&&(this.state===N.State.FRAG_LOADING||this.state===N.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==d.level&&G.loader&&(this.state=N.State.IDLE,G.loader.abort()));var X=E[v],J=0;if(T.live||(o=X.details)!==null&&o!==void 0&&o.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;J=this.alignPlaylists(T,X.details)}if(X.details=T,this.levelLastLoaded=v,this.hls.trigger(H.Events.LEVEL_UPDATED,{details:T,level:v}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=N.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,J),this.tick()},x._handleFragmentLoadProgress=function(p){var d,o=p.frag,E=p.part,v=p.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var I=T[o.level],G=I.details;if(!G){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var X=I.videoCodec,J=G.PTSKnown||!G.live,z=(d=o.initSegment)===null||d===void 0?void 0:d.data,W=this._getAudioCodec(I),q=this.transmuxer=this.transmuxer||new C.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ne=E?E.index:-1,ce=ne!==-1,ve=new k.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,v.byteLength,ne,ce),De=this.initPTS[o.cc];q.push(v,z,W,X,o,E,G.totalduration,J,ve,De)},x.onAudioTrackSwitching=function(p,d){var o=this.altAudio,E=!!d.url,v=d.id;if(!E){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var I=this.hls;o&&I.trigger(H.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),I.trigger(H.Events.AUDIO_TRACK_SWITCHED,{id:v})}},x.onAudioTrackSwitched=function(p,d){var o=d.id,E=!!this.hls.audioTracks[o].url;if(E){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=E,this.tick()},x.onBufferCreated=function(p,d){var o=d.tracks,E,v,T=!1;for(var I in o){var G=o[I];if(G.id==="main"){if(v=I,E=G,I==="video"){var X=o[I];X&&(this.videoBuffer=X.buffer)}}else T=!0}T&&E?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(p,d){var o=d.frag,E=d.part;if(o&&o.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(E?" p: "+E.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var v=E?E.stats:o.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,E)},x.onError=function(p,d){switch(d.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(O.PlaylistLevelType.MAIN,d);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==N.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=N.State.ERROR):!d.levelRetry&&this.state===N.State.WAITING_LEVEL&&(this.state=N.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var o=!0,E=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);E&&E.len>.5&&(o=!this.reduceMaxBufferLength(E.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var p=this.media,d=this.gapController;if(!p||!d||!p.readyState)return;var o=F.BufferHelper.getBuffered(p);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(p,d){var o=d.type;if(o!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(o===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,o,O.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(p,d){this.levels=d.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var p=this.media,d=p.currentTime,o=this.startPosition;if(o>=0&&d<o){if(p.seeking){y.logger.log("could not seek to "+o+", already seeking at "+d);return}var E=F.BufferHelper.getBuffered(p),v=E.length?E.start(0):0,T=v-o;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(y.logger.log("adjusting start position by "+T+" to match buffer start"),o+=T,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+d),p.currentTime=o}},x._getAudioCodec=function(p){var d=this.config.defaultAudioCodec||p.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},x._loadBitrateTestFrag=function(p){var d=this;this._doFragLoad(p).then(function(o){var E=d.hls;if(!o||E.nextLoadLevel||d.fragContextChanged(p))return;d.fragLoadError=0,d.state=N.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var v=p.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),E.trigger(H.Events.FRAG_LOADED,o)})},x._handleTransmuxComplete=function(p){var d,o="main",E=this.hls,v=p.remuxResult,T=p.chunkMeta,I=this.getCurrentContext(T);if(!I){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var G=I.frag,X=I.part,J=I.level,z=v.video,W=v.text,q=v.id3,ne=v.initSegment,ce=this.altAudio?void 0:v.audio;if(this.fragContextChanged(G))return;if(this.state=N.State.PARSING,ne){ne.tracks&&(this._bufferInitSegment(J,ne.tracks,G,T),E.trigger(H.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:o,tracks:ne.tracks}));var ve=ne.initPTS,De=ne.timescale;Object(V.isFiniteNumber)(ve)&&(this.initPTS[G.cc]=ve,E.trigger(H.Events.INIT_PTS_FOUND,{frag:G,id:o,initPTS:ve,timescale:De}))}if(z&&v.independent!==!1){if(J.details){var xe=z.startPTS,Ce=z.endPTS,Te=z.startDTS,Ee=z.endDTS;if(X)X.elementaryStreams[z.type]={startPTS:xe,endPTS:Ce,startDTS:Te,endDTS:Ee};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var ge=this.getLoadPosition()+this.config.maxBufferHole;if(ge<xe){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Ce,G.start,Ee,!0)}G.setElementaryStreamInfo(z.type,xe,Ce,Te,Ee),this.bufferFragmentData(z,G,X,T)}}else if(v.independent===!1){this.backtrack(G);return}if(ce){var se=ce.startPTS,ke=ce.endPTS,Ve=ce.startDTS,He=ce.endDTS;X&&(X.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:ke,startDTS:Ve,endDTS:He}),G.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,se,ke,Ve,He),this.bufferFragmentData(ce,G,X,T)}if(q!=null&&(d=q.samples)!==null&&d!==void 0&&d.length){var tt={frag:G,id:o,samples:q.samples};E.trigger(H.Events.FRAG_PARSING_METADATA,tt)}if(W){var Ke={frag:G,id:o,samples:W.samples};E.trigger(H.Events.FRAG_PARSING_USERDATA,Ke)}},x._bufferInitSegment=function(p,d,o,E){var v=this;if(this.state!==N.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var T=d.audio,I=d.video,G=d.audiovideo;if(T){var X=p.audioCodec,J=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(X&&(X.indexOf("mp4a.40.5")!==-1?X="mp4a.40.2":X="mp4a.40.5"),T.metadata.channelCount!==1&&J.indexOf("firefox")===-1&&(X="mp4a.40.5")),J.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(X="mp4a.40.2",this.log("Android: force audio codec to "+X)),p.audioCodec&&p.audioCodec!==X&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+X+'"'),T.levelCodec=X,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(X||"")+"/"+(p.audioCodec||"")+"/"+T.codec+"]")}I&&(I.levelCodec=p.videoCodec,I.id="main",this.log("Init video buffer, container:"+I.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+I.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(H.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(z){var W=d[z],q=W.initSegment;q!=null&&q.byteLength&&v.hls.trigger(H.Events.BUFFER_APPENDING,{type:z,data:q,frag:o,part:null,chunkMeta:E,parent:o.type})}),this.tick()},x.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var d=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,d?this.resetFragmentLoading(p):this.state=N.State.BACKTRACKING},x.checkFragmentChanged=function(){var p=this.media,d=null;if(p&&p.readyState>1&&p.seeking===!1){var o=p.currentTime;if(F.BufferHelper.isBuffered(p,o)?d=this.getAppendedFrag(o):F.BufferHelper.isBuffered(p,o+.1)&&(d=this.getAppendedFrag(o+.1)),d){var E=this.fragPlaying,v=d.level;(!E||d.sn!==E.sn||E.level!==v||d.urlId!==E.urlId)&&(this.hls.trigger(H.Events.FRAG_CHANGED,{frag:d}),(!E||E.level!==v)&&this.hls.trigger(H.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=d)}}},a(L,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),L}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"SubtitleStreamController",function(){return l});var V=D("./src/events.ts"),N=D("./src/utils/logger.ts"),P=D("./src/utils/buffer-helper.ts"),H=D("./src/controller/fragment-finders.ts"),F=D("./src/utils/discontinuities.ts"),M=D("./src/controller/level-helper.ts"),O=D("./src/controller/fragment-tracker.ts"),b=D("./src/controller/base-stream-controller.ts"),C=D("./src/types/loader.ts"),k=D("./src/types/level.ts");function _(h,w){for(var g=0;g<w.length;g++){var m=w[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(h,m.key,m)}}function A(h,w,g){return w&&_(h.prototype,w),g&&_(h,g),h}function y(h,w){h.prototype=Object.create(w.prototype),h.prototype.constructor=h,u(h,w)}function u(h,w){return u=Object.setPrototypeOf||function(m,L){return m.__proto__=L,m},u(h,w)}var a=500,l=function(h){y(w,h);function w(m,L){var x;return x=h.call(this,m,L,"[subtitle-stream-controller]")||this,x.levels=[],x.currentTrackId=-1,x.tracksBuffered=[],x.mainDetails=null,x._registerListeners(),x}var g=w.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var L=this.hls;L.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.on(V.Events.ERROR,this.onError,this),L.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g._unregisterListeners=function(){var L=this.hls;L.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.off(V.Events.ERROR,this.onError,this),L.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g.startLoad=function(){this.stopLoad(),this.state=b.State.IDLE,this.setInterval(a),this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(L,x){this.mainDetails=x.details},g.onSubtitleFragProcessed=function(L,x){var f=x.frag,p=x.success;if(this.fragPrevious=f,this.state=b.State.IDLE,!p)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var o,E=f.start,v=0;v<d.length;v++)if(E>=d[v].start&&E<=d[v].end){o=d[v];break}var T=f.start+f.duration;o?o.end=T:(o={start:E,end:T},d.push(o)),this.fragmentTracker.fragBuffered(f)},g.onBufferFlushing=function(L,x){var f=x.startOffset,p=x.endOffset;if(f===0&&p!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,o=this.levels;if(!o.length||!o[d]||!o[d].details)return;var E=o[d].details,v=E.targetduration,T=p-v;if(T<=0)return;x.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(I){for(var G=0;G<I.length;){if(I[G].end<=T){I.shift();continue}else if(I[G].start<T)I[G].start=T;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(f,T,C.PlaylistLevelType.SUBTITLE)}},g.onError=function(L,x){var f,p=x.frag;if(!p||p.type!==C.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=b.State.IDLE},g.onSubtitleTracksUpdated=function(L,x){var f=this,p=x.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(d){return new k.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){f.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(L,x){if(this.currentTrackId=x.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var f=this.levels[this.currentTrackId];f!=null&&f.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,f&&this.setInterval(a)},g.onSubtitleTrackLoaded=function(L,x){var f,p=x.details,d=x.id,o=this.currentTrackId,E=this.levels;if(!E.length)return;var v=E[o];if(d>=E.length||d!==o||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=v.details)!==null&&f!==void 0&&f.live){var T=this.mainDetails;if(p.deltaUpdateFailed||!T)return;var I=T.fragments[0];if(!v.details)p.hasProgramDateTime&&T.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(p,T):I&&Object(M.addSliding)(p,I.start);else{var G=this.alignPlaylists(p,v.details);G===0&&I&&Object(M.addSliding)(p,I.start)}}if(v.details=p,this.levelLastLoaded=d,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===b.State.IDLE){var X=Object(H.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);X||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},g._handleFragmentLoadComplete=function(L){var x=L.frag,f=L.payload,p=x.decryptdata,d=this.hls;if(this.fragContextChanged(x))return;if(f&&f.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(E){var v=performance.now();d.trigger(V.Events.FRAG_DECRYPTED,{frag:x,payload:E,stats:{tstart:o,tdecrypt:v}})})}},g.doTick=function(){if(!this.media){this.state=b.State.IDLE;return}if(this.state===b.State.IDLE){var L,x=this.currentTrackId,f=this.levels;if(!f.length||!f[x]||!f[x].details)return;var p=f[x].details,d=p.targetduration,o=this.config,E=this.media,v=P.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,E.currentTime-d,o.maxBufferHole),T=v.end,I=v.len,G=this.getMaxBufferLength()+d;if(I>G)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var X=p.fragments,J=X.length,z=p.edge,W,q=this.fragPrevious;if(T<z){var ne=o.maxFragLookUpTolerance;q&&p.hasProgramDateTime&&(W=Object(H.findFragmentByPDT)(X,q.endProgramDateTime,ne)),W||(W=Object(H.findFragmentByPTS)(q,X,T,ne),!W&&q&&q.start<X[0].start&&(W=X[0]))}else W=X[J-1];(L=W)!==null&&L!==void 0&&L.encrypted?(N.logger.log("Loading key for "+W.sn),this.state=b.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:W})):W&&this.fragmentTracker.getState(W)===O.FragmentState.NOT_LOADED&&this.loadFragment(W,p,T)}},g.loadFragment=function(L,x,f){this.fragCurrent=L,h.prototype.loadFragment.call(this,L,x,f)},A(w,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),w}(b.default)},"./src/controller/subtitle-track-controller.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),P=D("./src/controller/base-playlist-controller.ts"),H=D("./src/types/loader.ts");function F(_,A){for(var y=0;y<A.length;y++){var u=A[y];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function M(_,A,y){return A&&F(_.prototype,A),y&&F(_,y),_}function O(_,A){_.prototype=Object.create(A.prototype),_.prototype.constructor=_,b(_,A)}function b(_,A){return b=Object.setPrototypeOf||function(u,a){return u.__proto__=a,u},b(_,A)}var C=function(_){O(A,_);function A(u){var a;return a=_.call(this,u,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a.subtitleDisplay=!0,a.registerListeners(),a}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,_.prototype.destroy.call(this)},y.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.on(V.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.off(V.Events.ERROR,this.onError,this)},y.onMediaAttached=function(a,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},y.pollTrackChange=function(a){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,a)},y.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var a=k(this.media.textTracks);a.forEach(function(l){Object(N.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(a,l){this.tracks=l.subtitleTracks},y.onSubtitleTrackLoaded=function(a,l){var h=l.id,w=l.details,g=this.trackId,m=this.tracksInGroup[g];if(!m){this.warn("Invalid subtitle track id "+h);return}var L=m.details;m.details=l.details,this.log("subtitle track "+h+" loaded ["+w.startSN+"-"+w.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,L))},y.onLevelLoading=function(a,l){this.switchLevel(l.level)},y.onLevelSwitching=function(a,l){this.switchLevel(l.level)},y.switchLevel=function(a){var l=this.hls.levels[a];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var w=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(x){return!h||x.groupId===h});this.tracksInGroup=g;var m=this.findTrackId(w==null?void 0:w.name)||this.findTrackId();this.groupId=h;var L={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,L),m!==-1&&this.setSubtitleTrack(m,w)}},y.findTrackId=function(a){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var w=l[h];if((!this.selectDefaultTrack||w.default)&&(!a||a===w.name))return w.id}return-1},y.onError=function(a,l){if(_.prototype.onError.call(this,a,l),l.fatal||!l.context)return;l.context.type===H.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},y.loadPlaylist=function(a){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,w=l.groupId,g=l.url;if(a)try{g=a.addDirectives(g)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:g,id:h,groupId:w,deliveryDirectives:a||null})}},y.toggleTrackModes=function(a){var l=this,h=this.media,w=this.subtitleDisplay,g=this.trackId;if(!h)return;var m=k(h.textTracks),L=m.filter(function(p){return p.groupId===l.groupId});if(a===-1)[].slice.call(m).forEach(function(p){p.mode="disabled"});else{var x=L[g];x&&(x.mode="disabled")}var f=L[a];f&&(f.mode=w?"showing":"hidden")},y.setSubtitleTrack=function(a,l){var h,w=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=a;return}if(this.trackId!==a&&this.toggleTrackModes(a),this.trackId===a&&(a===-1||(h=w[a])!==null&&h!==void 0&&h.details)||a<-1||a>=w.length)return;this.clearTimer();var g=w[a];if(this.log("Switching to subtitle track "+a),this.trackId=a,g){var m=g.id,L=g.groupId,x=L===void 0?"":L,f=g.name,p=g.type,d=g.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:x,name:f,type:p,url:d});var o=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(o)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:a})},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var a=-1,l=k(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")a=h;else if(l[h].mode==="showing"){a=h;break}this.subtitleTrack!==a&&(this.subtitleTrack=a)},M(A,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(a,l)}}]),A}(P.default);function k(_){for(var A=[],y=0;y<_.length;y++){var u=_[y];u.kind==="subtitles"&&u.label&&A.push(_[y])}return A}$.default=C},"./src/controller/timeline-controller.ts":function(ie,$,D){"use strict";D.r($),D.d($,"TimelineController",function(){return k});var V=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),P=D("./src/utils/cea-608-parser.ts"),H=D("./src/utils/output-filter.ts"),F=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),O=D("./src/utils/imsc1-ttml-parser.ts"),b=D("./src/types/loader.ts"),C=D("./src/utils/logger.ts"),k=function(){function u(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=y(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var h=new H.default(this,"textTrack1"),w=new H.default(this,"textTrack2"),g=new H.default(this,"textTrack3"),m=new H.default(this,"textTrack4");this.cea608Parser1=new P.default(1,h,w),this.cea608Parser2=new P.default(3,g,m)}l.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(N.Events.FRAG_LOADING,this.onFragLoading,this),l.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=u.prototype;return a.destroy=function(){var h=this.hls;h.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(N.Events.FRAG_LOADING,this.onFragLoading,this),h.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(h,w,g,m,L){for(var x=!1,f=L.length;f--;){var p=L[f],d=A(p[0],p[1],w,g);if(d>=0&&(p[0]=Math.min(p[0],w),p[1]=Math.max(p[1],g),x=!0,d/(g-w)>.5))return}if(x||L.push([w,g]),this.config.renderTextTracksNatively){var o=this.captionsTracks[h];this.Cues.newCue(o,w,g,m)}else{var E=this.Cues.newCue(null,w,g,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:E,track:h})}},a.onInitPtsFound=function(h,w){var g=this,m=w.frag,L=w.id,x=w.initPTS,f=w.timescale,p=this.unparsedVttFrags;L==="main"&&(this.initPTS[m.cc]=x,this.timescale[m.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(d){g.onFragLoaded(N.Events.FRAG_LOADED,d)}))},a.getExistingTrack=function(h){var w=this.media;if(w)for(var g=0;g<w.textTracks.length;g++){var m=w.textTracks[g];if(m[h])return m}return null},a.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},a.createNativeTrack=function(h){if(this.captionsTracks[h])return;var w=this.captionsProperties,g=this.captionsTracks,m=this.media,L=w[h],x=L.label,f=L.languageCode,p=this.getExistingTrack(h);if(p)g[h]=p,Object(M.clearCurrentCues)(g[h]),Object(M.sendAddTrackEvent)(g[h],m);else{var d=this.createTextTrack("captions",x,f);d&&(d[h]=!0,g[h]=d)}},a.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var w=this.captionsProperties[h];if(!w)return;var g=w.label,m={_id:h,label:g,kind:"captions",default:w.media?!!w.media.default:!1,closedCaptions:w.media};this.nonNativeCaptionsTracks[h]=m,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},a.createTextTrack=function(h,w,g){var m=this.media;return m?m.addTextTrack(h,w,g):void 0},a.onMediaAttaching=function(h,w){this.media=w.media,this._cleanTracks()},a.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(w){Object(M.clearCurrentCues)(h[w]),delete h[w]}),this.nonNativeCaptionsTracks={}},a.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=y(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},a._cleanTracks=function(){var h=this.media;if(!h)return;var w=h.textTracks;if(w)for(var g=0;g<w.length;g++)Object(M.clearCurrentCues)(w[g])},a.onSubtitleTracksUpdated=function(h,w){var g=this;this.textTracks=[];var m=w.subtitleTracks||[],L=m.some(function(d){return d.textCodec===O.IMSC1_CODEC});if(this.config.enableWebVTT||L&&this.config.enableIMSC1){var x=this.tracks&&m&&this.tracks.length===m.length;if(this.tracks=m||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,o){var E;if(o<f.length){for(var v=null,T=0;T<f.length;T++)if(_(f[T],d)){v=f[T];break}v&&(E=v)}E?Object(M.clearCurrentCues)(E):(E=g.createTextTrack("subtitles",d.name,d.lang),E&&(E.mode="disabled")),E&&(E.groupId=d.groupId,g.textTracks.push(E))})}else if(!x&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},a.onManifestLoaded=function(h,w){var g=this;this.config.enableCEA708Captions&&w.captions&&w.captions.forEach(function(m){var L=/(?:CC|SERVICE)([1-4])/.exec(m.instreamId);if(!L)return;var x="textTrack"+L[1],f=g.captionsProperties[x];if(!f)return;f.label=m.name,m.lang&&(f.languageCode=m.lang),f.media=m})},a.onFragLoading=function(h,w){var g=this.cea608Parser1,m=this.cea608Parser2,L=this.lastSn,x=this.lastPartIndex;if(!this.enabled||!(g&&m))return;if(w.frag.type===b.PlaylistLevelType.MAIN){var f,p,d=w.frag.sn,o=(f=w==null||((p=w.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;d===L+1||d===L&&o===x+1||(g.reset(),m.reset()),this.lastSn=d,this.lastPartIndex=o}},a.onFragLoaded=function(h,w){var g=w.frag,m=w.payload,L=this.initPTS,x=this.unparsedVttFrags;if(g.type===b.PlaylistLevelType.SUBTITLE)if(m.byteLength){if(!Object(V.isFiniteNumber)(L[g.cc])){x.push(w),L.length&&this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Missing initial subtitle PTS")});return}var f=g.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var p=this.tracks[g.level],d=this.vttCCs;d[g.cc]||(d[g.cc]={start:g.start,prevCC:this.prevCC,new:!0},this.prevCC=g.cc),p&&p.textCodec===O.IMSC1_CODEC?this._parseIMSC1(g,m):this._parseVTTs(g,m,d)}}else this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(h,w){var g=this,m=this.hls;Object(O.parseIMSC1)(w,this.initPTS[h.cc],this.timescale[h.cc],function(L){g._appendCues(L,h.level),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(L){C.logger.log("Failed to parse IMSC1: "+L),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:L})})},a._parseVTTs=function(h,w,g){var m=this,L=this.hls;Object(F.parseWebVTT)(w,this.initPTS[h.cc],this.timescale[h.cc],g,h.cc,h.start,function(x){m._appendCues(x,h.level),L.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(x){m._fallbackToIMSC1(h,w),C.logger.log("Failed to parse VTT cue: "+x),L.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:x})})},a._fallbackToIMSC1=function(h,w){var g=this,m=this.tracks[h.level];m.textCodec||Object(O.parseIMSC1)(w,this.initPTS[h.cc],this.timescale[h.cc],function(){m.textCodec=O.IMSC1_CODEC,g._parseIMSC1(h,w)},function(){m.textCodec="wvtt"})},a._appendCues=function(h,w){var g=this.hls;if(this.config.renderTextTracksNatively){var m=this.textTracks[w];if(m.mode==="disabled")return;h.forEach(function(f){return Object(M.addCueToTrack)(m,f)})}else{var L=this.tracks[w],x=L.default?"default":"subtitles"+w;g.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:h,track:x})}},a.onFragDecrypted=function(h,w){var g=w.frag;if(g.type===b.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[g.cc])){this.unparsedVttFrags.push(w);return}this.onFragLoaded(N.Events.FRAG_LOADED,w)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(h,w){var g=this.cea608Parser1,m=this.cea608Parser2;if(!this.enabled||!(g&&m))return;for(var L=0;L<w.samples.length;L++){var x=w.samples[L].bytes;if(x){var f=this.extractCea608Data(x);g.addData(w.samples[L].pts,f[0]),m.addData(w.samples[L].pts,f[1])}}},a.onBufferFlushing=function(h,w){var g=w.startOffset,m=w.endOffset,L=w.endOffsetSubtitles,x=w.type,f=this.media;if(!f||f.currentTime<m)return;if(!x||x==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(o){return Object(M.removeCuesInRange)(p[o],g,m)})}if(this.config.renderTextTracksNatively&&(g===0&&L!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(o){return Object(M.removeCuesInRange)(d[o],g,L)})}},a.extractCea608Data=function(h){for(var w=h[0]&31,g=2,m=[[],[]],L=0;L<w;L++){var x=h[g++],f=127&h[g++],p=127&h[g++],d=(4&x)!==0,o=3&x;if(f===0&&p===0)continue;d&&((o===0||o===1)&&(m[o].push(f),m[o].push(p)))}return m},u}();function _(u,a){return u&&u.label===a.name&&!(u.textTrack1||u.textTrack2)}function A(u,a,l,h){return Math.min(a,h)-Math.max(u,l)}function y(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return V});var V=function(){function N(H,F){this.subtle=void 0,this.aesIV=void 0,this.subtle=H,this.aesIV=F}var P=N.prototype;return P.decrypt=function(F,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,F)},N}()},"./src/crypt/aes-decryptor.ts":function(ie,$,D){"use strict";D.r($),D.d($,"removePadding",function(){return N}),D.d($,"default",function(){return P});var V=D("./src/utils/typed-array.ts");function N(H){var F=H.byteLength,M=F&&new DataView(H.buffer).getUint8(F-1);return M?Object(V.sliceUint8)(H,0,F-M):H}var P=function(){function H(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var F=H.prototype;return F.uint8ArrayToUint32Array_=function(O){for(var b=new DataView(O),C=new Uint32Array(4),k=0;k<4;k++)C[k]=b.getUint32(k*4);return C},F.initTable=function(){var O=this.sBox,b=this.invSBox,C=this.subMix,k=C[0],_=C[1],A=C[2],y=C[3],u=this.invSubMix,a=u[0],l=u[1],h=u[2],w=u[3],g=new Uint32Array(256),m=0,L=0,x=0;for(x=0;x<256;x++)x<128?g[x]=x<<1:g[x]=x<<1^283;for(x=0;x<256;x++){var f=L^L<<1^L<<2^L<<3^L<<4;f=f>>>8^f&255^99,O[m]=f,b[f]=m;var p=g[m],d=g[p],o=g[d],E=g[f]*257^f*16843008;k[m]=E<<24|E>>>8,_[m]=E<<16|E>>>16,A[m]=E<<8|E>>>24,y[m]=E,E=o*16843009^d*65537^p*257^m*16843008,a[f]=E<<24|E>>>8,l[f]=E<<16|E>>>16,h[f]=E<<8|E>>>24,w[f]=E,m?(m=p^g[g[g[o^p]]],L^=g[g[L]]):m=L=1}},F.expandKey=function(O){for(var b=this.uint8ArrayToUint32Array_(O),C=!0,k=0;k<b.length&&C;)C=b[k]===this.key[k],k++;if(C)return;this.key=b;var _=this.keySize=b.length;if(_!==4&&_!==6&&_!==8)throw new Error("Invalid aes key size="+_);var A=this.ksRows=(_+6+1)*4,y,u,a=this.keySchedule=new Uint32Array(A),l=this.invKeySchedule=new Uint32Array(A),h=this.sBox,w=this.rcon,g=this.invSubMix,m=g[0],L=g[1],x=g[2],f=g[3],p,d;for(y=0;y<A;y++){if(y<_){p=a[y]=b[y];continue}d=p,y%_===0?(d=d<<8|d>>>24,d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255],d^=w[y/_|0]<<24):_>6&&y%_===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),a[y]=p=(a[y-_]^d)>>>0}for(u=0;u<A;u++)y=A-u,u&3?d=a[y]:d=a[y-4],u<4||y<=4?l[u]=d:l[u]=m[h[d>>>24]]^L[h[d>>>16&255]]^x[h[d>>>8&255]]^f[h[d&255]],l[u]=l[u]>>>0},F.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},F.decrypt=function(O,b,C){for(var k=this.keySize+6,_=this.invKeySchedule,A=this.invSBox,y=this.invSubMix,u=y[0],a=y[1],l=y[2],h=y[3],w=this.uint8ArrayToUint32Array_(C),g=w[0],m=w[1],L=w[2],x=w[3],f=new Int32Array(O),p=new Int32Array(f.length),d,o,E,v,T,I,G,X,J,z,W,q,ne,ce,ve=this.networkToHostOrderSwap;b<f.length;){for(J=ve(f[b]),z=ve(f[b+1]),W=ve(f[b+2]),q=ve(f[b+3]),T=J^_[0],I=q^_[1],G=W^_[2],X=z^_[3],ne=4,ce=1;ce<k;ce++)d=u[T>>>24]^a[I>>16&255]^l[G>>8&255]^h[X&255]^_[ne],o=u[I>>>24]^a[G>>16&255]^l[X>>8&255]^h[T&255]^_[ne+1],E=u[G>>>24]^a[X>>16&255]^l[T>>8&255]^h[I&255]^_[ne+2],v=u[X>>>24]^a[T>>16&255]^l[I>>8&255]^h[G&255]^_[ne+3],T=d,I=o,G=E,X=v,ne=ne+4;d=A[T>>>24]<<24^A[I>>16&255]<<16^A[G>>8&255]<<8^A[X&255]^_[ne],o=A[I>>>24]<<24^A[G>>16&255]<<16^A[X>>8&255]<<8^A[T&255]^_[ne+1],E=A[G>>>24]<<24^A[X>>16&255]<<16^A[T>>8&255]<<8^A[I&255]^_[ne+2],v=A[X>>>24]<<24^A[T>>16&255]<<16^A[I>>8&255]<<8^A[G&255]^_[ne+3],p[b]=ve(d^g),p[b+1]=ve(v^m),p[b+2]=ve(E^L),p[b+3]=ve(o^x),g=J,m=z,L=W,x=q,b=b+4}return p.buffer},H}()},"./src/crypt/decrypter.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return b});var V=D("./src/crypt/aes-crypto.ts"),N=D("./src/crypt/fast-aes-key.ts"),P=D("./src/crypt/aes-decryptor.ts"),H=D("./src/utils/logger.ts"),F=D("./src/utils/mp4-tools.ts"),M=D("./src/utils/typed-array.ts"),O=16,b=function(){function C(_,A,y){var u=y===void 0?{}:y,a=u.removePKCS7Padding,l=a===void 0?!0:a;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=_,this.config=A,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(w){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var k=C.prototype;return k.destroy=function(){this.observer=null},k.isSync=function(){return this.config.enableSoftwareAES},k.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var y=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(P.removePadding)(y):y},k.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},k.decrypt=function(A,y,u,a){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),y,u);var l=this.flush();l&&a(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),y,u).then(a)},k.softwareDecrypt=function(A,y,u){var a=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(A=Object(F.appendUint8Array)(h,A),this.remainderData=null);var w=this.getValidChunk(A);if(!w.length)return null;a&&(u=a);var g=this.softwareDecrypter;g||(g=this.softwareDecrypter=new P.default),g.expandKey(y);var m=l;return this.currentResult=g.decrypt(w.buffer,0,u),this.currentIV=Object(M.sliceUint8)(w,-16).buffer,m||null},k.webCryptoDecrypt=function(A,y,u){var a=this,l=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new N.default(l,y)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var w=new V.default(l,u);return w.decrypt(A.buffer,h)}).catch(function(h){return a.onWebCryptoError(h,A,y,u)})},k.onWebCryptoError=function(A,y,u,a){return H.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,u,a)},k.getValidChunk=function(A){var y=A,u=A.length-A.length%O;return u!==A.length&&(y=Object(M.sliceUint8)(A,0,u),this.remainderData=Object(M.sliceUint8)(A,u)),y},k.logOnce=function(A){if(!this.logEnabled)return;H.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1},C}()},"./src/crypt/fast-aes-key.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return V});var V=function(){function N(H,F){this.subtle=void 0,this.key=void 0,this.subtle=H,this.key=F}var P=N.prototype;return P.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},N}()},"./src/demux/aacdemuxer.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/adts.ts"),P=D("./src/utils/logger.ts"),H=D("./src/demux/id3.ts");function F(b,C){b.prototype=Object.create(C.prototype),b.prototype.constructor=b,M(b,C)}function M(b,C){return M=Object.setPrototypeOf||function(_,A){return _.__proto__=A,_},M(b,C)}var O=function(b){F(C,b);function C(_,A){var y;return y=b.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=_,y.config=A,y}var k=C.prototype;return k.resetInitSegment=function(A,y,u){b.prototype.resetInitSegment.call(this,A,y,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:A,duration:u,inputTimeScale:9e4,dropped:0}},C.probe=function(A){if(!A)return!1;for(var y=H.getID3Data(A,0)||[],u=y.length,a=A.length;u<a;u++)if(N.probe(A,u))return P.logger.log("ADTS sync word found !"),!0;return!1},k.canParse=function(A,y){return N.canParse(A,y)},k.appendFrame=function(A,y,u){N.initTrackConfig(A,this.observer,y,u,A.manifestCodec);var a=N.appendFrame(A,y,u,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},C}(V.default);O.minProbeByteLength=9,$.default=O},"./src/demux/adts.ts":function(ie,$,D){"use strict";D.r($),D.d($,"getAudioConfig",function(){return H}),D.d($,"isHeaderPattern",function(){return F}),D.d($,"getHeaderLength",function(){return M}),D.d($,"getFullFrameLength",function(){return O}),D.d($,"canGetFrameLength",function(){return b}),D.d($,"isHeader",function(){return C}),D.d($,"canParse",function(){return k}),D.d($,"probe",function(){return _}),D.d($,"initTrackConfig",function(){return A}),D.d($,"getFrameDuration",function(){return y}),D.d($,"parseFrameHeader",function(){return u}),D.d($,"appendFrame",function(){return a});var V=D("./src/utils/logger.ts"),N=D("./src/errors.ts"),P=D("./src/events.ts");function H(l,h,w,g){var m,L,x,f,p=navigator.userAgent.toLowerCase(),d=g,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((h[w+2]&192)>>>6)+1;var E=(h[w+2]&60)>>>2;if(E>o.length-1){l.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return x=(h[w+2]&1)<<2,x|=(h[w+3]&192)>>>6,V.logger.log("manifest codec:"+g+", ADTS type:"+m+", samplingIndex:"+E),/firefox/i.test(p)?E>=6?(m=5,f=new Array(4),L=E-3):(m=2,f=new Array(2),L=E):p.indexOf("android")!==-1?(m=2,f=new Array(2),L=E):(m=5,f=new Array(4),g&&(g.indexOf("mp4a.40.29")!==-1||g.indexOf("mp4a.40.5")!==-1)||!g&&E>=6?L=E-3:((g&&g.indexOf("mp4a.40.2")!==-1&&(E>=6&&x===1||/vivaldi/i.test(p))||!g&&x===1)&&(m=2,f=new Array(2)),L=E)),f[0]=m<<3,f[0]|=(E&14)>>1,f[1]|=(E&1)<<7,f[1]|=x<<3,m===5&&(f[1]|=(L&14)>>1,f[2]=(L&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:o[E],channelCount:x,codec:"mp4a.40."+m,manifestCodec:d}}function F(l,h){return l[h]===255&&(l[h+1]&246)===240}function M(l,h){return l[h+1]&1?7:9}function O(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function b(l,h){return h+5<l.length}function C(l,h){return h+1<l.length&&F(l,h)}function k(l,h){return b(l,h)&&F(l,h)&&O(l,h)<=l.length-h}function _(l,h){if(C(l,h)){var w=M(l,h);if(h+w>=l.length)return!1;var g=O(l,h);if(g<=w)return!1;var m=h+g;return m===l.length||C(l,m)}return!1}function A(l,h,w,g,m){if(!l.samplerate){var L=H(h,w,g,m);if(!L)return;l.config=L.config,l.samplerate=L.samplerate,l.channelCount=L.channelCount,l.codec=L.codec,l.manifestCodec=L.manifestCodec,V.logger.log("parsed codec:"+l.codec+", rate:"+L.samplerate+", channels:"+L.channelCount)}}function y(l){return 1024*9e4/l}function u(l,h,w,g,m){var L=M(l,h),x=O(l,h);if(x-=L,x>0){var f=w+g*m;return{headerLength:L,frameLength:x,stamp:f}}}function a(l,h,w,g,m){var L=y(l.samplerate),x=u(h,w,g,m,L);if(x){var f=x.frameLength,p=x.headerLength,d=x.stamp,o=p+f,E=Math.max(0,w+o-h.length),v;E?(v=new Uint8Array(o-p),v.set(h.subarray(w+p,h.length),0)):v=h.subarray(w+p,w+o);var T={unit:v,pts:d};return E||l.samples.push(T),{sample:T,length:o,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(ie,$,D){"use strict";D.r($),D.d($,"initPTSFn",function(){return O});var V=D("./src/polyfills/number.ts"),N=D("./src/demux/id3.ts"),P=D("./src/demux/dummy-demuxed-track.ts"),H=D("./src/utils/mp4-tools.ts"),F=D("./src/utils/typed-array.ts"),M=function(){function b(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var C=b.prototype;return C.resetInitSegment=function(_,A,y){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},C.resetTimeStamp=function(){},C.resetContiguity=function(){},C.canParse=function(_,A){return!1},C.appendFrame=function(_,A,y){},C.demux=function(_,A){this.cachedData&&(_=Object(H.appendUint8Array)(this.cachedData,_),this.cachedData=null);var y=N.getID3Data(_,0),u=y?y.length:0,a,l,h=this._audioTrack,w=this._id3Track,g=y?N.getTimeStamp(y):void 0,m=_.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(g,A)),y&&y.length>0&&w.samples.push({pts:this.initPTS,dts:this.initPTS,data:y}),l=this.initPTS;u<m;){if(this.canParse(_,u)){var L=this.appendFrame(h,_,u);L?(this.frameIndex++,l=L.sample.pts,u+=L.length,a=u):u=m}else N.canParse(_,u)?(y=N.getID3Data(_,u),w.samples.push({pts:l,dts:l,data:y}),u+=y.length,a=u):u++;if(u===m&&a!==m){var x=Object(F.sliceUint8)(_,a);this.cachedData?this.cachedData=Object(H.appendUint8Array)(this.cachedData,x):this.cachedData=x}}return{audioTrack:h,avcTrack:Object(P.dummyTrack)(),id3Track:w,textTrack:Object(P.dummyTrack)()}},C.demuxSampleAes=function(_,A,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},C.flush=function(_){var A=this.cachedData;return A&&(this.cachedData=null,this.demux(A,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(P.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(P.dummyTrack)()}},C.destroy=function(){},b}(),O=function(C,k){return Object(V.isFiniteNumber)(C)?C*90:k*9e4};$.default=M},"./src/demux/chunk-cache.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return V});var V=function(){function P(){this.chunks=[],this.dataLength=0}var H=P.prototype;return H.push=function(M){this.chunks.push(M),this.dataLength+=M.length},H.flush=function(){var M=this.chunks,O=this.dataLength,b;if(M.length)M.length===1?b=M[0]:b=N(M,O);else return new Uint8Array(0);return this.reset(),b},H.reset=function(){this.chunks.length=0,this.dataLength=0},P}();function N(P,H){for(var F=new Uint8Array(H),M=0,O=0;O<P.length;O++){var b=P[O];F.set(b,M),M+=b.length}return F}},"./src/demux/dummy-demuxed-track.ts":function(ie,$,D){"use strict";D.r($),D.d($,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/utils/logger.ts"),N=function(){function P(F){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=F,this.bytesAvailable=F.byteLength,this.word=0,this.bitsAvailable=0}var H=P.prototype;return H.loadWord=function(){var M=this.data,O=this.bytesAvailable,b=M.byteLength-O,C=new Uint8Array(4),k=Math.min(4,O);if(k===0)throw new Error("no bytes available");C.set(M.subarray(b,b+k)),this.word=new DataView(C.buffer).getUint32(0),this.bitsAvailable=k*8,this.bytesAvailable-=k},H.skipBits=function(M){var O;this.bitsAvailable>M?(this.word<<=M,this.bitsAvailable-=M):(M-=this.bitsAvailable,O=M>>3,M-=O>>3,this.bytesAvailable-=O,this.loadWord(),this.word<<=M,this.bitsAvailable-=M)},H.readBits=function(M){var O=Math.min(this.bitsAvailable,M),b=this.word>>>32-O;return M>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0?this.word<<=O:this.bytesAvailable>0&&this.loadWord(),O=M-O,O>0&&this.bitsAvailable?b<<O|this.readBits(O):b},H.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()},H.skipUEG=function(){this.skipBits(1+this.skipLZ())},H.skipEG=function(){this.skipBits(1+this.skipLZ())},H.readUEG=function(){var M=this.skipLZ();return this.readBits(M+1)-1},H.readEG=function(){var M=this.readUEG();return 1&M?1+M>>>1:-1*(M>>>1)},H.readBoolean=function(){return this.readBits(1)===1},H.readUByte=function(){return this.readBits(8)},H.readUShort=function(){return this.readBits(16)},H.readUInt=function(){return this.readBits(32)},H.skipScalingList=function(M){for(var O=8,b=8,C,k=0;k<M;k++)b!==0&&(C=this.readEG(),b=(O+C+256)%256),O=b===0?O:b},H.readSPS=function(){var M=0,O=0,b=0,C=0,k,_,A,y=this.readUByte.bind(this),u=this.readBits.bind(this),a=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),w=this.skipEG.bind(this),g=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);y();var L=y();if(u(5),h(3),y(),g(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var x=a();if(x===3&&h(1),g(),g(),h(1),l())for(_=x!==3?8:12,A=0;A<_;A++)l()&&(A<6?m(16):m(64))}g();var f=a();if(f===0)a();else if(f===1)for(h(1),w(),w(),k=a(),A=0;A<k;A++)w();g(),h(1);var p=a(),d=a(),o=u(1);o===0&&h(1),h(1),l()&&(M=a(),O=a(),b=a(),C=a());var E=[1,1];if(l()&&l()){var v=y();switch(v){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((p+1)*16-M*2-O*2),height:(2-o)*(d+1)*16-(o?2:4)*(b+C),pixelRatio:E}},H.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();$.default=N},"./src/demux/id3.ts":function(ie,$,D){"use strict";D.r($),D.d($,"isHeader",function(){return V}),D.d($,"isFooter",function(){return N}),D.d($,"getID3Data",function(){return P}),D.d($,"canParse",function(){return F}),D.d($,"getTimeStamp",function(){return M}),D.d($,"isTimeStampFrame",function(){return O}),D.d($,"getID3Frames",function(){return C}),D.d($,"decodeFrame",function(){return k}),D.d($,"utf8ArrayToStr",function(){return a}),D.d($,"testables",function(){return l});var V=function(m,L){return L+10<=m.length&&(m[L]===73&&m[L+1]===68&&m[L+2]===51&&(m[L+3]<255&&m[L+4]<255&&(m[L+6]<128&&m[L+7]<128&&m[L+8]<128&&m[L+9]<128)))},N=function(m,L){return L+10<=m.length&&(m[L]===51&&m[L+1]===68&&m[L+2]===73&&(m[L+3]<255&&m[L+4]<255&&(m[L+6]<128&&m[L+7]<128&&m[L+8]<128&&m[L+9]<128)))},P=function(m,L){for(var x=L,f=0;V(m,L);){f+=10;var p=H(m,L+6);f+=p,N(m,L+10)&&(f+=10),L+=f}return f>0?m.subarray(x,x+f):void 0},H=function(m,L){var x=0;return x=(m[L]&127)<<21,x|=(m[L+1]&127)<<14,x|=(m[L+2]&127)<<7,x|=m[L+3]&127,x},F=function(m,L){return V(m,L)&&H(m,L+6)+10<=m.length-L},M=function(m){for(var L=C(m),x=0;x<L.length;x++){var f=L[x];if(O(f))return u(f)}return},O=function(m){return m&&m.key==="PRIV"&&m.info==="com.apple.streaming.transportStreamTimestamp"},b=function(m){var L=String.fromCharCode(m[0],m[1],m[2],m[3]),x=H(m,4),f=10;return{type:L,size:x,data:m.subarray(f,f+x)}},C=function(m){for(var L=0,x=[];V(m,L);){var f=H(m,L+6);L+=10;for(var p=L+f;L+8<p;){var d=b(m.subarray(L)),o=k(d);o&&x.push(o),L+=d.size+10}N(m,L)&&(L+=10)}return x},k=function(m){return m.type==="PRIV"?_(m):m.type[0]==="W"?y(m):A(m)},_=function(m){if(m.size<2)return;var L=a(m.data,!0),x=new Uint8Array(m.data.subarray(L.length+1));return{key:m.type,info:L,data:x.buffer}},A=function(m){if(m.size<2)return;if(m.type==="TXXX"){var L=1,x=a(m.data.subarray(L),!0);L+=x.length+1;var f=a(m.data.subarray(L));return{key:m.type,info:x,data:f}}var p=a(m.data.subarray(1));return{key:m.type,data:p}},y=function(m){if(m.type==="WXXX"){if(m.size<2)return;var L=1,x=a(m.data.subarray(L),!0);L+=x.length+1;var f=a(m.data.subarray(L));return{key:m.type,info:x,data:f}}var p=a(m.data);return{key:m.type,data:p}},u=function(m){if(m.data.byteLength===8){var L=new Uint8Array(m.data),x=L[3]&1,f=(L[4]<<23)+(L[5]<<15)+(L[6]<<7)+L[7];return f/=45,x&&(f+=4772185884e-2),Math.round(f)}return},a=function(m,L){L===void 0&&(L=!1);var x=w();if(x){var f=x.decode(m);if(L){var p=f.indexOf("\0");return p!==-1?f.substring(0,p):f}return f.replace(/\0/g,"")}for(var d=m.length,o,E,v,T="",I=0;I<d;){if(o=m[I++],o===0&&L)return T;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(o);break;case 12:case 13:E=m[I++],T+=String.fromCharCode((o&31)<<6|E&63);break;case 14:E=m[I++],v=m[I++],T+=String.fromCharCode((o&15)<<12|(E&63)<<6|(v&63)<<0);break;default:}}return T},l={decodeTextFrame:A},h;function w(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/id3.ts"),P=D("./src/utils/logger.ts"),H=D("./src/demux/mpegaudio.ts");function F(b,C){b.prototype=Object.create(C.prototype),b.prototype.constructor=b,M(b,C)}function M(b,C){return M=Object.setPrototypeOf||function(_,A){return _.__proto__=A,_},M(b,C)}var O=function(b){F(C,b);function C(){return b.apply(this,arguments)||this}var k=C.prototype;return k.resetInitSegment=function(A,y,u){b.prototype.resetInitSegment.call(this,A,y,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:A,duration:u,inputTimeScale:9e4,dropped:0}},C.probe=function(A){if(!A)return!1;for(var y=N.getID3Data(A,0)||[],u=y.length,a=A.length;u<a;u++)if(H.probe(A,u))return P.logger.log("MPEG Audio sync word found !"),!0;return!1},k.canParse=function(A,y){return H.canParse(A,y)},k.appendFrame=function(A,y,u){return this.initPTS===null?void 0:H.appendFrame(A,y,u,this.initPTS,this.frameIndex)},C}(V.default);O.minProbeByteLength=4,$.default=O},"./src/demux/mp4demuxer.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/utils/mp4-tools.ts"),N=D("./src/demux/dummy-demuxed-track.ts"),P=function(){function H(M,O){this.remainderData=null,this.config=void 0,this.config=O}var F=H.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(){},F.resetContiguity=function(){},H.probe=function(O){return Object(V.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},F.demux=function(O){var b=O,C=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(b=Object(V.appendUint8Array)(this.remainderData,O));var k=Object(V.segmentValidRange)(b);this.remainderData=k.remainder,C.samples=k.valid||new Uint8Array}else C.samples=b;return{audioTrack:Object(N.dummyTrack)(),avcTrack:C,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},F.flush=function(){var O=Object(N.dummyTrack)();return O.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:O,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},F.demuxSampleAes=function(O,b,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},H}();P.minProbeByteLength=1024,$.default=P},"./src/demux/mpegaudio.ts":function(ie,$,D){"use strict";D.r($),D.d($,"appendFrame",function(){return M}),D.d($,"parseHeader",function(){return O}),D.d($,"isHeaderPattern",function(){return b}),D.d($,"isHeader",function(){return C}),D.d($,"canParse",function(){return k}),D.d($,"probe",function(){return _});var V=null,N=[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],P=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],H=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function M(A,y,u,a,l){if(u+24>y.length)return;var h=O(y,u);if(h&&u+h.frameLength<=y.length){var w=h.samplesPerFrame*9e4/h.sampleRate,g=a+l*w,m={unit:y.subarray(u,u+h.frameLength),pts:g,dts:g};return A.config=[],A.channelCount=h.channelCount,A.samplerate=h.sampleRate,A.samples.push(m),{sample:m,length:h.frameLength,missing:0}}}function O(A,y){var u=A[y+1]>>3&3,a=A[y+1]>>1&3,l=A[y+2]>>4&15,h=A[y+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var w=A[y+2]>>1&1,g=A[y+3]>>6,m=u===3?3-a:a===3?3:4,L=N[m*14+l-1]*1e3,x=u===3?0:u===2?1:2,f=P[x*3+h],p=g===3?1:2,d=H[u][a],o=F[a],E=d*8*o,v=Math.floor(d*L/f+w)*o;if(V===null){var T=navigator.userAgent||"",I=T.match(/Chrome\/(\d+)/i);V=I?parseInt(I[1]):0}var G=!!V&&V<=87;return G&&a===2&&L>=224e3&&g===0&&(A[y+3]=A[y+3]|128),{sampleRate:f,channelCount:p,frameLength:v,samplesPerFrame:E}}}function b(A,y){return A[y]===255&&(A[y+1]&224)===224&&(A[y+1]&6)!==0}function C(A,y){return y+1<A.length&&b(A,y)}function k(A,y){var u=4;return b(A,y)&&u<=A.length-y}function _(A,y){if(y+1<A.length&&b(A,y)){var u=4,a=O(A,y),l=u;a!=null&&a.frameLength&&(l=a.frameLength);var h=y+l;return h===A.length||C(A,h)}return!1}},"./src/demux/sample-aes.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/crypt/decrypter.ts"),N=D("./src/demux/tsdemuxer.ts"),P=function(){function H(M,O,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new V.default(M,O,{removePKCS7Padding:!1})}var F=H.prototype;return F.decryptBuffer=function(O,b){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,b)},F.decryptAacSample=function(O,b,C,k){var _=O[b].unit,A=_.subarray(16,_.length-_.length%16),y=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),u=this;this.decryptBuffer(y,function(a){var l=new Uint8Array(a);_.set(l,16),k||u.decryptAacSamples(O,b+1,C)})},F.decryptAacSamples=function(O,b,C){for(;;b++){if(b>=O.length){C();return}if(O[b].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(O,b,C,k),!k)return}},F.getAvcEncryptedData=function(O){for(var b=Math.floor((O.length-48)/160)*16+16,C=new Int8Array(b),k=0,_=32;_<=O.length-16;_+=160,k+=16)C.set(O.subarray(_,_+16),k);return C},F.getAvcDecryptedUnit=function(O,b){for(var C=new Uint8Array(b),k=0,_=32;_<=O.length-16;_+=160,k+=16)O.set(C.subarray(k,k+16),_);return O},F.decryptAvcSample=function(O,b,C,k,_,A){var y=Object(N.discardEPB)(_.data),u=this.getAvcEncryptedData(y),a=this;this.decryptBuffer(u.buffer,function(l){_.data=a.getAvcDecryptedUnit(y,l),A||a.decryptAvcSamples(O,b,C+1,k)})},F.decryptAvcSamples=function(O,b,C,k){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,C=0){if(b>=O.length){k();return}for(var _=O[b].units;!(C>=_.length);C++){var A=_[C];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var y=this.decrypter.isSync();if(this.decryptAvcSample(O,b,C,k,A,y),!y)return}}},H}();$.default=P},"./src/demux/transmuxer-interface.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return _});var V=D("./node_modules/webworkify-webpack/index.js"),N=D.n(V),P=D("./src/events.ts"),H=D("./src/demux/transmuxer.ts"),F=D("./src/utils/logger.ts"),M=D("./src/errors.ts"),O=D("./src/utils/mediasource-helper.ts"),b=D("./node_modules/eventemitter3/index.js"),C=D.n(b),k=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},_=function(){function A(u,a,l,h){var w=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=u,this.id=a,this.onTransmuxComplete=l,this.onFlush=h;var g=u.config,m=function(d,o){o=o||{},o.frag=w.frag,o.id=w.id,u.trigger(d,o)};this.observer=new b.EventEmitter,this.observer.on(P.Events.FRAG_DECRYPTED,m),this.observer.on(P.Events.ERROR,m);var L={mp4:k.isTypeSupported("video/mp4"),mpeg:k.isTypeSupported("audio/mpeg"),mp3:k.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(g.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var f;try{f=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(p){u.trigger(P.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},f.postMessage({cmd:"init",typeSupported:L,vendor:x,id:a,config:JSON.stringify(g)})}catch(p){F.logger.warn("Error in worker:",p),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new H.default(this.observer,L,g,x,a),this.worker=null}}else this.transmuxer=new H.default(this.observer,L,g,x,a)}var y=A.prototype;return y.destroy=function(){var a=this.worker;if(a)a.removeEventListener("message",this.onwmsg),a.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},y.push=function(a,l,h,w,g,m,L,x,f,p){var d=this;f.transmuxing.start=self.performance.now();var o=this.transmuxer,E=this.worker,v=m?m.start:g.start,T=g.decryptdata,I=this.frag,G=!(I&&g.cc===I.cc),X=!(I&&f.level===I.level),J=I?f.sn-I.sn:-1,z=this.part?f.part-this.part.index:1,W=!X&&(J===1||J===0&&z===1),q=self.performance.now();(X||J||g.stats.parsing.start===0)&&(g.stats.parsing.start=q),m&&(z||!W)&&(m.stats.parsing.start=q);var ne=new H.TransmuxState(G,W,x,X,v);if(!W||G){F.logger.log("[transmuxer-interface, "+g.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
|
discontinuity: `+G+`
|
|
trackSwitch: `+X+`
|
|
contiguous: `+W+`
|
|
accurateTimeOffset: `+x+`
|
|
timeOffset: `+v);var ce=new H.TransmuxConfig(h,w,l,L,p);this.configureTransmuxer(ce)}if(this.frag=g,this.part=m,E)E.postMessage({cmd:"demux",data:a,decryptdata:T,chunkMeta:f,state:ne},a instanceof ArrayBuffer?[a]:[]);else if(o){var ve=o.push(a,T,f,ne);Object(H.isPromise)(ve)?ve.then(function(De){d.handleTransmuxComplete(De)}):this.handleTransmuxComplete(ve)}},y.flush=function(a){var l=this;a.transmuxing.start=self.performance.now();var h=this.transmuxer,w=this.worker;if(w)w.postMessage({cmd:"flush",chunkMeta:a});else if(h){var g=h.flush(a);Object(H.isPromise)(g)?g.then(function(m){l.handleFlushResult(m,a)}):this.handleFlushResult(g,a)}},y.handleFlushResult=function(a,l){var h=this;a.forEach(function(w){h.handleTransmuxComplete(w)}),this.onFlush(l)},y.onWorkerMessage=function(a){var l=a.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},y.configureTransmuxer=function(a){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:a}):h&&h.configure(a)},y.handleTransmuxComplete=function(a){a.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(a)},A}()},"./src/demux/transmuxer-worker.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return M});var V=D("./src/demux/transmuxer.ts"),N=D("./src/events.ts"),P=D("./src/utils/logger.ts"),H=D("./node_modules/eventemitter3/index.js"),F=D.n(H);function M(_){var A=new H.EventEmitter,y=function(a,l){_.postMessage({event:a,data:l})};A.on(N.Events.FRAG_DECRYPTED,y),A.on(N.Events.ERROR,y),_.addEventListener("message",function(u){var a=u.data;switch(a.cmd){case"init":{var l=JSON.parse(a.config);_.transmuxer=new V.default(A,a.typeSupported,l,a.vendor,a.id),Object(P.enableLogs)(l.debug),y("init",null);break}case"configure":{_.transmuxer.configure(a.config);break}case"demux":{var h=_.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(V.isPromise)(h)?h.then(function(m){O(_,m)}):O(_,h);break}case"flush":{var w=a.chunkMeta,g=_.transmuxer.flush(w);Object(V.isPromise)(g)?g.then(function(m){C(_,m,w)}):C(_,g,w);break}default:break}})}function O(_,A){if(k(A.remuxResult))return;var y=[],u=A.remuxResult,a=u.audio,l=u.video;a&&b(y,a),l&&b(y,l),_.postMessage({event:"transmuxComplete",data:A},y)}function b(_,A){A.data1&&_.push(A.data1.buffer),A.data2&&_.push(A.data2.buffer)}function C(_,A,y){A.forEach(function(u){O(_,u)}),_.postMessage({event:"flush",data:y})}function k(_){return!_.audio&&!_.video&&!_.text&&!_.id3&&!_.initSegment}},"./src/demux/transmuxer.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return l}),D.d($,"isPromise",function(){return g}),D.d($,"TransmuxConfig",function(){return m}),D.d($,"TransmuxState",function(){return L});var V=D("./src/events.ts"),N=D("./src/errors.ts"),P=D("./src/crypt/decrypter.ts"),H=D("./src/demux/aacdemuxer.ts"),F=D("./src/demux/mp4demuxer.ts"),M=D("./src/demux/tsdemuxer.ts"),O=D("./src/demux/mp3demuxer.ts"),b=D("./src/remux/mp4-remuxer.ts"),C=D("./src/remux/passthrough-remuxer.ts"),k=D("./src/demux/chunk-cache.ts"),_=D("./src/utils/mp4-tools.ts"),A=D("./src/utils/logger.ts"),y;try{y=self.performance.now.bind(self.performance)}catch(x){A.logger.debug("Unable to use Performance API on this environment"),y=self.Date.now}var u=[{demux:M.default,remux:b.default},{demux:F.default,remux:C.default},{demux:H.default,remux:b.default},{demux:O.default,remux:b.default}],a=1024;u.forEach(function(x){var f=x.demux;a=Math.max(a,f.minProbeByteLength)});var l=function(){function x(p,d,o,E,v){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 k.default,this.observer=p,this.typeSupported=d,this.config=o,this.vendor=E,this.id=v}var f=x.prototype;return f.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},f.push=function(d,o,E,v){var T=this,I=E.transmuxing;I.executeStart=y();var G=new Uint8Array(d),X=this.cache,J=this.config,z=this.currentTransmuxState,W=this.transmuxConfig;v&&(this.currentTransmuxState=v);var q=h(G,o);if(q&&q.method==="AES-128"){var ne=this.getDecrypter();if(J.enableSoftwareAES){var ce=ne.softwareDecrypt(G,q.key.buffer,q.iv.buffer);if(!ce)return I.executeEnd=y(),w(E);G=new Uint8Array(ce)}else return this.decryptionPromise=ne.webCryptoDecrypt(G,q.key.buffer,q.iv.buffer).then(function(Me){var We=T.push(Me,null,E);return T.decryptionPromise=null,We}),this.decryptionPromise}var ve=v||z,De=ve.contiguous,xe=ve.discontinuity,Ce=ve.trackSwitch,Te=ve.accurateTimeOffset,Ee=ve.timeOffset,ge=W.audioCodec,se=W.videoCodec,ke=W.defaultInitPts,Ve=W.duration,He=W.initSegmentData;if((xe||Ce)&&this.resetInitSegment(He,ge,se,Ve),xe&&this.resetInitialTimestamp(ke),De||this.resetContiguity(),this.needsProbing(G,xe,Ce)){if(X.dataLength){var tt=X.flush();G=Object(_.appendUint8Array)(tt,G)}this.configureTransmuxer(G,W)}var Ke=this.transmux(G,q,Ee,Te,E),Le=this.currentTransmuxState;return Le.contiguous=!0,Le.discontinuity=!1,Le.trackSwitch=!1,I.executeEnd=y(),Ke},f.flush=function(d){var o=this,E=d.transmuxing;E.executeStart=y();var v=this.decrypter,T=this.cache,I=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return o.flush(d)});var X=[],J=I.timeOffset;if(v){var z=v.flush();z&&X.push(this.push(z,null,d))}var W=T.dataLength;T.reset();var q=this.demuxer,ne=this.remuxer;if(!q||!ne)return W>=a&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=y(),[w(d)];var ce=q.flush(J);return g(ce)?ce.then(function(ve){return o.flushRemux(X,ve,d),X}):(this.flushRemux(X,ce,d),X)},f.flushRemux=function(d,o,E){var v=o.audioTrack,T=o.avcTrack,I=o.id3Track,G=o.textTrack,X=this.currentTransmuxState,J=X.accurateTimeOffset,z=X.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+E.sn+(E.part>-1?" p: "+E.part:"")+" of level "+E.level);var W=this.remuxer.remux(v,T,I,G,z,J,!0,this.id);d.push({remuxResult:W,chunkMeta:E}),E.transmuxing.executeEnd=y()},f.resetInitialTimestamp=function(d){var o=this.demuxer,E=this.remuxer;if(!o||!E)return;o.resetTimeStamp(d),E.resetTimeStamp(d)},f.resetContiguity=function(){var d=this.demuxer,o=this.remuxer;if(!d||!o)return;d.resetContiguity(),o.resetNextTimestamp()},f.resetInitSegment=function(d,o,E,v){var T=this.demuxer,I=this.remuxer;if(!T||!I)return;T.resetInitSegment(o,E,v),I.resetInitSegment(d,o,E)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(d,o,E,v,T){var I;return o&&o.method==="SAMPLE-AES"?I=this.transmuxSampleAes(d,o,E,v,T):I=this.transmuxUnencrypted(d,E,v,T),I},f.transmuxUnencrypted=function(d,o,E,v){var T=this.demuxer.demux(d,o,!1,!this.config.progressive),I=T.audioTrack,G=T.avcTrack,X=T.id3Track,J=T.textTrack,z=this.remuxer.remux(I,G,X,J,o,E,!1,this.id);return{remuxResult:z,chunkMeta:v}},f.transmuxSampleAes=function(d,o,E,v,T){var I=this;return this.demuxer.demuxSampleAes(d,o,E).then(function(G){var X=I.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,E,v,!1,I.id);return{remuxResult:X,chunkMeta:T}})},f.configureTransmuxer=function(d,o){for(var E=this.config,v=this.observer,T=this.typeSupported,I=this.vendor,G=o.audioCodec,X=o.defaultInitPts,J=o.duration,z=o.initSegmentData,W=o.videoCodec,q,ne=0,ce=u.length;ne<ce;ne++)if(u[ne].demux.probe(d)){q=u[ne];break}q||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:F.default,remux:C.default});var ve=this.demuxer,De=this.remuxer,xe=q.remux,Ce=q.demux;(!De||!(De instanceof xe))&&(this.remuxer=new xe(v,E,T,I)),(!ve||!(ve instanceof Ce))&&(this.demuxer=new Ce(v,E,T),this.probe=Ce.probe),this.resetInitSegment(z,G,W,J),this.resetInitialTimestamp(X)},f.needsProbing=function(d,o,E){return!this.demuxer||!this.remuxer||o||E},f.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new P.default(this.observer,this.config)),d},x}();function h(x,f){var p=null;return x.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var w=function(f){return{remuxResult:{},chunkMeta:f}};function g(x){return"then"in x&&x.then instanceof Function}var m=function(f,p,d,o,E){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=p,this.initSegmentData=d,this.duration=o,this.defaultInitPts=E},L=function(f,p,d,o,E){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=p,this.accurateTimeOffset=d,this.trackSwitch=o,this.timeOffset=E}},"./src/demux/tsdemuxer.ts":function(ie,$,D){"use strict";D.r($),D.d($,"discardEPB",function(){return w});var V=D("./src/demux/adts.ts"),N=D("./src/demux/mpegaudio.ts"),P=D("./src/demux/exp-golomb.ts"),H=D("./src/demux/id3.ts"),F=D("./src/demux/sample-aes.ts"),M=D("./src/events.ts"),O=D("./src/utils/mp4-tools.ts"),b=D("./src/utils/logger.ts"),C=D("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},_=function(){function g(L,x,f){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=L,this.config=x,this.typeSupported=f}g.probe=function(x){var f=g.syncOffset(x);return f<0?!1:(f&&b.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},g.syncOffset=function(x){for(var f=Math.min(1e3,x.length-3*188),p=0;p<f;){if(x[p]===71&&x[p+188]===71&&x[p+2*188]===71)return p;p++}return-1},g.createTrack=function(x,f){return{container:x==="video"||x==="audio"?"video/mp2t":void 0,type:x,id:k[x],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:x==="audio"?f:void 0}};var m=g.prototype;return m.resetInitSegment=function(x,f,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video",p),this._audioTrack=g.createTrack("audio",p),this._id3Track=g.createTrack("id3",p),this._txtTrack=g.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=f,this._duration=p},m.resetTimeStamp=function(){},m.resetContiguity=function(){var x=this._audioTrack,f=this._avcTrack,p=this._id3Track;x&&(x.pesData=null),f&&(f.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},m.demux=function(x,f,p,d){p===void 0&&(p=!1),d===void 0&&(d=!1),p||(this.sampleAes=null);var o,E=this._avcTrack,v=this._audioTrack,T=this._id3Track,I=E.pid,G=E.pesData,X=v.pid,J=T.pid,z=v.pesData,W=T.pesData,q=!1,ne=this.pmtParsed,ce=this._pmtId,ve=x.length;if(this.remainderData&&(x=Object(O.appendUint8Array)(this.remainderData,x),ve=x.length,this.remainderData=null),ve<188&&!d)return this.remainderData=x,{audioTrack:v,avcTrack:E,id3Track:T,textTrack:this._txtTrack};var De=Math.max(0,g.syncOffset(x));ve-=(ve+De)%188,ve<x.byteLength&&!d&&(this.remainderData=new Uint8Array(x.buffer,ve,x.buffer.byteLength-ve));for(var xe=De;xe<ve;xe+=188)if(x[xe]===71){var Ce=!!(x[xe+1]&64),Te=((x[xe+1]&31)<<8)+x[xe+2],Ee=(x[xe+3]&48)>>4,ge=void 0;if(Ee>1){if(ge=xe+5+x[xe+4],ge===xe+188)continue}else ge=xe+4;switch(Te){case I:Ce&&(G&&(o=a(G))&&this.parseAVCPES(o,!1),G={data:[],size:0}),G&&(G.data.push(x.subarray(ge,xe+188)),G.size+=xe+188-ge);break;case X:Ce&&(z&&(o=a(z))&&(v.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),z={data:[],size:0}),z&&(z.data.push(x.subarray(ge,xe+188)),z.size+=xe+188-ge);break;case J:Ce&&(W&&(o=a(W))&&this.parseID3PES(o),W={data:[],size:0}),W&&(W.data.push(x.subarray(ge,xe+188)),W.size+=xe+188-ge);break;case 0:Ce&&(ge+=x[ge]+1),ce=this._pmtId=y(x,ge);break;case ce:{Ce&&(ge+=x[ge]+1);var se=u(x,ge,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);I=se.avc,I>0&&(E.pid=I),X=se.audio,X>0&&(v.pid=X,v.isAAC=se.isAAC),J=se.id3,J>0&&(T.pid=J),q&&!ne&&(b.logger.log("reparse from beginning"),q=!1,xe=De-188),ne=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E.pesData=G,v.pesData=z,T.pesData=W;var ke={audioTrack:v,avcTrack:E,id3Track:T,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(ke),ke},m.flush=function(){var x=this.remainderData;this.remainderData=null;var f;return x?f=this.demux(x,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},m.extractRemainingSamples=function(x){var f=x.audioTrack,p=x.avcTrack,d=x.id3Track,o=p.pesData,E=f.pesData,v=d.pesData,T;o&&(T=a(o))?(this.parseAVCPES(T,!0),p.pesData=null):p.pesData=o,E&&(T=a(E))?(f.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),f.pesData=null):(E!=null&&E.size&&b.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=E),v&&(T=a(v))?(this.parseID3PES(T),d.pesData=null):d.pesData=v},m.demuxSampleAes=function(x,f,p){var d=this.demux(x,p,!0,!this.config.progressive),o=this.sampleAes=new F.default(this.observer,this.config,f);return this.decrypt(d,o)},m.decrypt=function(x,f){return new Promise(function(p){var d=x.audioTrack,o=x.avcTrack;d.samples&&d.isAAC?f.decryptAacSamples(d.samples,0,function(){o.samples?f.decryptAvcSamples(o.samples,0,0,function(){p(x)}):p(x)}):o.samples&&f.decryptAvcSamples(o.samples,0,0,function(){p(x)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(x,f){var p=this,d=this._avcTrack,o=this.parseAVCNALu(x.data),E=!1,v=this.avcSample,T,I=!1;x.data=null,v&&o.length&&!d.audFound&&(l(v,d),v=this.avcSample=A(!1,x.pts,x.dts,"")),o.forEach(function(G){switch(G.type){case 1:{T=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),E&&(v.debug+="NDR "),v.frame=!0;var X=G.data;if(I&&X.length>4){var J=new P.default(X).readSliceType();(J===2||J===4||J===7||J===9)&&(v.key=!0)}break}case 5:T=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),E&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{T=!0,E&&v&&(v.debug+="SEI ");var z=new P.default(w(G.data));z.readUByte();for(var W=0,q=0,ne=!1,ce=0;!ne&&z.bytesAvailable>1;){W=0;do ce=z.readUByte(),W+=ce;while(ce===255);q=0;do ce=z.readUByte(),q+=ce;while(ce===255);if(W===4&&z.bytesAvailable!==0){ne=!0;var ve=z.readUByte();if(ve===181){var De=z.readUShort();if(De===49){var xe=z.readUInt();if(xe===1195456820){var Ce=z.readUByte();if(Ce===3){for(var Te=z.readUByte(),Ee=z.readUByte(),ge=31&Te,se=[Te,Ee],ke=0;ke<ge;ke++)se.push(z.readUByte()),se.push(z.readUByte()),se.push(z.readUByte());h(p._txtTrack.samples,{type:3,pts:x.pts,bytes:se})}}}}}else if(W===5&&z.bytesAvailable!==0){if(ne=!0,q>16){for(var Ve=[],He=0;He<16;He++)Ve.push(z.readUByte().toString(16)),(He===3||He===5||He===7||He===9)&&Ve.push("-");for(var tt=q-16,Ke=new Uint8Array(tt),Le=0;Le<tt;Le++)Ke[Le]=z.readUByte();h(p._txtTrack.samples,{pts:x.pts,payloadType:W,uuid:Ve.join(""),userData:Object(H.utf8ArrayToStr)(Ke),userDataBytes:Ke})}}else if(q<z.bytesAvailable)for(var Me=0;Me<q;Me++)z.readUByte()}break}case 7:if(T=!0,I=!0,E&&v&&(v.debug+="SPS "),!d.sps){var We=new P.default(G.data),Xe=We.readSPS();d.width=Xe.width,d.height=Xe.height,d.pixelRatio=Xe.pixelRatio,d.sps=[G.data],d.duration=p._duration;for(var Ge=G.data.subarray(1,4),Fe="avc1.",Be=0;Be<3;Be++){var ot=Ge[Be].toString(16);ot.length<2&&(ot="0"+ot),Fe+=ot}d.codec=Fe}break;case 8:T=!0,E&&v&&(v.debug+="PPS "),d.pps||(d.pps=[G.data]);break;case 9:T=!1,d.audFound=!0,v&&l(v,d),v=p.avcSample=A(!1,x.pts,x.dts,E?"AUD ":"");break;case 12:T=!1;break;default:T=!1,v&&(v.debug+="unknown NAL "+G.type+" ");break}if(v&&T){var et=v.units;et.push(G)}}),f&&v&&(l(v,d),this.avcSample=null)},m.getLastNalUnit=function(){var x,f=this.avcSample,p;if(!f||f.units.length===0){var d=this._avcTrack.samples;f=d[d.length-1]}if((x=f)!==null&&x!==void 0&&x.units){var o=f.units;p=o[o.length-1]}return p},m.parseAVCNALu=function(x){var f=x.byteLength,p=this._avcTrack,d=p.naluState||0,o=d,E=[],v=0,T,I,G,X=-1,J=0;for(d===-1&&(X=0,J=x[0]&31,d=0,v=1);v<f;){if(T=x[v++],!d){d=T?0:1;continue}if(d===1){d=T?0:2;continue}if(!T)d=3;else if(T===1){if(X>=0){var z={data:x.subarray(X,v-d-1),type:J};E.push(z)}else{var W=this.getLastNalUnit();if(W&&(o&&v<=4-o&&(W.state&&(W.data=W.data.subarray(0,W.data.byteLength-o))),I=v-d-1,I>0)){var q=new Uint8Array(W.data.byteLength+I);q.set(W.data,0),q.set(x.subarray(0,I),W.data.byteLength),W.data=q,W.state=0}}v<f?(G=x[v]&31,X=v,J=G,d=0):d=-1}else d=0}if(X>=0&&d>=0){var ne={data:x.subarray(X,f),type:J,state:d};E.push(ne)}if(E.length===0){var ce=this.getLastNalUnit();if(ce){var ve=new Uint8Array(ce.data.byteLength+x.byteLength);ve.set(ce.data,0),ve.set(x,ce.data.byteLength),ce.data=ve}}return p.naluState=d,E},m.parseAACPES=function(x){var f=0,p=this._audioTrack,d=this.aacOverFlow,o=x.data;if(d){this.aacOverFlow=null;var E=d.sample.unit.byteLength,v=Math.min(d.missing,E),T=E-v;d.sample.unit.set(o.subarray(0,v),T),p.samples.push(d.sample),f=d.missing}var I,G;for(I=f,G=o.length;I<G-1&&!V.isHeader(o,I);I++);if(I!==f){var X,J;if(I<G-1?(X="AAC PES did not start with ADTS header,offset:"+I,J=!1):(X="no ADTS header found in AAC PES",J=!0),b.logger.warn("parsing error:"+X),this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.FRAG_PARSING_ERROR,fatal:J,reason:X}),J)return}V.initTrackConfig(p,this.observer,o,I,this.audioCodec);var z;if(x.pts!==void 0)z=x.pts;else if(d){var W=V.getFrameDuration(p.samplerate);z=d.sample.pts+W}else{b.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;I<G;)if(V.isHeader(o,I)){if(I+5<G){var ne=V.appendFrame(p,o,I,z,q);if(ne)if(ne.missing)this.aacOverFlow=ne;else{I+=ne.length,q++;continue}}break}else I++},m.parseMPEGPES=function(x){var f=x.data,p=f.length,d=0,o=0,E=x.pts;if(E===void 0){b.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<p;)if(N.isHeader(f,o)){var v=N.appendFrame(this._audioTrack,f,o,E,d);if(v)o+=v.length,d++;else break}else o++},m.parseID3PES=function(x){if(x.pts===void 0){b.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(x)},g}();_.minProbeByteLength=188;function A(g,m,L,x){return{key:g,frame:!1,pts:m,dts:L,units:[],debug:x,length:0}}function y(g,m){return(g[m+10]&31)<<8|g[m+11]}function u(g,m,L,x){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(g[m+1]&15)<<8|g[m+2],d=m+3+p-4,o=(g[m+10]&15)<<8|g[m+11];for(m+=12+o;m<d;){var E=(g[m+1]&31)<<8|g[m+2];switch(g[m]){case 207:if(!x){b.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=E);break;case 21:f.id3===-1&&(f.id3=E);break;case 219:if(!x){b.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=E);break;case 3:case 4:L?f.audio===-1&&(f.audio=E,f.isAAC=!1):b.logger.log("MPEG audio found, not supported in this browser");break;case 36:b.logger.warn("Unsupported HEVC stream type found");break;default:break}m+=((g[m+3]&15)<<8|g[m+4])+5}return f}function a(g){var m=0,L,x,f,p,d,o=g.data;if(!g||g.size===0)return null;for(;o[0].length<19&&o.length>1;){var E=new Uint8Array(o[0].length+o[1].length);E.set(o[0]),E.set(o[1],o[0].length),o[0]=E,o.splice(1,1)}L=o[0];var v=(L[0]<<16)+(L[1]<<8)+L[2];if(v===1){if(x=(L[4]<<8)+L[5],x&&x>g.size-6)return null;var T=L[7];T&192&&(p=(L[9]&14)*536870912+(L[10]&255)*4194304+(L[11]&254)*16384+(L[12]&255)*128+(L[13]&254)/2,T&64?(d=(L[14]&14)*536870912+(L[15]&255)*4194304+(L[16]&254)*16384+(L[17]&255)*128+(L[18]&254)/2,p-d>60*9e4&&(b.logger.warn(Math.round((p-d)/9e4)+"s delta between PTS and DTS, align them"),p=d)):d=p),f=L[8];var I=f+9;if(g.size<=I)return null;g.size-=I;for(var G=new Uint8Array(g.size),X=0,J=o.length;X<J;X++){L=o[X];var z=L.byteLength;if(I)if(I>z){I-=z;continue}else L=L.subarray(I),z-=I,I=0;G.set(L,m),m+=z}return x&&(x-=f+3),{data:G,pts:p,dts:d,len:x}}return null}function l(g,m){if(g.units.length&&g.frame){if(g.pts===void 0){var L=m.samples,x=L.length;if(x){var f=L[x-1];g.pts=f.pts,g.dts=f.dts}else{m.dropped++;return}}m.samples.push(g)}g.debug.length&&b.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g,m){var L=g.length;if(L>0){if(m.pts>=g[L-1].pts)g.push(m);else for(var x=L-1;x>=0;x--)if(m.pts<g[x].pts){g.splice(x,0,m);break}}else g.push(m)}function w(g){for(var m=g.byteLength,L=[],x=1;x<m-2;)g[x]===0&&g[x+1]===0&&g[x+2]===3?(L.push(x+2),x+=2):x++;if(L.length===0)return g;var f=m-L.length,p=new Uint8Array(f),d=0;for(x=0;x<f;d++,x++)d===L[0]&&(d++,L.shift()),p[x]=g[d];return p}$.default=_},"./src/errors.ts":function(ie,$,D){"use strict";D.r($),D.d($,"ErrorTypes",function(){return V}),D.d($,"ErrorDetails",function(){return N});var V;(function(P){P.NETWORK_ERROR="networkError",P.MEDIA_ERROR="mediaError",P.KEY_SYSTEM_ERROR="keySystemError",P.MUX_ERROR="muxError",P.OTHER_ERROR="otherError"})(V||(V={}));var N;(function(P){P.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",P.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",P.KEY_SYSTEM_NO_SESSION="keySystemNoSession",P.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",P.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",P.MANIFEST_LOAD_ERROR="manifestLoadError",P.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",P.MANIFEST_PARSING_ERROR="manifestParsingError",P.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",P.LEVEL_EMPTY_ERROR="levelEmptyError",P.LEVEL_LOAD_ERROR="levelLoadError",P.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",P.LEVEL_SWITCH_ERROR="levelSwitchError",P.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",P.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",P.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",P.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",P.FRAG_LOAD_ERROR="fragLoadError",P.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",P.FRAG_DECRYPT_ERROR="fragDecryptError",P.FRAG_PARSING_ERROR="fragParsingError",P.REMUX_ALLOC_ERROR="remuxAllocError",P.KEY_LOAD_ERROR="keyLoadError",P.KEY_LOAD_TIMEOUT="keyLoadTimeOut",P.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",P.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",P.BUFFER_APPEND_ERROR="bufferAppendError",P.BUFFER_APPENDING_ERROR="bufferAppendingError",P.BUFFER_STALLED_ERROR="bufferStalledError",P.BUFFER_FULL_ERROR="bufferFullError",P.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",P.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",P.INTERNAL_EXCEPTION="internalException",P.INTERNAL_ABORTED="aborted",P.UNKNOWN="unknown"})(N||(N={}))},"./src/events.ts":function(ie,$,D){"use strict";D.r($),D.d($,"Events",function(){return V});var V;(function(N){N.MEDIA_ATTACHING="hlsMediaAttaching",N.MEDIA_ATTACHED="hlsMediaAttached",N.MEDIA_DETACHING="hlsMediaDetaching",N.MEDIA_DETACHED="hlsMediaDetached",N.BUFFER_RESET="hlsBufferReset",N.BUFFER_CODECS="hlsBufferCodecs",N.BUFFER_CREATED="hlsBufferCreated",N.BUFFER_APPENDING="hlsBufferAppending",N.BUFFER_APPENDED="hlsBufferAppended",N.BUFFER_EOS="hlsBufferEos",N.BUFFER_FLUSHING="hlsBufferFlushing",N.BUFFER_FLUSHED="hlsBufferFlushed",N.MANIFEST_LOADING="hlsManifestLoading",N.MANIFEST_LOADED="hlsManifestLoaded",N.MANIFEST_PARSED="hlsManifestParsed",N.LEVEL_SWITCHING="hlsLevelSwitching",N.LEVEL_SWITCHED="hlsLevelSwitched",N.LEVEL_LOADING="hlsLevelLoading",N.LEVEL_LOADED="hlsLevelLoaded",N.LEVEL_UPDATED="hlsLevelUpdated",N.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",N.LEVELS_UPDATED="hlsLevelsUpdated",N.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",N.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",N.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",N.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",N.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",N.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",N.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",N.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",N.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",N.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",N.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",N.CUES_PARSED="hlsCuesParsed",N.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",N.INIT_PTS_FOUND="hlsInitPtsFound",N.FRAG_LOADING="hlsFragLoading",N.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",N.FRAG_LOADED="hlsFragLoaded",N.FRAG_DECRYPTED="hlsFragDecrypted",N.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",N.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",N.FRAG_PARSING_METADATA="hlsFragParsingMetadata",N.FRAG_PARSED="hlsFragParsed",N.FRAG_BUFFERED="hlsFragBuffered",N.FRAG_CHANGED="hlsFragChanged",N.FPS_DROP="hlsFpsDrop",N.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",N.ERROR="hlsError",N.DESTROYING="hlsDestroying",N.KEY_LOADING="hlsKeyLoading",N.KEY_LOADED="hlsKeyLoaded",N.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",N.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return g});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(V),P=D("./src/loader/playlist-loader.ts"),H=D("./src/loader/key-loader.ts"),F=D("./src/controller/id3-track-controller.ts"),M=D("./src/controller/latency-controller.ts"),O=D("./src/controller/level-controller.ts"),b=D("./src/controller/fragment-tracker.ts"),C=D("./src/controller/stream-controller.ts"),k=D("./src/is-supported.ts"),_=D("./src/utils/logger.ts"),A=D("./src/config.ts"),y=D("./node_modules/eventemitter3/index.js"),u=D.n(y),a=D("./src/events.ts"),l=D("./src/errors.ts");function h(m,L){for(var x=0;x<L.length;x++){var f=L[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function w(m,L,x){return L&&h(m.prototype,L),x&&h(m,x),m}var g=function(){m.isSupported=function(){return Object(k.isSupported)()};function m(x){x===void 0&&(x={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.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 f=this.config=Object(A.mergeConfig)(m.DefaultConfig,x);this.userConfig=x,Object(_.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(A.enableStreamingMode)(f);var p=f.abrController,d=f.bufferController,o=f.capLevelController,E=f.fpsController,v=this.abrController=new p(this),T=this.bufferController=new d(this),I=this.capLevelController=new o(this),G=new E(this),X=new P.default(this),J=new H.default(this),z=new F.default(this),W=this.levelController=new O.default(this),q=new b.FragmentTracker(this),ne=this.streamController=new C.default(this,q);I.setStreamController(ne),G.setStreamController(ne);var ce=[W,ne];this.networkControllers=ce;var ve=[X,J,v,T,I,G,z,q];this.audioTrackController=this.createController(f.audioTrackController,null,ce),this.createController(f.audioStreamController,q,ce),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,ce),this.createController(f.subtitleStreamController,q,ce),this.createController(f.timelineController,null,ve),this.emeController=this.createController(f.emeController,null,ve),this.cmcdController=this.createController(f.cmcdController,null,ve),this.latencyController=this.createController(M.default,null,ve),this.coreComponents=ve}var L=m.prototype;return L.createController=function(f,p,d){if(f){var o=p?new f(this,p):new f(this);return d&&d.push(o),o}return null},L.on=function(f,p,d){d===void 0&&(d=this),this._emitter.on(f,p,d)},L.once=function(f,p,d){d===void 0&&(d=this),this._emitter.once(f,p,d)},L.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},L.off=function(f,p,d,o){d===void 0&&(d=this),this._emitter.off(f,p,d,o)},L.listeners=function(f){return this._emitter.listeners(f)},L.emit=function(f,p,d){return this._emitter.emit(f,p,d)},L.trigger=function(f,p){if(this.config.debug)return this.emit(f,f,p);try{return this.emit(f,f,p)}catch(d){_.logger.error("An internal error happened while handling event "+f+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(a.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:f,error:d})}return!1},L.listenerCount=function(f){return this._emitter.listenerCount(f)},L.destroy=function(){_.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(f){return f.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(f){return f.destroy()}),this.coreComponents.length=0},L.attachMedia=function(f){_.logger.log("attachMedia"),this._media=f,this.trigger(a.Events.MEDIA_ATTACHING,{media:f})},L.detachMedia=function(){_.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(f){this.stopLoad();var p=this.media,d=this.url,o=this.url=V.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});_.logger.log("loadSource:"+o),p&&d&&d!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(a.Events.MANIFEST_LOADING,{url:f})},L.startLoad=function(f){f===void 0&&(f=-1),_.logger.log("startLoad("+f+")"),this.networkControllers.forEach(function(p){p.startLoad(f)})},L.stopLoad=function(){_.logger.log("stopLoad"),this.networkControllers.forEach(function(f){f.stopLoad()})},L.swapAudioCodec=function(){_.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},L.recoverMediaError=function(){_.logger.log("recoverMediaError");var f=this._media;this.detachMedia(),f&&this.attachMedia(f)},L.removeLevel=function(f,p){p===void 0&&(p=0),this.levelController.removeLevel(f,p)},w(m,[{key:"levels",get:function(){var f=this.levelController.levels;return f||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(f){_.logger.log("set currentLevel:"+f),this.loadLevel=f,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(f){_.logger.log("set nextLevel:"+f),this.levelController.manualLevel=f,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(f){_.logger.log("set loadLevel:"+f),this.levelController.manualLevel=f}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(f){this.levelController.nextLoadLevel=f}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(f){_.logger.log("set firstLevel:"+f),this.levelController.firstLevel=f}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(f){_.logger.log("set startLevel:"+f),f!==-1&&(f=Math.max(f,this.minAutoLevel)),this.levelController.startLevel=f}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(f){var p=!!f;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(f){this._autoLevelCapping!==f&&(_.logger.log("set autoLevelCapping:"+f),this._autoLevelCapping=f)}},{key:"bandwidthEstimate",get:function(){var f=this.abrController.bwEstimator;return f?f.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var f=this.levels,p=this.config.minAutoBitrate;if(!f)return 0;for(var d=f.length,o=0;o<d;o++)if(f[o].maxBitrate>p)return o;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,p=this.autoLevelCapping,d;return p===-1&&f&&f.length?d=f.length-1:d=p,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var p=this.audioTrackController;p&&(p.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return m.defaultConfig?m.defaultConfig:A.hlsDefaultConfig},set:function(f){m.defaultConfig=f}}]),m}();g.defaultConfig=void 0},"./src/is-supported.ts":function(ie,$,D){"use strict";D.r($),D.d($,"isSupported",function(){return P}),D.d($,"changeTypeSupported",function(){return H});var V=D("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function P(){var F=Object(V.getMediaSource)();if(!F)return!1;var M=N(),O=F&&typeof F.isTypeSupported=="function"&&F.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!O&&!!b}function H(){var F,M=N();return typeof(M==null||((F=M.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return _}),D.d($,"LoadError",function(){return y});var V=D("./src/polyfills/number.ts"),N=D("./src/errors.ts");function P(u,a){u.prototype=Object.create(a.prototype),u.prototype.constructor=u,b(u,a)}function H(u){var a=typeof Map=="function"?new Map:void 0;return H=function(h){if(h===null||!O(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(h))return a.get(h);a.set(h,w)}function w(){return F(h,arguments,C(this).constructor)}return w.prototype=Object.create(h.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),b(w,h)},H(u)}function F(u,a,l){return M()?F=Reflect.construct:F=function(w,g,m){var L=[null];L.push.apply(L,g);var x=Function.bind.apply(w,L),f=new x;return m&&b(f,m.prototype),f},F.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(u){return!1}}function O(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function b(u,a){return b=Object.setPrototypeOf||function(h,w){return h.__proto__=w,h},b(u,a)}function C(u){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},C(u)}var k=Math.pow(2,17),_=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var a=u.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(h,w){var g=this,m=h.url;if(!m)return Promise.reject(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(m?"part list":"url")));this.abort();var L=this.config,x=L.fLoader,f=L.loader;return new Promise(function(p,d){g.loader&&g.loader.destroy();var o=g.loader=h.loader=x?new x(L):new f(L),E=A(h),v={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};h.stats=o.stats,o.load(E,v,{onSuccess:function(I,G,X,J){g.resetLoader(h,o),p({frag:h,part:null,payload:I.data,networkDetails:J})},onError:function(I,G,X){g.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:I,networkDetails:X}))},onAbort:function(I,G,X){g.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:X}))},onTimeout:function(I,G,X){g.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:X}))},onProgress:function(I,G,X,J){w&&w({frag:h,part:null,payload:X,networkDetails:J})}})})},a.loadPart=function(h,w,g){var m=this;this.abort();var L=this.config,x=L.fLoader,f=L.loader;return new Promise(function(p,d){m.loader&&m.loader.destroy();var o=m.loader=h.loader=x?new x(L):new f(L),E=A(h,w),v={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};w.stats=o.stats,o.load(E,v,{onSuccess:function(I,G,X,J){m.resetLoader(h,o),m.updateStatsFromPart(h,w);var z={frag:h,part:w,payload:I.data,networkDetails:J};g(z),p(z)},onError:function(I,G,X){m.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:w,response:I,networkDetails:X}))},onAbort:function(I,G,X){h.stats.aborted=w.stats.aborted,m.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:w,networkDetails:X}))},onTimeout:function(I,G,X){m.resetLoader(h,o),d(new y({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:w,networkDetails:X}))}})})},a.updateStatsFromPart=function(h,w){var g=h.stats,m=w.stats,L=m.total;if(g.loaded+=m.loaded,L){var x=Math.round(h.duration/w.duration),f=Math.min(Math.round(g.loaded/L),x),p=x-f,d=p*Math.round(g.loaded/f);g.total=g.loaded+d}else g.total=Math.max(g.loaded,g.total);var o=g.loading,E=m.loading;o.start?o.first+=E.first-E.start:(o.start=E.start,o.first=E.first),o.end=E.end},a.resetLoader=function(h,w){h.loader=null,this.loader===w&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),w.destroy()},u}();function A(u,a){a===void 0&&(a=null);var l=a||u,h={frag:u,part:a,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},w=l.byteRangeStartOffset,g=l.byteRangeEndOffset;return Object(V.isFiniteNumber)(w)&&Object(V.isFiniteNumber)(g)&&(h.rangeStart=w,h.rangeEnd=g),h}var y=function(u){P(a,u);function a(l){for(var h,w=arguments.length,g=new Array(w>1?w-1:0),m=1;m<w;m++)g[m-1]=arguments[m];return h=u.call.apply(u,[this].concat(g))||this,h.data=void 0,h.data=l,h}return a}(H(Error))},"./src/loader/fragment.ts":function(ie,$,D){"use strict";D.r($),D.d($,"ElementaryStreamTypes",function(){return _}),D.d($,"BaseSegment",function(){return A}),D.d($,"Fragment",function(){return y}),D.d($,"Part",function(){return u});var V=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),P=D.n(N),H=D("./src/utils/logger.ts"),F=D("./src/loader/level-key.ts"),M=D("./src/loader/load-stats.ts");function O(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,b(a,l)}function b(a,l){return b=Object.setPrototypeOf||function(w,g){return w.__proto__=g,w},b(a,l)}function C(a,l){for(var h=0;h<l.length;h++){var w=l[h];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(a,w.key,w)}}function k(a,l,h){return l&&C(a.prototype,l),h&&C(a,h),a}var _;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(_||(_={}));var A=function(){function a(h){var w;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(w={},w[_.AUDIO]=null,w[_.VIDEO]=null,w[_.AUDIOVIDEO]=null,w),this.baseurl=h}var l=a.prototype;return l.setByteRange=function(w,g){var m=w.split("@",2),L=[];m.length===1?L[0]=g?g.byteRangeEndOffset:0:L[0]=parseInt(m[1]),L[1]=parseInt(m[0])+L[0],this._byteRange=L},k(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(w){this._url=w}}]),a}(),y=function(a){O(l,a);function l(w,g){var m;return m=a.call(this,g)||this,m._decryptdata=null,m.rawProgramDateTime=null,m.programDateTime=null,m.tagList=[],m.duration=0,m.sn=0,m.levelkey=void 0,m.type=void 0,m.loader=null,m.level=-1,m.cc=0,m.startPTS=void 0,m.endPTS=void 0,m.appendedPTS=void 0,m.startDTS=void 0,m.endDTS=void 0,m.start=0,m.deltaPTS=void 0,m.maxStartPTS=void 0,m.minEndPTS=void 0,m.stats=new M.LoadStats,m.urlId=0,m.data=void 0,m.bitrateTest=!1,m.title=null,m.initSegment=null,m.type=w,m}var h=l.prototype;return h.createInitializationVector=function(g){for(var m=new Uint8Array(16),L=12;L<16;L++)m[L]=g>>8*(15-L)&255;return m},h.setDecryptDataFromLevelKey=function(g,m){var L=g;return(g==null?void 0:g.method)==="AES-128"&&g.uri&&!g.iv&&(L=F.LevelKey.fromURI(g.uri),L.method=g.method,L.iv=this.createInitializationVector(m),L.keyFormat="identity"),L},h.setElementaryStreamInfo=function(g,m,L,x,f,p){p===void 0&&(p=!1);var d=this.elementaryStreams,o=d[g];if(!o){d[g]={startPTS:m,endPTS:L,startDTS:x,endDTS:f,partial:p};return}o.startPTS=Math.min(o.startPTS,m),o.endPTS=Math.max(o.endPTS,L),o.startDTS=Math.min(o.startDTS,x),o.endDTS=Math.max(o.endDTS,f)},h.clearElementaryStreamInfo=function(){var g=this.elementaryStreams;g[_.AUDIO]=null,g[_.VIDEO]=null,g[_.AUDIOVIDEO]=null},k(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var g=this.sn;typeof g!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&H.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),g=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,g)}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 g=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+g*1e3}},{key:"encrypted",get:function(){var g;return!!((g=this.decryptdata)!==null&&g!==void 0&&g.keyFormat&&this.decryptdata.uri)}}]),l}(A),u=function(a){O(l,a);function l(h,w,g,m,L){var x;x=a.call(this,g)||this,x.fragOffset=0,x.duration=0,x.gap=!1,x.independent=!1,x.relurl=void 0,x.fragment=void 0,x.index=void 0,x.stats=new M.LoadStats,x.duration=h.decimalFloatingPoint("DURATION"),x.gap=h.bool("GAP"),x.independent=h.bool("INDEPENDENT"),x.relurl=h.enumeratedString("URI"),x.fragment=w,x.index=m;var f=h.enumeratedString("BYTERANGE");return f&&x.setByteRange(f,L),L&&(x.fragOffset=L.fragOffset+L.duration),x}return k(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var w=this.elementaryStreams;return!!(w.audio||w.video||w.audiovideo)}}]),l}(A)},"./src/loader/key-loader.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return H});var V=D("./src/events.ts"),N=D("./src/errors.ts"),P=D("./src/utils/logger.ts"),H=function(){function F(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var M=F.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 b in this.loaders){var C=this.loaders[b];C&&C.destroy()}this.loaders={}},M.onKeyLoading=function(b,C){var k=C.frag,_=k.type,A=this.loaders[_];if(!k.decryptdata){P.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=k.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(A&&(P.logger.warn("abort previous key loader for type:"+_),A.abort()),!y){P.logger.warn("key uri is falsy");return}var a=u.loader,l=k.loader=this.loaders[_]=new a(u);this.decrypturl=y,this.decryptkey=null;var h={url:y,frag:k,responseType:"arraybuffer"},w={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,w,g)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:k}))},M.loadsuccess=function(b,C,k){var _=k.frag;if(!_.decryptdata){P.logger.error("after key load, decryptdata unset");return}this.decryptkey=_.decryptdata.key=new Uint8Array(b.data),_.loader=null,delete this.loaders[_.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:_})},M.loaderror=function(b,C){var k=C.frag,_=k.loader;_&&_.abort(),delete this.loaders[k.type],this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:b})},M.loadtimeout=function(b,C){var k=C.frag,_=k.loader;_&&_.abort(),delete this.loaders[k.type],this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},F}()},"./src/loader/level-details.ts":function(ie,$,D){"use strict";D.r($),D.d($,"LevelDetails",function(){return F});var V=D("./src/polyfills/number.ts");function N(M,O){for(var b=0;b<O.length;b++){var C=O[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(M,C.key,C)}}function P(M,O,b){return O&&N(M.prototype,O),b&&N(M,b),M}var H=10,F=function(){function M(b){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=b}var O=M.prototype;return O.reloaded=function(C){if(!C){this.advanced=!0,this.updated=!0;return}var k=this.lastPartSn-C.lastPartSn,_=this.lastPartIndex-C.lastPartIndex;this.updated=this.endSN!==C.endSN||!!_||!!k,this.advanced=this.endSN>C.endSN||k>0||k===0&&_>0,this.updated||this.advanced?this.misses=Math.floor(C.misses*.6):this.misses=C.misses+1,this.availabilityDelay=C.availabilityDelay},P(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||H}},{key:"drift",get:function(){var C=this.driftEndTime-this.driftStartTime;if(C>0){var k=this.driftEnd-this.driftStart;return k*1e3/C}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var C;return(C=this.partList)!==null&&C!==void 0&&C.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var C;return(C=this.fragments)!==null&&C!==void 0&&C.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 C;return(C=this.partList)!==null&&C!==void 0&&C.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var C;return(C=this.partList)!==null&&C!==void 0&&C.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),M}()},"./src/loader/level-key.ts":function(ie,$,D){"use strict";D.r($),D.d($,"LevelKey",function(){return F});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(V);function P(M,O){for(var b=0;b<O.length;b++){var C=O[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(M,C.key,C)}}function H(M,O,b){return O&&P(M.prototype,O),b&&P(M,b),M}var F=function(){M.fromURL=function(b,C){return new M(b,C)},M.fromURI=function(b){return new M(b)};function M(O,b){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,b?this._uri=Object(V.buildAbsoluteURL)(O,b,{alwaysNormalize:!0}):this._uri=O}return H(M,[{key:"uri",get:function(){return this._uri}}]),M}()},"./src/loader/load-stats.ts":function(ie,$,D){"use strict";D.r($),D.d($,"LoadStats",function(){return V});var V=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return l});var V=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),P=D.n(N),H=D("./src/loader/fragment.ts"),F=D("./src/loader/level-details.ts"),M=D("./src/loader/level-key.ts"),O=D("./src/utils/attr-list.ts"),b=D("./src/utils/logger.ts"),C=D("./src/utils/codecs.ts"),k=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,_=/#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"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function a(L){var x,f;return u.test((x=(f=N.parseURL(L))===null||f===void 0?void 0:f.path)!=null?x:"")}var l=function(){function L(){}return L.findGroup=function(f,p){for(var d=0;d<f.length;d++){var o=f[d];if(o.id===p)return o}},L.convertAVC1ToAVCOTI=function(f){var p=f.split(".");if(p.length>2){var d=p.shift()+".";return d+=parseInt(p.shift()).toString(16),d+=("000"+parseInt(p.shift()).toString(16)).substr(-4),d}return f},L.resolve=function(f,p){return N.buildAbsoluteURL(p,f,{alwaysNormalize:!0})},L.parseMasterPlaylist=function(f,p){var d=[],o={},E=!1;k.lastIndex=0;for(var v;(v=k.exec(f))!=null;)if(v[1]){var T=new O.AttrList(v[1]),I={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:L.resolve(v[2],p)},G=T.decimalResolution("RESOLUTION");G&&(I.width=G.width,I.height=G.height),h((T.CODECS||"").split(/[ ,]+/).filter(function(J){return J}),I),I.videoCodec&&I.videoCodec.indexOf("avc1")!==-1&&(I.videoCodec=L.convertAVC1ToAVCOTI(I.videoCodec)),d.push(I)}else if(v[3]){var X=new O.AttrList(v[3]);X["DATA-ID"]&&(E=!0,o[X["DATA-ID"]]=X)}return{levels:d,sessionData:E?o:null}},L.parseMasterPlaylistMedia=function(f,p,d,o){o===void 0&&(o=[]);var E,v=[],T=0;for(_.lastIndex=0;(E=_.exec(f))!==null;){var I=new O.AttrList(E[1]);if(I.TYPE===d){var G={attrs:I,bitrate:0,id:T++,groupId:I["GROUP-ID"],instreamId:I["INSTREAM-ID"],name:I.NAME||I.LANGUAGE||"",type:d,default:I.bool("DEFAULT"),autoselect:I.bool("AUTOSELECT"),forced:I.bool("FORCED"),lang:I.LANGUAGE,url:I.URI?L.resolve(I.URI,p):""};if(o.length){var X=L.findGroup(o,G.groupId)||o[0];w(G,X,"audioCodec"),w(G,X,"textCodec")}v.push(G)}}return v},L.parseLevelPlaylist=function(f,p,d,o,E){var v=new F.LevelDetails(p),T=v.fragments,I=null,G=0,X=0,J=0,z=0,W=null,q=new H.Fragment(o,p),ne,ce,ve,De=-1,xe=!1;for(A.lastIndex=0,v.m3u8=f;(ne=A.exec(f))!==null;){xe&&(xe=!1,q=new H.Fragment(o,p),q.start=J,q.sn=G,q.cc=z,q.level=d,I&&(q.initSegment=I,q.rawProgramDateTime=I.rawProgramDateTime));var Ce=ne[1];if(Ce){q.duration=parseFloat(Ce);var Te=(" "+ne[2]).slice(1);q.title=Te||null,q.tagList.push(Te?["INF",Ce,Te]:["INF",Ce])}else if(ne[3])Object(V.isFiniteNumber)(q.duration)&&(q.start=J,ve&&(q.levelkey=ve),q.sn=G,q.level=d,q.cc=z,q.urlId=E,T.push(q),q.relurl=(" "+ne[3]).slice(1),m(q,W),W=q,J+=q.duration,G++,X=0,xe=!0);else if(ne[4]){var Ee=(" "+ne[4]).slice(1);W?q.setByteRange(Ee,W):q.setByteRange(Ee)}else if(ne[5])q.rawProgramDateTime=(" "+ne[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),De===-1&&(De=T.length);else{if(ne=ne[0].match(y),!ne){b.logger.warn("No matches on slow regex match for level playlist!");continue}for(ce=1;ce<ne.length&&!(typeof ne[ce]!="undefined");ce++);var ge=(" "+ne[ce]).slice(1),se=(" "+ne[ce+1]).slice(1),ke=ne[ce+2]?(" "+ne[ce+2]).slice(1):"";switch(ge){case"PLAYLIST-TYPE":v.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":G=v.startSN=parseInt(se);break;case"SKIP":{var Ve=new O.AttrList(se),He=Ve.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(He)){v.skippedSegments=He;for(var tt=He;tt--;)T.unshift(null);G+=He}var Ke=Ve.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ke&&(v.recentlyRemovedDateranges=Ke.split(" "));break}case"TARGETDURATION":v.targetduration=parseFloat(se);break;case"VERSION":v.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":v.live=!1;break;case"#":(se||ke)&&q.tagList.push(ke?[se,ke]:[se]);break;case"DIS":z++;case"GAP":q.tagList.push([ge]);break;case"BITRATE":q.tagList.push([ge,se]);break;case"DISCONTINUITY-SEQ":z=parseInt(se);break;case"KEY":{var Le,Me=new O.AttrList(se),We=Me.enumeratedString("METHOD"),Xe=Me.URI,Ge=Me.hexadecimalInteger("IV"),Fe=Me.enumeratedString("KEYFORMATVERSIONS"),Be=Me.enumeratedString("KEYID"),ot=(Le=Me.enumeratedString("KEYFORMAT"))!=null?Le:"identity",et=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(et.indexOf(ot)>-1){b.logger.warn("Keyformat "+ot+" is not supported from the manifest");continue}else if(ot!=="identity")continue;We&&(ve=M.LevelKey.fromURL(p,Xe),Xe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(We)>=0&&(ve.method=We,ve.keyFormat=ot,Be&&(ve.keyID=Be),Fe&&(ve.keyFormatVersions=Fe),ve.iv=Ge));break}case"START":{var Ze=new O.AttrList(se),rt=Ze.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(rt)&&(v.startTimeOffset=rt);break}case"MAP":{var ht=new O.AttrList(se);q.relurl=ht.URI,ht.BYTERANGE&&q.setByteRange(ht.BYTERANGE),q.level=d,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,I=q,xe=!0;break}case"SERVER-CONTROL":{var Qe=new O.AttrList(se);v.canBlockReload=Qe.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=Qe.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&Qe.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=Qe.optionalFloat("PART-HOLD-BACK",0),v.holdBack=Qe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Je=new O.AttrList(se);v.partTarget=Je.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=v.partList;we||(we=v.partList=[]);var lt=X>0?we[we.length-1]:void 0,it=X++,Ae=new H.Part(new O.AttrList(se),q,p,it,lt);we.push(Ae),q.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Ne=new O.AttrList(se);v.preloadHint=Ne;break}case"RENDITION-REPORT":{var me=new O.AttrList(se);v.renditionReports=v.renditionReports||[],v.renditionReports.push(me);break}default:b.logger.warn("line parsed but not handled: "+ne);break}}}W&&!W.relurl?(T.pop(),J-=W.duration,v.partList&&(v.fragmentHint=W)):v.partList&&(m(q,W),q.cc=z,v.fragmentHint=q);var de=T.length,fe=T[0],ee=T[de-1];if(J+=v.skippedSegments*v.targetduration,J>0&&de&&ee){v.averagetargetduration=J/de;var te=ee.sn;v.endSN=te!=="initSegment"?te:0,fe&&(v.startCC=fe.cc,fe.initSegment||v.fragments.every(function(ae){return ae.relurl&&a(ae.relurl)})&&(b.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new H.Fragment(o,p),q.relurl=ee.relurl,q.level=d,q.sn="initSegment",fe.initSegment=q,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(J+=v.fragmentHint.duration),v.totalduration=J,v.endCC=z,De>0&&g(T,De),v},L}();function h(L,x){["video","audio","text"].forEach(function(f){var p=L.filter(function(o){return Object(C.isCodecType)(o,f)});if(p.length){var d=p.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});x[f+"Codec"]=d.length>0?d[0]:p[0],L=L.filter(function(o){return p.indexOf(o)===-1})}}),x.unknownCodecs=L}function w(L,x,f){var p=x[f];p&&(L[f]=p)}function g(L,x){for(var f=L[x],p=x;p--;){var d=L[p];if(!d)return;d.programDateTime=f.programDateTime-d.duration*1e3,f=d}}function m(L,x){L.rawProgramDateTime?L.programDateTime=Date.parse(L.rawProgramDateTime):x!=null&&x.programDateTime&&(L.programDateTime=x.endProgramDateTime),Object(V.isFiniteNumber)(L.programDateTime)||(L.programDateTime=null,L.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),P=D("./src/errors.ts"),H=D("./src/utils/logger.ts"),F=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/m3u8-parser.ts"),O=D("./src/types/loader.ts"),b=D("./src/utils/attr-list.ts");function C(A){var y=A.type;switch(y){case O.PlaylistContextType.AUDIO_TRACK:return O.PlaylistLevelType.AUDIO;case O.PlaylistContextType.SUBTITLE_TRACK:return O.PlaylistLevelType.SUBTITLE;default:return O.PlaylistLevelType.MAIN}}function k(A,y){var u=A.url;return(u===void 0||u.indexOf("data:")===0)&&(u=y.url),u}var _=function(){function A(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var y=A.prototype;return y.registerListeners=function(){var a=this.hls;a.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var a=this.hls;a.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(a){var l=this.hls.config,h=l.pLoader,w=l.loader,g=h||w,m=new g(l);return a.loader=m,this.loaders[a.type]=m,m},y.getInternalLoader=function(a){return this.loaders[a.type]},y.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},y.destroyInternalLoaders=function(){for(var a in this.loaders){var l=this.loaders[a];l&&l.destroy(),this.resetInternalLoader(a)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(a,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},y.onLevelLoading=function(a,l){var h=l.id,w=l.level,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:null,level:w,responseType:"text",type:O.PlaylistContextType.LEVEL,url:g,deliveryDirectives:m})},y.onAudioTrackLoading=function(a,l){var h=l.id,w=l.groupId,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:w,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:g,deliveryDirectives:m})},y.onSubtitleTrackLoading=function(a,l){var h=l.id,w=l.groupId,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:w,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:g,deliveryDirectives:m})},y.load=function(a){var l,h=this.hls.config,w=this.getInternalLoader(a);if(w){var g=w.context;if(g&&g.url===a.url){H.logger.trace("[playlist-loader]: playlist request ongoing");return}H.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),w.abort()}var m,L,x,f;switch(a.type){case O.PlaylistContextType.MANIFEST:m=h.manifestLoadingMaxRetry,L=h.manifestLoadingTimeOut,x=h.manifestLoadingRetryDelay,f=h.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:m=0,L=h.levelLoadingTimeOut;break;default:m=h.levelLoadingMaxRetry,L=h.levelLoadingTimeOut,x=h.levelLoadingRetryDelay,f=h.levelLoadingMaxRetryTimeout;break}if(w=this.createInternalLoader(a),(l=a.deliveryDirectives)!==null&&l!==void 0&&l.part){var p;if(a.type===O.PlaylistContextType.LEVEL&&a.level!==null?p=this.hls.levels[a.level].details:a.type===O.PlaylistContextType.AUDIO_TRACK&&a.id!==null?p=this.hls.audioTracks[a.id].details:a.type===O.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(p=this.hls.subtitleTracks[a.id].details),p){var d=p.partTarget,o=p.targetduration;d&&o&&(L=Math.min(Math.max(d*3,o*.8)*1e3,L))}}var E={timeout:L,maxRetry:m,retryDelay:x,maxRetryDelay:f,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};w.load(a,E,v)},y.loadsuccess=function(a,l,h,w){if(w===void 0&&(w=null),h.isSidxRequest){this.handleSidxRequest(a,h),this.handlePlaylistLoaded(a,l,h,w);return}this.resetInternalLoader(h.type);var g=a.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,h,"no EXTM3U delimiter",w);return}l.parsing.start=performance.now(),g.indexOf("#EXTINF:")>0||g.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,l,h,w):this.handleMasterPlaylist(a,l,h,w)},y.loaderror=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,a)},y.loadtimeout=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},y.handleMasterPlaylist=function(a,l,h,w){var g=this.hls,m=a.data,L=k(a,h),x=M.default.parseMasterPlaylist(m,L),f=x.levels,p=x.sessionData;if(!f.length){this.handleManifestParsingError(a,h,"no level found in manifest",w);return}var d=f.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),o=f.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),E=M.default.parseMasterPlaylistMedia(m,L,"AUDIO",d),v=M.default.parseMasterPlaylistMedia(m,L,"SUBTITLES",o),T=M.default.parseMasterPlaylistMedia(m,L,"CLOSED-CAPTIONS");if(E.length){var I=E.some(function(G){return!G.url});!I&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(H.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}g.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:E,subtitles:v,captions:T,url:L,stats:l,networkDetails:w,sessionData:p})},y.handleTrackOrLevelPlaylist=function(a,l,h,w){var g=this.hls,m=h.id,L=h.level,x=h.type,f=k(a,h),p=Object(V.isFiniteNumber)(m)?m:0,d=Object(V.isFiniteNumber)(L)?L:p,o=C(h),E=M.default.parseLevelPlaylist(a.data,f,d,o,p);if(!E.fragments.length){g.trigger(N.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(x===O.PlaylistContextType.MANIFEST){var v={attrs:new b.AttrList({}),bitrate:0,details:E,name:"",url:f};g.trigger(N.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:f,stats:l,networkDetails:w,sessionData:null})}if(l.parsing.end=performance.now(),E.needSidxRanges){var T,I=(T=E.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:I,isSidxRequest:!0,type:x,level:L,levelDetails:E,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=E,this.handlePlaylistLoaded(a,l,h,w)},y.handleSidxRequest=function(a,l){var h=Object(F.parseSegmentIndex)(new Uint8Array(a.data));if(!h)return;var w=h.references,g=l.levelDetails;w.forEach(function(m,L){var x=m.info,f=g.fragments[L];f.byteRange.length===0&&f.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),f.initSegment&&f.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},y.handleManifestParsingError=function(a,l,h,w){this.hls.trigger(N.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===O.PlaylistContextType.MANIFEST,url:a.url,reason:h,response:a,context:l,networkDetails:w})},y.handleNetworkError=function(a,l,h,w){h===void 0&&(h=!1),H.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var g=P.ErrorDetails.UNKNOWN,m=!1,L=this.getInternalLoader(a);switch(a.type){case O.PlaylistContextType.MANIFEST:g=h?P.ErrorDetails.MANIFEST_LOAD_TIMEOUT:P.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case O.PlaylistContextType.LEVEL:g=h?P.ErrorDetails.LEVEL_LOAD_TIMEOUT:P.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case O.PlaylistContextType.AUDIO_TRACK:g=h?P.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:P.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:g=h?P.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:P.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}L&&this.resetInternalLoader(a.type);var x={type:P.ErrorTypes.NETWORK_ERROR,details:g,fatal:m,url:a.url,loader:L,context:a,networkDetails:l};w&&(x.response=w),this.hls.trigger(N.Events.ERROR,x)},y.handlePlaylistLoaded=function(a,l,h,w){var g=h.type,m=h.level,L=h.id,x=h.groupId,f=h.loader,p=h.levelDetails,d=h.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(a,h,"invalid target duration",w);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(g){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:p,level:m||0,id:L||0,stats:l,networkDetails:w,deliveryDirectives:d});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:p,id:L||0,groupId:x||"",stats:l,networkDetails:w,deliveryDirectives:d});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:p,id:L||0,groupId:x||"",stats:l,networkDetails:w,deliveryDirectives:d});break}},A}();$.default=_},"./src/polyfills/number.ts":function(ie,$,D){"use strict";D.r($),D.d($,"isFiniteNumber",function(){return V}),D.d($,"MAX_SAFE_INTEGER",function(){return N});var V=Number.isFinite||function(P){return typeof P=="number"&&isFinite(P)},N=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ie,$,D){"use strict";D.r($);var V=function(){function N(){}return N.getSilentFrame=function(H,F){switch(H){case"mp4a.40.2":if(F===1)return new Uint8Array([0,200,0,128,35,128]);if(F===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(F===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(F===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(F===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(F===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(F===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},N}();$.default=V},"./src/remux/mp4-generator.ts":function(ie,$,D){"use strict";D.r($);var V=Math.pow(2,32)-1,N=function(){function P(){}return P.init=function(){P.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var F;for(F in P.types)P.types.hasOwnProperty(F)&&(P.types[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.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]),O=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);P.HDLR_TYPES={video:M,audio:O};var b=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),C=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=C,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var k=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,k,A,k,_),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,b))},P.box=function(F){for(var M=8,O=arguments.length,b=new Array(O>1?O-1:0),C=1;C<O;C++)b[C-1]=arguments[C];for(var k=b.length,_=k;k--;)M+=b[k].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(F,4),k=0,M=8;k<_;k++)A.set(b[k],M),M+=b[k].byteLength;return A},P.hdlr=function(F){return P.box(P.types.hdlr,P.HDLR_TYPES[F])},P.mdat=function(F){return P.box(P.types.mdat,F)},P.mdhd=function(F,M){M*=F;var O=Math.floor(M/(V+1)),b=Math.floor(M%(V+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},P.mdia=function(F){return P.box(P.types.mdia,P.mdhd(F.timescale,F.duration),P.hdlr(F.type),P.minf(F))},P.mfhd=function(F){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,F>>24,F>>16&255,F>>8&255,F&255]))},P.minf=function(F){return F.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(F)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(F))},P.moof=function(F,M,O){return P.box(P.types.moof,P.mfhd(F),P.traf(O,M))},P.moov=function(F){for(var M=F.length,O=[];M--;)O[M]=P.trak(F[M]);return P.box.apply(null,[P.types.moov,P.mvhd(F[0].timescale,F[0].duration)].concat(O).concat(P.mvex(F)))},P.mvex=function(F){for(var M=F.length,O=[];M--;)O[M]=P.trex(F[M]);return P.box.apply(null,[P.types.mvex].concat(O))},P.mvhd=function(F,M){M*=F;var O=Math.floor(M/(V+1)),b=Math.floor(M%(V+1)),C=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,b>>24,b>>16&255,b>>8&255,b&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 P.box(P.types.mvhd,C)},P.sdtp=function(F){var M=F.samples||[],O=new Uint8Array(4+M.length),b,C;for(b=0;b<M.length;b++)C=M[b].flags,O[b+4]=C.dependsOn<<4|C.isDependedOn<<2|C.hasRedundancy;return P.box(P.types.sdtp,O)},P.stbl=function(F){return P.box(P.types.stbl,P.stsd(F),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(F){var M=[],O=[],b,C,k;for(b=0;b<F.sps.length;b++)C=F.sps[b],k=C.byteLength,M.push(k>>>8&255),M.push(k&255),M=M.concat(Array.prototype.slice.call(C));for(b=0;b<F.pps.length;b++)C=F.pps[b],k=C.byteLength,O.push(k>>>8&255),O.push(k&255),O=O.concat(Array.prototype.slice.call(C));var _=P.box(P.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|F.sps.length].concat(M).concat([F.pps.length]).concat(O))),A=F.width,y=F.height,u=F.pixelRatio[0],a=F.pixelRatio[1];return P.box(P.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,y>>8&255,y&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]),_,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255])))},P.esds=function(F){var M=F.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(F.config).concat([6,1,2]))},P.mp4a=function(F){var M=F.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),P.box(P.types.esds,P.esds(F)))},P.mp3=function(F){var M=F.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},P.stsd=function(F){return F.type==="audio"?!F.isAAC&&F.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(F)):P.box(P.types.stsd,P.STSD,P.mp4a(F)):P.box(P.types.stsd,P.STSD,P.avc1(F))},P.tkhd=function(F){var M=F.id,O=F.duration*F.timescale,b=F.width,C=F.height,k=Math.floor(O/(V+1)),_=Math.floor(O%(V+1));return P.box(P.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,k>>24,k>>16&255,k>>8&255,k&255,_>>24,_>>16&255,_>>8&255,_&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,b>>8&255,b&255,0,0,C>>8&255,C&255,0,0]))},P.traf=function(F,M){var O=P.sdtp(F),b=F.id,C=Math.floor(M/(V+1)),k=Math.floor(M%(V+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,C>>24,C>>16&255,C>>8&255,C&255,k>>24,k>>16&255,k>>8&255,k&255])),P.trun(F,O.length+16+20+8+16+8+8),O)},P.trak=function(F){return F.duration=F.duration||4294967295,P.box(P.types.trak,P.tkhd(F),P.mdia(F))},P.trex=function(F){var M=F.id;return P.box(P.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]))},P.trun=function(F,M){var O=F.samples||[],b=O.length,C=12+16*b,k=new Uint8Array(C),_,A,y,u,a,l;for(M+=8+C,k.set([0,0,15,1,b>>>24&255,b>>>16&255,b>>>8&255,b&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),_=0;_<b;_++)A=O[_],y=A.duration,u=A.size,a=A.flags,l=A.cts,k.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,a.degradPrio&240<<8,a.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*_);return P.box(P.types.trun,k)},P.initSegment=function(F){P.types||P.init();var M=P.moov(F),O=new Uint8Array(P.FTYP.byteLength+M.byteLength);return O.set(P.FTYP),O.set(M,P.FTYP.byteLength),O},P}();N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0,$.default=N},"./src/remux/mp4-remuxer.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return l}),D.d($,"normalizePts",function(){return h});var V=D("./src/polyfills/number.ts"),N=D("./src/remux/aac-helper.ts"),P=D("./src/remux/mp4-generator.ts"),H=D("./src/events.ts"),F=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),O=D("./src/types/loader.ts"),b=D("./src/utils/timescale-conversion.ts");function C(){return C=Object.assign||function(L){for(var x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(L[p]=f[p])}return L},C.apply(this,arguments)}var k=10*1e3,_=1024,A=1152,y=null,u=null,a=!1,l=function(){function L(f,p,d,o){if(o===void 0&&(o=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=p,this.typeSupported=d,this.ISGenerated=!1,y===null){var E=navigator.userAgent||"",v=E.match(/Chrome\/(\d+)/i);y=v?parseInt(v[1]):0}if(u===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);u=T?parseInt(T[1]):0}a=!!y&&y<75||!!u&&u<600}var x=L.prototype;return x.destroy=function(){},x.resetTimeStamp=function(p){M.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},x.resetNextTimestamp=function(){M.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},x.resetInitSegment=function(){M.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},x.getVideoStartPts=function(p){var d=!1,o=p.reduce(function(E,v){var T=v.pts-E;return T<-4294967296?(d=!0,h(E,v.pts)):T>0?E:v.pts},p[0].pts);return d&&M.logger.debug("PTS rollover detected"),o},x.remux=function(p,d,o,E,v,T,I,G){var X,J,z,W,q,ne,ce=v,ve=v,De=p.pid>-1,xe=d.pid>-1,Ce=d.samples.length,Te=p.samples.length>0,Ee=Ce>1,ge=(!De||Te)&&(!xe||Ee)||this.ISGenerated||I;if(ge){this.ISGenerated||(z=this.generateIS(p,d,v));var se=this.isVideoContiguous,ke=-1;if(Ee&&(ke=w(d.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(ne=!0,ke>0){M.logger.warn("[mp4-remuxer]: Dropped "+ke+" out of "+Ce+" video samples due to a missing keyframe");var Ve=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(ke),d.dropped+=ke,ve+=(d.samples[0].pts-Ve)/(d.timescale||9e4)}else ke===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ne=!1);if(this.ISGenerated){if(Te&&Ee){var He=this.getVideoStartPts(d.samples),tt=h(p.samples[0].pts,He)-He,Ke=tt/d.inputTimeScale;ce+=Math.max(0,Ke),ve+=Math.max(0,-Ke)}if(Te){if(p.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(p,d,v)),J=this.remuxAudio(p,ce,this.isAudioContiguous,T,xe||Ee||G===O.PlaylistLevelType.AUDIO?ve:void 0),Ee){var Le=J?J.endPTS-J.startPTS:0;d.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(p,d,v)),X=this.remuxVideo(d,ve,se,Le)}}else Ee&&(X=this.remuxVideo(d,ve,se,0));X&&(X.firstKeyFrame=ke,X.independent=ke!==-1)}}return this.ISGenerated&&(o.samples.length&&(q=this.remuxID3(o,v)),E.samples.length&&(W=this.remuxText(E,v))),{audio:J,video:X,initSegment:z,independent:ne,text:W,id3:q}},x.generateIS=function(p,d,o){var E=p.samples,v=d.samples,T=this.typeSupported,I={},G=!Object(V.isFiniteNumber)(this._initPTS),X="audio/mp4",J,z,W;if(G&&(J=z=Infinity),p.config&&E.length&&(p.timescale=p.samplerate,p.isAAC||(T.mpeg?(X="audio/mpeg",p.codec=""):T.mp3&&(p.codec="mp3")),I.audio={id:"audio",container:X,codec:p.codec,initSegment:!p.isAAC&&T.mpeg?new Uint8Array(0):P.default.initSegment([p]),metadata:{channelCount:p.channelCount}},G&&(W=p.inputTimeScale,J=z=E[0].pts-Math.round(W*o))),d.sps&&d.pps&&v.length&&(d.timescale=d.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:P.default.initSegment([d]),metadata:{width:d.width,height:d.height}},G)){W=d.inputTimeScale;var q=this.getVideoStartPts(v),ne=Math.round(W*o);z=Math.min(z,h(v[0].dts,q)-ne),J=Math.min(J,q-ne)}if(Object.keys(I).length)return this.ISGenerated=!0,G&&(this._initPTS=J,this._initDTS=z),{tracks:I,initPTS:J,timescale:W}},x.remuxVideo=function(p,d,o,E){var v=p.inputTimeScale,T=p.samples,I=[],G=T.length,X=this._initPTS,J=this.nextAvcDts,z=8,W,q,ne,ce=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,De=0,xe=!1;if(!o||J===null){var Ce=d*v,Te=T[0].pts-h(T[0].dts,T[0].pts);J=Ce-Te}for(var Ee=0;Ee<G;Ee++){var ge=T[Ee];if(ge.pts=h(ge.pts-X,J),ge.dts=h(ge.dts-X,J),ge.dts>ge.pts){var se=9e4*.2;De=Math.max(Math.min(De,ge.pts-ge.dts),-1*se)}ge.dts<T[Ee>0?Ee-1:Ee].dts&&(xe=!0)}xe&&T.sort(function(Lt,Tt){var ut=Lt.dts-Tt.dts,Bt=Lt.pts-Tt.pts;return ut||Bt}),q=T[0].dts,ne=T[T.length-1].dts;var ke=Math.round((ne-q)/(G-1));if(De<0){if(De<ke*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(b.toMsFromMpegTsClock)(-ke,!0)+" ms");for(var Ve=De,He=0;He<G;He++)T[He].dts=Ve=Math.max(Ve,T[He].pts-ke),T[He].pts=Math.max(Ve,T[He].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(b.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var tt=0;tt<G;tt++)T[tt].dts=T[tt].dts+De}q=T[0].dts}if(o){var Ke=q-J,Le=Ke>ke,Me=Ke<-1;if(Le||Me){Le?M.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(Ke,!0)+" ms ("+Ke+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-Ke,!0)+" ms ("+Ke+"dts) overlapping between fragments detected"),q=J;var We=T[0].pts-Ke;T[0].dts=q,T[0].pts=We,M.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(We,!0)+"/"+Object(b.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(b.toMsFromMpegTsClock)(Ke,!0)+" ms")}}a&&(q=Math.max(0,q));for(var Xe=0,Ge=0,Fe=0;Fe<G;Fe++){for(var Be=T[Fe],ot=Be.units,et=ot.length,Ze=0,rt=0;rt<et;rt++)Ze+=ot[rt].data.length;Ge+=Ze,Xe+=et,Be.length=Ze,Be.dts=Math.max(Be.dts,q),Be.pts=Math.max(Be.pts,Be.dts,0),ce=Math.min(Be.pts,ce),ve=Math.max(Be.pts,ve)}ne=T[G-1].dts;var ht=Ge+4*Xe+8,Qe;try{Qe=new Uint8Array(ht)}catch(Lt){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ht,reason:"fail allocating video mdat "+ht});return}var Je=new DataView(Qe.buffer);Je.setUint32(0,ht),Qe.set(P.default.types.mdat,4);for(var we=0;we<G;we++){for(var lt=T[we],it=lt.units,Ae=0,Ne=0,me=it.length;Ne<me;Ne++){var de=it[Ne],fe=de.data,ee=de.data.byteLength;Je.setUint32(z,ee),z+=4,Qe.set(fe,z),z+=ee,Ae+=4+ee}if(we<G-1)W=T[we+1].dts-lt.dts;else{var te=this.config,ae=lt.dts-T[we>0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(te.maxBufferHole*v),pe=(E?ce+E*v:this.nextAudioPts)-lt.pts;pe>ue?(W=pe-ae,W<0&&(W=ae),M.logger.log("[mp4-remuxer]: It is approximately "+pe/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=ae}else W=ae}var Se=Math.round(lt.pts-lt.dts);I.push(new g(lt.key,W,Ae,Se))}if(I.length&&y&&y<70){var Oe=I[0].flags;Oe.dependsOn=2,Oe.isNonSync=0}console.assert(W!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=J=ne+W,this.isVideoContiguous=!0;var qe=P.default.moof(p.sequenceNumber++,q,C({},p,{samples:I})),pt="video",dt={data1:qe,data2:Qe,startPTS:ce/v,endPTS:(ve+W)/v,startDTS:q/v,endDTS:J/v,type:pt,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(Qe.length,"MDAT length must not be zero"),dt},x.remuxAudio=function(p,d,o,E,v){var T=p.inputTimeScale,I=p.samplerate?p.samplerate:T,G=T/I,X=p.isAAC?_:A,J=X*G,z=this._initPTS,W=!p.isAAC&&this.typeSupported.mpeg,q=[],ne=p.samples,ce=W?0:8,ve=this.nextAudioPts||-1,De=d*T;if(this.isAudioContiguous=o=o||ne.length&&ve>0&&(E&&Math.abs(De-ve)<9e3||Math.abs(h(ne[0].pts-z,De)-ve)<20*J),ne.forEach(function(fe){fe.pts=h(fe.pts-z,De)}),!o||ve<0){if(ne=ne.filter(function(fe){return fe.pts>=0}),!ne.length)return;v===0?ve=0:E?ve=Math.max(0,De):ve=ne[0].pts}if(p.isAAC)for(var xe=v!==void 0,Ce=this.config.maxAudioFramesDrift,Te=0,Ee=ve;Te<ne.length;Te++){var ge=ne[Te],se=ge.pts,ke=se-Ee,Ve=Math.abs(1e3*ke/T);if(ke<=-Ce*J&&xe)Te===0&&(M.logger.warn("Audio frame @ "+(se/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ke/T)+" ms."),this.nextAudioPts=ve=Ee=se);else if(ke>=Ce*J&&Ve<k&&xe){var He=Math.round(ke/J);Ee=se-He*J,Ee<0&&(He--,Ee+=J),Te===0&&(this.nextAudioPts=ve=Ee),M.logger.warn("[mp4-remuxer]: Injecting "+He+" audio frame @ "+(Ee/T).toFixed(3)+"s due to "+Math.round(1e3*ke/T)+" ms gap.");for(var tt=0;tt<He;tt++){var Ke=Math.max(Ee,0),Le=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);Le||(M.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=ge.unit.subarray()),ne.splice(Te,0,{unit:Le,pts:Ke}),Ee+=J,Te++}}ge.pts=Ee,Ee+=J}for(var Me=null,We=null,Xe,Ge=0,Fe=ne.length;Fe--;)Ge+=ne[Fe].unit.byteLength;for(var Be=0,ot=ne.length;Be<ot;Be++){var et=ne[Be],Ze=et.unit,rt=et.pts;if(We!==null){var ht=q[Be-1];ht.duration=Math.round((rt-We)/G)}else if(o&&p.isAAC&&(rt=ve),Me=rt,Ge>0){Ge+=ce;try{Xe=new Uint8Array(Ge)}catch(fe){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ge,reason:"fail allocating audio mdat "+Ge});return}if(!W){var Qe=new DataView(Xe.buffer);Qe.setUint32(0,Ge),Xe.set(P.default.types.mdat,4)}}else return;Xe.set(Ze,ce);var Je=Ze.byteLength;ce+=Je,q.push(new g(!0,X,Je,0)),We=rt}var we=q.length;if(!we)return;var lt=q[q.length-1];this.nextAudioPts=ve=We+G*lt.duration;var it=W?new Uint8Array(0):P.default.moof(p.sequenceNumber++,Me/G,C({},p,{samples:q}));p.samples=[];var Ae=Me/T,Ne=ve/T,me="audio",de={data1:it,data2:Xe,startPTS:Ae,endPTS:Ne,startDTS:Ae,endDTS:Ne,type:me,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(Xe.length,"MDAT length must not be zero"),de},x.remuxEmptyAudio=function(p,d,o,E){var v=p.inputTimeScale,T=p.samplerate?p.samplerate:v,I=v/T,G=this.nextAudioPts,X=(G!==null?G:E.startDTS*v)+this._initDTS,J=E.endDTS*v+this._initDTS,z=I*_,W=Math.ceil((J-X)/z),q=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ne=[],ce=0;ce<W;ce++){var ve=X+ce*z;ne.push({unit:q,pts:ve,dts:ve})}return p.samples=ne,this.remuxAudio(p,d,o,!1)},x.remuxID3=function(p,d){var o=p.samples.length;if(!o)return;for(var E=p.inputTimeScale,v=this._initPTS,T=this._initDTS,I=0;I<o;I++){var G=p.samples[I];G.pts=h(G.pts-v,d*E)/E,G.dts=h(G.dts-T,d*E)/E}var X=p.samples;return p.samples=[],{samples:X}},x.remuxText=function(p,d){var o=p.samples.length;if(!o)return;for(var E=p.inputTimeScale,v=this._initPTS,T=0;T<o;T++){var I=p.samples[T];I.pts=h(I.pts-v,d*E)/E}p.samples.sort(function(X,J){return X.pts-J.pts});var G=p.samples;return p.samples=[],{samples:G}},L}();function h(L,x){var f;if(x===null)return L;for(x<L?f=-8589934592:f=8589934592;Math.abs(L-x)>4294967296;)L+=f;return L}function w(L){for(var x=0;x<L.length;x++)if(L[x].key)return x;return-1}var g=function(x,f,p,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=p,this.cts=d,this.flags=new m(x)},m=function(x){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=x?2:1,this.isNonSync=x?0:1}},"./src/remux/passthrough-remuxer.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/polyfills/number.ts"),N=D("./src/utils/mp4-tools.ts"),P=D("./src/loader/fragment.ts"),H=D("./src/utils/logger.ts"),F=function(){function b(){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 C=b.prototype;return C.destroy=function(){},C.resetTimeStamp=function(_){this.initPTS=_,this.lastEndDTS=null},C.resetNextTimestamp=function(){this.lastEndDTS=null},C.resetInitSegment=function(_,A,y){this.audioCodec=A,this.videoCodec=y,this.generateInitSegment(_),this.emitInitSegment=!0},C.generateInitSegment=function(_){var A=this.audioCodec,y=this.videoCodec;if(!_||!_.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(N.parseInitSegment)(_);A||(A=O(u.audio,P.ElementaryStreamTypes.AUDIO)),y||(y=O(u.video,P.ElementaryStreamTypes.VIDEO));var a={};u.audio&&u.video?a.audiovideo={container:"video/mp4",codec:A+","+y,initSegment:_,id:"main"}:u.audio?a.audio={container:"audio/mp4",codec:A,initSegment:_,id:"audio"}:u.video?a.video={container:"video/mp4",codec:y,initSegment:_,id:"main"}:H.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},C.remux=function(_,A,y,u,a){var l=this.initPTS,h=this.lastEndDTS,w={audio:void 0,video:void 0,text:u,id3:y,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=a||0);var g=A.samples;if(!g||!g.length)return w;var m={initPTS:void 0,timescale:1},L=this.initData;if((!L||!L.length)&&(this.generateInitSegment(g),L=this.initData),!L||!L.length)return H.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(l)||(this.initPTS=m.initPTS=l=M(L,g,h));var x=Object(N.getDuration)(g,L),f=h,p=x+f;Object(N.offsetStartDTS)(L,g,l),x>0?this.lastEndDTS=p:(H.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!L.audio,o=!!L.video,E="";d&&(E+="audio"),o&&(E+="video");var v={data1:g,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:E,hasAudio:d,hasVideo:o,nb:1,dropped:0};return w.audio=v.type==="audio"?v:void 0,w.video=v.type!=="audio"?v:void 0,w.text=u,w.id3=y,w.initSegment=m,w},b}(),M=function(C,k,_){return Object(N.getStartDTS)(C,k)-_};function O(b,C){var k=b==null?void 0:b.codec;return k&&k.length>4?k:k==="hvc1"?"hvc1.1.c.L120.90":k==="av01"?"av01.0.04M.08":k==="avc1"||C===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=F},"./src/task-loop.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return V});var V=function(){function N(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var P=N.prototype;return P.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},P.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},P.onHandlerDestroyed=function(){},P.hasInterval=function(){return!!this._tickInterval},P.hasNextTick=function(){return!!this._tickTimer},P.setInterval=function(F){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,F),!0)},P.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},P.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},P.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},P.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},P.doTick=function(){},N}()},"./src/types/cmcd.ts":function(ie,$,D){"use strict";D.r($),D.d($,"CMCDVersion",function(){return V}),D.d($,"CMCDObjectType",function(){return N}),D.d($,"CMCDStreamingFormat",function(){return P}),D.d($,"CMCDStreamType",function(){return H});var V=1,N;(function(F){F.MANIFEST="m",F.AUDIO="a",F.VIDEO="v",F.MUXED="av",F.INIT="i",F.CAPTION="c",F.TIMED_TEXT="tt",F.KEY="k",F.OTHER="o"})(N||(N={}));var P;(function(F){F.DASH="d",F.HLS="h",F.SMOOTH="s",F.OTHER="o"})(P||(P={}));var H;(function(F){F.VOD="v",F.LIVE="l"})(H||(H={}))},"./src/types/level.ts":function(ie,$,D){"use strict";D.r($),D.d($,"HlsSkip",function(){return P}),D.d($,"getSkipValue",function(){return H}),D.d($,"HlsUrlParameters",function(){return F}),D.d($,"Level",function(){return M});function V(O,b){for(var C=0;C<b.length;C++){var k=b[C];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(O,k.key,k)}}function N(O,b,C){return b&&V(O.prototype,b),C&&V(O,C),O}var P;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(P||(P={}));function H(O,b){var C=O.canSkipUntil,k=O.canSkipDateRanges,_=O.endSN,A=b!==void 0?b-_:0;return C&&A<C?k?P.v2:P.Yes:P.No}var F=function(){function O(C,k,_){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=C,this.part=k,this.skip=_}var b=O.prototype;return b.addDirectives=function(k){var _=new self.URL(k);return this.msn!==void 0&&_.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&_.searchParams.set("_HLS_part",this.part.toString()),this.skip&&_.searchParams.set("_HLS_skip",this.skip),_.toString()},O}(),M=function(){function O(b){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=[b.url],this.attrs=b.attrs,this.bitrate=b.bitrate,b.details&&(this.details=b.details),this.id=b.id||0,this.name=b.name,this.width=b.width||0,this.height=b.height||0,this.audioCodec=b.audioCodec,this.videoCodec=b.videoCodec,this.unknownCodecs=b.unknownCodecs,this.codecSet=[b.videoCodec,b.audioCodec].filter(function(C){return C}).join(",").replace(/\.[^.,]+/g,"")}return N(O,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(C){var k=C%this.url.length;this._urlId!==k&&(this.details=void 0,this._urlId=k)}}]),O}()},"./src/types/loader.ts":function(ie,$,D){"use strict";D.r($),D.d($,"PlaylistContextType",function(){return V}),D.d($,"PlaylistLevelType",function(){return N});var V;(function(P){P.MANIFEST="manifest",P.LEVEL="level",P.AUDIO_TRACK="audioTrack",P.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var N;(function(P){P.MAIN="main",P.AUDIO="audio",P.SUBTITLE="subtitle"})(N||(N={}))},"./src/types/transmuxer.ts":function(ie,$,D){"use strict";D.r($),D.d($,"ChunkMetadata",function(){return V});var V=function(H,F,M,O,b,C){O===void 0&&(O=0),b===void 0&&(b=-1),C===void 0&&(C=!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=N(),this.buffering={audio:N(),video:N(),audiovideo:N()},this.level=H,this.sn=F,this.id=M,this.size=O,this.part=b,this.partial=C};function N(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ie,$,D){"use strict";D.r($),D.d($,"AttrList",function(){return P});var V=/^(\d+)x(\d+)$/,N=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,P=function(){function H(M){typeof M=="string"&&(M=H.parseAttrList(M));for(var O in M)M.hasOwnProperty(O)&&(this[O]=M[O])}var F=H.prototype;return F.decimalInteger=function(O){var b=parseInt(this[O],10);return b>Number.MAX_SAFE_INTEGER?Infinity:b},F.hexadecimalInteger=function(O){if(this[O]){var b=(this[O]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var C=new Uint8Array(b.length/2),k=0;k<b.length/2;k++)C[k]=parseInt(b.slice(k*2,k*2+2),16);return C}else return null},F.hexadecimalIntegerAsNumber=function(O){var b=parseInt(this[O],16);return b>Number.MAX_SAFE_INTEGER?Infinity:b},F.decimalFloatingPoint=function(O){return parseFloat(this[O])},F.optionalFloat=function(O,b){var C=this[O];return C?parseFloat(C):b},F.enumeratedString=function(O){return this[O]},F.bool=function(O){return this[O]==="YES"},F.decimalResolution=function(O){var b=V.exec(this[O]);return b===null?void 0:{width:parseInt(b[1],10),height:parseInt(b[2],10)}},H.parseAttrList=function(O){var b,C={},k='"';for(N.lastIndex=0;(b=N.exec(O))!==null;){var _=b[2];_.indexOf(k)===0&&_.lastIndexOf(k)===_.length-1&&(_=_.slice(1,-1)),C[b[1]]=_}return C},H}()},"./src/utils/binary-search.ts":function(ie,$,D){"use strict";D.r($);var V={search:function(P,H){for(var F=0,M=P.length-1,O=null,b=null;F<=M;){O=(F+M)/2|0,b=P[O];var C=H(b);if(C>0)F=O+1;else if(C<0)M=O-1;else return b}return null}};$.default=V},"./src/utils/buffer-helper.ts":function(ie,$,D){"use strict";D.r($),D.d($,"BufferHelper",function(){return P});var V=D("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},P=function(){function H(){}return H.isBuffered=function(M,O){try{if(M){for(var b=H.getBuffered(M),C=0;C<b.length;C++)if(O>=b.start(C)&&O<=b.end(C))return!0}}catch(k){}return!1},H.bufferInfo=function(M,O,b){try{if(M){var C=H.getBuffered(M),k=[],_;for(_=0;_<C.length;_++)k.push({start:C.start(_),end:C.end(_)});return this.bufferedInfo(k,O,b)}}catch(A){}return{len:0,start:O,end:O,nextStart:void 0}},H.bufferedInfo=function(M,O,b){O=Math.max(0,O),M.sort(function(m,L){var x=m.start-L.start;return x||L.end-m.end});var C=[];if(b)for(var k=0;k<M.length;k++){var _=C.length;if(_){var A=C[_-1].end;M[k].start-A<b?M[k].end>A&&(C[_-1].end=M[k].end):C.push(M[k])}else C.push(M[k])}else C=M;for(var y=0,u,a=O,l=O,h=0;h<C.length;h++){var w=C[h].start,g=C[h].end;if(O+b>=w&&O<g)a=w,l=g,y=l-O;else if(O+b<w){u=w;break}}return{len:y,start:a||0,end:l||0,nextStart:u}},H.getBuffered=function(M){try{return M.buffered}catch(O){return V.logger.log("failed to get media.buffered",O),N}},H}()},"./src/utils/cea-608-parser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"Row",function(){return l}),D.d($,"CaptionScreen",function(){return h});var V=D("./src/utils/logger.ts"),N={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},P=function(p){var d=p;return N.hasOwnProperty(p)&&(d=N[p]),String.fromCharCode(d)},H=15,F=100,M={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},b={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},C={25:2,26:4,29:6,30:8,31:10,27:13,28:15},k=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],_;(function(f){f[f.ERROR=0]="ERROR",f[f.TEXT=1]="TEXT",f[f.WARNING=2]="WARNING",f[f.INFO=2]="INFO",f[f.DEBUG=3]="DEBUG",f[f.DATA=3]="DATA"})(_||(_={}));var A=function(){function f(){this.time=null,this.verboseLevel=_.ERROR}var p=f.prototype;return p.log=function(o,E){this.verboseLevel>=o&&V.logger.log(this.time+" ["+o+"] "+E)},f}(),y=function(p){for(var d=[],o=0;o<p.length;o++)d.push(p[o].toString(16));return d},u=function(){function f(d,o,E,v,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=o||!1,this.italics=E||!1,this.background=v||"black",this.flash=T||!1}var p=f.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(o){for(var E=["foreground","underline","italics","background","flash"],v=0;v<E.length;v++){var T=E[v];o.hasOwnProperty(T)&&(this[T]=o[T])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},p.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),a=function(){function f(d,o,E,v,T,I){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(o,E,v,T,I)}var p=f.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(o,E){this.uchar=o,this.penState.copy(E)},p.setPenState=function(o){this.penState.copy(o)},p.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},p.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},p.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},f}(),l=function(){function f(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<F;o++)this.chars.push(new a);this.logger=d,this.pos=0,this.currPenState=new u}var p=f.prototype;return p.equals=function(o){for(var E=!0,v=0;v<F;v++)if(!this.chars[v].equals(o.chars[v])){E=!1;break}return E},p.copy=function(o){for(var E=0;E<F;E++)this.chars[E].copy(o.chars[E])},p.isEmpty=function(){for(var o=!0,E=0;E<F;E++)if(!this.chars[E].isEmpty()){o=!1;break}return o},p.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(_.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>F&&(this.logger.log(_.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},p.moveCursor=function(o){var E=this.pos+o;if(o>1)for(var v=this.pos+1;v<E+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(E)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(o){o>=144&&this.backSpace();var E=P(o);if(this.pos>=F){this.logger.log(_.ERROR,"Cannot insert "+o.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(o){var E;for(E=o;E<F;E++)this.chars[E].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var o=[],E=!0,v=0;v<F;v++){var T=this.chars[v].uchar;T!==" "&&(E=!1),o.push(T)}return E?"":o.join("")},p.setPenStyles=function(o){this.currPenState.setStyles(o);var E=this.chars[this.pos];E.setPenState(this.currPenState)},f}(),h=function(){function f(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<H;o++)this.rows.push(new l(d));this.logger=d,this.currRow=H-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=f.prototype;return p.reset=function(){for(var o=0;o<H;o++)this.rows[o].clear();this.currRow=H-1},p.equals=function(o){for(var E=!0,v=0;v<H;v++)if(!this.rows[v].equals(o.rows[v])){E=!1;break}return E},p.copy=function(o){for(var E=0;E<H;E++)this.rows[E].copy(o.rows[E])},p.isEmpty=function(){for(var o=!0,E=0;E<H;E++)if(!this.rows[E].isEmpty()){o=!1;break}return o},p.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},p.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},p.insertChar=function(o){var E=this.rows[this.currRow];E.insertChar(o)},p.setPen=function(o){var E=this.rows[this.currRow];E.setPenStyles(o)},p.moveCursor=function(o){var E=this.rows[this.currRow];E.moveCursor(o)},p.setCursor=function(o){this.logger.log(_.INFO,"setCursor: "+o);var E=this.rows[this.currRow];E.setCursor(o)},p.setPAC=function(o){this.logger.log(_.INFO,"pacData = "+JSON.stringify(o));var E=o.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var v=0;v<H;v++)this.rows[v].clear();var T=this.currRow+1-this.nrRollUpRows,I=this.lastOutputScreen;if(I){var G=I.rows[T].cueStartTime,X=this.logger.time;if(G&&X!==null&&G<X)for(var J=0;J<this.nrRollUpRows;J++)this.rows[E-this.nrRollUpRows+J+1].copy(I.rows[T+J])}}this.currRow=E;var z=this.rows[this.currRow];if(o.indent!==null){var W=o.indent,q=Math.max(W-1,0);z.setCursor(o.indent),o.color=z.chars[q].penState.foreground}var ne={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(ne)},p.setBkgData=function(o){this.logger.log(_.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},p.setRollUpRows=function(o){this.nrRollUpRows=o},p.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(_.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(_.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(o,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(_.INFO,"Rolling up")},p.getDisplayText=function(o){o=o||!1;for(var E=[],v="",T=-1,I=0;I<H;I++){var G=this.rows[I].getTextString();G&&(T=I+1,o?E.push("Row "+T+": '"+G+"'"):E.push(G.trim()))}return E.length>0&&(o?v="["+E.join(" | ")+"]":v=E.join(`
|
|
`)),v},p.getTextAndFormat=function(){return this.rows},f}(),w=function(){function f(d,o,E){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=d,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new h(E),this.nonDisplayedMemory=new h(E),this.lastOutputScreen=new h(E),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=E}var p=f.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(o){this.outputFilter=o},p.setPAC=function(o){this.writeScreen.setPAC(o)},p.setBkgData=function(o){this.writeScreen.setBkgData(o)},p.setMode=function(o){if(o===this.mode)return;this.mode=o,this.logger.log(_.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o},p.insertChars=function(o){for(var E=0;E<o.length;E++)this.writeScreen.insertChar(o[E]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(_.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(_.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},p.ccRCL=function(){this.logger.log(_.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){if(this.logger.log(_.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(_.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.ccRU=function(o){this.logger.log(_.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},p.ccFON=function(){this.logger.log(_.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(_.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(_.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(_.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(_.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(_.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(_.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.ccEOC=function(){if(this.logger.log(_.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(_.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(o){this.logger.log(_.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},p.ccMIDROW=function(o){var E={flash:!1};if(E.underline=o%2===1,E.italics=o>=46,E.italics)E.foreground="white";else{var v=Math.floor(o/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=T[v]}this.logger.log(_.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},p.outputDataUpdate=function(o){o===void 0&&(o=!1);var E=this.logger.time;if(E===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=E:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,E,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},f}(),g=function(){function f(d,o,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new A;this.channels=[null,new w(d,o,v),new w(d+1,E,v)],this.cmdHistory=x(),this.logger=v}var p=f.prototype;return p.getHandler=function(o){return this.channels[o].getHandler()},p.setHandler=function(o,E){this.channels[o].setHandler(E)},p.addData=function(o,E){var v,T,I,G=!1;this.logger.time=o;for(var X=0;X<E.length;X+=2){if(T=E[X]&127,I=E[X+1]&127,T===0&&I===0)continue;if(this.logger.log(_.DATA,"["+y([E[X],E[X+1]])+"] -> ("+y([T,I])+")"),v=this.parseCmd(T,I),v||(v=this.parseMidrow(T,I)),v||(v=this.parsePAC(T,I)),v||(v=this.parseBackgroundAttributes(T,I)),!v&&(G=this.parseChars(T,I),G)){var J=this.currentChannel;if(J&&J>0){var z=this.channels[J];z.insertChars(G)}else this.logger.log(_.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!G&&this.logger.log(_.WARNING,"Couldn't parse cleaned data "+y([T,I])+" orig: "+y([E[X],E[X+1]]))}},p.parseCmd=function(o,E){var v=this.cmdHistory,T=(o===20||o===28||o===21||o===29)&&E>=32&&E<=47,I=(o===23||o===31)&&E>=33&&E<=35;if(!(T||I))return!1;if(L(o,E,v))return m(null,null,v),this.logger.log(_.DEBUG,"Repeated command ("+y([o,E])+") is dropped"),!0;var G=o===20||o===21||o===23?1:2,X=this.channels[G];return o===20||o===21||o===28||o===29?E===32?X.ccRCL():E===33?X.ccBS():E===34?X.ccAOF():E===35?X.ccAON():E===36?X.ccDER():E===37?X.ccRU(2):E===38?X.ccRU(3):E===39?X.ccRU(4):E===40?X.ccFON():E===41?X.ccRDC():E===42?X.ccTR():E===43?X.ccRTD():E===44?X.ccEDM():E===45?X.ccCR():E===46?X.ccENM():E===47&&X.ccEOC():X.ccTO(E-32),m(o,E,v),this.currentChannel=G,!0},p.parseMidrow=function(o,E){var v=0;if((o===17||o===25)&&E>=32&&E<=47){if(o===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(_.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[v];return T?(T.ccMIDROW(E),this.logger.log(_.DEBUG,"MIDROW ("+y([o,E])+")"),!0):!1}return!1},p.parsePAC=function(o,E){var v,T=this.cmdHistory,I=(o>=17&&o<=23||o>=25&&o<=31)&&E>=64&&E<=127,G=(o===16||o===24)&&E>=64&&E<=95;if(!(I||G))return!1;if(L(o,E,T))return m(null,null,T),!0;var X=o<=23?1:2;E>=64&&E<=95?v=X===1?M[o]:b[o]:v=X===1?O[o]:C[o];var J=this.channels[X];return J?(J.setPAC(this.interpretPAC(v,E)),m(o,E,T),this.currentChannel=X,!0):!1},p.interpretPAC=function(o,E){var v,T={color:null,italics:!1,indent:null,underline:!1,row:o};return E>95?v=E-96:v=E-64,T.underline=(v&1)===1,v<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((v-16)/2)*4,T},p.parseChars=function(o,E){var v,T=null,I=null;if(o>=25?(v=2,I=o-8):(v=1,I=o),I>=17&&I<=19){var G;I===17?G=E+80:I===18?G=E+112:G=E+144,this.logger.log(_.INFO,"Special char '"+P(G)+"' in channel "+v),T=[G]}else o>=32&&o<=127&&(T=E===0?[o]:[o,E]);if(T){var X=y(T);this.logger.log(_.DEBUG,"Char codes = "+X.join(",")),m(o,E,this.cmdHistory)}return T},p.parseBackgroundAttributes=function(o,E){var v=(o===16||o===24)&&E>=32&&E<=47,T=(o===23||o===31)&&E>=45&&E<=47;if(!(v||T))return!1;var I,G={};o===16||o===24?(I=Math.floor((E-32)/2),G.background=k[I],E%2===1&&(G.background=G.background+"_semi")):E===45?G.background="transparent":(G.foreground="black",E===47&&(G.underline=!0));var X=o<=23?1:2,J=this.channels[X];return J.setBkgData(G),m(o,E,this.cmdHistory),!0},p.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var E=this.channels[o];E&&E.reset()}this.cmdHistory=x()},p.cueSplitAtTime=function(o){for(var E=0;E<this.channels.length;E++){var v=this.channels[E];v&&v.cueSplitAtTime(o)}},f}();function m(f,p,d){d.a=f,d.b=p}function L(f,p,d){return d.a===f&&d.b===p}function x(){return{a:null,b:null}}$.default=g},"./src/utils/codecs.ts":function(ie,$,D){"use strict";D.r($),D.d($,"isCodecType",function(){return N}),D.d($,"isCodecSupportedInMp4",function(){return P});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 N(H,F){var M=V[F];return!!M&&M[H.slice(0,4)]===!0}function P(H,F){return MediaSource.isTypeSupported((F||"video")+'/mp4;codecs="'+H+'"')}},"./src/utils/cues.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/utils/vttparser.ts"),N=D("./src/utils/webvtt-parser.ts"),P=D("./src/utils/texttrack-utils.ts"),H=/\s/,F={newCue:function(O,b,C,k){for(var _=[],A,y,u,a,l,h=self.VTTCue||self.TextTrackCue,w=0;w<k.rows.length;w++)if(A=k.rows[w],u=!0,a=0,l="",!A.isEmpty()){for(var g=0;g<A.chars.length;g++)H.test(A.chars[g].uchar)&&u?a++:(l+=A.chars[g].uchar,u=!1);A.cueStartTime=b,b===C&&(C+=1e-4),a>=16?a--:a++;var m=Object(V.fixLineBreaks)(l.trim()),L=Object(N.generateCueId)(b,C,m);(!O||!O.cues||!O.cues.getCueById(L))&&(y=new h(b,C,m),y.id=L,y.line=w+1,y.align="left",y.position=10+Math.min(80,Math.floor(a*8/32)*10),_.push(y))}return O&&_.length&&(_.sort(function(x,f){return x.line==="auto"||f.line==="auto"?0:x.line>8&&f.line>8?f.line-x.line:x.line-f.line}),_.forEach(function(x){return Object(P.addCueToTrack)(O,x)})),_}};$.default=F},"./src/utils/discontinuities.ts":function(ie,$,D){"use strict";D.r($),D.d($,"findFirstFragWithCC",function(){return H}),D.d($,"shouldAlignOnDiscontinuities",function(){return F}),D.d($,"findDiscontinuousReferenceFrag",function(){return M}),D.d($,"adjustSlidingStart",function(){return b}),D.d($,"alignStream",function(){return C}),D.d($,"alignPDT",function(){return _}),D.d($,"alignFragmentByPDTDelta",function(){return A}),D.d($,"alignMediaPlaylistByPDT",function(){return y});var V=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts"),P=D("./src/controller/level-helper.ts");function H(u,a){for(var l=null,h=0,w=u.length;h<w;h++){var g=u[h];if(g&&g.cc===a){l=g;break}}return l}function F(u,a,l){return!!(a.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function M(u,a){var l=u.fragments,h=a.fragments;if(!h.length||!l.length){N.logger.log("No fragments to align");return}var w=H(l,h[0].cc);if(!w||w&&!w.startPTS){N.logger.log("No frag in previous level to align on");return}return w}function O(u,a){if(u){var l=u.start+a;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function b(u,a){for(var l=a.fragments,h=0,w=l.length;h<w;h++)O(l[h],u);a.fragmentHint&&O(a.fragmentHint,u),a.alignedSliding=!0}function C(u,a,l){if(!a)return;k(u,l,a),!l.alignedSliding&&a.details&&_(l,a.details),!l.alignedSliding&&a.details&&!l.skippedSegments&&Object(P.adjustSliding)(a.details,l)}function k(u,a,l){if(F(u,l,a)){var h=M(l.details,a);h&&Object(V.isFiniteNumber)(h.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),b(h.start,a))}}function _(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=u.fragments[0].programDateTime,w=(h-l)/1e3+a.fragments[0].start;w&&Object(V.isFiniteNumber)(w)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+w.toFixed(3)+" "+u.url+" "),b(w,u))}function A(u,a){var l=u.programDateTime;if(!l)return;var h=(l-a)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function y(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=a.fragments[0].start,w=l-h*1e3;u.fragments.forEach(function(g){A(g,w)}),u.fragmentHint&&A(u.fragmentHint,w),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/utils/ewma.ts"),N=function(){function P(F,M,O){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=O,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(F),this.fast_=new V.default(M)}var H=P.prototype;return H.update=function(M,O){var b=this.slow_,C=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new V.default(M,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==O&&(this.fast_=new V.default(O,C.getEstimate(),C.getTotalWeight()))},H.sample=function(M,O){M=Math.max(M,this.minDelayMs_);var b=8*O,C=M/1e3,k=b/C;this.fast_.sample(C,k),this.slow_.sample(C,k)},H.canEstimate=function(){var M=this.fast_;return M&&M.getTotalWeight()>=this.minWeight_},H.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},H.destroy=function(){},P}();$.default=N},"./src/utils/ewma.ts":function(ie,$,D){"use strict";D.r($);var V=function(){function N(H,F,M){F===void 0&&(F=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=H,this.alpha_=H?Math.exp(Math.log(.5)/H):0,this.estimate_=F,this.totalWeight_=M}var P=N.prototype;return P.sample=function(F,M){var O=Math.pow(this.alpha_,F);this.estimate_=M*(1-O)+O*this.estimate_,this.totalWeight_+=F},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var F=1-Math.pow(this.alpha_,this.totalWeight_);if(F)return this.estimate_/F}return this.estimate_},N}();$.default=V},"./src/utils/fetch-loader.ts":function(ie,$,D){"use strict";D.r($),D.d($,"fetchSupported",function(){return A});var V=D("./src/polyfills/number.ts"),N=D("./src/loader/load-stats.ts"),P=D("./src/demux/chunk-cache.ts");function H(h,w){h.prototype=Object.create(w.prototype),h.prototype.constructor=h,C(h,w)}function F(h){var w=typeof Map=="function"?new Map:void 0;return F=function(m){if(m===null||!b(m))return m;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(typeof w!="undefined"){if(w.has(m))return w.get(m);w.set(m,L)}function L(){return M(m,arguments,k(this).constructor)}return L.prototype=Object.create(m.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),C(L,m)},F(h)}function M(h,w,g){return O()?M=Reflect.construct:M=function(L,x,f){var p=[null];p.push.apply(p,x);var d=Function.bind.apply(L,p),o=new d;return f&&C(o,f.prototype),o},M.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function b(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function C(h,w){return C=Object.setPrototypeOf||function(m,L){return m.__proto__=L,m},C(h,w)}function k(h){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)},k(h)}function _(){return _=Object.assign||function(h){for(var w=1;w<arguments.length;w++){var g=arguments[w];for(var m in g)Object.prototype.hasOwnProperty.call(g,m)&&(h[m]=g[m])}return h},_.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var y=function(){function h(g){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=g.fetchSetup||a,this.controller=new self.AbortController,this.stats=new N.LoadStats}var w=h.prototype;return w.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},w.abortInternal=function(){var m=this.response;(!m||!m.ok)&&(this.stats.aborted=!0,this.controller.abort())},w.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},w.load=function(m,L,x){var f=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var d=u(m,this.controller.signal),o=x.onProgress,E=m.responseType==="arraybuffer",v=E?"byteLength":"length";this.context=m,this.config=L,this.callbacks=x,this.request=this.fetchSetup(m,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),x.onTimeout(p,m,f.response)},L.timeout),self.fetch(this.request).then(function(T){if(f.response=f.loader=T,!T.ok){var I=T.status,G=T.statusText;throw new l(G||"fetch, bad network response",I,T)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(T.headers.get("Content-Length")||"0"),o&&Object(V.isFiniteNumber)(L.highWaterMark)?f.loadProgressively(T,p,m,L.highWaterMark,o):E?T.arrayBuffer():T.text()}).then(function(T){var I=f.response;self.clearTimeout(f.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=T[v];var G={url:I.url,data:T};o&&!Object(V.isFiniteNumber)(L.highWaterMark)&&o(p,m,T,I),x.onSuccess(G,p,m,I)}).catch(function(T){if(self.clearTimeout(f.requestTimeout),p.aborted)return;var I=T.code||0;x.onError({code:I,text:T.message},m,T.details)})},w.getCacheAge=function(){var m=null;if(this.response){var L=this.response.headers.get("age");m=L?parseFloat(L):null}return m},w.loadProgressively=function(m,L,x,f,p){f===void 0&&(f=0);var d=new P.default,o=m.body.getReader(),E=function v(){return o.read().then(function(T){if(T.done)return d.dataLength&&p(L,x,d.flush(),m),Promise.resolve(new ArrayBuffer(0));var I=T.value,G=I.length;return L.loaded+=G,G<f||d.dataLength?(d.push(I),d.dataLength>=f&&p(L,x,d.flush(),m)):p(L,x,I,m),v()}).catch(function(){return Promise.reject()})};return E()},h}();function u(h,w){var g={method:"GET",mode:"cors",credentials:"same-origin",signal:w,headers:new self.Headers(_({},h.headers))};return h.rangeEnd&&g.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),g}function a(h,w){return new self.Request(h.url,w)}var l=function(h){H(w,h);function w(g,m,L){var x;return x=h.call(this,g)||this,x.code=void 0,x.details=void 0,x.code=m,x.details=L,x}return w}(F(Error));$.default=y},"./src/utils/imsc1-ttml-parser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"IMSC1_CODEC",function(){return b}),D.d($,"parseIMSC1",function(){return A});var V=D("./src/utils/mp4-tools.ts"),N=D("./src/utils/vttparser.ts"),P=D("./src/utils/vttcue.ts"),H=D("./src/demux/id3.ts"),F=D("./src/utils/timescale-conversion.ts"),M=D("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(f){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var o in d)Object.prototype.hasOwnProperty.call(d,o)&&(f[o]=d[o])}return f},O.apply(this,arguments)}var b="stpp.ttml.im1t",C=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,k=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_={left:"start",center:"center",right:"end",start:"start",end:"end"};function A(f,p,d,o,E){var v=Object(V.findBox)(new Uint8Array(f),["mdat"]);if(v.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var T=v[0],I=Object(H.utf8ArrayToStr)(new Uint8Array(f,T.start,T.end-T.start)),G=Object(F.toTimescaleFromScale)(p,1,d);try{o(y(I,G))}catch(X){E(X)}}function y(f,p){var d=new DOMParser,o=d.parseFromString(f,"text/xml"),E=o.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(v).reduce(function(z,W){return z[W]=E.getAttribute("ttp:"+W)||v[W],z},{}),I=E.getAttribute("xml:space")!=="preserve",G=a(u(E,"styling","style")),X=a(u(E,"layout","region")),J=u(E,"body","[begin]");return[].map.call(J,function(z){var W=l(z,I);if(!W||!z.hasAttribute("begin"))return null;var q=m(z.getAttribute("begin"),T),ne=m(z.getAttribute("dur"),T),ce=m(z.getAttribute("end"),T);if(q===null)throw g(z);if(ce===null){if(ne===null)throw g(z);ce=q+ne}var ve=new P.default(q-p,ce-p,W);ve.id=Object(M.generateCueId)(ve.startTime,ve.endTime,ve.text);var De=X[z.getAttribute("region")],xe=G[z.getAttribute("style")];ve.position=10,ve.size=80;var Ce=h(De,xe),Te=Ce.textAlign;if(Te){var Ee=_[Te];Ee&&(ve.lineAlign=Ee),ve.align=Te}return O(ve,Ce),ve}).filter(function(z){return z!==null})}function u(f,p,d){var o=f.getElementsByTagName(p)[0];return o?[].slice.call(o.querySelectorAll(d)):[]}function a(f){return f.reduce(function(p,d){var o=d.getAttribute("xml:id");return o&&(p[o]=d),p},{})}function l(f,p){return[].slice.call(f.childNodes).reduce(function(d,o,E){var v;return o.nodeName==="br"&&E?d+`
|
|
`:(v=o.childNodes)!==null&&v!==void 0&&v.length?l(o,p):p?d+o.textContent.trim().replace(/\s+/g," "):d+o.textContent},"")}function h(f,p){var d="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(E,v){var T=w(p,d,v)||w(f,d,v);return T&&(E[v]=T),E},{})}function w(f,p,d){return f.hasAttributeNS(p,d)?f.getAttributeNS(p,d):null}function g(f){return new Error("Could not parse ttml timestamp "+f)}function m(f,p){if(!f)return null;var d=Object(N.parseTimeStamp)(f);return d===null&&(C.test(f)?d=L(f,p):k.test(f)&&(d=x(f,p))),d}function L(f,p){var d=C.exec(f),o=(d[4]|0)+(d[5]|0)/p.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+o/p.frameRate}function x(f,p){var d=k.exec(f),o=Number(d[1]),E=d[2];switch(E){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/p.frameRate;case"t":return o/p.tickRate}return o}},"./src/utils/logger.ts":function(ie,$,D){"use strict";D.r($),D.d($,"enableLogs",function(){return M}),D.d($,"logger",function(){return O});var V=function(){},N={trace:V,debug:V,log:V,warn:V,info:V,error:V},P=N;function H(b){var C=self.console[b];return C?C.bind(self.console,"["+b+"] >"):V}function F(b){for(var C=arguments.length,k=new Array(C>1?C-1:0),_=1;_<C;_++)k[_-1]=arguments[_];k.forEach(function(A){P[A]=b[A]?b[A].bind(b):H(A)})}function M(b){if(self.console&&b===!0||typeof b=="object"){F(b,"debug","log","info","warn","error");try{P.log()}catch(C){P=N}}else P=N}var O=P},"./src/utils/mediakeys-helper.ts":function(ie,$,D){"use strict";D.r($),D.d($,"KeySystems",function(){return V}),D.d($,"requestMediaKeySystemAccess",function(){return N});var V;(function(P){P.WIDEVINE="com.widevine.alpha",P.PLAYREADY="com.microsoft.playready"})(V||(V={}));var N=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ie,$,D){"use strict";D.r($),D.d($,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ie,$,D){"use strict";D.r($),D.d($,"bin2str",function(){return F}),D.d($,"readUint16",function(){return M}),D.d($,"readUint32",function(){return O}),D.d($,"writeUint32",function(){return b}),D.d($,"findBox",function(){return C}),D.d($,"parseSegmentIndex",function(){return k}),D.d($,"parseInitSegment",function(){return _}),D.d($,"getStartDTS",function(){return A}),D.d($,"getDuration",function(){return y}),D.d($,"computeRawDurationFromSamples",function(){return u}),D.d($,"offsetStartDTS",function(){return a}),D.d($,"segmentValidRange",function(){return l}),D.d($,"appendUint8Array",function(){return h});var V=D("./src/utils/typed-array.ts"),N=D("./src/loader/fragment.ts"),P=Math.pow(2,32)-1,H=[].push;function F(w){return String.fromCharCode.apply(null,w)}function M(w,g){"data"in w&&(g+=w.start,w=w.data);var m=w[g]<<8|w[g+1];return m<0?65536+m:m}function O(w,g){"data"in w&&(g+=w.start,w=w.data);var m=w[g]<<24|w[g+1]<<16|w[g+2]<<8|w[g+3];return m<0?4294967296+m:m}function b(w,g,m){"data"in w&&(g+=w.start,w=w.data),w[g]=m>>24,w[g+1]=m>>16&255,w[g+2]=m>>8&255,w[g+3]=m&255}function C(w,g){var m=[];if(!g.length)return m;var L,x,f;"data"in w?(L=w.data,x=w.start,f=w.end):(L=w,x=0,f=L.byteLength);for(var p=x;p<f;){var d=O(L,p),o=F(L.subarray(p+4,p+8)),E=d>1?p+d:f;if(o===g[0])if(g.length===1)m.push({data:L,start:p+8,end:E});else{var v=C({data:L,start:p+8,end:E},g.slice(1));v.length&&H.apply(m,v)}p=E}return m}function k(w){var g=C(w,["moov"]),m=g[0],L=m?m.end:null,x=C(w,["sidx"]);if(!x||!x[0])return null;var f=[],p=x[0],d=p.data[0],o=d===0?8:16,E=O(p,o);o+=4;var v=0,T=0;d===0?o+=8:o+=16,o+=2;var I=p.end+T,G=M(p,o);o+=2;for(var X=0;X<G;X++){var J=o,z=O(p,J);J+=4;var W=z&2147483647,q=(z&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ne=O(p,J);J+=4,f.push({referenceSize:W,subsegmentDuration:ne,info:{duration:ne/E,start:I,end:I+W-1}}),I+=W,J+=4,o=J}return{earliestPresentationTime:v,timescale:E,version:d,referencesCount:G,references:f,moovEndOffset:L}}function _(w){for(var g=[],m=C(w,["moov","trak"]),L=0;L<m.length;L++){var x=m[L],f=C(x,["tkhd"])[0];if(f){var p=f.data[f.start],d=p===0?12:20,o=O(f,d),E=C(x,["mdia","mdhd"])[0];if(E){p=E.data[E.start],d=p===0?12:20;var v=O(E,d),T=C(x,["mdia","hdlr"])[0];if(T){var I=F(T.data.subarray(T.start+8,T.start+12)),G={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[I];if(G){var X=C(x,["mdia","minf","stbl","stsd"])[0],J=void 0;X&&(J=F(X.data.subarray(X.start+12,X.start+16))),g[o]={timescale:v,type:G},g[G]={timescale:v,id:o,codec:J}}}}}}var z=C(w,["moov","mvex","trex"]);return z.forEach(function(W){var q=O(W,4),ne=g[q];ne&&(ne.default={duration:O(W,12),flags:O(W,20)})}),g}function A(w,g){return C(g,["moof","traf"]).reduce(function(m,L){var x=C(L,["tfdt"])[0],f=x.data[x.start],p=C(L,["tfhd"]).reduce(function(d,o){var E=O(o,4),v=w[E];if(v){var T=O(x,4);f===1&&(T*=Math.pow(2,32),T+=O(x,8));var I=v.timescale||9e4,G=T/I;if(isFinite(G)&&(d===null||G<d))return G}return d},null);return p!==null&&isFinite(p)&&(m===null||p<m)?p:m},null)||0}function y(w,g){for(var m=0,L=0,x=0,f=C(w,["moof","traf"]),p=0;p<f.length;p++){var d=f[p],o=C(d,["tfhd"])[0],E=O(o,4),v=g[E];if(!v)continue;var T=v.default,I=O(o,0)|(T==null?void 0:T.flags),G=T==null?void 0:T.duration;I&8&&(I&2?G=O(o,12):G=O(o,8));for(var X=v.timescale||9e4,J=C(d,["trun"]),z=0;z<J.length;z++){if(G){var W=O(J[z],4);m=G*W}else m=u(J[z]);v.type===N.ElementaryStreamTypes.VIDEO?L+=m/X:v.type===N.ElementaryStreamTypes.AUDIO&&(x+=m/X)}}if(L===0&&x===0){var q=k(w);if(q!=null&&q.references)return q.references.reduce(function(ne,ce){return ne+ce.info.duration||0},0)}return L||x}function u(w){var g=O(w,0),m=8;g&1&&(m+=4),g&4&&(m+=4);for(var L=0,x=O(w,4),f=0;f<x;f++){if(g&256){var p=O(w,m);L+=p,m+=4}g&512&&(m+=4),g&1024&&(m+=4),g&2048&&(m+=4)}return L}function a(w,g,m){C(g,["moof","traf"]).forEach(function(L){C(L,["tfhd"]).forEach(function(x){var f=O(x,4),p=w[f];if(!p)return;var d=p.timescale||9e4;C(L,["tfdt"]).forEach(function(o){var E=o.data[o.start],v=O(o,4);if(E===0)b(o,4,v-m*d);else{v*=Math.pow(2,32),v+=O(o,8),v-=m*d,v=Math.max(v,0);var T=Math.floor(v/(P+1)),I=Math.floor(v%(P+1));b(o,4,T),b(o,8,I)}})})})}function l(w){var g={valid:null,remainder:null},m=C(w,["moof"]);if(m){if(m.length<2)return g.remainder=w,g}else return g;var L=m[m.length-1];return g.valid=Object(V.sliceUint8)(w,0,L.start-8),g.remainder=Object(V.sliceUint8)(w,L.start-8),g}function h(w,g){var m=new Uint8Array(w.length+g.length);return m.set(w),m.set(g,w.length),m}},"./src/utils/output-filter.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return V});var V=function(){function N(H,F){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=H,this.trackName=F}var P=N.prototype;return P.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},P.newCue=function(F,M,O){(this.startTime===null||this.startTime>F)&&(this.startTime=F),this.endTime=M,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},P.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(ie,$,D){"use strict";D.r($),D.d($,"sendAddTrackEvent",function(){return N}),D.d($,"addCueToTrack",function(){return P}),D.d($,"clearCurrentCues",function(){return H}),D.d($,"removeCuesInRange",function(){return F}),D.d($,"getCuesInRange",function(){return O});var V=D("./src/utils/logger.ts");function N(b,C){var k;try{k=new Event("addtrack")}catch(_){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=b,C.dispatchEvent(k)}function P(b,C){var k=b.mode;if(k==="disabled"&&(b.mode="hidden"),b.cues&&!b.cues.getCueById(C.id))try{if(b.addCue(C),!b.cues.getCueById(C.id))throw new Error("addCue is failed for: "+C)}catch(A){V.logger.debug("[texttrack-utils]: "+A);var _=new self.TextTrackCue(C.startTime,C.endTime,C.text);_.id=C.id,b.addCue(_)}k==="disabled"&&(b.mode=k)}function H(b){var C=b.mode;if(C==="disabled"&&(b.mode="hidden"),b.cues)for(var k=b.cues.length;k--;)b.removeCue(b.cues[k]);C==="disabled"&&(b.mode=C)}function F(b,C,k){var _=b.mode;if(_==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var A=O(b.cues,C,k),y=0;y<A.length;y++)b.removeCue(A[y]);_==="disabled"&&(b.mode=_)}function M(b,C){if(C<b[0].startTime)return 0;var k=b.length-1;if(C>b[k].endTime)return-1;for(var _=0,A=k;_<=A;){var y=Math.floor((A+_)/2);if(C<b[y].startTime)A=y-1;else if(C>b[y].startTime&&_<k)_=y+1;else return y}return b[_].startTime-C<C-b[A].startTime?_:A}function O(b,C,k){var _=[],A=M(b,C);if(A>-1)for(var y=A,u=b.length;y<u;y++){var a=b[y];if(a.startTime>=C&&a.endTime<=k)_.push(a);else if(a.startTime>k)return _}return _}},"./src/utils/time-ranges.ts":function(ie,$,D){"use strict";D.r($);var V={toString:function(P){for(var H="",F=P.length,M=0;M<F;M++)H+="["+P.start(M).toFixed(3)+","+P.end(M).toFixed(3)+"]";return H}};$.default=V},"./src/utils/timescale-conversion.ts":function(ie,$,D){"use strict";D.r($),D.d($,"toTimescaleFromBase",function(){return N}),D.d($,"toTimescaleFromScale",function(){return P}),D.d($,"toMsFromMpegTsClock",function(){return H}),D.d($,"toMpegTsClockFromTimescale",function(){return F});var V=9e4;function N(M,O,b,C){b===void 0&&(b=1),C===void 0&&(C=!1);var k=M*O*b;return C?Math.round(k):k}function P(M,O,b,C){return b===void 0&&(b=1),C===void 0&&(C=!1),N(M,O,1/b,C)}function H(M,O){return O===void 0&&(O=!1),N(M,1e3,1/V,O)}function F(M,O){return O===void 0&&(O=1),N(M,V,1/O)}},"./src/utils/typed-array.ts":function(ie,$,D){"use strict";D.r($),D.d($,"sliceUint8",function(){return V});function V(N,P,H){return Uint8Array.prototype.slice?N.slice(P,H):new Uint8Array(Array.prototype.slice.call(N,P,H))}},"./src/utils/vttcue.ts":function(ie,$,D){"use strict";D.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],N=["start","middle","end","left","right"];function P(b,C){if(typeof C!="string")return!1;if(!Array.isArray(b))return!1;var k=C.toLowerCase();return~b.indexOf(k)?k:!1}function H(b){return P(V,b)}function F(b){return P(N,b)}function M(b){for(var C=arguments.length,k=new Array(C>1?C-1:0),_=1;_<C;_++)k[_-1]=arguments[_];for(var A=1;A<arguments.length;A++){var y=arguments[A];for(var u in y)b[u]=y[u]}return b}function O(b,C,k){var _=this,A={enumerable:!0};_.hasBeenReset=!1;var y="",u=!1,a=b,l=C,h=k,w=null,g="",m=!0,L="auto",x="start",f=50,p="middle",d=50,o="middle";Object.defineProperty(_,"id",M({},A,{get:function(){return y},set:function(v){y=""+v}})),Object.defineProperty(_,"pauseOnExit",M({},A,{get:function(){return u},set:function(v){u=!!v}})),Object.defineProperty(_,"startTime",M({},A,{get:function(){return a},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");a=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",M({},A,{get:function(){return l},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",M({},A,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",M({},A,{get:function(){return w},set:function(v){w=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",M({},A,{get:function(){return g},set:function(v){var T=H(v);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");g=T,this.hasBeenReset=!0}})),Object.defineProperty(_,"snapToLines",M({},A,{get:function(){return m},set:function(v){m=!!v,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",M({},A,{get:function(){return L},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",M({},A,{get:function(){return x},set:function(v){var T=F(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");x=T,this.hasBeenReset=!0}})),Object.defineProperty(_,"position",M({},A,{get:function(){return f},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");f=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",M({},A,{get:function(){return p},set:function(v){var T=F(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");p=T,this.hasBeenReset=!0}})),Object.defineProperty(_,"size",M({},A,{get:function(){return d},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");d=v,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",M({},A,{get:function(){return o},set:function(v){var T=F(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");o=T,this.hasBeenReset=!0}})),_.displayState=void 0}return O.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"parseTimeStamp",function(){return P}),D.d($,"fixLineBreaks",function(){return C}),D.d($,"VTTParser",function(){return k});var V=D("./src/utils/vttcue.ts"),N=function(){function _(){}var A=_.prototype;return A.decode=function(u,a){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},_}();function P(_){function A(u,a,l,h){return(u|0)*3600+(a|0)*60+(l|0)+parseFloat(h||0)}var y=_.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?A(y[2],y[3],0,y[4]):A(y[1],y[2],y[3],y[4]):null}var H=function(){function _(){this.values=Object.create(null)}var A=_.prototype;return A.set=function(u,a){!this.get(u)&&a!==""&&(this.values[u]=a)},A.get=function(u,a,l){return l?this.has(u)?this.values[u]:a[l]:this.has(u)?this.values[u]:a},A.has=function(u){return u in this.values},A.alt=function(u,a,l){for(var h=0;h<l.length;++h)if(a===l[h]){this.set(u,a);break}},A.integer=function(u,a){/^-?\d+$/.test(a)&&this.set(u,parseInt(a,10))},A.percent=function(u,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var l=parseFloat(a);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},_}();function F(_,A,y,u){var a=u?_.split(u):[_];for(var l in a){if(typeof a[l]!="string")continue;var h=a[l].split(y);if(h.length!==2)continue;var w=h[0],g=h[1];A(w,g)}}var M=new V.default(0,0,""),O=M.align==="middle"?"middle":"center";function b(_,A,y){var u=_;function a(){var w=P(_);if(w===null)throw new Error("Malformed timestamp: "+u);return _=_.replace(/^[^\sa-zA-Z-]+/,""),w}function l(w,g){var m=new H;F(w,function(f,p){var d;switch(f){case"region":for(var o=y.length-1;o>=0;o--)if(y[o].id===p){m.set(f,y[o].region);break}break;case"vertical":m.alt(f,p,["rl","lr"]);break;case"line":d=p.split(","),m.integer(f,d[0]),m.percent(f,d[0])&&m.set("snapToLines",!1),m.alt(f,d[0],["auto"]),d.length===2&&m.alt("lineAlign",d[1],["start",O,"end"]);break;case"position":d=p.split(","),m.percent(f,d[0]),d.length===2&&m.alt("positionAlign",d[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":m.percent(f,p);break;case"align":m.alt(f,p,["start",O,"end","left","right"]);break}},/:/,/\s/),g.region=m.get("region",null),g.vertical=m.get("vertical","");var L=m.get("line","auto");L==="auto"&&M.line===-1&&(L=-1),g.line=L,g.lineAlign=m.get("lineAlign","start"),g.snapToLines=m.get("snapToLines",!0),g.size=m.get("size",100),g.align=m.get("align",O);var x=m.get("position","auto");x==="auto"&&M.position===50&&(x=g.align==="start"||g.align==="left"?0:g.align==="end"||g.align==="right"?100:50),g.position=x}function h(){_=_.replace(/^\s+/,"")}if(h(),A.startTime=a(),h(),_.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);_=_.substr(3),h(),A.endTime=a(),h(),l(_,A)}function C(_){return _.replace(/<br(?: \/)?>/gi,`
|
|
`)}var k=function(){function _(){this.state="INITIAL",this.buffer="",this.decoder=new N,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=_.prototype;return A.parse=function(u){var a=this;u&&(a.buffer+=a.decoder.decode(u,{stream:!0}));function l(){var x=a.buffer,f=0;for(x=C(x);f<x.length&&x[f]!=="\r"&&x[f]!==`
|
|
`;)++f;var p=x.substr(0,f);return x[f]==="\r"&&++f,x[f]===`
|
|
`&&++f,a.buffer=x.substr(f),p}function h(x){F(x,function(f,p){},/:/)}try{var w="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;w=l();var g=w.match(/^()?WEBVTT([ \t].*)?$/);if(!g||!g[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var m=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;m?m=!1:w=l();switch(a.state){case"HEADER":/:/.test(w)?h(w):w||(a.state="ID");continue;case"NOTE":w||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(w)){a.state="NOTE";break}if(!w)continue;if(a.cue=new V.default(0,0,""),a.state="CUE",w.indexOf("-->")===-1){a.cue.id=w;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{b(w,a.cue,a.regionList)}catch(x){a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var L=w.indexOf("-->")!==-1;if(!w||L&&(m=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
|
|
`),a.cue.text+=w}continue;case"BADCUE":w||(a.state="ID")}}}catch(x){a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},A.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
|
|
|
|
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){u.onparsingerror&&u.onparsingerror(a)}return u.onflush&&u.onflush(),this},_}()},"./src/utils/webvtt-parser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"generateCueId",function(){return k}),D.d($,"parseWebVTT",function(){return A});var V=D("./src/polyfills/number.ts"),N=D("./src/utils/vttparser.ts"),P=D("./src/demux/id3.ts"),H=D("./src/utils/timescale-conversion.ts"),F=D("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,O=function(u,a,l){return l===void 0&&(l=0),u.substr(l,a.length)===a},b=function(u){var a=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),w=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(a)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(w))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return a+=1e3*l,a+=60*1e3*h,a+=60*60*1e3*w,a},C=function(u){for(var a=5381,l=u.length;l;)a=a*33^u.charCodeAt(--l);return(a>>>0).toString()};function k(y,u,a){return C(y.toString())+C(u.toString())+C(a)}var _=function(u,a,l){var h=u[a],w=u[h.prevCC];if(!w||!w.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(g=w)!==null&&g!==void 0&&g.new;){var g;u.ccOffset+=h.start-w.start,h.new=!1,h=w,w=u[h.prevCC]}u.presentationOffset=l};function A(y,u,a,l,h,w,g,m){var L=new N.VTTParser,x=Object(P.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(M,`
|
|
`).split(`
|
|
`),f=[],p=Object(H.toMpegTsClockFromTimescale)(u,a),d="00:00.000",o=0,E=0,v,T=!0,I=!1;L.oncue=function(G){var X=l[h],J=l.ccOffset,z=(o-p)/9e4;if(X!=null&&X.new&&(E!==void 0?J=l.ccOffset=X.start:_(l,h,z)),z&&(J=z-l.presentationOffset),I){var W=G.endTime-G.startTime,q=Object(F.normalizePts)((G.startTime+J-E)*9e4,w*9e4)/9e4;G.startTime=q,G.endTime=q+W}var ne=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ne)),G.id||(G.id=k(G.startTime,G.endTime,ne)),G.endTime>0&&f.push(G)},L.onparsingerror=function(G){v=G},L.onflush=function(){if(v){m(v);return}g(f)},x.forEach(function(G){if(T)if(O(G,"X-TIMESTAMP-MAP=")){T=!1,I=!0,G.substr(16).split(",").forEach(function(X){O(X,"LOCAL:")?d=X.substr(6):O(X,"MPEGTS:")&&(o=parseInt(X.substr(7)))});try{E=b(d)/1e3}catch(X){I=!1,v=X}return}else G===""&&(T=!1);L.parse(G+`
|
|
`)}),L.flush()}},"./src/utils/xhr-loader.ts":function(ie,$,D){"use strict";D.r($);var V=D("./src/utils/logger.ts"),N=D("./src/loader/load-stats.ts"),P=/^age:\s*[\d.]+\s*$/m,H=function(){function F(O){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=O?O.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var M=F.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var b=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),b&&(b.onreadystatechange=null,b.onprogress=null,b.readyState!==4&&(this.stats.aborted=!0,b.abort()))},M.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(b,C,k){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=b,this.config=C,this.callbacks=k,this.retryDelay=C.retryDelay,this.loadInternal()},M.loadInternal=function(){var b=this.config,C=this.context;if(!b)return;var k=this.loader=new self.XMLHttpRequest,_=this.stats;_.loading.first=0,_.loaded=0;var A=this.xhrSetup;try{if(A)try{A(k,C.url)}catch(a){k.open("GET",C.url,!0),A(k,C.url)}k.readyState||k.open("GET",C.url,!0);var y=this.context.headers;if(y)for(var u in y)k.setRequestHeader(u,y[u])}catch(a){this.callbacks.onError({code:k.status,text:a.message},C,k);return}C.rangeEnd&&k.setRequestHeader("Range","bytes="+C.rangeStart+"-"+(C.rangeEnd-1)),k.onreadystatechange=this.readystatechange.bind(this),k.onprogress=this.loadprogress.bind(this),k.responseType=C.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),k.send()},M.readystatechange=function(){var b=this.context,C=this.loader,k=this.stats;if(!b||!C)return;var _=C.readyState,A=this.config;if(k.aborted)return;if(_>=2)if(self.clearTimeout(this.requestTimeout),k.loading.first===0&&(k.loading.first=Math.max(self.performance.now(),k.loading.start)),_===4){C.onreadystatechange=null,C.onprogress=null;var y=C.status;if(y>=200&&y<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var u,a;if(b.responseType==="arraybuffer"?(u=C.response,a=u.byteLength):(u=C.responseText,a=u.length),k.loaded=k.total=a,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(k,b,u,C),!this.callbacks)return;var h={url:C.responseURL,data:u};this.callbacks.onSuccess(h,k,b,C)}else k.retry>=A.maxRetry||y>=400&&y<499?(V.logger.error(y+" while loading "+b.url),this.callbacks.onError({code:y,text:C.statusText},b,C)):(V.logger.warn(y+" while loading "+b.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),k.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 b=this.callbacks;b&&(this.abortInternal(),b.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(b){var C=this.stats;C.loaded=b.loaded,b.lengthComputable&&(C.total=b.total)},M.getCacheAge=function(){var b=null;if(this.loader&&P.test(this.loader.getAllResponseHeaders())){var C=this.loader.getResponseHeader("age");b=C?parseFloat(C):null}return b},F}();$.default=H}}).default})},vHTk:function(Et,nt,re){Et.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|