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
904 KiB
361 lines
904 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[245,7],{"+NIl":function(Et,at,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,E=A.length-1;E>=0;E--){var u=A[E];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function W(_,A,E){return function(){this.name=_,this.bracketNo=0,this.style=A,this.styles=E,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=W("importmodule","tag",["string","builtin"]),M.documentclass=W("documentclass","tag",["","atom"]),M.usepackage=W("usepackage","tag",["atom"]),M.begin=W("begin","tag",["atom"]),M.end=W("end","tag",["atom"]),M.label=W("label","tag",["atom"]),M.ref=W("ref","tag",["atom"]),M.eqref=W("eqref","tag",["atom"]),M.cite=W("cite","tag",["atom"]),M.bibitem=W("bibitem","tag",["atom"]),M.Bibitem=W("Bibitem","tag",["atom"]),M.RBibitem=W("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 v(_,A){var E;if(_.match(/^\\[a-zA-Z@]+/)){var u=_.current().slice(1);return E=M.hasOwnProperty(u)?M[u]:M.DEFAULT,E=new E,V(A,E),O(A,k),E.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 o=_.next();if(o=="%")return _.skipToEnd(),"comment";if(o=="}"||o=="]"){if(E=N(A),E)E.closeBracket(o),O(A,k);else return"error";return"bracket"}else return o=="{"||o=="["?(E=M.DEFAULT,E=new E,V(A,E),"bracket"):/\d/.test(o)?(_.eatWhile(/[\w.%]/),"atom"):(_.eatWhile(/[\w\-_]/),E=H(A),E.name=="begin"&&(E.argument=_.current()),E.styleIdentifier())}function C(_,A,E){if(_.eatSpace())return null;if(E&&_.match(E))return O(A,v),"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 E=_.peek(),u;return E=="{"||E=="["?(u=N(A),u.openBracket(E),_.eat(E),O(A,v),"bracket"):/[ \t\r]/.test(E)?(_.eat(E),null):(O(A,v),P(A),v(_,A))}return{startState:function(){var _=D.inMathMode?function(A,E){return C(A,E)}:v;return{cmdState:[],f:_}},copyState:function(_){return{cmdState:_.cmdState.slice(),f:_.f}},token:function(_,A){return A.f(_,A)},blankLine:function(_){_.f=v,_.cmdState.length=0},lineComment:"%"}}),ie.defineMIME("text/x-stex","stex"),ie.defineMIME("text/x-latex","stex")})},"19Vz":function(Et,at,re){(function(ie){ie(re("VrN/"))})(function(ie){ie.defineOption("placeholder","",function(W,M,O){var v=O&&O!=ie.Init;if(M&&!v)W.on("blur",N),W.on("change",P),W.on("swapDoc",P),ie.on(W.getInputField(),"compositionupdate",W.state.placeholderCompose=function(){V(W)}),P(W);else if(!M&&v){W.off("blur",N),W.off("change",P),W.off("swapDoc",P),ie.off(W.getInputField(),"compositionupdate",W.state.placeholderCompose),$(W);var C=W.getWrapperElement();C.className=C.className.replace(" CodeMirror-empty","")}M&&!W.hasFocus()&&N(W)});function $(W){W.state.placeholder&&(W.state.placeholder.parentNode.removeChild(W.state.placeholder),W.state.placeholder=null)}function D(W){$(W);var M=W.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=W.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var O=W.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),M.appendChild(O),W.display.lineSpace.insertBefore(M,W.display.lineSpace.firstChild)}function V(W){setTimeout(function(){var M=!1,O=W.getInputField();O.nodeName=="TEXTAREA"?M=!O.value:W.lineCount()==1&&(M=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),M?D(W):$(W)},20)}function N(W){H(W)&&D(W)}function P(W){var M=W.getWrapperElement(),O=H(W);M.className=M.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?D(W):$(W)}function H(W){return W.lineCount()===1&&W.getLine(0)===""}})},"1eCo":function(Et,at,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={},W=N.htmlMode?$:D;for(var M in W)H[M]=W[M];for(var M in N)H[M]=N[M];var O,v;function C(a,b){function y(G){return b.tokenize=G,G(a,b)}var T=a.next();if(T=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?y(A("atom","]]>")):null:a.match("--")?y(A("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),y(E(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=A("meta","?>"),"meta"):(O=a.eat("/")?"closeTag":"openTag",b.tokenize=k,"tag bracket");if(T=="&"){var I;return a.eat("#")?a.eat("x")?I=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):I=a.eatWhile(/[\d]/)&&a.eat(";"):I=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),I?"atom":"error"}else return a.eatWhile(/[^&<]/),null}C.isInText=!0;function k(a,b){var y=a.next();if(y==">"||y=="/"&&a.eat(">"))return b.tokenize=C,O=y==">"?"endTag":"selfcloseTag","tag bracket";if(y=="=")return O="equals",null;if(y=="<"){b.tokenize=C,b.state=h,b.tagName=b.tagStart=null;var T=b.tokenize(a,b);return T?T+" tag error":"tag error"}else return/[\'\"]/.test(y)?(b.tokenize=_(y),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function _(a){var b=function(y,T){for(;!y.eol();)if(y.next()==a){T.tokenize=k;break}return"string"};return b.isInAttribute=!0,b}function A(a,b){return function(y,T){for(;!y.eol();){if(y.match(b)){T.tokenize=C;break}y.next()}return a}}function E(a){return function(b,y){for(var T;(T=b.next())!=null;){if(T=="<")return y.tokenize=E(a+1),y.tokenize(b,y);if(T==">")if(a==1){y.tokenize=C;break}else return y.tokenize=E(a-1),y.tokenize(b,y)}return"meta"}}function u(a,b,y){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=y,(H.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,b){for(var y;;){if(!a.context)return;if(y=a.context.tagName,!H.contextGrabbers.hasOwnProperty(y)||!H.contextGrabbers[y].hasOwnProperty(b))return;o(a)}}function h(a,b,y){return a=="openTag"?(y.tagStart=b.column(),w):a=="closeTag"?g:h}function w(a,b,y){return a=="word"?(y.tagName=b.current(),v="tag",x):H.allowMissingTagName&&a=="endTag"?(v="tag bracket",x(a,b,y)):(v="error",w)}function g(a,b,y){if(a=="word"){var T=b.current();return y.context&&y.context.tagName!=T&&H.implicitlyClosed.hasOwnProperty(y.context.tagName)&&o(y),y.context&&y.context.tagName==T||H.matchClosing===!1?(v="tag",m):(v="tag error",L)}else return H.allowMissingTagName&&a=="endTag"?(v="tag bracket",m(a,b,y)):(v="error",L)}function m(a,b,y){return a!="endTag"?(v="error",m):(o(y),h)}function L(a,b,y){return v="error",m(a,b,y)}function x(a,b,y){if(a=="word")return v="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var T=y.tagName,I=y.tagStart;return y.tagName=y.tagStart=null,a=="selfcloseTag"||H.autoSelfClosers.hasOwnProperty(T)?l(y,T):(l(y,T),y.context=new u(y,T,I==y.indented)),h}return v="error",x}function f(a,b,y){return a=="equals"?p:(H.allowMissing||(v="error"),x(a,b,y))}function p(a,b,y){return a=="string"?d:a=="word"&&H.allowUnquoted?(v="string",x):(v="error",x(a,b,y))}function d(a,b,y){return a=="string"?d:x(a,b,y)}return{startState:function(a){var b={tokenize:C,state:h,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;O=null;var y=b.tokenize(a,b);return(y||O)&&y!="comment"&&(v=null,b.state=b.state(O||y,a,b),v&&(y=v=="error"?y+" error":v)),y},indent:function(a,b,y){var T=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+P;if(T&&T.noIndent)return ie.Pass;if(a.tokenize!=k&&a.tokenize!=C)return y?y.match(/^(\s*)/)[0].length:0;if(a.tagName)return H.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+P*(H.multilineTagIndentFactor||1);if(H.alignCDATA&&/<!\[CDATA\[/.test(b))return 0;var I=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);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:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:H.htmlMode?"html":"xml",helperType:H.htmlMode?"html":"xml",skipAttribute:function(a){a.state==p&&(a.state=x)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],y=a.context;y;y=y.prev)y.tagName&&b.push(y.tagName);return b.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,at,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"),W=re("oBTY"),M=re("tJVT"),O=re("PpiC"),v=re("q1tI"),C=re.n(v),k=function(A){var E=A.InputRight,u=A.value,o=u===void 0?[]:u,l=A.onChange,h=l===void 0?function(){}:l,w=Object(O.a)(A,["InputRight","value","onChange"]),g=Object(v.useState)(),m=Object(M.a)(g,2),L=m[0],x=m[1],f=function(a){var b=o.filter(function(y,T){return T!==a});h(b)},p=function(a){if(a.preventDefault(),!L)return;h([].concat(Object(W.a)(o),[L])),x(null)};return C.a.createElement("div",null,C.a.createElement(P.a,Object(H.a)({},w,{value:L,onChange:function(a){return x(a.target.value)},onPressEnter:p,onBlur:p})),E,C.a.createElement("div",{className:"mt20"},o==null?void 0:o.map(function(d,a){return C.a.createElement($.a,{className:"ml10 mr10",count:"x",onClick:function(){return f(a)}},C.a.createElement(V.a,{type:"primary",ghost:!0},d))})))};at.a=k},"7Cbv":function(Et,at,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=[],W=0;W<256;++W)H.push((W+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 v(k,_,A){k=k||{};var E=k.random||(k.rng||D)();if(E[6]=E[6]&15|64,E[8]=E[8]&63|128,_){A=A||0;for(var u=0;u<16;++u)_[A+u]=E[u];return _}return O(E)}var C=at.a=v},"7ahc":function(Et,at,re){"use strict";re.d(at,"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"),W=re("OaEy"),M=re("2fM7"),O=re("q1tI"),v=re.n(O),C=re("VrN/"),k=re.n(C),_=re("p77/"),A=re.n(_),E=re("c5Ni"),u=re.n(E),o=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"]};at.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 a(y){d(h[y][1])}function b(y){m(y)}return v.a.createElement(P.a,Object($.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),v.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(M.a,{onChange:a},Object.keys(h).map(function(y){return v.a.createElement(o,{key:y,value:y},h[y][0])}))),v.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(w,{mode:p})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.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)(),a=Object(O.useState)(),b=Object(H.a)(a,2),y=b[0],T=b[1];return Object(O.useEffect)(function(){if(y){function I(G){var X=G.getValue();L&&L(X)}return y.on("change",I),function(){y.off("change",I)}}},[y,L]),Object(O.useEffect)(function(){y&&y.setOption("mode",x)},[y,x]),Object(O.useEffect)(function(){y&&((m!==y.getValue()||m==="")&&setTimeout(function(){y.setValue(m||" ")},300))},[y,m]),Object(O.useEffect)(function(){if(d.current&&!y){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,y]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:d}))}},"7ixt":function(Et,at,re){"use strict";re.d(at,"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,at,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("."),W=H>-1&&V.substring(H+1,V.length);if(W)return ie.findModeByExtension(W)},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,at,re){Et.exports={button:"button___1wy9m"}},"93VE":function(Et,at,re){},"9Bee":function(Et,at,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"),W=re("WmNS"),M=re.n(W),O=re("q1tI"),v=re.n(O),C=re("vg9a"),k=re("DlQD"),_=re.n(k),A=re("rUJ1");function E(F,s){var c=F.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=[],o=["<ul>"],l=new _.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function w(){u.length=0,o=["<ul>"]}var g={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(F,s,c,R){if(s>=F.length||F[s].level<=c)return s;var Z=F[s];R.push("<li><a href='#"+Z.anchor+"'>"+Z.text+"</a>"),s++;var U=[];return s=m(F,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(F,s,c,R),s}function L(){return m(u,0,0,o),o.push("</ul>"),o.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=E(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,a[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++,"__")},a={};function b(){return a}function y(){p=0,a={}}function T(F){return F=F.replace(f,function(s,c){var R=d();return a[R]={type:"inline",expression:c},R}),F}var I=l.listitem;l.listitem=function(F){return I(T(F))};var G=l.paragraph;l.paragraph=function(F){return G(T(F))};var X=l.tablecell;l.tablecell=function(F,s){return X(T(F),s)},l.code=function(F,s,c){var R=(s||"").match(/\S*/)[0];return R?["latex","katex","math"].indexOf(R)>=0?"<p class='editormd-tex'>".concat(F,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?F:Object(A.escape)(F,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(c?F:Object(A.escape)(F,!0))+"</code></pre>"},l.heading=function(F,s,c){var R=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:R,level:s,text:F}),"<h"+s+' id="'+R+'">'+F+"</h"+s+">"},_.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),_.a.use({tokenizer:x,renderer:l});var J=_.a,z=re("SJMd"),j=re("ulZh"),q=re.n(j),ne=re("m3rI"),ce=re("Oy/b"),ve=re("p5ED"),ke=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(F,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])})(F,s)};function Ce(F,s){function c(){this.constructor=F}xe(F,s),F.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Se(F,s,c,R){return new(c||(c=Promise))(function(Z,U){function he(ft){try{Ve(R.next(ft))}catch(Ie){U(Ie)}}function Re(ft){try{Ve(R.throw(ft))}catch(Ie){U(Ie)}}function Ve(ft){var Ie;ft.done?Z(ft.value):(Ie=ft.value,Ie instanceof c?Ie:new c(function(bt){bt(Ie)})).then(he,Re)}Ve((R=R.apply(F,s||[])).next())})}function Ee(F,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(Ve){return function(ft){return function(Ie){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,R&&(Z=2&Ie[0]?R.return:Ie[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Ie[1])).done)return Z;switch(R=0,Z&&(Ie=[2&Ie[0],Z.value]),Ie[0]){case 0:case 1:Z=Ie;break;case 4:return he.label++,{value:Ie[1],done:!1};case 5:he.label++,R=Ie[1],Ie=[0];continue;case 7:Ie=he.ops.pop(),he.trys.pop();continue;default:if(!(Z=he.trys,(Z=Z.length>0&&Z[Z.length-1])||Ie[0]!==6&&Ie[0]!==2)){he=0;continue}if(Ie[0]===3&&(!Z||Ie[1]>Z[0]&&Ie[1]<Z[3])){he.label=Ie[1];break}if(Ie[0]===6&&he.label<Z[1]){he.label=Z[1],Z=Ie;break}if(Z&&he.label<Z[2]){he.label=Z[2],he.ops.push(Ie);break}Z[2]&&he.ops.pop(),he.trys.pop();continue}Ie=s.call(F,he)}catch(bt){Ie=[6,bt],R=0}finally{c=Z=0}if(5&Ie[0])throw Ie[1];return{value:Ie[0]?Ie[1]:void 0,done:!0}}([Ve,ft])}}}function me(){for(var F=0,s=0,c=arguments.length;s<c;s++)F+=arguments[s].length;var R=Array(F),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 F(){}return F.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},F.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)}},F.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&&F.setAttributes(Z,R),Z},F.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&&F.setAttributes(he,U),he},F.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&F.setAttributes(R,c),R},F.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&&F.setAttributes(R,c),R},F.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&&F.setAttributes(Z,R),Z},F.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&F.setAttributes(c,s),c},F.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},F.createMarker=function(s,c,R,Z,U,he,Re){var Ve=document.createElementNS("http://www.w3.org/2000/svg","marker");return F.setAttributes(Ve,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",he.toString()]]),Ve.appendChild(Re),Ve},F.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&F.setAttributes(c,s),c},F.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&F.setAttributes(R,c),R},F.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&F.setAttributes(c,s),c},F.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},F.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&F.setAttributes(R,c),R},F}(),De=function(){function F(){}return F.addKey=function(s){F.key=s},Object.defineProperty(F,"isLicensed",{get:function(){return!!F.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(F.key)},enumerable:!1,configurable:!0}),F}(),ze=function(){function F(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return F.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 Ve=Re.outerHTML,ft=he.getContext("2d");Z.markersOnly!==!0&&ft.drawImage(s,0,0,he.width,he.height);var Ie=window.URL,bt=new Image(he.width,he.height);bt.setAttribute("crossOrigin","anonymous");var Ft=new Blob([Ve],{type:"image/svg+xml"}),Yt=Ie.createObjectURL(Ft);bt.onload=function(){ft.drawImage(bt,0,0),Ie.revokeObjectURL(Yt);var Mr=he.toDataURL(Z.imageType,Z.imageQuality);U(Mr)},bt.src=Yt})},F}(),He=function(){},qe=function(){function F(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(F.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(F.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(F.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),F.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},F.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)},F.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;
|
|
`))},F.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},F}(),Ke=function(F,s){this.selector=F,this.style=s},Le=function(F,s){this.localName=F,this.style=s},Pe=function(){function F(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 F.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()},F.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},F.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},F.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},F.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]))}},F.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")},F.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)})},F.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)},F.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+`
|
|
`))},F.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"},F.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])},F.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)},F.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(R){return R.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},F.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")})},F}(),je=function(){function F(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 F.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;
|
|
`))},F.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)},F.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")},F.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,Ve;U.className=c.toolboxButtonStyleClass.name+" "+(he===R?""+((Re=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Re!==void 0?Re:c.toolboxActiveButtonStyleColorsClass.name):""+((Ve=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ve!==void 0?Ve:c.toolboxButtonStyleColorsClass.name))})},F}(),Xe=function(F,s){this.title=F,this.icon=s},Ge=function(F){function s(c,R,Z,U){var he=F.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,F),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),Me=function(){function F(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(F.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),F.prototype.ownsTarget=function(s){return!1},Object.defineProperty(F.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),F.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},F.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},F.prototype.pointerDown=function(s,c){},F.prototype.dblClick=function(s,c){},F.prototype.manipulate=function(s){},F.prototype.pointerUp=function(s){this.stateChanged()},F.prototype.dispose=function(){},F.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},F.prototype.getState=function(){return{typeName:F.typeName,state:this.state,notes:this.notes}},F.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},F.prototype.scale=function(s,c){},F.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},F.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},F.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)}},F.typeName="MarkerBase",F}(),Ne=function(){function F(){this.findGripByVisual=this.findGripByVisual.bind(this)}return F.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},F}(),Qe=function(){function F(){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 F.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},F}(),Je=function(){function F(){}return F.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},F.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},F}(),Ye=function(F){function s(c,R,Z){var U=F.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,F),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!!F.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){F.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;F.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(){F.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){F.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 Ne,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 Qe;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,Ve=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,Ve,Z),this.positionGrip(this.controlGrips.centerLeft.visual,R,he),this.positionGrip(this.controlGrips.centerRight.visual,Ve,he),this.positionGrip(this.controlGrips.bottomLeft.visual,R,Re),this.positionGrip(this.controlGrips.bottomCenter.visual,U,Re),this.positionGrip(this.controlGrips.bottomRight.visual,Ve,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:Je.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Je.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},F.prototype.getState.call(this))},s.prototype.restoreState=function(c){F.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(Je.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,R.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Je.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,R.containerTransformMatrix))},s.prototype.scale=function(c,R){F.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}(Me),it=function(F){function s(c,R,Z){var U=F.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,F),s.prototype.ownsTarget=function(c){return!(!F.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){F.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){F.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){F.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){F.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){F.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},F.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(),F.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){F.prototype.scale.call(this,c,R),this.setSize()},s.title="Rectangle marker",s}(Ye),st=function(F){function s(c,R,Z,U){var he=F.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,F),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 Ve=document.createElement("hr");Ve.style.minWidth="20px",Ve.style.border="0px",Ve.style.borderTop=Z+"px solid "+c.uiStyleSettings.toolboxColor,Ve.style.flexGrow="2",Re.appendChild(Ve),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),et=function(F){function s(c,R,Z,U){var he=F.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,F),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),tt=function(F){function s(c,R,Z){var U=F.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 st("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,F),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=F.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}(it),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},ut=function(F){function s(c,R,Z){var U=F.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,F),s.prototype.ownsTarget=function(c){return!!F.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,R){F.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;F.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(){F.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){F.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 Qe;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},F.prototype.getState.call(this))},s.prototype.restoreState=function(c){F.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){F.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}(Me),nt=function(F){function s(c,R,Z){var U=F.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 st("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,F),s.prototype.ownsTarget=function(c){return!(!F.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){F.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},F.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){F.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}(ut),Ae=function(F){function s(c,R,Z,U){var he=F.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,F),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),Ue=function(F){function s(c,R,Z){var U=F.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,F),s.prototype.ownsTarget=function(c){if(F.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){F.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){F.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){F.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){F.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),F.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(){F.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),F.prototype.deselect.call(this)},s.prototype.dblClick=function(c,R){F.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},F.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(),F.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){F.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}(Ye),ge=function(F){function s(c,R,Z){var U=F.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 st("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.lineWidthPanel.onWidthChanged=U.setLineWidth,U}return Ce(s,F),s.prototype.ownsTarget=function(c){return!(!F.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):F.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()):F.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){F.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()):F.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(),F.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),F.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],Ve=!1,ft=0;ft<this.canvasElement.height;ft++)for(var Ie=0;Ie<this.canvasElement.width;Ie++)c.data[ft*this.canvasElement.width*4+4*Ie+3]>0&&(Ve=!0,ft<U&&(U=ft),Ie<Z&&(Z=Ie),ft>Re&&(Re=ft),Ie>he&&(he=Ie));if(Ve){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},F.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),F.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,R){F.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}(Ye),de=function(F){function s(c,R,Z){var U=F.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,F),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 Ve="both";switch(Re){case 0:Ve="both";break;case 1:Ve="start";break;case 2:Ve="end";break;case 3:Ve="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=Ve===U.currentType?U.uiStyleSettings.toolboxAccentColor:"transparent",ft.addEventListener("click",function(){c.setCurrentType(Ve,ft)}),R.appendChild(ft),Ve==="both"||Ve==="start"){var Ie=document.createElement("div");Ie.style.display="flex",Ie.style.alignItems="center",Ie.style.minHeight="20px",Ie.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>`,Ie.style.marginLeft="5px",ft.appendChild(Ie)}var bt=document.createElement("div");bt.style.display="flex",bt.style.alignItems="center",bt.style.minHeight="20px",bt.style.flexGrow="2";var Ft=document.createElement("hr");if(Ft.style.minWidth="20px",Ft.style.border="0px",Ft.style.borderTop="3px solid "+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee"),Ft.style.flexGrow="2",bt.appendChild(Ft),ft.appendChild(bt),Ve==="both"||Ve==="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(F){function s(c,R,Z){var U=F.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,F),s.prototype.ownsTarget=function(c){return!(!F.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){F.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(F.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},F.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){F.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}(nt),ee=function(F){function s(c,R,Z){var U=F.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,F),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=F.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}(it),te=function(F){function s(c,R,Z,U){var he=F.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,F),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(F){function s(c,R,Z){var U=F.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,F),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=F.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(F){function s(c,R,Z){var U=F.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 Qe,U.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),U.controlBox.appendChild(U.tipGrip.visual),U}return Ce(s,F),s.prototype.ownsTarget=function(c){return F.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"&&F.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):F.prototype.pointerDown.call(this,c,R)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,F.prototype.pointerUp.call(this,c);else{var R=this.state==="creating";F.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 F.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){F.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(),F.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},F.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,F.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,R){F.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}(Ue),Te=function(F){function s(c,R,Z){var U=F.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",me(Z.defaultColorSet,["transparent"]),Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.fillPanel=new Ge("Fill color",me(Z.defaultColorSet,["transparent"]),U.fillColor,ue),U.fillPanel.onColorChanged=U.setFillColor,U.strokeWidthPanel=new st("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("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,F),s.prototype.ownsTarget=function(c){return!(!F.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){F.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){F.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){F.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){F.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){F.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},F.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(),F.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){F.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}(Ye),Oe=function(F){function s(c,R,Z){return F.call(this,c,R,Z)||this}return Ce(s,F),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!F.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){F.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(F.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=F.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){F.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}(nt),rt=function(F){function s(c,R,Z){var U=F.call(this,c,R,Z)||this;return U.strokePanel.colors=Z.defaultColorSet,U.fillColor="transparent",U}return Ce(s,F),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=F.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}(Te),pt=function(){function F(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(F.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),F.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))},F.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},F.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},F.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}},F.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},F}(),dt=function(F){function s(c,R,Z){var U=F.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 st("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,F),s.prototype.ownsTarget=function(c){return!(!F.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){F.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(){F.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,F.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){F.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),F.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),F.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,F.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},F.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){F.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}(ut),Lt=function(){function F(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(F.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),F.prototype.preventDefault=function(){this._defaultPrevented=!0},F}(),Tt=function(F){function s(c,R,Z){var U=F.call(this,c,!1)||this;return U.dataUrl=R,U.state=Z,U}return Ce(s,F),s}(Lt),ht=function(F){function s(c,R,Z){Z===void 0&&(Z=!1);var U=F.call(this,c,Z)||this;return U.marker=R,U}return Ce(s,F),s}(Lt),Bt=function(){function F(){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 F.prototype.addEventListener=function(s,c){this[s].push(c)},F.prototype.removeEventListener=function(s,c){var R=this[s].indexOf(c);R>-1&&this[s].splice(R,1)},F}(),Ct=function(){function F(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=F.instanceCounter++,this.styles=new qe(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(F.prototype,"ALL_MARKER_TYPES",{get:function(){return[tt,ge,fe,Ue,rt,Te,ae,pe,Oe,ee,nt,dt]},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[tt,ge,fe,Ue,Te,ae,pe]},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"BASIC_MARKER_TYPES",{get:function(){return[tt,ge,fe,Ue,ae]},enumerable:!1,configurable:!0}),Object.defineProperty(F.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(F.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(F.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(F.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),F.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),De.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},F.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))})},F.prototype.render=function(){return Se(this,void 0,void 0,function(){var s;return Ee(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new ze).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()]}})})},F.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)}},F.prototype.addMarkersToToolbar=function(){for(var s,c=[],R=0;R<arguments.length;R++)c[R]=arguments[R];(s=this._availableMarkerTypes).push.apply(s,c)},F.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},F.prototype.removeRenderEventListener=function(s){},F.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},F.prototype.removeCloseEventListener=function(s){},F.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))},F.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)},F.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},F.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},F.prototype.scaleMarkers=function(s,c){var R,Z=this;this._currentMarker&&this._currentMarker instanceof Ue?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)},F.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"},F.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.top},F.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)},F.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)},F.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},F.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)},F.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},F.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},F.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)},F.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},F.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)},F.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()},F.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")},F.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"},F.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},F.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 Pe(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 je(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},F.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},F.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},F.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())},F.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()}},F.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Z){var U=new ht(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 ht(s,R))})}}},F.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(he){var Re=new ht(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(Ve){return Ve(new ht(s,Re))})},Z=this,U=this.markers.length-1;U>=0;U--)R(U);this.addUndoStep()}},Object.defineProperty(F.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),F.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))},F.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)},F.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},F.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))})}},F.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},F.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))}))},F.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},F.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))}))},F.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},F.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},F.prototype.startRenderAndClose=function(){return Se(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]}})})},F.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},F.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))})},F.prototype.addNewMarker=function(s){var c=se.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},F.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 ht(R,R._currentMarker))}))},F.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof ge&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(ge):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(R){return R(new ht(c,c._currentMarker))})},F.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},F.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},F.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(R){return R(new ht(c,s))})},F.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 ht(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 ht(c,c._currentMarker))}))},F.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))},F.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()}},F.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}))},F.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()},F.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},F.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},F.prototype.clientToLocalCoordinates=function(s,c){var R=this.markerImage.getBoundingClientRect();return{x:(s-R.left)/this.zoomLevel,y:(c-R.top)/this.zoomLevel}},F.prototype.onWindowResize=function(){this.positionUI()},F.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()},F.prototype.addLicenseKey=function(s){De.addKey(s)},F.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},F.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},F.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(F.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),F.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))}))},F.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))}))},F.instanceCounter=0,F}();/* **********************************
|
|
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(F,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])})(F,s)};function Dt(F,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=F}_t(F,s),F.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function mt(F,s,c,R){return new(c||(c=Promise))(function(Z,U){function he(ft){try{Ve(R.next(ft))}catch(Ie){U(Ie)}}function Re(ft){try{Ve(R.throw(ft))}catch(Ie){U(Ie)}}function Ve(ft){var Ie;ft.done?Z(ft.value):(Ie=ft.value,Ie instanceof c?Ie:new c(function(bt){bt(Ie)})).then(he,Re)}Ve((R=R.apply(F,s||[])).next())})}function or(F,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(Ve){return function(ft){return function(Ie){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,R&&(Z=2&Ie[0]?R.return:Ie[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Ie[1])).done)return Z;switch(R=0,Z&&(Ie=[2&Ie[0],Z.value]),Ie[0]){case 0:case 1:Z=Ie;break;case 4:return he.label++,{value:Ie[1],done:!1};case 5:he.label++,R=Ie[1],Ie=[0];continue;case 7:Ie=he.ops.pop(),he.trys.pop();continue;default:if(!(Z=he.trys,(Z=Z.length>0&&Z[Z.length-1])||Ie[0]!==6&&Ie[0]!==2)){he=0;continue}if(Ie[0]===3&&(!Z||Ie[1]>Z[0]&&Ie[1]<Z[3])){he.label=Ie[1];break}if(Ie[0]===6&&he.label<Z[1]){he.label=Z[1],Z=Ie;break}if(Z&&he.label<Z[2]){he.label=Z[2],he.ops.push(Ie);break}Z[2]&&he.ops.pop(),he.trys.pop();continue}Ie=s.call(F,he)}catch(bt){Ie=[6,bt],R=0}finally{c=Z=0}if(5&Ie[0])throw Ie[1];return{value:Ie[0]?Ie[1]:void 0,done:!0}}([Ve,ft])}}}var Zt=function(){function F(){}return F.addKey=function(s){F.key=s},Object.defineProperty(F,"isLicensed",{get:function(){return!!F.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(F.key)},enumerable:!1,configurable:!0}),F}(),vt=function(){function F(){}return F.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},F.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)}},F.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&&F.setAttributes(Z,R),Z},F.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&&F.setAttributes(he,U),he},F.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&F.setAttributes(R,c),R},F.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&&F.setAttributes(R,c),R},F.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&&F.setAttributes(Z,R),Z},F.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&F.setAttributes(c,s),c},F.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},F.createMarker=function(s,c,R,Z,U,he,Re){var Ve=document.createElementNS("http://www.w3.org/2000/svg","marker");return F.setAttributes(Ve,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",he.toString()]]),Ve.appendChild(Re),Ve},F.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&F.setAttributes(c,s),c},F.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&F.setAttributes(R,c),R},F.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&F.setAttributes(c,s),c},F.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},F.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&F.setAttributes(R,c),R},F.createElement=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&F.setAttributes(R,c),R},F.getHollowRectanglePath=function(s,c,R,Z,U,he,Re,Ve){return"M"+s+","+c+"V"+(c+Z)+"H"+(s+R)+"V"+c+"H"+U+"V"+he+"H"+(U+Re)+"V"+(he+Ve)+"H"+U+"V"+c+"Z"},F}(),vr=function(){function F(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(F.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(F.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(F.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),F.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},F.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)},F.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;
|
|
`))},F.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},F}(),sr=function(F,s){this.selector=F,this.style=s},Kt=function(F,s){this.localName=F,this.style=s},Ur=function(){function F(){this.blocks=[],this.display=""}return F.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},F.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},F.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},F}(),ci=function(){function F(){}return F.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},F}(),qr=function(F){function s(){var c=F!==null&&F.apply(this,arguments)||this;return c.buttons=[],c}return Dt(s,F),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=F.prototype.getUI.call(this);return this.buttons.forEach(function(R){return c.appendChild(R.getUI())}),c},s}(ci),Ut=function(){function F(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(F.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),F.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},F.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,"")))},F.prototype.hide=function(){this._isHidden=!0},F}(),ct=function(F){function s(){var c=F!==null&&F.apply(this,arguments)||this;return c.elements=[],c}return Dt(s,F),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=F.prototype.getUI.call(this);return this.elements.forEach(function(R){return c.appendChild(R)}),c},s}(ci),Gr=function(){function F(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(F.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),F.prototype.getVerticalLength=function(s){return s/this.ratio},F.prototype.getHorizontalLength=function(s){return s*this.ratio},F}(),ei=function(){function F(){}return F.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 Ve=vt.createElement("clipPath",[["id","text-bg-clip"]]);Re.appendChild(Ve);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 Ie=vt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ie.appendChild(vt.createTSpan(s+":"+c)),he.appendChild(Ie);var bt=Ie.getBBox();vt.setAttributes(Ie,[["x",((24-bt.width)/2).toString()],["y",((24-bt.height)/2-bt.y).toString()]]);var Ft=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 Ve.appendChild(Ft),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>'},F}(),yr=function(F){function s(c,R,Z){var U=F.call(this,c,R)||this;return U.isDropdownOpen=!1,U.onClick=U.dropdownButtonClicked,U.dropdownButtons=Z,U}return Dt(s,F),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}(Ut),Ot=function(){function F(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 F.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},F.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(R){return vt.setAttributes(R,[["cx",s.toString()],["cy",c.toString()]])})},F}(),Fr=function(){function F(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(F.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(F.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(F.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),F.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()},F.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},F.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)},F.prototype.clientToLocalCoordinates=function(s,c){var R=this.container.getBoundingClientRect();return{x:s-R.left+this.margin,y:c-R.top+this.margin}},F.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)},F.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()},F.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},F.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},F.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))},F.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)}},F.prototype.getRescaledRect=function(s,c,R,Z,U,he){var Re=R/s,Ve=Z/c;return{x:(U.x-he)*Re+he,y:(U.y-he)*Ve+he,width:U.width*Re,height:U.height*Ve}},F.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)},F}(),Vr=function(){function F(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(F.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),F.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},F.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},F.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},F.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},F.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()]])}},F.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)}},F.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},F}(),fi=function(){function F(){this.naturalSize=!1,this.imageType="image/png"}return F.prototype.rasterize=function(s,c,R,Z,U,he,Re){var Ve=this;return new Promise(function(ft){var Ie=document.createElement("canvas");Ie.width=s.width.baseVal.value-2*Z,Ie.height=s.height.baseVal.value-2*Z;var bt=1,Ft=1;Ve.naturalSize===!0?(bt=c.naturalWidth/(s.width.baseVal.value-2*Z)/he,Ft=c.naturalHeight/(s.height.baseVal.value-2*Z)/Re,Ie.width=c.naturalWidth/he,Ie.height=c.naturalHeight/Re):Ve.width!==void 0&&Ve.height!==void 0&&(bt=Ve.width/R.width,Ft=Ve.height/R.height,Ie.width*=bt,Ie.height*=Ft);var Yt=Ie.getContext("2d");Yt.translate(Ie.width/2,Ie.height/2),Yt.rotate(U*Math.PI/180),Yt.scale(he,Re),Yt.translate(-Ie.width/2,-Ie.height/2),Yt.drawImage(c,0,0,Ie.width,Ie.height);var Mr=document.createElement("canvas");Mr.width=R.width*bt,Mr.height=R.height*Ft,Mr.getContext("2d").putImageData(Yt.getImageData((R.x-Z)*bt,(R.y-Z)*Ft,R.width*bt,R.height*Ft),0,0),ft(Mr.toDataURL(Ve.imageType,Ve.imageQuality))})},F}(),Fe=function(){function F(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=F.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(F.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(F.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(F.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(F.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(F.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(F.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}),F.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},F.prototype.show=function(){this.showUI(),this.open()},F.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)},F.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},F.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},F.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},F.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},F.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))},F.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)}},F.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},F.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"},F.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()},F.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()},F.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},F.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)},F.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},F.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 Fr(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()},F.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)}},F.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)},F.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},F.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},F.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"},F.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},F.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},F.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},F.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Ur,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(Ft){var Yt=new Ut(ei.getIcon(Ft.horizontal,Ft.vertical),Ft.horizontal===0&&Ft.vertical===0?"FREE":Ft.horizontal+":"+Ft.vertical);Yt.onClick=function(){return s.ratioButtonClicked(Ft)},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 Ut('<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 Ut('<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 Ve=document.createElement("a");Ve.style.color="currentColor",Ve.href="https://markerjs.com/products/cropro",Ve.target="_blank",Ve.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(Ve),he.addElement(Re)}var ft=new qr;ft.minWidth=3*this.toolbarHeight+"px",ft.contentAlign="end",this.topToolbar.addButtonBlock(ft);var Ie=new Ut('<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");Ie.onClick=this.startRenderAndClose,ft.addButton(Ie),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ie.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var bt=new Ut('<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)},F.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Ur,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 Ut('<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 Ut('<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 Ut('<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 Ve=new Ut('<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");Ve.onClick=this.flipVerticallyButtonClicked,he.addButton(Ve)},F.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},F.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},F.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)},F.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},F.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},F.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()}},F.prototype.clientToLocalCoordinates=function(s,c){var R=this.cropImage.getBoundingClientRect();return{x:s-R.left,y:c-R.top}},F.prototype.onWindowResize=function(){this.positionUI()},F.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()},F.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)},F.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)},F.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},F.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},F.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},F.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},F.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},F.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},F.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]}})})},F.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()]}})})},F.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;
|
|
`))},F.instanceCounter=0,F}(),wt=re("8hTe"),pi=re.n(wt),mi=/<pre[^>]*>/g;function gi(F){var s=document.createElement("div");return s.innerHTML=F,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=at.a=function(F){var s=F.value,c=s===void 0?"":s,R=F.edit,Z=R===void 0?!1:R,U=F.className,he=F.showTextOnly,Re=F.showLines,Ve=F.replaces,ft=F.zoomImg,Ie=F.hasMask,bt=F.style,Ft=bt===void 0?{}:bt,Yt=F.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 Fe(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(ke.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&&Ve(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(ke.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&&Ve(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=b();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"),y(),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&&(Ft=Object(N.a)(Object(N.a)({},Ft),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),y(),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 v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:zr,style:Object(N.a)({},Ft),className:"".concat(U||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),v.a.createElement("div",{ref:xr,className:pi.a.button},v.a.createElement($.a,null,v.a.createElement(V.a,{onClick:function(){return zi()}},"\u88C1\u526A"),v.a.createElement(V.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.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,at,re){"use strict";re.d(at,"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 W=setInterval(H,N);return function(){return clearInterval(W)}}},[N])}},"9ZNV":function(Et,at,re){"use strict";re.d(at,"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),W=re("TSYQ"),M=re.n(W),O=function(C){var k=C.cancelText,_=k===void 0?"\u53D6\u6D88":k,A=C.okText,E=A===void 0?"\u786E\u5B9A":A,u=C.loading,o=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:o,onClick:f},g),E)))}},Bd2K:function(Et,at,re){(function(ie){ie(re("VrN/"),re("osHv"))})(function(ie){ie.defineOption("autoCloseTags",!1,function(M,O,v){if(v!=ie.Init&&v&&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(),v=[],C=M.getOption("autoCloseTags"),k=0;k<O.length;k++){if(!O[k].empty())return ie.Pass;var _=O[k].head,A=M.getTokenAt(_),E=ie.innerMode(M.getMode(),A.state),u=E.state,o=E.mode.xmlCurrentTag&&E.mode.xmlCurrentTag(u),l=o&&o.name;if(!l)return ie.Pass;var h=E.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"&&o.close||A.string.indexOf("/")==_.ch-A.start-1||w&&H(w,m)>-1||W(M,E.mode.xmlCurrentContext&&E.mode.xmlCurrentContext(u)||[],l,_,!0))return ie.Pass;var L=typeof C=="object"&&C.emptyTags;if(L&&H(L,l)>-1){v[k]={text:"/>",newPos:ie.Pos(_.line,_.ch+2)};continue}var x=g&&H(g,m)>-1;v[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=v[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 v=M.listSelections(),C=[],k=O?"/":"</",_=M.getOption("autoCloseTags"),A=typeof _=="object"&&_.dontIndentOnSlash,E=0;E<v.length;E++){if(!v[E].empty())return ie.Pass;var u=v[E].head,o=M.getTokenAt(u),l=ie.innerMode(M.getMode(),o.state),h=l.state;if(O&&(o.type=="string"||o.string.charAt(0)!="<"||o.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&&W(M,m,m[m.length-1],u))return ie.Pass;w=k+m[m.length-1]}M.getLine(u.line).charAt(o.end)!=">"&&(w+=">"),C[E]=w}if(M.replaceSelections(C),v=M.listSelections(),!A)for(var E=0;E<v.length;E++)(E==v.length-1||v[E].head.line<v[E+1].head.line)&&M.indentLine(v[E].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 v=0,C=M.length;v<C;++v)if(M[v]==O)return v;return-1}function W(M,O,v,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!=v)return!1;for(var E=k?1:0,u=O.length-1;u>=0&&O[u]==v;u--)++E;C=A.to;for(var u=1;u<E;u++){var o=ie.scanForClosingTag(M,C,null,_);if(!o||o.tag!=v)return!1;C=o.to}return!0}})},BjJ7:function(Et,at,re){"use strict";re.d(at,"d",function(){return $}),re.d(at,"c",function(){return D}),re.d(at,"e",function(){return V}),re.d(at,"b",function(){return N}),re.d(at,"a",function(){return H});var ie=re("m3rI");function $(W){var M=!0;if(W.length>0){for(var O=0;O<W.length;O++)if(W[O].compile_success==0||!W[O].compile_success){M=!1;break}}else M=!1;return M}function D(W){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],v=0;v<W.length;v++){var C=W[v],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(W,M,O){for(var v=0;v<W.length;v++){var C=W[v];if(C.key===M){C.children=O;break}C.children&&V(C.children,M,O)}return W}function N(W,M,O){var v;return function(){var C=this,k=arguments,_=function(){v=null,O||W.apply(C,k)},A=O&&!v;clearTimeout(v),v=setTimeout(_,M),A&&W.apply(C,k)}}var P=!0,H=ie.a.API_SERVER},"C+DQ":function(Et,at,re){},DlQD:function(Et,at,re){(function(ie,$){Et.exports=$()})(this,function(){"use strict";function ie(ge,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(ge,ee.key,ee)}}function $(ge,de,fe){return de&&ie(ge.prototype,de),fe&&ie(ge,fe),ge}function D(ge,de){if(!ge)return;if(typeof ge=="string")return V(ge,de);var fe=Object.prototype.toString.call(ge).slice(8,-1);if(fe==="Object"&&ge.constructor&&(fe=ge.constructor.name),fe==="Map"||fe==="Set")return Array.from(ge);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return V(ge,de)}function V(ge,de){(de==null||de>ge.length)&&(de=ge.length);for(var fe=0,ee=new Array(de);fe<de;fe++)ee[fe]=ge[fe];return ee}function N(ge,de){var fe;if(typeof Symbol=="undefined"||ge[Symbol.iterator]==null){if(Array.isArray(ge)||(fe=D(ge))||de&&ge&&typeof ge.length=="number"){fe&&(ge=fe);var ee=0;return function(){return ee>=ge.length?{done:!0}:{done:!1,value:ge[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=ge[Symbol.iterator](),fe.next.bind(fe)}function P(ge,de){return de={exports:{}},ge(de,de.exports),de.exports}var H=P(function(ge){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){ge.exports.defaults=ee}ge.exports={defaults:de(),getDefaults:de,changeDefaults:fe}}),W=H.defaults,M=H.getDefaults,O=H.changeDefaults,v=/[&<>"']/,C=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,A={"&":"&","<":"<",">":">",'"':""","'":"'"},E=function(de){return A[de]};function u(ge,de){if(de){if(v.test(ge))return ge.replace(C,E)}else if(k.test(ge))return ge.replace(_,E);return ge}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(ge){return ge.replace(o,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(ge,de){ge=ge.source||ge,de=de||"";var fe={replace:function(te,ae){return ae=ae.source||ae,ae=ae.replace(h,"$1"),ge=ge.replace(te,ae),fe},getRegex:function(){return new RegExp(ge,de)}};return fe}var g=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(ge,de,fe){if(ge){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=a(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 a(ge,de){x[" "+ge]||(f.test(ge)?x[" "+ge]=ge+"/":x[" "+ge]=I(ge,"/",!0)),ge=x[" "+ge];var fe=ge.indexOf(":")===-1;return de.substring(0,2)==="//"?fe?de:ge.replace(p,"$1")+de:de.charAt(0)==="/"?fe?de:ge.replace(d,"$1")+de:ge+de}var b={exec:function(){}};function y(ge){for(var de=1,fe,ee;de<arguments.length;de++){fe=arguments[de];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(ge[ee]=fe[ee])}return ge}function T(ge,de){var fe=ge.replace(/\|/g,function(ae,ue,pe){for(var Te=!1,Oe=ue;--Oe>=0&&pe[Oe]==="\\";)Te=!Te;return Te?"|":" |"}),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(ge,de,fe){var ee=ge.length;if(ee===0)return"";for(var te=0;te<ee;){var ae=ge.charAt(ee-te-1);if(ae===de&&!fe)te++;else if(ae!==de&&fe)te++;else break}return ge.substr(0,ee-te)}function G(ge,de){if(ge.indexOf(de[1])===-1)return-1;for(var fe=ge.length,ee=0,te=0;te<fe;te++)if(ge[te]==="\\")te++;else if(ge[te]===de[0])ee++;else if(ge[te]===de[1]&&(ee--,ee<0))return te;return-1}function X(ge){ge&&ge.sanitize&&!ge.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:a,noopTest:b,merge:y,splitCells:T,rtrim:I,findClosingBracket:G,checkSanitizeDeprecation:X},z=H.defaults,j=J.rtrim,q=J.splitCells,ne=J.escape,ce=J.findClosingBracket;function ve(ge,de,fe){var ee=de.href,te=de.title?ne(de.title):null,ae=ge[1].replace(/\\([\[\]])/g,"$1");return ge[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 ke(ge,de){var fe=ge.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 ge(fe){this.options=fe||z}var de=ge.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:j(pe,`
|
|
`)}}},de.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ae=te[0],ue=ke(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,Te=ue[ue.length-1]===")",Oe={type:"list",raw:ae,ordered:pe,start:pe?+ue.slice(0,-1):"",loose:!1,items:[]},rt=te[0].match(this.rules.block.item),pt=!1,dt,Lt,Tt,ht,Bt,Ct,_t,Dt=rt.length,mt=0;mt<Dt;mt++)dt=rt[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(rt[mt+1])[0],(pe?Tt.length===1||!Te&&Tt[Tt.length-1]===")":Tt.length>1||this.options.smartLists&&Tt!==ue)&&(ht=rt.slice(mt+1).join(`
|
|
`),Oe.raw=Oe.raw.substring(0,Oe.raw.length-ht.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 Te=te[2],Oe="";if(this.options.pedantic){var rt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Te);rt?(Te=rt[1],Oe=rt[3]):Oe=""}else Oe=te[3]?te[3].slice(1,-1):"";Te=Te.trim().replace(/^<([\s\S]*)>$/,"$1");var pt=ve(te,{href:Te&&Te.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 Te=ve(ae,ue,ae[0]);return Te}},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 Te;(ue=pe.exec(te))!=null;)if(Te=this.rules.inline.strong.middle.exec(te.slice(0,ue.index+3)),Te)return{type:"strong",raw:ee.slice(0,Te[0].length),text:ee.slice(2,Te[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 Te;(ue=pe.exec(te))!=null;)if(Te=this.rules.inline.em.middle.exec(te.slice(0,ue.index+2)),Te)return{type:"em",raw:ee.slice(0,Te[0].length),text:ee.slice(1,Te[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 Te;do Te=ae[0],ae[0]=this.rules.inline._backpedal.exec(ae[0])[0];while(Te!==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}}},ge}(),Ce=J.noopTest,Se=J.edit,Ee=J.merge,me={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Se(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=Se(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=Se(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",me._comment=/<!--(?!-?>)[\s\S]*?-->/,me.html=Se(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Se(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.blockquote=Se(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Ee({},me),me.gfm=Ee({},me.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),me.gfm.nptable=Se(me.gfm.nptable).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.gfm.table=Se(me.gfm.table).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.pedantic=Ee({},me.normal,{html:Se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Ce,paragraph:Se(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url: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=Se(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Se(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Se(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Se(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Se(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Se(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Se(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Se(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Se(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Se(se._blockSkip,"g").getRegex(),se.overlapSkip=Se(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=Se(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=Se(se.tag).replace("comment",me._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Se(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Se(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Se(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:Se(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=Ee({},se.normal,{escape:Se(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=Se(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=Ee({},se.gfm,{br:Se(se.br).replace("{2,}","*").getRegex(),text:Se(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var De={block:me,inline:se},ze=H.defaults,He=De.block,qe=De.inline;function Ke(ge){return ge.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(ge){var de="",fe,ee,te=ge.length;for(fe=0;fe<te;fe++)ee=ge.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var Pe=function(){function ge(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||ze,this.options.tokenizer=this.options.tokenizer||new xe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:He.normal,inline:qe.normal};this.options.pedantic?(ee.block=He.pedantic,ee.inline=qe.pedantic):this.options.gfm&&(ee.block=He.gfm,this.options.breaks?ee.inline=qe.breaks:ee.inline=qe.gfm),this.tokenizer.rules=ee}ge.lex=function(ee,te){var ae=new ge(te);return ae.lex(ee)};var de=ge.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,Te,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),Te=ue.items.length,pe=0;pe<Te;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 rt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(rt);break}else throw new Error(rt)}}return te},de.inline=function(ee){var te,ae,ue,pe,Te,Oe,rt=ee.length;for(te=0;te<rt;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(Te=Oe.cells[ae],Oe.tokens.cells[ae]=[],ue=0;ue<Te.length;ue++)Oe.tokens.cells[ae][ue]=[],this.inlineTokens(Te[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 Te,Oe=ee,rt;if(this.tokens.links){var pt=Object.keys(this.tokens.links);if(pt.length>0)for(;(rt=this.tokenizer.rules.inline.reflinkSearch.exec(Oe))!=null;)pt.includes(rt[0].slice(rt[0].lastIndexOf("[")+1,-1))&&(Oe=Oe.slice(0,rt.index)+"["+"a".repeat(rt[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(rt=this.tokenizer.rules.inline.blockSkip.exec(Oe))!=null;)Oe=Oe.slice(0,rt.index)+"["+"a".repeat(rt[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(Te=this.tokenizer.escape(ee)){ee=ee.substring(Te.raw.length),te.push(Te);continue}if(Te=this.tokenizer.tag(ee,ae,ue)){ee=ee.substring(Te.raw.length),ae=Te.inLink,ue=Te.inRawBlock,te.push(Te);continue}if(Te=this.tokenizer.link(ee)){ee=ee.substring(Te.raw.length),Te.type==="link"&&(Te.tokens=this.inlineTokens(Te.text,[],!0,ue)),te.push(Te);continue}if(Te=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(Te.raw.length),Te.type==="link"&&(Te.tokens=this.inlineTokens(Te.text,[],!0,ue)),te.push(Te);continue}if(Te=this.tokenizer.strong(ee,Oe,pe)){ee=ee.substring(Te.raw.length),Te.tokens=this.inlineTokens(Te.text,[],ae,ue),te.push(Te);continue}if(Te=this.tokenizer.em(ee,Oe,pe)){ee=ee.substring(Te.raw.length),Te.tokens=this.inlineTokens(Te.text,[],ae,ue),te.push(Te);continue}if(Te=this.tokenizer.codespan(ee)){ee=ee.substring(Te.raw.length),te.push(Te);continue}if(Te=this.tokenizer.br(ee)){ee=ee.substring(Te.raw.length),te.push(Te);continue}if(Te=this.tokenizer.del(ee)){ee=ee.substring(Te.raw.length),Te.tokens=this.inlineTokens(Te.text,[],ae,ue),te.push(Te);continue}if(Te=this.tokenizer.autolink(ee,Le)){ee=ee.substring(Te.raw.length),te.push(Te);continue}if(!ae&&(Te=this.tokenizer.url(ee,Le))){ee=ee.substring(Te.raw.length),te.push(Te);continue}if(Te=this.tokenizer.inlineText(ee,ue,Ke)){ee=ee.substring(Te.raw.length),pe=Te.raw.slice(-1),te.push(Te);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},$(ge,null,[{key:"rules",get:function(){return{block:He,inline:qe}}}]),ge}(),je=H.defaults,Xe=J.cleanUrl,Ge=J.escape,Me=function(){function ge(fe){this.options=fe||je}var de=ge.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},ge}(),Ne=function(){function ge(){}var de=ge.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""},ge}(),Qe=function(){function ge(){this.seen={}}var de=ge.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},ge}(),Je=H.defaults,Ye=J.unescape,it=function(){function ge(fe){this.options=fe||Je,this.options.renderer=this.options.renderer||new Me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ne,this.slugger=new Qe}ge.parse=function(ee,te){var ae=new ge(te);return ae.parse(ee)};var de=ge.prototype;return de.parse=function(ee,te){te===void 0&&(te=!0);var ae="",ue,pe,Te,Oe,rt,pt,dt,Lt,Tt,ht,Bt,Ct,_t,Dt,mt,or,Zt,vt,vr=ee.length;for(ue=0;ue<vr;ue++){ht=ee[ue];switch(ht.type){case"space":continue;case"hr":{ae+=this.renderer.hr();continue}case"heading":{ae+=this.renderer.heading(this.parseInline(ht.tokens),ht.depth,Ye(this.parseInline(ht.tokens,this.textRenderer)),this.slugger);continue}case"code":{ae+=this.renderer.code(ht.text,ht.lang,ht.escaped);continue}case"table":{for(Lt="",dt="",Oe=ht.header.length,pe=0;pe<Oe;pe++)dt+=this.renderer.tablecell(this.parseInline(ht.tokens.header[pe]),{header:!0,align:ht.align[pe]});for(Lt+=this.renderer.tablerow(dt),Tt="",Oe=ht.cells.length,pe=0;pe<Oe;pe++){for(pt=ht.tokens.cells[pe],dt="",rt=pt.length,Te=0;Te<rt;Te++)dt+=this.renderer.tablecell(this.parseInline(pt[Te]),{header:!1,align:ht.align[Te]});Tt+=this.renderer.tablerow(dt)}ae+=this.renderer.table(Lt,Tt);continue}case"blockquote":{Tt=this.parse(ht.tokens),ae+=this.renderer.blockquote(Tt);continue}case"list":{for(Bt=ht.ordered,Ct=ht.start,_t=ht.loose,Oe=ht.items.length,Tt="",pe=0;pe<Oe;pe++)mt=ht.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(ht.text);continue}case"paragraph":{ae+=this.renderer.paragraph(this.parseInline(ht.tokens));continue}case"text":{for(Tt=ht.tokens?this.parseInline(ht.tokens):ht.text;ue+1<vr&&ee[ue+1].type==="text";)ht=ee[++ue],Tt+=`
|
|
`+(ht.tokens?this.parseInline(ht.tokens):ht.text);ae+=te?this.renderer.paragraph(Tt):Tt;continue}default:{var sr='Token with "'+ht.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,Te=ee.length;for(ue=0;ue<Te;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},ge}(),st=J.merge,et=J.checkSanitizeDeprecation,tt=J.escape,we=H.getDefaults,ut=H.changeDefaults,nt=H.defaults;function Ae(ge,de,fe){if(typeof ge=="undefined"||ge===null)throw new Error("marked(): input parameter is undefined or null");if(typeof ge!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(ge)+", string expected");if(typeof de=="function"&&(fe=de,de=null),de=st({},Ae.defaults,de||{}),et(de),fe){var ee=de.highlight,te;try{te=Pe.lex(ge,de)}catch(Te){return fe(Te)}var ae=function(Oe){var rt;if(!Oe)try{rt=it.parse(te,de)}catch(pt){Oe=pt}return de.highlight=ee,Oe?fe(Oe):fe(null,rt)};if(!ee||ee.length<3)return ae();if(delete de.highlight,!te.length)return ae();var ue=0;Ae.walkTokens(te,function(Te){Te.type==="code"&&(ue++,setTimeout(function(){ee(Te.text,Te.lang,function(Oe,rt){if(Oe)return ae(Oe);rt!=null&&rt!==Te.text&&(Te.text=rt,Te.escaped=!0),ue--,ue===0&&ae()})},0))}),ue===0&&ae();return}try{var pe=Pe.lex(ge,de);return de.walkTokens&&Ae.walkTokens(pe,de.walkTokens),it.parse(pe,de)}catch(Te){if(Te.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+tt(Te.message+"",!0)+"</pre>";throw Te}}Ae.options=Ae.setOptions=function(ge){return st(Ae.defaults,ge),ut(Ae.defaults),Ae},Ae.getDefaults=we,Ae.defaults=nt,Ae.use=function(ge){var de=st({},ge);if(ge.renderer&&function(){var ee=Ae.defaults.renderer||new Me,te=function(pe){var Te=ee[pe];ee[pe]=function(){for(var Oe=arguments.length,rt=new Array(Oe),pt=0;pt<Oe;pt++)rt[pt]=arguments[pt];var dt=ge.renderer[pe].apply(ee,rt);return dt===!1&&(dt=Te.apply(ee,rt)),dt}};for(var ae in ge.renderer)te(ae);de.renderer=ee}(),ge.tokenizer&&function(){var ee=Ae.defaults.tokenizer||new xe,te=function(pe){var Te=ee[pe];ee[pe]=function(){for(var Oe=arguments.length,rt=new Array(Oe),pt=0;pt<Oe;pt++)rt[pt]=arguments[pt];var dt=ge.tokenizer[pe].apply(ee,rt);return dt===!1&&(dt=Te.apply(ee,rt)),dt}};for(var ae in ge.tokenizer)te(ae);de.tokenizer=ee}(),ge.walkTokens){var fe=Ae.defaults.walkTokens;de.walkTokens=function(ee){ge.walkTokens(ee),fe&&fe(ee)}}Ae.setOptions(de)},Ae.walkTokens=function(ge,de){for(var fe=N(ge),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 Te=N(te.tokens.cells),Oe;!(Oe=Te()).done;)for(var rt=Oe.value,pt=N(rt),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=it,Ae.parser=it.parse,Ae.Renderer=Me,Ae.TextRenderer=Ne,Ae.Lexer=Pe,Ae.lexer=Pe.lex,Ae.Tokenizer=xe,Ae.Slugger=Qe,Ae.parse=Ae;var Ue=Ae;return Ue})},ELLl:function(Et,at,re){(function(ie){ie(re("VrN/"))})(function(ie){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=ie.Pos;ie.defineOption("autoCloseBrackets",!1,function(A,E,u){u&&u!=ie.Init&&(A.removeKeyMap(N),A.state.closeBrackets=null),E&&(P(V(E,"pairs")),A.state.closeBrackets=E,A.addKeyMap(N))});function V(A,E){return E=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[E]!=null?A[E]:$[E]}var N={Backspace:M,Enter:O};function P(A){for(var E=0;E<A.length;E++){var u=A.charAt(E),o="'"+u+"'";N[o]||(N[o]=H(u))}}P($.pairs+"`");function H(A){return function(E){return C(E,A)}}function W(A){var E=A.state.closeBrackets;if(!E||E.override)return E;var u=A.getModeAt(A.getCursor());return u.closeBrackets||E}function M(A){var E=W(A);if(!E||A.getOption("disableInput"))return ie.Pass;for(var u=V(E,"pairs"),o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return ie.Pass;var h=k(A,o[l].head);if(!h||u.indexOf(h)%2!=0)return ie.Pass}for(var l=o.length-1;l>=0;l--){var w=o[l].head;A.replaceRange("",D(w.line,w.ch-1),D(w.line,w.ch+1),"+delete")}}function O(A){var E=W(A),u=E&&V(E,"explode");if(!u||A.getOption("disableInput"))return ie.Pass;for(var o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return ie.Pass;var h=k(A,o[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"),o=A.listSelections();for(var g=0;g<o.length;g++){var m=o[g].head.line;A.indentLine(m,null,!0),A.indentLine(m+1,null,!0)}})}function v(A){var E=ie.cmpPos(A.anchor,A.head)>0;return{anchor:new D(A.anchor.line,A.anchor.ch+(E?-1:1)),head:new D(A.head.line,A.head.ch+(E?1:-1))}}function C(A,E){var u=W(A);if(!u||A.getOption("disableInput"))return ie.Pass;var o=V(u,"pairs"),l=o.indexOf(E);if(l==-1)return ie.Pass;for(var h=V(u,"closeBefore"),w=V(u,"triples"),g=o.charAt(l+1)==E,m=A.listSelections(),L=l%2==0,x,f=0;f<m.length;f++){var p=m[f],d=p.head,a,b=A.getRange(d,D(d.line,d.ch+1));if(L&&!p.empty())a="surround";else if((g||!L)&&b==E)g&&_(A,d)?a="both":w.indexOf(E)>=0&&A.getRange(d,D(d.line,d.ch+3))==E+E+E?a="skipThree":a="skip";else if(g&&d.ch>1&&w.indexOf(E)>=0&&A.getRange(D(d.line,d.ch-2),d)==E+E){if(d.ch>2&&/\bstring/.test(A.getTokenTypeAt(D(d.line,d.ch-2))))return ie.Pass;a="addFour"}else if(g){var y=d.ch==0?" ":A.getRange(D(d.line,d.ch-1),d);if(!ie.isWordChar(b)&&y!=E&&!ie.isWordChar(y))a="both";else return ie.Pass}else if(L&&(b.length===0||/\s/.test(b)||h.indexOf(b)>-1))a="both";else return ie.Pass;if(!x)x=a;else if(x!=a)return ie.Pass}var T=l%2?o.charAt(l-1):E,I=l%2?E:o.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]=v(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,E){var u=A.getRange(D(E.line,E.ch-1),D(E.line,E.ch+1));return u.length==2?u:null}function _(A,E){var u=A.getTokenAt(D(E.line,E.ch+1));return/\bstring/.test(u.type)&&u.start==E.ch&&(E.ch==0||!/\bstring/.test(A.getTokenTypeAt(E)))}})},F8wB:function(Et,at,re){Et.exports={loading:"loading___1SIOG"}},Gytx:function(Et,at){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 W=Object.prototype.hasOwnProperty.bind($),M=0;M<P.length;M++){var O=P[M];if(!W(O))return!1;var v=ie[O],C=$[O];if(N=D?D.call(V,v,C,O):void 0,N===!1||N===void 0&&v!==C)return!1}return!0}},HV1I:function(Et,at,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,at,re){},LdHM:function(Et,at,re){"use strict";re.d(at,"b",function(){return h}),re.d(at,"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"),W=re("ODXe"),M=re("4IlW"),O=re("bX4T"),v=re("YrtM"),C=re("TSYQ"),k=re.n(C),_=re("+nKL"),A=re("8OUc"),E=function(q,ne){var ce=q.prefixCls,ve=q.id,ke=q.flattenOptions,xe=q.childrenAsData,Ce=q.values,Se=q.searchValue,Ee=q.multiple,me=q.defaultActiveFirstOption,se=q.height,De=q.itemHeight,ze=q.notFoundContent,He=q.open,qe=q.menuItemSelectedIcon,Ke=q.virtual,Le=q.onSelect,Pe=q.onToggleOpen,je=q.onActiveValue,Xe=q.onScroll,Ge=q.onMouseEnter,Me="".concat(ce,"-item"),Ne=Object(v.a)(function(){return ke},[He,ke],function(Ue,ge){return ge[0]&&Ue[1]!==ge[1]}),Qe=N.useRef(null),Je=function(ge){ge.preventDefault()},Ye=function(ge){Qe.current&&Qe.current.scrollTo({index:ge})},it=function(ge){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Ne.length,ee=0;ee<fe;ee+=1){var te=(ge+ee*de+fe)%fe,ae=Ne[te],ue=ae.group,pe=ae.data;if(!ue&&!pe.disabled)return te}return-1},st=N.useState(function(){return it(0)}),et=Object(W.a)(st,2),tt=et[0],we=et[1],ut=function(ge){we(ge);var de=Ne[ge];if(!de){je(null,-1);return}je(de.data.value,ge)};N.useEffect(function(){ut(me!==!1?it(0):-1)},[Ne.length,Se]),N.useEffect(function(){var Ue=setTimeout(function(){if(!Ee&&He&&Ce.size===1){var ge=Array.from(Ce)[0],de=Ne.findIndex(function(fe){var ee=fe.data;return ee.value===ge});ut(de),Ye(de)}});return function(){return clearTimeout(Ue)}},[He]);var nt=function(ge){ge!==void 0&&Le(ge,{selected:!Ce.has(ge)}),Ee||Pe(!1)};if(N.useImperativeHandle(ne,function(){return{onKeyDown:function(ge){var de=ge.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=it(tt+fe,fe);Ye(ee),ut(ee)}break}case M.a.ENTER:{var te=Ne[tt];te&&!te.data.disabled?nt(te.data.value):nt(void 0),He&&ge.preventDefault();break}case M.a.ESC:Pe(!1)}},onKeyUp:function(){},scrollTo:function(ge){Ye(ge)}}}),Ne.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Me,"-empty"),onMouseDown:Je},ze);function Ae(Ue){var ge=Ne[Ue];if(!ge)return null;var de=ge.data||{},fe=de.value,ee=de.label,te=de.children,ae=Object(O.a)(de,!0),ue=xe?te:ee;return ge?N.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},ae,{key:Ue,role:"option",id:"".concat(ve,"_list_").concat(Ue),"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(tt-1),Ae(tt),Ae(tt+1)),N.createElement(_.a,{itemKey:"key",ref:Qe,data:Ne,height:se,itemHeight:De,fullHeight:!1,onMouseDown:Je,onScroll:Xe,virtual:Ke,onMouseEnter:Ge},function(Ue,ge){var de,fe=Ue.group,ee=Ue.groupOption,te=Ue.data,ae=te.label,ue=te.key;if(fe)return N.createElement("div",{className:k()(Me,"".concat(Me,"-group"))},ae!==void 0?ae:ue);var pe=te.disabled,Te=te.value,Oe=te.title,rt=te.children,pt=te.style,dt=te.className,Lt=Object(H.a)(te,["disabled","value","title","children","style","className"]),Tt=Ce.has(Te),ht="".concat(Me,"-option"),Bt=k()(Me,ht,dt,(de={},Object(P.a)(de,"".concat(ht,"-grouped"),ee),Object(P.a)(de,"".concat(ht,"-active"),tt===ge&&!pe),Object(P.a)(de,"".concat(ht,"-disabled"),pe),Object(P.a)(de,"".concat(ht,"-selected"),Tt),de)),Ct=xe?rt:ae,_t=!qe||typeof qe=="function"||Tt;return N.createElement("div",Object.assign({},Lt,{"aria-selected":Tt,className:Bt,title:Oe,onMouseMove:function(){if(tt===ge||pe)return;ut(ge)},onClick:function(){pe||nt(Te)},style:pt}),N.createElement("div",{className:"".concat(ht,"-content")},Ct||Te),N.isValidElement(qe)||Tt,_t&&N.createElement(A.a,{className:"".concat(Me,"-option-state"),customizeIcon:qe,customizeIconProps:{isSelected:Tt}},Tt?"\u2713":null))}))},u=N.forwardRef(E);u.displayName="OptionList";var o=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(j){var q=j.key,ne=j.props,ce=ne.children,ve=ne.value,ke=Object(H.a)(ne,["children","value"]);return Object(m.a)({key:q,value:ve!==void 0?ve:q,children:ce},ke)}function f(j){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(j).map(function(ne,ce){if(!N.isValidElement(ne)||!ne.type)return null;var ve=ne.type.isSelectOptGroup,ke=ne.key,xe=ne.props,Ce=xe.children,Se=Object(H.a)(xe,["children"]);return q||!ve?x(ne):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(ke===null?ce:ke,"__"),label:ke},Se),{},{options:f(Ce)})}).filter(function(ne){return ne})}var p=re("2Qr1"),d=re("qNPg"),a=re("U8pU"),b=re("Kwbf"),y=re("WKfj");function T(j){var q=j.mode,ne=j.options,ce=j.children,ve=j.backfill,ke=j.allowClear,xe=j.placeholder,Ce=j.getInputElement,Se=j.showSearch,Ee=j.onSearch,me=j.defaultOpen,se=j.autoFocus,De=j.labelInValue,ze=j.value,He=j.inputValue,qe=j.optionLabelProp,Ke=q==="multiple"||q==="tags",Le=Se!==void 0?Se:Ke||q==="combobox",Pe=ne||f(ce);if(Object(b.a)(q!=="tags"||Pe.every(function(Me){return!Me.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var je=Pe.some(function(Me){return Me.options?Me.options.some(function(Ne){return typeof("value"in Ne?Ne.value:Ne.key)=="number"}):typeof("value"in Me?Me.value:Me.key)=="number"});Object(b.a)(!je,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(q!=="combobox"||!qe,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(b.a)(q==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(b.b)(q!=="combobox"||!Ce||!ke||!xe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ee&&!Le&&q!=="combobox"&&q!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!me||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),ze!=null){var Xe=Object(y.d)(ze);Object(b.a)(!De||Xe.every(function(Me){return Object(a.a)(Me)==="object"&&("key"in Me||"value"in Me)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Ke||Array.isArray(ze),"`value` should be array when `mode` is `multiple` or `tags`")}if(ce){var Ge=null;Object(L.a)(ce).some(function(Me){if(!N.isValidElement(Me)||!Me.type)return!1;var Ne=Me.type;if(Ne.isSelectOption)return!1;if(Ne.isSelectOptGroup){var Qe=Object(L.a)(Me.props.children).every(function(Je){return!N.isValidElement(Je)||!Me.type||Je.type.isSelectOption?!0:(Ge=Je.type,!1)});return!Qe}return Ge=Ne,!0}),Ge&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Ge.displayName||Ge.name||Ge,"`.")),Object(b.a)(He===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var I=T,G=Object(d.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:I,fillOptionsWithMissingValue:p.a}),X=function(j){Object(D.a)(ne,j);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=at.c=J},Ly88:function(Et,at,re){"use strict";re.r(at);var ie=re("14J3"),$=re("BMrR"),D=re("jCWc"),V=re("kPKH"),N=re("OaEy"),P=re("2fM7"),H=re("7Kak"),W=re("9yH6"),M=re("5NDa"),O=re("5rEg"),v=re("2qtc"),C=re("kLXV"),k=re("miYZ"),_=re("tsqr"),A=re("9og8"),E=re("k1fw"),u=re("y8nQ"),o=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"),a=re.n(d),b=re("LvDl"),y=re.n(b),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]},j=function(ne){var ce,ve,ke,xe=ne.shixunsDetail,Ce=ne.dispatch,Se=ne.match,Ee=ne.practiceSetting,me=Object(h.a)(ne,["shixunsDetail","dispatch","match","practiceSetting"]),se=o.a.useForm(),De=Object(l.a)(se,1),ze=De[0],He=Object(m.useState)({}),qe=Object(l.a)(He,2),Ke=qe[0],Le=qe[1],Pe=Object(m.useState)([100,200]),je=Object(l.a)(Pe,2),Xe=je[0],Ge=je[1],Me=xe.challengesNew,Ne=Object(m.useState)(),Qe=Object(l.a)(Ne,2),Je=Qe[0],Ye=Qe[1],it=Object(m.useState)(),st=Object(l.a)(it,2),et=st[0],tt=st[1],we=Object(m.useState)(!0),ut=Object(l.a)(we,2),nt=ut[0],Ae=ut[1],Ue=Object(m.useState)(1),ge=Object(l.a)(Ue,2),de=ge[0],fe=ge[1],ee=Object(m.useRef)({subject:"",difficulty:1,score:100,task_pass:Object(X.a)(Me.task_pass_default)}),te=Object(m.useRef)(null),ae=Ee.selectQuestionParams,ue=Ee.id,pe=Ee.newQuestion;Object(m.useEffect)(function(){Se.params.challengesId?(tt(!0),Te()):(Ae(!0),tt(!1),Ce({type:"shixunsDetail/getChallengesNew",payload:Object(E.a)({},Se.params)}),Ae(!1)),setTimeout(function(){document.getElementById("practice-scroll").scrollTo(0,0)},300)},[Se.params]),Object(m.useEffect)(function(){return Tt(),function(){clearTimeout(te.current)}},[Ke]);var Te=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:Se.params.id,challengeId:Se.params.challengesId,tab:0});case 3:Dt=Zt.sent,Dt&&(mt=Object(E.a)(Object(E.a)({},Dt),{},{task_pass:Object(X.a)(Dt.task_pass)}),Ye(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),ze.setFieldsValue(Object(E.a)({},Dt)),Le(Object(E.a)({},Dt))},rt=function(_t){var Dt=z[_t],mt=Dt==null?void 0:Dt[0];Ge(Dt),ze.setFieldsValue({score:mt}),Le(Object(E.a)(Object(E.a)({},ze.getFieldsValue()),{score:mt}))},pt=function(_t,Dt){Le(Object(E.a)({},ze.getFieldsValue())),"difficulty"in _t&&rt(_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]:{},!(!et&&((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(!et){Kt.next=10;break}return Kt.next=7,Object(p.Mb)(Object(E.a)(Object(E.a)({},Se.params),{},{tab:0,challenge:Object(E.a)({},mt),challenge_tag:mt.challenge_tag}));case 7:return or=Kt.sent,or&&(Ce({type:"practiceSetting/setUpdateIndex"}),x.d.replace("/shixuns/".concat(Se.params.id,"/edit/").concat(Se.params.challengesId,"/tab=2"))),Kt.abrupt("return");case 10:return Zt=Object(E.a)({},Ke),Zt.identifier=Se.params.id,Zt.st=0,Kt.next=15,Object(p.b)(Object(E.a)({},Zt));case 15:vt=Kt.sent,vt.status===1&&(x.d.replace("/shixuns/".concat(Se.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(ht,500)},ht=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(b.isNumber)(Ke[mt])?String(Ke[mt]):Ke[mt],Zt=Object(b.isNumber)(ee.current[mt])?String(ee.current[mt]):ee.current[mt];return!Object(b.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:a.a.bg,id:"practice-scroll"},L.a.createElement(o.a,{key:de,form:ze,className:a.a.formWrap,scrollToFirstError:!0,layout:"vertical",onValuesChange:pt,onFinish:dt},L.a.createElement(G.a,{activeIndex:0,isEdit:et}),L.a.createElement(o.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(o.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:Se.params.challengesId||"3",watch:!0,defaultValue:et?Je==null?void 0:Je.task_pass:Me.task_pass_default})),L.a.createElement(o.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(W.a.Group,{disabled:((ve=xe.detail)===null||ve===void 0?void 0:ve.shixun_status)===2},L.a.createElement(W.a,{value:1},"\u7B80\u5355"),L.a.createElement(W.a,{style:{marginLeft:70},value:2},"\u4E2D\u7B49"),L.a.createElement(W.a,{style:{marginLeft:70},value:3},"\u56F0\u96BE"))),L.a.createElement(o.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(o.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:((ke=xe.detail)===null||ke===void 0?void 0:ke.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 ze.submit()},className:"customFixedButton",onCancel:Lt}),L.a.createElement(I.a,{loading:nt}))};at.default=Object(x.a)(function(q){var ne=q.shixunsDetail,ce=q.newCourse,ve=q.globalSetting,ke=q.practiceSetting;return{shixunsDetail:ne,newCourse:ce,globalSetting:ve,practiceSetting:ke}})(j)},M8RZ:function(Et,at,re){"use strict";re.d(at,"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"),W=re.n(H),M=function(O){Object(D.a)(C,O);var v=Object(V.a)(C);function C(k){var _;Object(ie.a)(this,C),_=v.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,at,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,E=k.id,u=k.overlayInnerStyle;return V.createElement("div",{className:"".concat(A,"-inner"),id:E,role:"tooltip",style:u},typeof _=="function"?_():_)},W=H,M=function(k,_){var A=k.overlayClassName,E=k.trigger,u=E===void 0?["hover"]:E,o=k.mouseEnterDelay,l=o===void 0?0:o,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,a=k.animation,b=k.placement,y=b===void 0?"right":b,T=k.align,I=T===void 0?{}:T,G=k.destroyTooltipOnHide,X=G===void 0?!1:G,J=k.defaultVisible,z=k.getTooltipContainer,j=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,me=Ee===void 0?null:Ee,se=k.overlay,De=k.id;return[V.createElement("div",{className:"".concat(L,"-arrow"),key:"arrow"},me),V.createElement(W,{key:"content",prefixCls:L,id:De,overlay:se,overlayInnerStyle:j})]},ke=!1,xe=!1;if(typeof X=="boolean")ke=X;else if(X&&Object(ie.a)(X)==="object"){var Ce=X.keepParent;ke=Ce===!0,xe=Ce===!1}return V.createElement(N.a,Object.assign({popupClassName:A,prefixCls:L,popup:ve,action:u,builtinPlacements:P.a,popupPlacement:y,ref:ne,popupAlign:I,getPopupContainer:z,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:d,popupAnimation:a,defaultPopupVisible:J,destroyPopupOnHide:ke,autoDestroy:xe,mouseLeaveDelay:w,popupStyle:g,mouseEnterDelay:l},ce),x)},O=Object(V.forwardRef)(M),v=at.a=O},Ot1p:function(Et,at,re){"use strict";var ie=re("2qtc"),$=re("kLXV"),D=re("rAM+"),V=re("miYZ"),N=re("tsqr"),P=re("9og8"),H=re("tJVT"),W=re("jrin"),M=re("WmNS"),O=re.n(M),v=re("q1tI"),C=re.n(v),k=re("VrN/"),_=re.n(k),A=re("bdgK"),E=re("p77/"),u=re("Bd2K"),o=re("ELLl"),l=re("19Vz"),h=re("lZu9"),w=re("+NIl"),g=re("kSUc"),m=re("9Bee"),L=function(pe){var Te=pe.value,Oe=Te===void 0?"":Te,rt=pe.className,pt=pe.showTextOnly,dt=pe.showLines,Lt=pe.style,Tt=Lt===void 0?{}:Lt,ht=Object(v.useMemo)(function(){return""},[Oe]);return C.a.createElement(C.a.Fragment,null,C.a.createElement("div",{dangerouslySetInnerHTML:{__html:ht}}))},x=re("0Owb"),f=re("dejd"),p=re("C+DQ"),d=re("1vsH"),a=re("m3rI"),b=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function y(pe){var Te=pe.onActionCallback,Oe=pe.title,rt=pe.icon,pt=pe.actionName,dt=pe.className,Lt=dt===void 0?"":dt,Tt=pe.children;function ht(){Te(pt)}return C.a.createElement("a",{title:Oe,className:Lt,onClick:ht},C.a.createElement("i",{className:"md-iconfont ".concat(rt)}),Tt)}var T=function(pe){var Te=pe.watch,Oe=pe.showNullButton,rt=pe.onActionCallback,pt=pe.fullScreen,dt=pe.insertTemp,Lt=pe.hidetoolBar,Tt=pe.uuid,ht=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(a.a.PROXY_SERVER)));var Bt=[].concat(b,[{title:"".concat(Te?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Te?"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(y,Object(x.a)({},Ct,{onActionCallback:rt})):C.a.createElement("span",{className:"v-line"}))}),Oe?C.a.createElement("li",null,C.a.createElement(y,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:rt},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(y,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(dt),onActionCallback:rt},C.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),C.a.createElement("li",{className:"btn-full-screen"},C.a.createElement(y,{icon:"".concat(pt?"icon-shrink":"icon-enlarge"),title:pt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:rt})))},I=re("M8RZ"),G=re("+L6B"),X=re("2/Rp"),J=re("y8nQ"),z=re("Vl3Y"),j=re("5NDa"),q=re("5rEg"),ne={labelCol:{span:4},wrapperCol:{span:20}},ce=function(pe){var Te=pe.callback,Oe=pe.onCancel;function rt(pt){Te(pt)}return C.a.createElement(z.a,Object(x.a)({},ne,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:rt}),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"),ke=re("HmJG"),xe=re("BjJ7"),Ce=z.a.useForm,Se={width:280,marginRight:10},Ee={labelCol:{span:5},wrapperCol:{span:19}},me=function(pe){var Te=pe.callback,Oe=pe.onCancel,rt=Ce(),pt=Object(H.a)(rt,1),dt=pt[0];function Lt(Bt){Te(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 ht(Bt){var Ct=Bt.target.files[0];De(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:Se})),C.a.createElement(se,{onFileChange:ht}))),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 Te=pe.onFileChange;return C.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",C.a.createElement("input",{type:"file",onChange:Te}))}function De(pe,Te){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 rt=new window.XMLHttpRequest;rt.withCredentials=!0,rt.addEventListener("load",function(pt){Te(JSON.parse(pt.target.responseText),pe)},!1),rt.addEventListener("error",function(pt){console.error(pt)},!1),rt.open("POST","".concat(xe.a,"/api/attachments.json")),rt.send(Oe)}var ze=re("giR+"),He=re("fyUT"),qe=re("7Kak"),Ke=re("9yH6"),Le=Ke.a.Group,Pe={margin:"0 8px"},je=function(pe){var Te=pe.callback,Oe=pe.onCancel;function rt(pt){Te(pt)}return C.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:rt},C.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},C.a.createElement("span",{style:Pe},"\u5355\u5143\u683C\u6570\uFF1A"),C.a.createElement("span",{style:Pe},"\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:Pe},"\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:Pe},"\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"),Me="link",Ne="upload-image",Qe="code-block",Je="add-table",Ye="------------",it={default:Ye,left:":".concat(Ye),center:":".concat(Ye,":"),right:"".concat(Ye,":")},st=re("9VGf"),et,tt;function we(){}var ut=0,nt=1e4,Ae="\u2581",Ue=`
|
|
**\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 ge(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=(et={},Object(W.a)(et,fe+"-B","bold"),Object(W.a)(et,fe+"-I","italic"),et),ae=(tt={},Object(W.a)(tt,Me,"\u6DFB\u52A0\u94FE\u63A5"),Object(W.a)(tt,Qe,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(W.a)(tt,Ne,"\u6DFB\u52A0\u6587\u4EF6"),Object(W.a)(tt,Je,"\u6DFB\u52A0\u8868\u683C"),tt),ue=at.a=function(pe){var Te=pe.defaultValue,Oe=Te===void 0?"":Te,rt=pe.onChange,pt=pe.width,dt=pt===void 0?"100%":pt,Lt=pe.height,Tt=Lt===void 0?400:Lt,ht=pe.miniToolbar,Bt=ht===void 0?!1:ht,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,Ur=pe.noStorage,ci=Ur===void 0?!1:Ur,qr=pe.showNullButton,Ut=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,Fr=pe.onCMBeforeChange,Vr=pe.onFullScreen,fi=pe.className,Fe=fi===void 0?"":fi,wt=pe.disablePaste,pi=wt===void 0?!1:wt,mi=pe.placeholder,gi=mi===void 0?"":mi,vi=pe.values,F=vi===void 0?"":vi,s=Object(v.useState)(null),c=Object(H.a)(s,2),R=c[0],Z=c[1],U=Object(v.useState)(Oe),he=Object(H.a)(U,2),Re=he[0],Ve=he[1],ft=Object(v.useState)(Dt),Ie=Object(H.a)(ft,2),bt=Ie[0],Ft=Ie[1],Yt=Object(v.useState)(yr),Mr=Object(H.a)(Yt,2),br=Mr[0],xr=Mr[1],Xr=Object(v.useState)(""),Ri=Object(H.a)(Xr,2),lr=Ri[0],jr=Ri[1],oi=Object(v.useState)(0),si=Object(H.a)(oi,2),Ir=si[0],Oi=si[1],yi=Object(v.useState)(Tt),zi=Object(H.a)(yi,2),Ki=zi[0],Yr=zi[1],zr=Object(v.useState)(!1),bi=Object(H.a)(zr,2),dn=bi[0],xi=bi[1],qt=Object(v.useRef)(Object(Ge.a)()),jt=Object(v.useRef)(!1),pr=Object(v.useRef)(),Pt=Object(v.useRef)(),tr=Object(v.useRef)(),Gt=Object(v.useRef)(),ti=Object(v.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(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):It.content_type.indexOf("pdf")>-1?R.replaceSelection('<a href="'.concat(a.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(a.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(v.useEffect)(function(){Ve(F),R==null||R.setValue(F)},[F]),Object(v.useEffect)(function(){Vr==null||Vr(br)},[br]),Object(v.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();De(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(a.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(a.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(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(a.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();De(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(a.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(a.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(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(a.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(v.useCallback)(function(){if(tr.current)try{}catch(gt){console.log(gt,"---- to set md editor body height")}},[Ki,tr,br]);Object(v.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(v.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(W.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(v.useEffect)(function(){yr!==br&&xr(yr)},[yr]),Object(st.a)(function(){if(!ci&&Ir>0){var gt=new Date().getTime(),At=window.sessionStorage.getItem(vr);gt>=Ir+nt&&(!At||At!==Re)&&(window.sessionStorage.setItem(vr,Re),xi(!0))}},nt),Object(v.useEffect)(function(){Ft(Dt)},[R,Dt]),Object(v.useEffect)(function(){R&&(_t&&R.focus())},[R,_t]),Object(v.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(v.useEffect)(function(){if(R&&Fr){function gt(At,xt){Fr(At,xt)}return R.on("beforeChange",gt),function(){R.off("beforeChange",gt)}}},[R,Fr]),Object(v.useEffect)(function(){if(R&&Ot){function gt(){Ot(R.getValue())}return R.on("blur",gt),function(){R.off("blur",gt)}}},[R,Ot]),Object(v.useEffect)(function(){if(R){function gt(At){var xt=At.getValue();Ve(xt),Oi(new Date().getTime()),At.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),rt&&rt(xt)}return R.on("change",gt),function(){R.off("change",gt)}}},[R,rt]),Object(v.useEffect)(function(){R&&(Oe==null?(R.setValue(""),Ve("")):Oe!==R.getValue()&&(R.setValue(Oe),Ve(Oe),R.setCursor(R.lineCount(),0)))},[R,Oe]);var Vi=Object(v.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(Ue),R.focus();case"eraser":return R.setValue(""),R.focus();case"trigger-watch":return Ft(!bt),R.focus();case"trigger-full-screen":return xr(!br),R.focus();case Me:jr(Me);return;case Qe:jr(Qe);return;case Ne:jr(Ne);return;case Je:jr(Je);return;default:throw new Error}},[R,bt,br]),Ei=Object(v.useCallback)(function(gt){jr("");switch(lr){case Me:var At=gt.title,xt=gt.link;return R.replaceSelection("[".concat(At,"](").concat(xt,")")),R.focus();case Qe:var Rt=gt.language,Nt=gt.content;return R.replaceSelection(["```"+Rt,Nt,"```"].join(`
|
|
`)),R.focus();case Ne:var Vt=gt.src,It=gt.alt;return It?R.replaceSelection(".concat(Vt,' "').concat(It,'" )')):R.replaceSelection("")),R.focus();case Je: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(it[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(v.useMemo)(function(){switch(lr){case Me:return C.a.createElement(ce,{callback:Ei,onCancel:Si});case Qe:return C.a.createElement(ve.b,{callback:Ei,onCancel:Si});case Ne:return C.a.createElement(me,{callback:Ei,onCancel:Si});case Je:return C.a.createElement(je,{callback:Ei,onCancel:Si});default:return null}},[lr]);function Si(){jr("")}Object(v.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(v.useEffect)(function(){Yr(Tt)},[Tt]);var ri=ge(dt),fn=ge(Ki),$r={width:ri,height:fn},pn=Object(v.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),Ve(xt),R==null||R.setValue(xt)}return C.a.createElement(v.Fragment,null,C.a.createElement("div",{className:"markdown-editor-wrapper",ref:tr},C.a.createElement("div",{className:"markdown-editor-container ".concat(Fe," ").concat(bt?"on-preview":""," ").concat(Bt?"mini":""," ").concat(br?"full-screen":""),style:$r},C.a.createElement(T,{insertTemp:mt,watch:bt,fullScreen:br,showNullButton:Ut,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,at){/**
|
|
* @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 W=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"],v=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],C=[v,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],k=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],_=[v,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],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",E=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[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,E,u,o,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",a="pln",b="tag",y="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 Pe=0,je=!1,Xe=!1,Ge=0,Me=Le.length;Ge<Me;++Ge){var Ne=Le[Ge];if(Ne.ignoreCase)Xe=!0;else if(/[a-z]/i.test(Ne.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){je=!0,Xe=!1;break}}var Qe={b:8,t:9,n:10,v:11,f:12,r:13};function Je(tt){var we=tt.charCodeAt(0);if(we!==92)return we;var ut=tt.charAt(1);return we=Qe[ut],we||("0"<=ut&&ut<="7"?parseInt(tt.substring(1),8):ut==="u"||ut==="x"?parseInt(tt.substring(2),16):tt.charCodeAt(1))}function Ye(tt){if(tt<32)return(tt<16?"\\x0":"\\x")+tt.toString(16);var we=String.fromCharCode(tt);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function it(tt){var we=tt.substring(1,tt.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")),ut=[],nt=we[0]==="^",Ae=["["];nt&&Ae.push("^");for(var Ue=nt?1:0,ge=we.length;Ue<ge;++Ue){var de=we[Ue];if(/\\[bdsw]/i.test(de))Ae.push(de);else{var fe=Je(de),ee;Ue+2<ge&&we[Ue+1]==="-"?(ee=Je(we[Ue+2]),Ue+=2):ee=fe,ut.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||ut.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||ut.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}ut.sort(function(pe,Te){return pe[0]-Te[0]||Te[1]-pe[1]});for(var te=[],ae=[],Ue=0;Ue<ut.length;++Ue){var ue=ut[Ue];ue[0]<=ae[1]+1?ae[1]=Math.max(ae[1],ue[1]):te.push(ae=ue)}for(var Ue=0;Ue<te.length;++Ue){var ue=te[Ue];Ae.push(Ye(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Ae.push("-"),Ae.push(Ye(ue[1])))}return Ae.push("]"),Ae.join("")}function st(tt){for(var we=tt.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")),ut=we.length,nt=[],Ae=0,Ue=0;Ae<ut;++Ae){var ge=we[Ae];if(ge==="(")++Ue;else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&(de<=Ue?nt[de]=-1:we[Ae]=Ye(de))}}for(var Ae=1;Ae<nt.length;++Ae)nt[Ae]===-1&&(nt[Ae]=++Pe);for(var Ae=0,Ue=0;Ae<ut;++Ae){var ge=we[Ae];if(ge==="(")++Ue,nt[Ue]||(we[Ae]="(?:");else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&de<=Ue&&(we[Ae]="\\"+nt[de])}}for(var Ae=0;Ae<ut;++Ae)we[Ae]==="^"&&we[Ae+1]!=="^"&&(we[Ae]="");if(tt.ignoreCase&&je)for(var Ae=0;Ae<ut;++Ae){var ge=we[Ae],fe=ge.charAt(0);ge.length>=2&&fe==="["?we[Ae]=it(ge):fe!=="\\"&&(we[Ae]=ge.replace(/[a-zA-Z]/g,function(ae){var ue=ae.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return we.join("")}for(var et=[],Ge=0,Me=Le.length;Ge<Me;++Ge){var Ne=Le[Ge];if(Ne.global||Ne.multiline)throw new Error(""+Ne);et.push("(?:"+st(Ne)+")")}return new RegExp(et.join("|"),Xe?"gi":"g")}function j(Le,Pe){var je=/(?:^|\s)nocode(?:\s|$)/,Xe=[],Ge=0,Me=[],Ne=0;function Qe(Je){var Ye=Je.nodeType;if(Ye==1){if(je.test(Je.className))return;for(var it=Je.firstChild;it;it=it.nextSibling)Qe(it);var st=Je.nodeName.toLowerCase();(st==="br"||st==="li")&&(Xe[Ne]=`
|
|
`,Me[Ne<<1]=Ge++,Me[Ne++<<1|1]=Je)}else if(Ye==3||Ye==4){var et=Je.nodeValue;et.length&&(Pe?et=et.replace(/\r\n?/g,`
|
|
`):et=et.replace(/[ \t\r\n]+/g," "),Xe[Ne]=et,Me[Ne<<1]=Ge,Ge+=et.length,Me[Ne++<<1|1]=Je)}}return Qe(Le),{sourceCode:Xe.join("").replace(/\n$/,""),spans:Me}}function q(Le,Pe,je,Xe,Ge){if(!je)return;var Me={sourceNode:Le,pre:1,langExtension:null,numberLines:null,sourceCode:je,spans:null,basePos:Pe,decorations:null};Xe(Me),Ge.push.apply(Ge,Me.decorations)}var ne=/\S/;function ce(Le){for(var Pe=void 0,je=Le.firstChild;je;je=je.nextSibling){var Xe=je.nodeType;Pe=Xe===1?Pe?Le:je:Xe===3&&ne.test(je.nodeValue)?Le:Pe}return Pe===Le?void 0:Pe}function ve(Le,Pe){var je={},Xe;(function(){for(var Ne=Le.concat(Pe),Qe=[],Je={},Ye=0,it=Ne.length;Ye<it;++Ye){var st=Ne[Ye],et=st[3];if(et)for(var tt=et.length;--tt>=0;)je[et.charAt(tt)]=st;var we=st[1],ut=""+we;Je.hasOwnProperty(ut)||(Qe.push(we),Je[ut]=null)}Qe.push(/[\0-\uffff]/),Xe=z(Qe)})();var Ge=Pe.length,Me=function(Ne){for(var Qe=Ne.sourceCode,Je=Ne.basePos,Ye=Ne.sourceNode,it=[Je,a],st=0,et=Qe.match(Xe)||[],tt={},we=0,ut=et.length;we<ut;++we){var nt=et[we],Ae=tt[nt],Ue=void 0,ge;if(typeof Ae=="string")ge=!1;else{var de=je[nt.charAt(0)];if(de)Ue=nt.match(de[1]),Ae=de[0];else{for(var fe=0;fe<Ge;++fe)if(de=Pe[fe],Ue=nt.match(de[1]),Ue){Ae=de[0];break}Ue||(Ae=a)}ge=Ae.length>=5&&Ae.substring(0,5)==="lang-",ge&&!(Ue&&typeof Ue[1]=="string")&&(ge=!1,Ae=T),ge||(tt[nt]=Ae)}var ee=st;if(st+=nt.length,!ge)it.push(Je+ee,Ae);else{var te=Ue[1],ae=nt.indexOf(te),ue=ae+te.length;Ue[2]&&(ue=nt.length-Ue[2].length,ae=ue-te.length);var pe=Ae.substring(5);q(Ye,Je+ee,nt.substring(0,ae),Me,it),q(Ye,Je+ee+ae,te,se(pe,te),it),q(Ye,Je+ee+ue,nt.substring(ue),Me,it)}}Ne.decorations=it};return Me}function ke(Le){var Pe=[],je=[];Le.tripleQuotedStrings?Pe.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Le.multiLineStrings?Pe.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Pe.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Le.verbatimStrings&&je.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Xe=Le.hashComments;Xe&&(Le.cStyleComments?(Xe>1?Pe.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Pe.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),je.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Pe.push([x,/^#[^\r\n]*/,null,"#"])),Le.cStyleComments&&(je.push([x,/^\/\/[^\r\n]*/,null]),je.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ge=Le.regexLiterals;if(Ge){var Me=Ge>1?"":`
|
|
\r`,Ne=Me?".":"[\\S\\s]",Qe="/(?=[^/*"+Me+"])(?:[^/\\x5B\\x5C"+Me+"]|\\x5C"+Ne+"|\\x5B(?:[^\\x5C\\x5D"+Me+"]|\\x5C"+Ne+")*(?:\\x5D|$))+/";je.push(["lang-regex",RegExp("^"+J+"("+Qe+")")])}var Je=Le.types;Je&&je.push([f,Je]);var Ye=(""+Le.keywords).replace(/^ | $/g,"");Ye.length&&je.push([L,new RegExp("^(?:"+Ye.replace(/[\s,]+/g,"|")+")\\b"),null]),Pe.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var it="^.[^\\s\\w.$@'\"`/\\\\]*";return Le.regexLiterals&&(it+="(?!s*/)"),je.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[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"],[a,/^\\[\s\S]?/,null],[d,new RegExp(it),null]),ve(Pe,je)}var xe=ke({keywords:w,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(Le,Pe,je){for(var Xe=/(?:^|\s)nocode(?:\s|$)/,Ge=/\r\n?|\n/,Me=Le.ownerDocument,Ne=Me.createElement("li");Le.firstChild;)Ne.appendChild(Le.firstChild);var Qe=[Ne];function Je(we){var ut=we.nodeType;if(ut==1&&!Xe.test(we.className))if(we.nodeName==="br")Ye(we),we.parentNode&&we.parentNode.removeChild(we);else for(var nt=we.firstChild;nt;nt=nt.nextSibling)Je(nt);else if((ut==3||ut==4)&&je){var Ae=we.nodeValue,Ue=Ae.match(Ge);if(Ue){var ge=Ae.substring(0,Ue.index);we.nodeValue=ge;var de=Ae.substring(Ue.index+Ue[0].length);if(de){var fe=we.parentNode;fe.insertBefore(Me.createTextNode(de),we.nextSibling)}Ye(we),ge||we.parentNode.removeChild(we)}}}function Ye(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function ut(Ue,ge){var de=ge?Ue.cloneNode(!1):Ue,fe=Ue.parentNode;if(fe){var ee=ut(fe,1),te=Ue.nextSibling;ee.appendChild(de);for(var ae=te;ae;ae=te)te=ae.nextSibling,ee.appendChild(ae)}return de}for(var nt=ut(we.nextSibling,0),Ae;(Ae=nt.parentNode)&&Ae.nodeType===1;)nt=Ae;Qe.push(nt)}for(var it=0;it<Qe.length;++it)Je(Qe[it]);Pe===(Pe|0)&&Qe[0].setAttribute("value",Pe);var st=Me.createElement("ol");st.className="linenums";for(var et=Math.max(0,Pe-1|0)||0,it=0,tt=Qe.length;it<tt;++it)Ne=Qe[it],Ne.className="L"+(it+et)%10,Ne.firstChild||Ne.appendChild(Me.createTextNode("\xA0")),st.appendChild(Ne);Le.appendChild(st)}function Se(Le){var Pe=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Pe=Pe&&+Pe[1]<=8;var je=/\n/g,Xe=Le.sourceCode,Ge=Xe.length,Me=0,Ne=Le.spans,Qe=Ne.length,Je=0,Ye=Le.decorations,it=Ye.length,st=0;Ye[it]=Ge;var et,tt;for(tt=et=0;tt<it;)Ye[tt]!==Ye[tt+2]?(Ye[et++]=Ye[tt++],Ye[et++]=Ye[tt++]):tt+=2;for(it=et,tt=et=0;tt<it;){for(var we=Ye[tt],ut=Ye[tt+1],nt=tt+2;nt+2<=it&&Ye[nt+1]===ut;)nt+=2;Ye[et++]=we,Ye[et++]=ut,tt=nt}it=Ye.length=et;var Ae=Le.sourceNode,Ue="";Ae&&(Ue=Ae.style.display,Ae.style.display="none");try{for(var ge=null;Je<Qe;){var de=Ne[Je],fe=Ne[Je+2]||Ge,ee=Ye[st+2]||Ge,nt=Math.min(fe,ee),te=Ne[Je+1],ae;if(te.nodeType!==1&&(ae=Xe.substring(Me,nt))){Pe&&(ae=ae.replace(je,"\r")),te.nodeValue=ae;var ue=te.ownerDocument,pe=ue.createElement("span");pe.className=Ye[st+1];var Te=te.parentNode;Te.replaceChild(pe,te),pe.appendChild(te),Me<fe&&(Ne[Je+1]=te=ue.createTextNode(Xe.substring(nt,fe)),Te.insertBefore(te,pe.nextSibling))}Me=nt,Me>=fe&&(Je+=2),Me>=ee&&(st+=2)}}finally{Ae&&(Ae.style.display=Ue)}}var Ee={};function me(Le,Pe){for(var je=Pe.length;--je>=0;){var Xe=Pe[je];Ee.hasOwnProperty(Xe)?W.console&&console.warn("cannot override language handler %s",Xe):Ee[Xe]=Le}}function se(Le,Pe){return Le&&Ee.hasOwnProperty(Le)||(Le=/^\s*</.test(Pe)?"default-markup":"default-code"),Ee[Le]}me(xe,["default-code"]),me(ve([],[[a,/^[^<?]+/],[y,/^<!\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"]),me(ve([[a,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[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"]),me(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),me(ke({keywords:C,hashComments:!0,cStyleComments:!0,types:g}),["c","cc","cpp","cxx","cyc","m"]),me(ke({keywords:"null,true,false"}),["json"]),me(ke({keywords:_,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:g}),["cs"]),me(ke({keywords:k,cStyleComments:!0}),["java"]),me(ke({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(ke({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(ke({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(ke({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(ke({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(ke({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[m,/^[\s\S]+/]]),["regex"]);function De(Le){var Pe=Le.langExtension;try{var je=j(Le.sourceNode,Le.pre),Xe=je.sourceCode;Le.sourceCode=Xe,Le.spans=je.spans,Le.basePos=0,se(Pe,Xe)(Le),Se(Le)}catch(Ge){W.console&&console.log(Ge&&Ge.stack||Ge)}}function ze(Le,Pe,je){var Xe=je||!1,Ge=Pe||null,Me=document.createElement("div");Me.innerHTML="<pre>"+Le+"</pre>",Me=Me.firstChild,Xe&&Ce(Me,Xe,!0);var Ne={langExtension:Ge,numberLines:Xe,sourceNode:Me,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return De(Ne),Me.innerHTML}function He(Le,Pe){var je=Pe||document.body,Xe=je.ownerDocument||document;function Ge(de){return je.getElementsByTagName(de)}for(var Me=[Ge("pre"),Ge("code"),Ge("xmp")],Ne=[],Qe=0;Qe<Me.length;++Qe)for(var Je=0,Ye=Me[Qe].length;Je<Ye;++Je)Ne.push(Me[Qe][Je]);Me=null;var it=Date;it.now||(it={now:function(){return+new Date}});var st=0,et=/\blang(?:uage)?-([\w.]+)(?!\S)/,tt=/\bprettyprint\b/,we=/\bprettyprinted\b/,ut=/pre|xmp/i,nt=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Ue={};function ge(){for(var de=W.PR_SHOULD_USE_CONTINUATION?it.now()+250:Infinity;st<Ne.length&&it.now()<de;st++){for(var fe=Ne[st],ee=Ue,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!==Ue||tt.test(pe))&&!we.test(pe)){for(var Te=!1,Oe=fe.parentNode;Oe;Oe=Oe.parentNode){var rt=Oe.tagName;if(Ae.test(rt)&&Oe.className&&tt.test(Oe.className)){Te=!0;break}}if(!Te){fe.className+=" prettyprinted";var pt=ee.lang;if(!pt){pt=pe.match(et);var dt;!pt&&(dt=ce(fe))&&nt.test(dt.tagName)&&(pt=dt.className.match(et)),pt&&(pt=pt[1])}var Lt;if(ut.test(fe.tagName))Lt=1;else{var Tt=fe.currentStyle,ht=Xe.defaultView,Bt=Tt?Tt.whiteSpace:ht&&ht.getComputedStyle?ht.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};De(_t)}}}st<Ne.length?W.setTimeout(ge,250):typeof Le=="function"&&Le()}ge()}var qe=W.PR={createSimpleLexer:ve,registerLangHandler:me,sourceDecorator:ke,PR_ATTRIB_NAME:I,PR_ATTRIB_VALUE:G,PR_COMMENT:x,PR_DECLARATION:y,PR_KEYWORD:L,PR_LITERAL:p,PR_NOCODE:X,PR_PLAIN:a,PR_PUNCTUATION:d,PR_SOURCE:T,PR_STRING:m,PR_TAG:b,PR_TYPE:f,prettyPrintOne:D?W.prettyPrintOne=ze:P=ze,prettyPrint:H=D?W.prettyPrint=He:H=He},Ke=W.define;typeof Ke=="function"&&Ke.amd&&Ke("google-code-prettify",[],function(){return qe})})()},UUDw:function(Et,at,re){Et.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(Et,at,re){"use strict";re.d(at,"a",function(){return ie});var ie=function(D){var V=document.createElement("textarea");return V.value=D,V.value}},"VrN/":function(Et,at,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,W=H&&(V?document.documentMode||6:+(P||N)[1]),M=!P&&/WebKit\//.test(ie),O=M&&/Qt\/\d+\.\d+/.test(ie),v=!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),E=!P&&/AppleWebKit/.test(ie)&&/Mobile\/\w+/.test(ie),u=/Android/.test(ie),o=E||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ie),l=E||/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&&W>=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 a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var S=0;S<t.length;++S)n.appendChild(t[S]);return n}function b(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var y;document.createRange?y=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:y=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()};E?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 j(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,ke={toString:function(){return"CodeMirror.Pass"}},xe={scroll:!1},Ce={origin:"*mouse"},Se={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 me=[""];function se(e){for(;me.length<=e;)me.push(De(me)+" ");return me[e]}function De(e){return e[e.length-1]}function ze(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 qe(){}function Ke(e,t){var i;return Object.create?i=Object.create(e):(qe.prototype=e,i=new qe),t&&j(t,i),i}var Le=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Pe(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Le.test(e))}function je(e,t){return t?t.source.indexOf("\\w")>-1&&Pe(e)?!0:t.test(e):Pe(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 Me(e){return e.charCodeAt(0)>=768&&Ge.test(e)}function Ne(e,t,i){for(;(i<0?t>0:t<e.length)&&Me(e.charAt(t));)t+=i;return t}function Qe(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 Je(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 Ye=null;function it(e,t,i){var r;Ye=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:Ye=n),S.from==t&&(S.from!=S.to&&i!="before"?r=n:Ye=n)}return r!=null?r:Ye}var st=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 Be=0,We=le;Be<be;++Be){var $e=ye[Be];$e=="m"?ye[Be]=We:We=$e}for(var ot=0,Ze=le;ot<be;++ot){var lt=ye[ot];lt=="1"&&Ze=="r"?ye[ot]="n":S.test(lt)&&(Ze=lt,lt=="r"&&(ye[ot]="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))),De(Tr).level==1&&(ai=Q.match(/\s+$/))&&(De(Tr).to-=ai[0].length,Tr.push(new Y(0,be-ai[0].length,be)))),oe=="rtl"?Tr.reverse():Tr}}();function et(e,t){var i=e.order;return i==null&&(i=e.order=st(e.text,t)),i}var tt=[],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]||tt).concat(i)}};function ut(e,t){return e._handlers&&e._handlers[t]||tt}function nt(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=ut(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 Ue(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 ge(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 ut(e,t).length>0}function fe(e){e.prototype.on=function(t,i){we(this,t,i)},e.prototype.off=function(t,i){nt(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 Te(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&&W<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),rt;function pt(e){if(rt==null){var t=a("span","\u200B");d(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(rt=t.offsetWidth<=1&&t.offsetHeight>2&&!(H&&W<8))}var i=rt?a("span","\u200B"):a("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=y(t,0,1).getBoundingClientRect(),r=y(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/)},ht=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Bt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ct=null;function _t(e){if(Ct!=null)return Ct;var t=d(e,a("span","x")),i=t.getBoundingClientRect(),r=y(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]={};j(t,i)}function Ur(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 Ut=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};Ut.prototype.eol=function(){return this.pos>=this.string.length},Ut.prototype.sol=function(){return this.pos==this.lineStart},Ut.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ut.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Ut.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},Ut.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Ut.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ut.prototype.skipToEnd=function(){this.pos=this.string.length},Ut.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ut.prototype.backUp=function(e){this.pos-=e},Ut.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)},Ut.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Ut.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)}},Ut.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ut.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ut.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ut.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 Fr(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 Fe(e,t,i){if(i===void 0&&(i=null),!(this instanceof Fe))return new Fe(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 Fe(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 F(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 Fe(e.first,0);var i=e.first+e.size-1;return t.line>i?Fe(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?Fe(e.line,t):i<0?Fe(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,Ur(e.mode,t.state),i,t.lookAhead):new U(e,Ur(e.mode,t),i)},U.prototype.save=function(e){var t=e!==!1?Ur(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 Be=le;be<ye;){var We=n[le];We>ye&&n.splice(le,1,ye,n[le+1],We),le+=2,be=Math.min(ye,We)}if(!_e)return;if(oe.opaque)n.splice(Be,le-Be,ye,"overlay "+_e),le=Be+2;else for(;Be<le;Be+=2){var $e=n[Be+1];n[Be+1]=($e?$e+" ":"")+"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=Ve(e,Ot(t)),n=t.text.length>e.options.maxHighlightLength&&Ur(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 Ve(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 Ut(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&Ie(n,i.state);!S.eol();)bt(n,S,i.state),S.start=S.pos}function Ie(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 Ft=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=Ve(e,t.line,i),Q=new Ut(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 Ft(Q,B,Ur(n.mode,Y.state)));return r?oe:new Ft(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 Ut(t,e.options.tabSize,r),le,be=e.options.addModeClass&&[null];for(t==""&&Mr(Ie(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=De(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 Be=Y[_e];if(Be.to!=null&&(Be.to+=oe),Be.from==null){var We=Ir(K,Be.marker);We||(Be.from=oe,Q&&(K||(K=[])).push(Be))}else Be.from+=oe,Q&&(K||(K=[])).push(Be)}K&&(K=zr(K)),Y&&Y!=K&&(Y=zr(Y));var $e=[K];if(!Q){var ot=t.text.length-2,Ze;if(ot>0&&K)for(var lt=0;lt<K.length;++lt)K[lt].to==null&&(Ze||(Ze=[])).push(new si(K[lt].marker,null,null));for(var St=0;St<ot;++St)$e.push(Ze);$e.push(Y)}return $e}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 Be=ye.markedSpans[_e].marker;Be.readOnly&&(!r||ce(r,Be)==-1)&&(r||(r=[])).push(Be)}}),!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=b("span",null,null,M?"padding-right: .1px":null),r={pre:b("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var S=n?t.rest[n-1]:t.line,B=void 0;r.pos=0,r.addToken=It,Lt(e.display.measure)&&(B=et(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=a("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&&W<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&&W<9?oe.appendChild(a("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 Be=void 0;if(be[0]==" "){var We=e.cm.options.tabSize,$e=We-e.col%We;Be=oe.appendChild(a("span",se($e),"cm-tab")),Be.setAttribute("role","presentation"),Be.setAttribute("cm-text"," "),e.col+=$e}else be[0]=="\r"||be[0]==`
|
|
`?(Be=oe.appendChild(a("span",be[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Be.setAttribute("cm-text",be[0]),e.col+=1):(Be=e.cm.options.specialCharPlaceholder(be[0]),Be.setAttribute("cm-text",be[0]),H&&W<9?oe.appendChild(a("span",[Be])):oe.appendChild(Be),e.col+=1);e.map.push(e.pos,e.pos+1,Be),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||Q||S||B){var ot=i||"";r&&(ot+=r),n&&(ot+=n);var Ze=a("span",[oe],ot,S);if(B)for(var lt in B)B.hasOwnProperty(lt)&<!="style"&<!="class"&&Ze.setAttribute(lt,B[lt]);return e.content.appendChild(Ze)}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,Be,We,$e,ot;;){if(ye==Y){_e=Be=We=be="",ot=null,$e=null,ye=Infinity;for(var Ze=[],lt=void 0,St=0;St<r.length;++St){var yt=r[St],kt=yt.marker;if(kt.type=="bookmark"&&yt.from==Y&&kt.widgetNode)Ze.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,Be=""),kt.className&&(_e+=" "+kt.className),kt.css&&(be=(be?be+";":"")+kt.css),kt.startStyle&&yt.from==Y&&(We+=" "+kt.startStyle),kt.endStyle&&yt.to==ye&&(lt||(lt=[])).push(kt.endStyle,yt.to),kt.title&&((ot||(ot={})).title=kt.title),kt.attributes)for(var Xt in kt.attributes)(ot||(ot={}))[Xt]=kt.attributes[Xt];kt.collapsed&&(!$e||pr($e.marker,kt)<0)&&($e=yt)}else yt.from>Y&&ye>yt.from&&(ye=yt.from)}if(lt)for(var cr=0;cr<lt.length;cr+=2)lt[cr+1]==ye&&(Be+=" "+lt[cr]);if(!$e||$e.from==Y)for(var Qt=0;Qt<Ze.length;++Qt)Mt(t,0,Ze[Qt]);if($e&&($e.from||0)==Y){if(Mt(t,($e.to==null?K+1:$e.to)-Y,$e.marker,$e.from==null),$e.to==null)return;$e.to==Y&&($e=!1)}}if(Y>=K)break;for(var Br=Math.min(K,ye);;){if(oe){var Rr=Y+oe.length;if(!$e){var rr=Rr>Br?oe.slice(0,Br-Y):oe;t.addToken(t,rr,le?le+_e:_e,We,Y+rr.length==ye?Be:"",be,ot)}if(Rr>=Br){oe=oe.slice(Br-Y),Y=Br;break}Y=Rr,We=""}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(De(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=ut(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=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),H&&W<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):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=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var S=t.line.gutterMarkers;if(e.options.lineNumbers||S){var B=gn(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),S)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Q=e.display.gutterSpecs[Y].className,oe=S.hasOwnProperty(Q)&&S[Q];oe&&K.appendChild(a("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=a("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,a("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,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return 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 Us(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 Fs(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=Fs(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||(Us(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&&Me(t.line.text.charAt(n.coverStart+B));)--B;for(;n.coverStart+K<n.coverEnd&&Me(t.line.text.charAt(n.coverStart+K));)++K;if(H&&W<9&&B==0&&K==n.coverEnd-n.coverStart?Q=S.parentNode.getBoundingClientRect():Q=js(y(S,B,K).getClientRects(),r),Q.left||Q.right||B==0)break;K=B,B=B-1,Y="right"}H&&W<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&&W<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,Be=(ye+_e)/2,We=t.view.measure.heights,$e=0;$e<We.length-1&&!(Be<We[$e]);$e++);var ot=$e?We[$e-1]:0,Ze=We[$e],lt={left:(Y=="right"?Q.right:Q.left)-t.rect.left,right:(Y=="left"?Q.left:Q.right)-t.rect.left,top:ot,bottom:Ze};return!Q.left&&!Q.right&&(lt.bogus=!0),e.options.singleCursorHeightPerLine||(lt.rtop=ye,lt.rbottom=_e),lt}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 v&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return v&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=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,Be){var We=ni(e,n,_e,Be?"right":"left",S);return Be?We.left=We.right:We.right=We.left,Hn(e,r,We,i)}var K=et(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,Be,We){var $e=K[Be],ot=$e.level==1;return B(We?_e-1:_e,ot!=We)}var le=it(K,Y,Q),be=Ye,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=Fe(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=Fr(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=Qe(function(B){return ni(e,i,B-1).bottom<=r},n,0);return n=Qe(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=et(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=Qe(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),Be,We,$e=!1;if(ye){var ot=r-ye.left<ye.right-r,Ze=ot==Q;_e=be+(Ze?0:1),We=Ze?"after":"before",Be=ot?ye.left:ye.right}else{!Q&&(_e==Y||_e==K)&&_e++,We=_e==0?"after":_e==t.text.length?"before":ni(e,S,_e-(Q?1:0)).bottom+B<=n==Q?"after":"before";var lt=Zr(e,Fe(i,_e,We),"line",t,S);Be=lt.left,$e=n<lt.top?-1:n>=lt.bottom?1:0}return _e=Ne(t.text,_e,1),ga(i,_e,We,$e,r-Be)}function zs(e,t,i,r,n,S,B){var K=Qe(function(le){var be=n[le],ye=be.level!=1;return ya(Zr(e,Fe(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,Fe(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,Be=ni(e,r,_e?Math.min(Q,ye.to)-1:Math.max(Y,ye.from)).right,We=Be<S?S-Be+1e9:Be-S;(!oe||le>We)&&(oe=ye,le=We)}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=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(a("br"));Ii.appendChild(document.createTextNode("x"))}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=a("span","xxxxxxxxxx"),i=a("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=Fe(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(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var S=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));S.style.display="",S.style.left=r.other.left+"px",S.style.top=r.other.top+"px",S.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,S=document.createDocumentFragment(),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(Ze,lt,St,yt){lt<0&&(lt=0),lt=Math.round(lt),yt=Math.round(yt),S.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Ze+`px;
|
|
top: `+lt+"px; width: "+(St==null?Y-Ze:St)+`px;
|
|
height: `+(yt-lt)+"px"))}function le(Ze,lt,St){var yt=ct(n,Ze),kt=yt.text.length,Xt,cr;function Qt(rr,Or){return ma(e,Fe(Ze,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=et(yt,n.direction);return Je(Rr,lt||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=lt==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),Be=ct(n,ye.line),We=Cr(_e)==Cr(Be),$e=le(be.line,be.ch,We?_e.text.length+1:null).end,ot=le(ye.line,We?0:null,ye.ch).start;We&&($e.top<ot.top-2?(oe($e.right,$e.top,null,$e.bottom),oe(K,ot.top,ot.left,ot.bottom)):oe($e.right,$e.top,ot.left-$e.right,$e.bottom)),$e.bottom<ot.top&&oe(K,$e.bottom,null,ot.top)}i.appendChild(S)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(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&&W<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=Fr(t,r),B=Fr(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<S?(S=K,B=Fr(t,$r(ct(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=B&&(S=Fr(t,$r(ct(t,Y))-e.wrapper.clientHeight),B=Y)}return{from:S,to:Math.max(B,S+1)}}function Ys(e,t){if(Ue(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=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(S),S.scrollIntoView(n),e.display.lineSpace.removeChild(S)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Fe(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Fe(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&&(Ui(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&&Ui(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 Ui(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 Fi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,H&&W<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Fi.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}},Fi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Fi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Fi.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},Fi.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)},Fi.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:Fi,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"?Ui(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&&Ui(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&&Ui(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=Ve(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?Ur(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 Be=_e.nextSibling;return M&&l&&e.display.currentWheelTarget==_e?_e.style.display="none":_e.parentNode.removeChild(_e),Be}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(a("div",[a("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(a("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=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=b("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=b("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=b("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[S],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),H&&W<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!M&&!(D&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=ka(r.gutters,r.lineNumbers),_o(n),i.init(n)}var $n=0,Wr=null;H?Wr=-.53:D?Wr=15:v?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)),Ui(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 Be=B.scrollLeft-S.wheelStartX,We=B.scrollTop-S.wheelStartY,$e=We&&S.wheelDY&&We/S.wheelDY||Be&&S.wheelDX&&Be/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!$e)return;Wr=(Wr*$n+$e)/($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?Fe(e.from.line+e.text.length-1,De(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),Fe(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?Fe(i.line,e.ch-t.ch+i.ch):Fe(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Fe(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&&De(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(ot){return i?i[ot]:null}function S(ot,Ze,lt){ua(ot,Ze,lt,r),mr(ot,"change",ot,t)}function B(ot,Ze){for(var lt=[],St=ot;St<Ze;++St)lt.push(new Pi(Q[St],n(St),r));return lt}var K=t.from,Y=t.to,Q=t.text,oe=ct(e,K.line),le=ct(e,Y.line),be=De(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 Be=B(0,Q.length-1);S(le,le.text,ye),_e&&e.remove(K.line,_e),Be.length&&e.insert(K.line,Be)}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 We=B(1,Q.length-1);We.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,We)}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 $e=B(1,Q.length-1);_e>1&&e.remove(K.line+1,_e-1),e.insert(K.line+1,$e)}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 Uo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Uo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=De(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),De(e.done);if(e.done.length&&!De(e.done).ranges)return De(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),De(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=De(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=De(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,De(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=De(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Uo(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 Fo(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&&(De(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=De(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,ge(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,Fe(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Fe(t.line-1)):null:i>0&&t.ch==(r||ct(e,t.line)).text.length?t.line<e.first+e.size-1?Fe(t.line+1,0):null:new Fe(t.line,t.ch+i)}function Xo(e){e.setSelection(Fe(e.firstLine(),0),Fe(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(Be){var We=S.changes[Be];if(We.origin=t,le&&!Yo(e,We,!1))return K.length=0,{};oe.push(Ma(e,We));var $e=Be?Ra(e,We):De(K);Ln(e,We,$e,Fo(e,We)),!Be&&e.cm&&e.cm.scrollIntoView({from:We.from,to:Ai(We)});var ot=[];Li(e,function(Ze,lt){!lt&&ce(ot,Ze.history)==-1&&(qo(Ze.history,We),ot.push(Ze.history)),Ln(Ze,We,null,Fo(Ze,We))})},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(ze(e.sel.ranges,function(n){return new Ht(Fe(n.anchor.line+t,n.anchor.ch),Fe(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:Fe(e.first,0),to:Fe(t.to.line+n,t.to.ch),text:[De(t.text)],origin:t.origin}}var S=e.lastLine();t.to.line>S&&(t={from:t.from,to:Fe(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,Fe(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&&ge(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=Fe(Q.from.line+r,Q.from.ch),Q.to=Fe(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,F(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=Fe(t?S:Ot(S),B.from),e==-1))return i;if(B.to!=null&&(r=Fe(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&&j(r,S,!1),B>0||B==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=b("span",[S.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||S.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(S.widgetNode.insertLeft=!0)),S.collapsed){if(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=j(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=De(S)}),new On(S,B)}function rs(e){return e.findMarks(Fe(e.first,0),e.clipPos(Fe(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=Fe(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=Fe(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Fe(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"?Fe(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=ze(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,Fe(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),Ue(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 Be=new FileReader;Be.onerror=function(){return K()},Be.onload=function(){var We=Be.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(We)){K();return}S[_e]=We,K()},Be.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(Ue(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!k){var i=a("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=a("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=ze(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,De(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=Ne(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ua(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Fe(t.line,r,i<0?"after":"before")}function Fa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=et(i,t.doc.direction);if(S){var B=n<0?De(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=Qe(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 Fe(r,Q,Y)}}return new Fe(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=et(t,e.doc.direction);if(!n)return Ua(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=it(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 Ua(t,i,r);var K=function($e,ot){return Ba(t,$e instanceof Fe?$e.ch:$e,ot)},Y,Q=function($e){return e.options.lineWrapping?(Y=Y||Xi(e,t),co(e,t,Y,$e)):{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 Fe(i.line,be,ye)}}var _e=function($e,ot,Ze){for(var lt=function(Xt,cr){return cr?new Fe(i.line,K(Xt,1),"before"):new Fe(i.line,Xt,"after")};$e>=0&&$e<n.length;$e+=ot){var St=n[$e],yt=ot>0==(St.level!=1),kt=yt?Ze.begin:K(Ze.end,-1);if(St.from<=kt&&kt<St.to)return lt(kt,yt);if(kt=yt?St.from:K(St.to,-1),Ze.begin<=kt&&kt<Ze.end)return lt(kt,yt)}},Be=_e(S+r,r,oe);if(Be)return Be;var We=r>0?oe.end:K(oe.begin,-1);return We!=null&&!(r>0&&We==t.text.length)&&(Be=_e(r>0?0:n.length-1,r,Q(We)),Be)?Be: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:Fe(t.head.line+1,0)}:{from:t.head,to:Fe(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Fe(t.from().line,0),to:s(e.doc,Fe(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Fe(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(Fe(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Fe(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")},Se)},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")},Se)},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},Se)},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 Fe(n.line,n.ch-1)),n.ch>0)n=new Fe(n.line,n.ch+1),e.replaceRange(S.charAt(n.ch-1)+S.charAt(n.ch-2),Fe(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 Fe(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),Fe(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)),Fa(!0,e,r,t,1)}function Il(e,t){var i=ct(e.doc,t),r=Vi(i);return r!=i&&(t=Ot(r)),Fa(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=ct(e.doc,i.line),n=et(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 Fe(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)!=ke}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 Ul(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(),Ue(t,e))return;H&&W<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)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),nt(document,"keyup",i),nt(document,"mouseover",i))}we(document,"keyup",i),we(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ue(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Ue(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(Ul(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,Un;function Wl(e,t){var i=+new Date;return Un&&Un.compare(i,e,t)?(Bn=Un=null,"triple"):Bn&&Bn.compare(i,e,t)?(Un=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Un=null,"single")}function vs(e){var t=this,i=t.display;if(Ue(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=Te(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)!=ke}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,nt(n.wrapper.ownerDocument,"mouseup",B),nt(n.wrapper.ownerDocument,"mousemove",K),nt(n.scroller,"dragstart",Y),nt(n.scroller,"drop",B),S||(ee(Q),r.addNew||Jn(e.doc,i,null,null,r.extend),M&&!k||H&&W==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(Fe(t.line,0),s(e.doc,Fe(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(Ze){if(wt(le,Ze)==0)return;if(le=Ze,r.unit=="rectangle"){for(var lt=[],St=e.options.tabSize,yt=q(ct(S,i.line).text,i.ch,St),kt=q(ct(S,Ze.line).text,Ze.ch,St),Xt=Math.min(yt,kt),cr=Math.max(yt,kt),Qt=Math.min(i.line,Ze.line),Br=Math.min(e.lastLine(),Math.max(i.line,Ze.line));Qt<=Br;Qt++){var Rr=ct(S,Qt).text,rr=Ee(Rr,Xt,St);Xt==cr?lt.push(new Ht(Fe(Qt,rr),Fe(Qt,rr))):Rr.length>rr&<.push(new Ht(Fe(Qt,rr),Fe(Qt,Ee(Rr,cr,St))))}lt.length||lt.push(new Ht(i,i)),Sr(S,Qr(e,Y.ranges.slice(0,K).concat(lt),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ze)}else{var Or=B,gr=ys(e,Ze,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 Be(Ze){var lt=++_e,St=Ni(e,Ze,!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==lt&&Be(Ze)}),150)}else{var kt=Ze.clientY<ye.top?-20:Ze.clientY>ye.bottom?20:0;kt&&setTimeout(hr(e,function(){if(_e!=lt)return;n.scroller.scrollTop+=kt,Be(Ze)}),50)}}function We(Ze){e.state.selectingText=!1,_e=Infinity,Ze&&(ee(Ze),n.input.focus()),nt(n.wrapper.ownerDocument,"mousemove",$e),nt(n.wrapper.ownerDocument,"mouseup",ot),S.history.lastSelOrigin=null}var $e=hr(e,function(Ze){Ze.buttons===0||!Te(Ze)?We(Ze):Be(Ze)}),ot=hr(e,We);e.state.selectingText=ot,we(n.wrapper.ownerDocument,"mousemove",$e),we(n.wrapper.ownerDocument,"mouseup",ot)}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=et(n);if(!S)return t;var B=it(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=it(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,Be=ye?"after":"before";return i.ch==_e&&i.sticky==Be?t:new Ht(new Fe(i.line,_e,Be),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=Fr(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(Ue(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(Fe(B,oe))}B++});for(var K=S.length-1;K>=0;K--)rn(r.doc,n,S[K],Fe(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",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!w),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,S){var 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:nt;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?j(t):{},j(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&&!o&&S.input.focus(),H&&W<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Jl(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var 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&&W<11?we(t.scroller,"dblclick",hr(e,function(Y){if(Ue(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 Ue(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(!Ue(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(Fe(oe.line,0),s(e.doc,Fe(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),Ui(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){Ue(e,Y)||ue(Y)},over:function(Y){Ue(e,Y)||(_l(e,Y),ue(Y))},start:function(Y){return Ll(e,Y)},drop:hr(e,Al),leave:function(Y){Ue(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 Fn(e,t,i,r){var n=e.doc,S;i==null&&(i="add"),i=="smart"&&(n.mode.indent?S=Ve(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==ke||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,Fe(t,0),Fe(t,Q.length),"+input"),K.stateAfter=null,!0;for(var _e=0;_e<n.sel.ranges.length;_e++){var Be=n.sel.ranges[_e];if(Be.head.line==t&&Be.head.ch<Q.length){var We=Fe(t,Q.length);Na(n,_e,new Ht(We,We));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=ze(Y,function($e){return[$e]}));for(var le=e.curOp.updateInput,be=r.ranges.length-1;be>=0;be--){var ye=r.ranges[be],_e=ye.from(),Be=ye.to();ye.empty()&&(i&&i>0?_e=Fe(_e.line,_e.ch-i):e.state.overwrite&&!K?Be=Fe(Be.line,Math.min(ct(S,Be.line).text.length,Be.ch+De(Y).length)):K&&Jr&&Jr.lineWise&&Jr.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(_e=Be=Fe(_e.line,0)));var We={from:_e,to:Be,text:Q?Q[be%Q.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};tn(e.doc,We),mr(e,"inputRead",e,We)}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=Fn(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=Fn(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:Fe(n,0),head:Fe(n+1,0)};i.push(S),t.push(e.getRange(S.anchor,S.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),E&&(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)&&Fn(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&&(Fn(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)Fn(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,Fe(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=F(S,r==null?S.first+S.size-1:r),Ve(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,Fr(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()},Se)}),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},Se),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=je(Q,Y)?function(le){return je(le,Y)}:/\s/.test(Q)?function(le){return/\s/.test(le)}:function(le){return!/\s/.test(le)&&!je(le)};B>0&&oe(S.charAt(B-1));)--B;for(;K<S.length&&oe(S.charAt(K));)++K}return new Ht(Fe(r.line,B),Fe(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:Fe(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 ot=t.line+Y;return ot<e.first||ot>=e.first+e.size?!1:(t=new Fe(ot,t.ch,t.sticky),K=ct(e,ot))}function oe(ot){var Ze;if(r=="codepoint"){var lt=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(lt)?Ze=null:Ze=new Fe(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(lt>=55296&<<56320?2:1))),-i)}else n?Ze=Ml(e.cm,K,t,i):Ze=Ua(K,t,i);if(Ze==null)if(!ot&&Q())t=Fa(n,e.cm,K,t.line,Y);else return!1;else t=Ze;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 Be=K.text.charAt(t.ch)||`
|
|
`,We=je(Be,ye)?"w":be&&Be==`
|
|
`?"n":!be||/\s/.test(Be)?null:"p";if(be&&!_e&&!We&&(We="s"),le&&le!=We){i<0&&(i=1,oe(),t.sticky="after");break}if(We&&(le=We),i>0&&!oe(!_e))break}var $e=ea(e,t,S,B,!0);return pi(S,$e)&&($e.hitSide=!0),$e}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)||Ue(r,K)||Ts(K,r))return;W<=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)||Ue(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=y(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&&v&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=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=Fe(r.line-1,ct(e.doc,r.line-1).length)),n.ch==ct(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Fe(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,Fe(B,0),Fe(Q,ct(e.doc,Q).text.length));le.length>1&&be.length>1;)if(De(le)==De(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,Be=le[0],We=be[0],$e=Math.min(Be.length,We.length);ye<$e&&Be.charCodeAt(ye)==We.charCodeAt(ye);)++ye;for(var ot=De(le),Ze=De(be),lt=Math.min(ot.length-(le.length==1?ye:0),Ze.length-(be.length==1?ye:0));_e<lt&&ot.charCodeAt(ot.length-_e-1)==Ze.charCodeAt(Ze.length-_e-1);)++_e;if(le.length==1&&be.length==1&&B==r.line)for(;ye&&ye>r.ch&&ot.charCodeAt(ot.length-_e-1)==Ze.charCodeAt(Ze.length-_e-1);)ye--,_e++;le[le.length-1]=ot.slice(0,ot.length-_e).replace(/^\u200b+/,""),le[0]=le[0].slice(ye).replace(/\u200b+$/,"");var St=Fe(B,ye),yt=Fe(Q,be.length?De(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=et(r,e.doc.direction),B="left";if(S){var K=it(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 Be=ye.getAttribute("cm-marker"),We;if(Be){var $e=e.findMarks(Fe(r,0),Fe(n+1,0),Q(+Be));$e.length&&(We=$e[0].find(0))&&le(Gr(e.doc,We.from,We.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var ot=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;ot&&oe();for(var Ze=0;Ze<ye.childNodes.length;Ze++)be(ye.childNodes[Ze]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),ot&&(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(Fe(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(Fe(Ot(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var S=e.rest?De(e.rest):e.line;return ln(Fe(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(We,$e,ot){for(var Ze=-1;Ze<(Q?Q.length:0);Ze++)for(var lt=Ze<0?Y.map:Q[Ze],St=0;St<lt.length;St+=3){var yt=lt[St+2];if(yt==We||yt==$e){var kt=Ot(Ze<0?e.line:e.rest[Ze]),Xt=lt[St]+ot;return(ot<0||yt!=We)&&(Xt=lt[St+(ot?1:0)]),Fe(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(Fe(le.line,le.ch-ye),n);ye+=be.textContent.length}for(var _e=K.previousSibling,Be=i;_e;_e=_e.previousSibling){if(le=oe(_e,_e.firstChild,-1),le)return ln(Fe(le.line,le.ch+Be),n);Be+=_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),E&&(n.style.width="0px"),we(n,"input",function(){H&&W>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),we(n,"paste",function(B){if(Ue(r,B)||Ts(B,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(B){if(Ue(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)||Ue(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&&W>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",H&&W>=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"&&(!o||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||ht(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&&W>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var S=n.charCodeAt(0);if(S==8203&&!r&&(r="\u200B"),S==8666)return this.reset(),this.cm.execCommand("undo")}for(var 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&&W>=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 Be=i.somethingSelected(),We="\u200B"+(Be?n.value:"");n.value="\u21DA",n.value=We,t.prevInput=Be?"":"\u200B",n.selectionStart=1,n.selectionEnd=We.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&&W<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),n.selectionStart!=null){(!H||H&&W<9)&&be();var Be=0,We=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?hr(i,Xo)(i):Be++<10?r.detectingSelectAll=setTimeout(We,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(We,200)}}if(H&&W>=9&&be(),L){ue(e);var _e=function(){nt(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?j(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&&(nt(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=nt,e.on=we,e.wheelEventPixels=dl,e.Doc=kr,e.splitLines=Tt,e.countColumn=q,e.findColumn=Ee,e.isWordChar=Pe,e.Pass=ke,e.signal=Ae,e.Line=Pi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Fe,e.cmpPos=wt,e.modes=Dt,e.mimeModes=mt,e.resolveMode=vt,e.getMode=vr,e.modeExtensions=sr,e.extendMode=Kt,e.copyState=Ur,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=Ut,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,at,re){"use strict";re.r(at),re.d(at,"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"),W=re("rePB"),M=re("Zm9Q"),O=re("Kwbf"),v=re("c+Xe"),C=re("m+aA"),k=re("bdgK"),_=new Map;function A(xe){xe.forEach(function(Ce){var Se,Ee=Ce.target;(Se=_.get(Ee))===null||Se===void 0||Se.forEach(function(me){return me(Ee)})})}var E=new k.default(A),u=null,o=null;function l(xe,Ce){_.has(xe)||(_.set(xe,new Set),E.observe(xe)),_.get(xe).add(Ce)}function h(xe,Ce){_.has(xe)&&(_.get(xe).delete(Ce),_.get(xe).size||(E.unobserve(xe),_.delete(xe)))}var w=function(xe){Object(V.a)(Se,xe);var Ce=Object(N.a)(Se);function Se(){return Object($.a)(this,Se),Ce.apply(this,arguments)}return Object(D.a)(Se,[{key:"render",value:function(){return this.props.children}}]),Se}(P.Component),g=P.createContext(null);function m(xe){var Ce=xe.children,Se=xe.onBatchResize,Ee=P.useRef(0),me=P.useRef([]),se=P.useContext(g),De=P.useCallback(function(ze,He,qe){Ee.current+=1;var Ke=Ee.current;me.current.push({size:ze,element:He,data:qe}),Promise.resolve().then(function(){Ke===Ee.current&&(Se==null||Se(me.current),me.current=[])}),se==null||se(ze,He,qe)},[Se,se]);return P.createElement(g.Provider,{value:De},Ce)}function L(xe){var Ce=xe.children,Se=xe.disabled,Ee=P.useRef(null),me=P.useRef(null),se=P.useContext(g),De=P.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),ze=P.isValidElement(Ce)&&Object(v.c)(Ce),He=ze?Ce.ref:null,qe=P.useMemo(function(){return Object(v.a)(He,Ee)},[He,Ee]),Ke=P.useRef(xe);Ke.current=xe;var Le=P.useCallback(function(Pe){var je=Ke.current,Xe=je.onResize,Ge=je.data,Me=Pe.getBoundingClientRect(),Ne=Me.width,Qe=Me.height,Je=Pe.offsetWidth,Ye=Pe.offsetHeight,it=Math.floor(Ne),st=Math.floor(Qe);if(De.current.width!==it||De.current.height!==st||De.current.offsetWidth!==Je||De.current.offsetHeight!==Ye){var et={width:it,height:st,offsetWidth:Je,offsetHeight:Ye};De.current=et;var tt=Je===Math.round(Ne)?Ne:Je,we=Ye===Math.round(Qe)?Qe:Ye,ut=Object(H.a)(Object(H.a)({},et),{},{offsetWidth:tt,offsetHeight:we});se==null||se(ut,Pe,Ge),Xe&&Promise.resolve().then(function(){Xe(ut,Pe)})}},[]);return P.useEffect(function(){var Pe=Object(C.a)(Ee.current)||Object(C.a)(me.current);return Pe&&!Se&&l(Pe,Le),function(){return h(Pe,Le)}},[Ee.current,Se]),P.createElement(w,{ref:me},ze?P.cloneElement(Ce,{ref:qe}):Ce)}var x="rc-observer-key";function f(xe){var Ce=xe.children,Se=Object(M.a)(Ce);return Se.map(function(Ee,me){var se=(Ee==null?void 0:Ee.key)||"".concat(x,"-").concat(me);return P.createElement(L,Object(ie.a)({},xe,{key:se}),Ee)})}f.Collection=m;var p=f,d=re("bT9E"),a=re("TSYQ"),b=re.n(a),y=`
|
|
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,Se=xe.getAttribute("id")||xe.getAttribute("data-reactid")||xe.getAttribute("name");if(Ce&&I[Se])return I[Se];var Ee=window.getComputedStyle(xe),me=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")),De=parseFloat(Ee.getPropertyValue("border-bottom-width"))+parseFloat(Ee.getPropertyValue("border-top-width")),ze=T.map(function(qe){return"".concat(qe,":").concat(Ee.getPropertyValue(qe))}).join(";"),He={sizingStyle:ze,paddingSize:se,borderSize:De,boxSizing:me};return Ce&&Se&&(I[Se]=He),He}function J(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Se=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 me=X(xe,Ce),se=me.paddingSize,De=me.borderSize,ze=me.boxSizing,He=me.sizingStyle;G.setAttribute("style","".concat(He,";").concat(y)),G.value=xe.value||xe.placeholder||"";var qe=Number.MIN_SAFE_INTEGER,Ke=Number.MAX_SAFE_INTEGER,Le=G.scrollHeight,Pe;if(ze==="border-box"?Le+=De:ze==="content-box"&&(Le-=se),Se!==null||Ee!==null){G.value=" ";var je=G.scrollHeight-se;Se!==null&&(qe=je*Se,ze==="border-box"&&(qe=qe+se+De),Le=Math.max(qe,Le)),Ee!==null&&(Ke=je*Ee,ze==="border-box"&&(Ke=Ke+se+De),Pe=Le>Ke?"":"hidden",Le=Math.min(Ke,Le))}return{height:Le,minHeight:qe,maxHeight:Ke,overflowY:Pe,resize:"none"}}var z=re("Gytx"),j=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)(Se,xe);var Ce=Object(N.a)(Se);function Se(Ee){var me;return Object($.a)(this,Se),me=Ce.call(this,Ee),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(se){me.textArea=se},me.handleResize=function(se){var De=me.state.resizeStatus,ze=me.props,He=ze.autoSize,qe=ze.onResize;if(De!==q.NONE)return;typeof qe=="function"&&qe(se),He&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var se=me.props.autoSize;if(!se||!me.textArea)return;var De=se.minRows,ze=se.maxRows,He=J(me.textArea,!1,De,ze);me.setState({textareaStyles:He,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var se=me.props,De=se.prefixCls,ze=De===void 0?"rc-textarea":De,He=se.autoSize,qe=se.onResize,Ke=se.className,Le=se.disabled,Pe=me.state,je=Pe.textareaStyles,Xe=Pe.resizeStatus,Ge=Object(d.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Me=b()(ze,Ke,Object(W.a)({},"".concat(ze,"-disabled"),Le));"value"in Ge&&(Ge.value=Ge.value||"");var Ne=Object(H.a)(Object(H.a)(Object(H.a)({},me.props.style),je),Xe===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return P.createElement(p,{onResize:me.handleResize,disabled:!(He||qe)},P.createElement("textarea",Object(ie.a)({},Ge,{className:Me,style:Ne,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:q.NONE},me}return Object(D.a)(Se,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!j()(me.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var me=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,se)}}catch(De){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Se}(P.Component),ce=ne,ve=function(xe){Object(V.a)(Se,xe);var Ce=Object(N.a)(Se);function Se(Ee){var me;Object($.a)(this,Se),me=Ce.call(this,Ee),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(De){me.resizableTextArea=De},me.handleChange=function(De){var ze=me.props.onChange;me.setValue(De.target.value,function(){me.resizableTextArea.resizeTextarea()}),ze&&ze(De)},me.handleKeyDown=function(De){var ze=me.props,He=ze.onPressEnter,qe=ze.onKeyDown;De.keyCode===13&&He&&He(De),qe&&qe(De)};var se=typeof Ee.value=="undefined"||Ee.value===null?Ee.defaultValue:Ee.value;return me.state={value:se},me}return Object(D.a)(Se,[{key:"setValue",value:function(me,se){"value"in this.props||this.setState({value:me},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return 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(me){return"value"in me?{value:me.value}:null}}]),Se}(P.Component),ke=at.default=ve},ZpRC:function(Et,at,re){"use strict";function ie(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function $(v,C){return(!C||v!=="hidden")&&v!=="visible"&&v!=="clip"}function D(v,C){if(v.clientHeight<v.scrollHeight||v.clientWidth<v.scrollWidth){var k=getComputedStyle(v,null);return $(k.overflowY,C)||$(k.overflowX,C)||function(_){var A=function(E){if(!E.ownerDocument||!E.ownerDocument.defaultView)return null;try{return E.ownerDocument.defaultView.frameElement}catch(u){return null}}(_);return!!A&&(A.clientHeight<_.scrollHeight||A.clientWidth<_.scrollWidth)}(v)}return!1}function V(v,C,k,_,A,E,u,o){return E<v&&u>C||E>v&&u<C?0:E<=v&&o<=k||u>=C&&o>=k?E-v-_:u>C&&o<k||E<v&&o>k?u-C+A:0}var N=function(v,C){var k=window,_=C.scrollMode,A=C.block,E=C.inline,u=C.boundary,o=C.skipOverflowHiddenElements,l=typeof u=="function"?u:function(je){return je!==u};if(!ie(v))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,w=[],g=v;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,o)&&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=v.getBoundingClientRect(),d=p.height,a=p.width,b=p.top,y=p.right,T=p.bottom,I=p.left,G=A==="start"||A==="nearest"?b:A==="end"?T:b+d/2,X=E==="center"?I+a/2:E==="end"?y:I,J=[],z=0;z<w.length;z++){var j=w[z],q=j.getBoundingClientRect(),ne=q.height,ce=q.width,ve=q.top,ke=q.right,xe=q.bottom,Ce=q.left;if(_==="if-needed"&&b>=0&&I>=0&&T<=L&&y<=m&&b>=ve&&T<=xe&&I>=Ce&&y<=ke)return J;var Se=getComputedStyle(j),Ee=parseInt(Se.borderLeftWidth,10),me=parseInt(Se.borderTopWidth,10),se=parseInt(Se.borderRightWidth,10),De=parseInt(Se.borderBottomWidth,10),ze=0,He=0,qe="offsetWidth"in j?j.offsetWidth-j.clientWidth-Ee-se:0,Ke="offsetHeight"in j?j.offsetHeight-j.clientHeight-me-De:0;if(h===j)ze=A==="start"?G:A==="end"?G-L:A==="nearest"?V(f,f+L,L,me,De,f+G,f+G+d,d):G-L/2,He=E==="start"?X:E==="center"?X-m/2:E==="end"?X-m:V(x,x+m,m,Ee,se,x+X,x+X+a,a),ze=Math.max(0,ze+f),He=Math.max(0,He+x);else{ze=A==="start"?G-ve-me:A==="end"?G-xe+De+Ke:A==="nearest"?V(ve,xe,ne,me,De+Ke,G,G+d,d):G-(ve+ne/2)+Ke/2,He=E==="start"?X-Ce-Ee:E==="center"?X-(Ce+ce/2)+qe/2:E==="end"?X-ke+se+qe:V(Ce,ke,ce,Ee,se+qe,X,X+a,a);var Le=j.scrollLeft,Pe=j.scrollTop;G+=Pe-(ze=Math.max(0,Math.min(Pe+ze,j.scrollHeight-ne+Ke))),X+=Le-(He=Math.max(0,Math.min(Le+He,j.scrollWidth-ce+qe)))}J.push({el:j,top:ze,left:He})}return J};function P(v){return v===Object(v)&&Object.keys(v).length!==0}function H(v,C){C===void 0&&(C="auto");var k="scrollBehavior"in document.body.style;v.forEach(function(_){var A=_.el,E=_.top,u=_.left;A.scroll&&k?A.scroll({top:E,left:u,behavior:C}):(A.scrollTop=E,A.scrollLeft=u)})}function W(v){return v===!1?{block:"end",inline:"nearest"}:P(v)?v:{block:"start",inline:"nearest"}}function M(v,C){var k=!v.ownerDocument.documentElement.contains(v);if(P(C)&&typeof C.behavior=="function")return C.behavior(k?[]:N(v,C));if(k)return;var _=W(C);return H(N(v,_),_.behavior)}var O=at.a=M},bT9E:function(Et,at,re){"use strict";re.d(at,"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,at,re){},dejd:function(Et,at,re){},dmUQ:function(Et,at,re){"use strict";var ie=re("Ff2n"),$=re("rePB"),D=re("1OyB"),V=re("vuIU"),N=re("Ji7U"),P=re("md7G"),H=re("foSv"),W=re("q1tI"),M=re.n(W),O=re("TSYQ"),v=re.n(O),C=re("4IlW");function k(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(d);a&&(y=y.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),b.push.apply(b,y)}return b}function _(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?k(Object(b),!0).forEach(function(y){Object($.a)(d,y,b[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):k(Object(b)).forEach(function(y){Object.defineProperty(d,y,Object.getOwnPropertyDescriptor(b,y))})}return d}function A(d){var a=E();return function(){var y=Object(H.a)(d),T;if(a){var I=Object(H.a)(this).constructor;T=Reflect.construct(y,arguments,I)}else T=y.apply(this,arguments);return Object(P.a)(this,T)}}function E(){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 o(d){d.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},h=200,w=600,g=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,m=function(a){return a!=null},L=function(a,b){return b===a||typeof b=="number"&&typeof a=="number"&&isNaN(b)&&isNaN(a)},x=function(d){Object(N.a)(b,d);var a=A(b);function b(y){var T;Object(D.a)(this,b),T=a.call(this,y),T.onKeyDown=function(X){var J=T.props,z=J.onKeyDown,j=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&&j&&j(X);if(T.recordCursorPosition(),T.lastKeyCode=X.keyCode,z){for(var ce=arguments.length,ve=new Array(ce>1?ce-1:0),ke=1;ke<ce;ke++)ve[ke-1]=arguments[ke];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,j=new Array(z>1?z-1:0),q=1;q<z;q++)j[q-1]=arguments[q];J.apply(void 0,[X].concat(j))}},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 j=T.input.value,q=T.getInputDisplayValue({focus:!1,value:z});T.input.value=q&&Number(q),X.apply(void 0,arguments),T.input.value=j}},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,j=J.inputValue,q=J.value,ne;z?ne=j: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 j=T.cursorBefore.length;return T.lastKeyCode===C.a.DELETE&&T.cursorBefore.charAt(j-1)===X[0]?(T.fixCaret(j,j),!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 j=X.substring(z);return T.restoreByAfter(j)})},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=y.value;I===void 0&&(I=y.defaultValue),T.state={focused:y.autoFocus};var G=T.getValidValue(T.toNumber(I));return T.state=_(_({},T.state),{},{inputValue:T.toPrecisionAsStep(G),value:G}),T}return Object(V.a)(b,[{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,j=this.state.focused;if(T){if(!L(T.value,G)||!L(T.max,J)||!L(T.min,z)){var q=j?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(ke){}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,j=this.state.inputValue,q=j===void 0?null:j,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),j=this.getPrecision(J),q=this.getPrecision(T);return T?Math.max(q,z+j):z+j}},{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 j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var q=this["".concat(T,"Step")](j,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,j=I.autoComplete,q=I.upHandler,ne=I.downHandler,ce=I.className,ve=I.max,ke=I.min,xe=I.style,Ce=I.title,Se=I.onMouseEnter,Ee=I.onMouseLeave,me=I.onMouseOver,se=I.onMouseOut,De=I.required,ze=I.onClick,He=I.tabIndex,qe=I.type,Ke=I.placeholder,Le=I.id,Pe=I.inputMode,je=I.pattern,Xe=I.step,Ge=I.maxLength,Me=I.autoFocus,Ne=I.name,Qe=I.onPaste,Je=I.onInput,Ye=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"]),it=this.state,st=it.value,et=it.focused,tt=v()(G,(T={},Object($.a)(T,ce,!!ce),Object($.a)(T,"".concat(G,"-disabled"),X),Object($.a)(T,"".concat(G,"-focused"),et),T)),we={};Object.keys(Ye).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(we[ue]=Ye[ue])});var ut=!J&&!X,nt=this.getInputDisplayValue(null),Ae=(st||st===0)&&(isNaN(st)||Number(st)>=ve),Ue=(st||st===0)&&(isNaN(st)||Number(st)<=ke),ge=Ae||X||J,de=Ue||X||J,fe=v()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object($.a)({},"".concat(G,"-handler-up-disabled"),ge)),ee=v()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object($.a)({},"".concat(G,"-handler-down-disabled"),de)),te=z?{onTouchStart:ge?u:this.up,onTouchEnd:this.stop}:{onMouseDown:ge?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:tt,style:xe,title:Ce,onMouseEnter:Se,onMouseLeave:Ee,onMouseOver:me,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":ge,className:fe}),q||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),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:o}))),M.a.createElement("div",{className:"".concat(G,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":ke,"aria-valuemax":ve,"aria-valuenow":st,required:De,type:qe,placeholder:Ke,onPaste:Qe,onClick:ze,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:He,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:ut?this.onKeyDown:u,onKeyUp:ut?this.onKeyUp:u,autoFocus:Me,maxLength:Ge,readOnly:J,disabled:X,max:ve,min:ke,step:Xe,name:Ne,title:Ce,id:Le,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(nt),pattern:je,inputMode:Pe,onInput:Je},we))))}}]),b}(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=at.a=f},fnXi:function(Et,at,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"),W=re.n(H),M=function(v){var C=v.activeIndex,k=v.isEdit,_=k===void 0?!0:k,A=v.dispatch,E=v.practiceSetting,u=Object(N.i)(),o=u.id,l=u.challengesId,h=Object(D.useMemo)(function(){return[{name:"\u672C\u5173\u4EFB\u52A1",url:"/shixuns/".concat(o,"/edit/").concat(l,"/editcheckpoint")},{name:"\u8BC4\u6D4B\u8BBE\u7F6E",url:"/shixuns/".concat(o,"/edit/").concat(l,"/tab=2")},{name:"\u53C2\u8003\u7B54\u6848",url:"/shixuns/".concat(o,"/edit/").concat(l,"/tab=3")},{name:"\u5173\u5361\u6392\u884C\u699C",url:"/shixuns/".concat(o,"/edit/").concat(l,"/tab=4")}]},[o,l]),w=function(m){var L,x=function(){P.d.push(m),A({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};E!=null&&(L=E.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)," "))};at.a=Object(P.a)(function(O){var v=O.globalSetting,C=O.practiceSetting;return{globalSetting:v,practiceSetting:C}})(M)},kSUc:function(Et,at,re){},lZu9:function(Et,at,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 j=ie.findModeByName(z);j&&(z=j.mime||j.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 W in H)H.hasOwnProperty(W)&&D.tokenTypeOverrides[W]&&(H[W]=D.tokenTypeOverrides[W]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,C=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,_=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,E=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(z,j,q){return j.f=j.inline=q,q(z,j)}function h(z,j,q){return j.f=j.block=q,q(z,j)}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 j=N;if(!j){var q=ie.innerMode(V,z.htmlState);j=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}j&&(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,j){var q=z.column()===j.indentation,ne=w(j.prevLine.stream),ce=j.indentedCode,ve=j.prevLine.hr,ke=j.list!==!1,xe=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Ce=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,ke)){for(j.list=null;Ce<j.listStack[j.listStack.length-1];)j.listStack.pop(),j.listStack.length?j.indentation=j.listStack[j.listStack.length-1]:j.list=!1;j.list!==!1&&(j.indentationDiff=Ce-j.listStack[j.listStack.length-1])}var Se=!ne&&!ve&&!j.prevLine.header&&(!ke||!ce)&&!j.prevLine.fencedCodeEnd,Ee=(j.list===!1||ve||ne)&&j.indentation<=xe&&z.match(M),me=null;if(j.indentationDiff>=4&&(ce||j.prevLine.fencedCodeEnd||j.prevLine.header||ne))return z.skipToEnd(),j.indentedCode=!0,H.code;if(z.eatSpace())return null;if(q&&j.indentation<=xe&&(me=z.match(C))&&me[1].length<=6)return j.quote=0,j.header=me[1].length,j.thisLine.header=!0,D.highlightFormatting&&(j.formatting="header"),j.f=j.inline,f(j);if(j.indentation<=xe&&z.eat(">"))return j.quote=q?1:j.quote+1,D.highlightFormatting&&(j.formatting="quote"),z.eatSpace(),f(j);if(!Ee&&!j.setext&&q&&j.indentation<=xe&&(me=z.match(O))){var se=me[1]?"ol":"ul";return j.indentation=Ce+z.current().length,j.list=!0,j.quote=0,j.listStack.push(j.indentation),j.em=!1,j.strong=!1,j.code=!1,j.strikethrough=!1,D.taskLists&&z.match(v,!1)&&(j.taskList=!0),j.f=j.inline,D.highlightFormatting&&(j.formatting=["list","list-"+se]),f(j)}else{if(q&&j.indentation<=xe&&(me=z.match(A,!0)))return j.quote=0,j.fencedEndRE=new RegExp(me[1]+"+ *$"),j.localMode=D.fencedCodeBlockHighlighting&&P(me[2]||D.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=ie.startState(j.localMode)),j.f=j.block=x,D.highlightFormatting&&(j.formatting="code-block"),j.code=-1,f(j);if(j.setext||(!Se||!ke)&&!j.quote&&j.list===!1&&!j.code&&!Ee&&!E.test(z.string)&&(me=z.lookAhead(1))&&(me=me.match(k)))return j.setext?(j.header=j.setext,j.setext=0,z.skipToEnd(),D.highlightFormatting&&(j.formatting="header")):(j.header=me[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,f(j);if(Ee)return z.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,H.hr;if(z.peek()==="[")return l(z,j,I)}return l(z,j,j.inline)}function L(z,j){var q=V.token(z,j.htmlState);if(!N){var ne=ie.innerMode(V,j.htmlState);(ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText||j.md_inside&&z.current().indexOf(">")>-1)&&(j.f=d,j.block=m,j.htmlState=null)}return q}function x(z,j){var q=j.listStack[j.listStack.length-1]||0,ne=j.indentation<q,ce=q+3;if(j.fencedEndRE&&j.indentation<=ce&&(ne||z.match(j.fencedEndRE))){D.highlightFormatting&&(j.formatting="code-block");var ve;return ne||(ve=f(j)),j.localMode=j.localState=null,j.block=m,j.f=d,j.fencedEndRE=null,j.code=0,j.thisLine.fencedCodeEnd=!0,ne?h(z,j,j.block):ve}else return j.localMode?j.localMode.token(z,j.localState):(z.skipToEnd(),H.code)}function f(z){var j=[];if(z.formatting){j.push(H.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var q=0;q<z.formatting.length;q++)j.push(H.formatting+"-"+z.formatting[q]),z.formatting[q]==="header"&&j.push(H.formatting+"-"+z.formatting[q]+"-"+z.header),z.formatting[q]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?j.push(H.formatting+"-"+z.formatting[q]+"-"+z.quote):j.push("error"))}if(z.taskOpen)return j.push("meta"),j.length?j.join(" "):null;if(z.taskClosed)return j.push("property"),j.length?j.join(" "):null;if(z.linkHref?j.push(H.linkHref,"url"):(z.strong&&j.push(H.strong),z.em&&j.push(H.em),z.strikethrough&&j.push(H.strikethrough),z.emoji&&j.push(H.emoji),z.linkText&&j.push(H.linkText),z.code&&j.push(H.code),z.image&&j.push(H.image),z.imageAltText&&j.push(H.imageAltText,"link"),z.imageMarker&&j.push(H.imageMarker)),z.header&&j.push(H.header,H.header+"-"+z.header),z.quote&&(j.push(H.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?j.push(H.quote+"-"+z.quote):j.push(H.quote+"-"+D.maxBlockquoteDepth)),z.list!==!1){var ne=(z.listStack.length-1)%3;ne?ne===1?j.push(H.list2):j.push(H.list3):j.push(H.list1)}return z.trailingSpaceNewLine?j.push("trailing-space-new-line"):z.trailingSpace&&j.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),j.length?j.join(" "):null}function p(z,j){return z.match(_,!0)?f(j):void 0}function d(z,j){var q=j.text(z,j);if(typeof q!="undefined")return q;if(j.list)return j.list=null,f(j);if(j.taskList){var ne=z.match(v,!0)[1]===" ";return ne?j.taskOpen=!0:j.taskClosed=!0,D.highlightFormatting&&(j.formatting="task"),j.taskList=!1,f(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&z.match(/^#+$/,!0))return D.highlightFormatting&&(j.formatting="header"),f(j);var ce=z.next();if(j.linkTitle){j.linkTitle=!1;var ve=ce;ce==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var ke="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(ke),!0))return H.linkHref}if(ce==="`"){var xe=j.formatting;D.highlightFormatting&&(j.formatting="code"),z.eatWhile("`");var Ce=z.current().length;if(j.code==0&&(!j.quote||Ce==1))return j.code=Ce,f(j);if(Ce==j.code){var Se=f(j);return j.code=0,Se}else return j.formatting=xe,f(j)}else if(j.code)return f(j);if(ce==="\\"&&(z.next(),D.highlightFormatting)){var Ee=f(j),me=H.formatting+"-escape";return Ee?Ee+" "+me:me}if(ce==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,D.highlightFormatting&&(j.formatting="image"),f(j);if(ce==="["&&j.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,D.highlightFormatting&&(j.formatting="image"),f(j);if(ce==="]"&&j.imageAltText){D.highlightFormatting&&(j.formatting="image");var Ee=f(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=b,Ee}if(ce==="["&&!j.image)return j.linkText&&z.match(/^.*?\]/)||(j.linkText=!0,D.highlightFormatting&&(j.formatting="link")),f(j);if(ce==="]"&&j.linkText){D.highlightFormatting&&(j.formatting="link");var Ee=f(j);return j.linkText=!1,j.inline=j.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?b:d,Ee}if(ce==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Ee=f(j);return Ee?Ee+=" ":Ee="",Ee+H.linkInline}if(ce==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Ee=f(j);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 De=z.string.substring(z.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(De)&&(j.md_inside=!0)}return z.backUp(1),j.htmlState=ie.startState(V),h(z,j,L)}if(D.xml&&ce==="<"&&z.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(ce==="*"||ce==="_"){for(var ze=1,He=z.pos==1?" ":z.string.charAt(z.pos-2);ze<3&&z.eat(ce);)ze++;var qe=z.peek()||" ",Ke=!/\s/.test(qe)&&(!u.test(qe)||/\s/.test(He)||u.test(He)),Le=!/\s/.test(He)&&(!u.test(He)||/\s/.test(qe)||u.test(qe)),Pe=null,je=null;if(ze%2&&(!j.em&&Ke&&(ce==="*"||!Le||u.test(He))?Pe=!0:j.em==ce&&Le&&(ce==="*"||!Ke||u.test(qe))&&(Pe=!1)),ze>1&&(!j.strong&&Ke&&(ce==="*"||!Le||u.test(He))?je=!0:j.strong==ce&&Le&&(ce==="*"||!Ke||u.test(qe))&&(je=!1)),je!=null||Pe!=null){D.highlightFormatting&&(j.formatting=Pe==null?"strong":je==null?"em":"strong em"),Pe===!0&&(j.em=ce),je===!0&&(j.strong=ce);var Se=f(j);return Pe===!1&&(j.em=!1),je===!1&&(j.strong=!1),Se}}else if(ce===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return f(j);z.backUp(1)}if(D.strikethrough){if(ce==="~"&&z.eatWhile(ce)){if(j.strikethrough){D.highlightFormatting&&(j.formatting="strikethrough");var Se=f(j);return j.strikethrough=!1,Se}else if(z.match(/^[^\s]/,!1))return j.strikethrough=!0,D.highlightFormatting&&(j.formatting="strikethrough"),f(j)}else if(ce===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return f(j);z.backUp(2)}}if(D.emoji&&ce===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,D.highlightFormatting&&(j.formatting="emoji");var Xe=f(j);return j.emoji=!1,Xe}return ce===" "&&(z.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),f(j)}function a(z,j){var q=z.next();if(q===">"){j.f=j.inline=d,D.highlightFormatting&&(j.formatting="link");var ne=f(j);return ne?ne+=" ":ne="",ne+H.linkInline}return z.match(/^[^>]+/,!0),H.linkInline}function b(z,j){if(z.eatSpace())return null;var q=z.next();return q==="("||q==="["?(j.f=j.inline=T(q==="("?")":"]"),D.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,f(j)):"error"}var y={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function T(z){return function(j,q){var ne=j.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 j.match(y[z]),q.linkHref=!0,f(q)}}function I(z,j){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=G,z.next(),D.highlightFormatting&&(j.formatting="link"),j.linkText=!0,f(j)):l(z,j,d)}function G(z,j){if(z.match(/^\]:/,!0)){j.f=j.inline=X,D.highlightFormatting&&(j.formatting="link");var q=f(j);return j.linkText=!1,q}return z.match(/^([^\]\\]|\\.)+/,!0),H.linkText}function X(z,j){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?j.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),j.f=j.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,j){if(j.formatting=!1,z!=j.thisLine.stream){if(j.header=0,j.hr=!1,z.match(/^\s*$/,!0))return g(j),null;if(j.prevLine=j.thisLine,j.thisLine={stream:z},j.taskList=!1,j.trailingSpace=0,j.trailingSpaceNewLine=!1,!j.localState&&(j.f=j.block,j.f!=L)){var q=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(j.indentation=q,j.indentationDiff=null,q>0)return null}}return j.f(z,j)},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,j,q){return z.block==L&&V.indent?V.indent(z.htmlState,j,q):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,j,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,at,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)};at.a=H},osHv:function(Et,at,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";var $=ie.Pos;function D(u,o){return u.line-o.line||u.ch-o.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,o,l,h){this.line=o,this.ch=l,this.cm=u,this.text=u.getLine(o),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function W(u,o){var l=u.cm.getTokenTypeAt($(u.line,o));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 v(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(M(u))continue;return}if(!W(u,o+1)){u.ch=o+1;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function C(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!W(u,o+1)){u.ch=o;continue}P.lastIndex=o,u.ch=o;var l=P.exec(u.text);if(l&&l.index==o)return l}}function k(u){for(;;){P.lastIndex=u.ch;var o=P.exec(u.text);if(!o){if(M(u))continue;return}if(!W(u,o.index+1)){u.ch=o.index+1;continue}return u.ch=o.index+o[0].length,o}}function _(u){for(;;){var o=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!W(u,o+1)){u.ch=o;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function A(u,o){for(var l=[];;){var h=k(u),w,g=u.line,m=u.ch-(h?h[0].length:0);if(!h||!(w=v(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&&(!o||o==h[2]))return{tag:h[2],from:$(g,m),to:$(u.line,u.ch)}}else l.push(h[2])}}function E(u,o){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&&(!o||o==m[2]))return{tag:m[2],from:$(u.line,u.ch),to:$(w,g)}}}}ie.registerHelper("fold","xml",function(u,o){for(var l=new H(u,o.line,0);;){var h=k(l);if(!h||l.line!=o.line)return;var w=v(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,o,l){var h=new H(u,o.line,o.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var w=v(h),g=w&&$(h.line,h.ch),m=w&&C(h);if(!w||!m||D(h,o)>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:E(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,o,l,h){for(var w=new H(u,o.line,o.ch,l);;){var g=E(w,h);if(!g)break;var m=new H(u,o.line,o.ch,l),L=A(m,g.tag);if(L)return{open:g,close:L}}},ie.scanForClosingTag=function(u,o,l,h){var w=new H(u,o.line,o.ch,h?{from:0,to:h}:null);return A(w,l)}})},p5ED:function(Et,at,re){"use strict";var ie=re("+L6B"),$=re("2/Rp"),D=re("5Dmo"),V=re("3S7+"),N=re("k1fw"),P=re("9og8"),H=re("tJVT"),W=re("WmNS"),M=re.n(W),O=re("q1tI"),v=re.n(O),C=re("vHTk"),k=re.n(C),_=re("yEEn"),A=re("ZW9T"),E=re("1vsH"),u=re("V0Rq"),o=re("m3rI");at.a=function(l){var h,w,g,m,L,x,f=l.editOffice,p=f===void 0?"view":f,d=l.data,a=l.theme,b=l.type,y=l.filename,T=l.monacoEditor,I=l.className,G=l.style,X=l.close,J=l.onClose,z=l.hasMask,j=l.disabledDownload,q=Object(O.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ne=Object(H.a)(q,2),ce=ne[0],ve=ne[1],ke=Object(O.useState)(""),xe=Object(H.a)(ke,2),Ce=xe[0],Se=xe[1],Ee=Object(O.useState)(),me=Object(H.a)(Ee,2),se=me[0],De=me[1],ze=window.ENV==="build"?"/react/build":"",He=o.a.PROXY_SERVER||location.origin,qe,Ke=1024*1024,Le=10*Ke,Pe=Object(O.useRef)();(h=d)!==null&&h!==void 0&&h.startsWith("/api")&&b!=="txt"&&(d=o.a.API_SERVER+d),b==="office"&&(qe=Object(E.T)(d).filesize,qe>Le&&(b="other")),y&&T&&(T.filename=y),Object(O.useEffect)(function(){var Me,Ne,Qe=(Me=document.cookie)===null||Me===void 0||((Ne=Me.replace(/\s/g,""))===null||Ne===void 0)?void 0:Ne.split(";");Qe==null||Qe.map(function(Je){var Ye=Je.split("=");Ye[0]==="_educoder_session"&&Se(Ye[1])})},[]),Object(O.useEffect)(function(){b==="office"&&je()},[b,d]);var je=function(){var Me=Object(P.a)(M.a.mark(function Ne(){var Qe,Je,Ye;return M.a.wrap(function(st){for(;;)switch(st.prev=st.next){case 0:return console.log("data:",d),Qe=d,d.startsWith("http")||(Qe=location.origin+Qe),Je=new URL(Qe).pathname.split("/").pop(),st.next=6,Object(u.V)({attachment_id:Je});case 6:Ye=st.sent,De(Ye);case 8:case"end":return st.stop()}},Ne)}));return function(){return Me.apply(this,arguments)}}(),Xe=function(){if(d.startsWith("http")||d.startsWith("blob:")){Ge();return}Object(E.z)(y||"educoder",d,y)},Ge=function(){Object(E.x)(y||"educoder",decodeURIComponent(d))};return v.a.createElement("div",{style:Object(N.a)({},G||{}),className:"".concat(z&&k.a.bgBlack," ").concat(b?k.a.wrp:"hide")},X&&v.a.createElement("div",{className:k.a.close,ref:Pe},!j&&v.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Pe.current}},v.a.createElement("span",{onClick:Ge},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Pe.current}},v.a.createElement("span",{className:"",onClick:J},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(k.a[I]," ").concat(I," ").concat(k.a.monaco," ").concat(b==="txt"?"show":"hide")},b==="txt"&&v.a.createElement(A.b,T)),b==="audio"&&v.a.createElement("audio",{src:"".concat(((w=d)===null||w===void 0?void 0:w.indexOf("http://"))>-1||((g=d)===null||g===void 0?void 0:g.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(d),autoPlay:!0}),b==="video"&&v.a.createElement(v.a.Fragment,null,((m=d)===null||m===void 0?void 0:m.indexOf("http"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(d),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(d),autoPlay:!0})),b==="office"&&se&&v.a.createElement("iframe",{src:"".concat(ze,"/office.html?key=").concat(se.key,"&url=").concat(He+se.url,"&callbackUrl=").concat(He+se.callbackUrl,"&fileType=").concat(se.fileType,"&title=").concat(se.title,"&model=").concat(p,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!j)}),b==="html"&&v.a.createElement("iframe",{src:d+"&disposition=inline"}),b==="pdf"&&v.a.createElement("iframe",{src:"".concat(ze,"/js/pdfview/index.html?url=").concat(d,"&disabledDownload=").concat(!!j)}),b==="image"&&v.a.createElement("img",{src:"".concat(((L=d)===null||L===void 0?void 0:L.indexOf("http://"))>-1||((x=d)===null||x===void 0?void 0:x.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(d)}),b==="other"&&v.a.createElement("div",null,v.a.createElement($.a,{type:"primary",size:"large",onClick:Xe},v.a.createElement(_.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),b==="download"&&v.a.createElement($.a,{type:"primary",size:"large",onClick:Xe},v.a.createElement(_.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(Et,at,re){},rUJ1:function(Et,at){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 W(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,a)=>(a=a.source||a,a=a.replace(M,"$1"),x=x.replace(d,a),p),getRegex:()=>new RegExp(x,f)};return p}const v=/[^\w:]/g,C=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(x,f,p){if(x){let d;try{d=decodeURIComponent(W(p)).replace(v,"").toLowerCase()}catch(a){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}f&&!C.test(p)&&(p=o(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(d){return null}return p}const _={},A=/^[^:]+:\/*[^/]*$/,E=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(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(E,"$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,(b,y,T)=>{let I=!1,G=y;for(;--G>=0&&T[G]==="\\";)I=!I;return I?"|":" |"}),d=p.split(/ \|/);let a=0;if(d.length>f)d.splice(f);else for(;d.length<f;)d.push("");for(;a<d.length;a++)d[a]=d[a].trim().replace(/\\\|/g,"|");return d}function g(x,f,p){const d=x.length;if(d===0)return"";let a=0;for(;a<d;){const b=x.charAt(d-a-1);if(b===f&&!p)a++;else if(b!==f&&p)a++;else break}return x.substr(0,d-a)}function m(x,f){if(x.indexOf(f[1])===-1)return-1;const p=x.length;let d=0,a=0;for(;a<p;a++)if(x[a]==="\\")a++;else if(x[a]===f[0])d++;else if(x[a]===f[1]&&(d--,d<0))return a;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:W,edit:O,cleanUrl:k,resolveUrl:o,noopTest:l,merge:h,splitCells:w,rtrim:g,findClosingBracket:m,checkSanitizeDeprecation:L}},ulZh:function(Et,at,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(W){return V[W]}.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(v,C,k){this.fn=v,this.context=C,this.once=k||!1}function W(v,C,k,_,A){if(typeof k!="function")throw new TypeError("The listener must be a function");var E=new H(k,_||v,A),u=N?N+C:C;return v._events[u]?v._events[u].fn?v._events[u]=[v._events[u],E]:v._events[u].push(E):(v._events[u]=E,v._eventsCount++),v}function M(v,C){--v._eventsCount===0?v._events=new P:delete v._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,E=_.length,u=new Array(E);A<E;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,E,u){var o=N?N+C:C;if(!this._events[o])return!1;var l=this._events[o],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,E),!0;case 6:return l.fn.call(l.context,k,_,A,E,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 W(this,C,k,_,!1)},O.prototype.once=function(C,k,_){return W(this,C,k,_,!0)},O.prototype.removeListener=function(C,k,_,A){var E=N?N+C:C;if(!this._events[E])return this;if(!k)return M(this,E),this;var u=this._events[E];if(u.fn)u.fn===k&&(!A||u.once)&&(!_||u.context===_)&&M(this,E);else{for(var o=0,l=[],h=u.length;o<h;o++)(u[o].fn!==k||A&&!u[o].once||_&&u[o].context!==_)&&l.push(u[o]);l.length?this._events[E]=l.length===1?l[0]:l:M(this,E)}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,W=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(O,v,C){if(C=C||{},O=O.trim(),v=v.trim(),!v){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(v);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return C.alwaysNormalize?(_.path=M.normalizePath(_.path),M.buildURLFromParts(_)):v;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 E=P.exec(A.path);A.netLoc=E[1],A.path=E[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 o=A.path,l=o.substring(0,o.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 v=N.exec(O);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(H,"");O.length!==(O=O.replace(W,"")).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 _(E){if(k[E])return k[E].exports;var u=k[E]={i:E,l:!1,exports:{}};return C[E].call(u.exports,u,u.exports,_),u.l=!0,u.exports}_.m=C,_.c=k,_.i=function(E){return E},_.d=function(E,u,o){_.o(E,u)||Object.defineProperty(E,u,{configurable:!1,enumerable:!0,get:o})},_.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},_.n=function(E){var u=E&&E.__esModule?function(){return E.default}:function(){return E};return _.d(u,"a",u),u},_.o=function(E,u){return Object.prototype.hasOwnProperty.call(E,u)},_.p="/",_.oe=function(E){throw console.error(E),E};var A=_(_.s=ENTRY_MODULE);return A.default||A}var N="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function H(C){return(C+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function W(C){return!isNaN(1*C)}function M(C,k,_){var A={};A[_]=[];var E=k.toString(),u=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return A;for(var o=u[1],l=new RegExp("(\\\\n|\\W)"+H(o)+P,"g"),h;h=l.exec(E);){if(h[3]==="dll-reference")continue;A[_].push(h[3])}for(l=new RegExp("\\("+H(o)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+P,"g");h=l.exec(E);)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++)W(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 v(C,k){for(var _={main:[k]},A={main:[]},E={main:{}};O(_);)for(var u=Object.keys(_),o=0;o<u.length;o++){var l=u[o],h=_[l],w=h.pop();if(E[l]=E[l]||{},E[l][w]||!C[l][w])continue;E[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)}:v(_,C),E="";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__; })",E=E+"var "+w+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(g))+")({"+A[w].map(function(m){return""+JSON.stringify(m)+": "+_[w][m].toString()}).join(",")+`});
|
|
`}),E=E+"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([E],{type:"text/javascript"});if(k.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.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"),W=D("./src/controller/subtitle-track-controller.ts"),M=D("./src/controller/buffer-controller.ts"),O=D("./src/controller/timeline-controller.ts"),v=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"),E=D("./src/utils/fetch-loader.ts"),u=D("./src/utils/cues.ts"),o=D("./src/utils/mediakeys-helper.ts"),l=D("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var a=1;a<arguments.length;a++){var b=arguments[a];for(var y in b)Object.prototype.hasOwnProperty.call(b,y)&&(d[y]=b[y])}return d},h.apply(this,arguments)}function w(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(d);a&&(y=y.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),b.push.apply(b,y)}return b}function g(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?w(Object(b),!0).forEach(function(y){m(d,y,b[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):w(Object(b)).forEach(function(y){Object.defineProperty(d,y,Object.getOwnPropertyDescriptor(b,y))})}return d}function m(d,a,b){return a in d?Object.defineProperty(d,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):d[a]=b,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:v.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:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},x()),{},{subtitleStreamController:H.SubtitleStreamController,subtitleTrackController:W.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,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},d,a)}function p(d){var a=d.loader;if(a!==E.default&&a!==A.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var b=Object(E.fetchSupported)();b&&(d.loader=E.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"),W=D("./src/errors.ts"),M=D("./src/types/loader.ts"),O=D("./src/utils/logger.ts");function v(_,A){for(var E=0;E<A.length;E++){var u=A[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function C(_,A,E){return A&&v(_.prototype,A),E&&v(_,E),_}var k=function(){function _(E){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=E;var u=E.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,o){var l=o.frag;if(l.type===M.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=o.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(u,o){var l=this.hls.config;o.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,w=l.config,g=l.media;if(!u||!g)return;var m=o?o.stats:u.stats,L=o?o.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,a=p[u.level],b=m.total||Math.max(m.loaded,Math.round(L*a.maxBitrate/8)),y=Math.max(1,m.bwEstimate?m.bwEstimate/8:m.loaded*1e3/x),T=(b-m.loaded)/y,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*y),X<G)break}if(X>=T)return;var j=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+u.sn+(o?" part "+o.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+J+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(j)?(j/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:o,stats:m})},A.onFragLoaded=function(u,o){var l=o.frag,h=o.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,o){var l=o.frag,h=o.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,o){switch(o.details){case W.ErrorDetails.FRAG_LOAD_ERROR:case W.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,o=this.partCurrent,l=this.hls,h=l.maxAutoLevel,w=l.config,g=l.minAutoLevel,m=l.media,L=o?o.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,a=this.findBestLevel(p,g,h,d,w.abrBandWidthFactor,w.abrBandWidthUpFactor);if(a>=0)return a;O.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=L?Math.min(L,w.maxStarvationDelay):w.maxStarvationDelay,y=w.abrBandWidthFactor,T=w.abrBandWidthUpFactor;if(!d){var I=this.bitrateTestDelay;if(I){var G=L?Math.min(L,w.maxLoadingDelay):w.maxLoadingDelay;b=G-I,O.logger.trace("bitrate test took "+Math.round(1e3*I)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),y=T=1}}return a=this.findBestLevel(p,g,h,d+b,y,T),Math.max(a,0)},A.findBestLevel=function(u,o,l,h,w,g){for(var m,L=this.fragCurrent,x=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,d=p[f],a=!!(d!=null&&(m=d.details)!==null&&m!==void 0&&m.live),b=d==null?void 0:d.codecSet,y=x?x.duration:L?L.duration:0,T=l;T>=o;T--){var I=p[T];if(!I||b&&I.codecSet!==b)continue;var G=I.details,X=(x?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||y,J=void 0;T<=f?J=w*u:J=g*u;var z=p[T].maxBitrate,j=z*X/J;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(J)+"/"+z+"/"+X+"/"+h+"/"+j),J>z&&(!j||a&&!this.bitrateTestDelay||j<h))return T}return-1},C(_,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,o=this.bwEstimator;if(u!==-1&&(!o||!o.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"),W=D("./src/controller/fragment-tracker.ts"),M=D("./src/types/level.ts"),O=D("./src/types/loader.ts"),v=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"),E=D("./src/utils/discontinuities.ts"),u=D("./src/errors.ts"),o=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 a;return a=L.call(this,p,d,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var 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,a){var b=a.frag,y=a.id,T=a.initPTS;if(y==="main"){var I=b.cc;this.initPTS[b.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 a=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,a>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+a.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,a=this.levels,b=this.trackId,y=a==null||((d=a[b])===null||d===void 0)?void 0:d.details;if(y){if(this.waitForCdnTuneIn(y))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,j=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=j.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)o.logger.log("Waiting fragment cc ("+J.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),ke=H.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),xe=Object(A.fragmentWithinToleranceTest)(ke.end,this.config.maxFragLookUpTolerance,J);xe<0&&(o.logger.log("Waiting fragment cc ("+J.cc+") @ "+J.start+" cancelled because another fragment at "+ke.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 a=this.mediaBuffer?this.mediaBuffer:d,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},f.doTickIdle=function(){var d,a,b=this.hls,y=this.levels,T=this.media,I=this.trackId,G=b.config;if(!y||!y[I])return;if(!T&&(this.startFragRequested||!G.startFragPrefetch))return;var X=y[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,v.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var j=z.len,q=this.getMaxBufferLength(),ne=this.audioSwitch;if(j>=q&&!ne)return;if(!ne&&this._streamEnded(z,J)){b.trigger(P.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var ce=J.fragments,ve=ce[0].start,ke=z.end;if(ne){var xe=this.getLoadPosition();ke=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(ke,J);if(!Ce){this.bufferFlushed=!0;return}((d=Ce.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=Ce.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Ce,J):this.loadFragment(Ce,J,ke)},f.getMaxBufferLength=function(){var d=L.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return a===null?d:Math.max(d,a.len)},f.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(d,a){var b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(y){return new M.Level(y)})},f.onAudioTrackSwitching=function(d,a){var b=!!a.url;this.trackId=a.id;var y=this.fragCurrent;y!=null&&y.loader&&y.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(g):this.resetTransmuxer(),b?(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,a){this.mainDetails=a.details},f.onAudioTrackLoaded=function(d,a){var b,y=this.levels,T=a.details,I=a.id;if(!y){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=y[I],X=0;if(T.live||(b=G.details)!==null&&b!==void 0&&b.live){var J=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!J)return;!G.details&&T.hasProgramDateTime&&J.hasProgramDateTime?(Object(E.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 a,b=d.frag,y=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 "+b.sn+" of level "+b.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 j=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[b.cc],ce=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(ne!==void 0){var ve=!1,ke=y?y.index:-1,xe=ke!==-1,Ce=new _.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,T.byteLength,ke,xe);q.push(T,ce,j,"",b,y,z.totalduration,ve,Ce,ne)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Se=this.waitingData=this.waitingData||{frag:b,part:y,cache:new C.default,complete:!1},Ee=Se.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,a){var b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(d,a){var b=a.frag,y=a.part;if(b.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(y?" p: "+y.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,y)},f.onError=function(d,a){switch(a.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=a.fatal?N.State.ERROR:N.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var b=!0,y=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);y&&y.len>.5&&(b=!this.reduceMaxBufferLength(y.len)),b&&(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,a){var b=a.type;b===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(d){var a,b="audio",y=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,j=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),y.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:X,id:b,tracks:ne.tracks})),z){var ce=z.startPTS,ve=z.endPTS,ke=z.startDTS,xe=z.endDTS;J&&(J.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ce,endPTS:ve,startDTS:ke,endDTS:xe}),X.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ce,ve,ke,xe),this.bufferFragmentData(z,X,J,I)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var Ce=l({frag:X,id:b},q);y.trigger(P.Events.FRAG_PARSING_METADATA,Ce)}if(j){var Se=l({frag:X,id:b},j);y.trigger(P.Events.FRAG_PARSING_USERDATA,Se)}},f._bufferInitSegment=function(d,a,b){if(this.state!==N.State.PARSING)return;d.video&&delete d.video;var y=d.audio;if(!y)return;y.levelCodec=y.codec,y.id="audio",this.log("Init audio buffer, container:"+y.container+", codecs[parsed]=["+y.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,d);var T=y.initSegment;if(T!=null&&T.byteLength){var I={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:T};this.hls.trigger(P.Events.BUFFER_APPENDING,I)}this.tick()},f.loadFragment=function(d,a,b){var y=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||y===W.FragmentState.NOT_LOADED||y===W.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):a.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,a,b)))},f.completeAudioSwitch=function(){var d=this.hls,a=this.media,b=this.trackId;a&&(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:b})},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 W(k,_){for(var A=0;A<_.length;A++){var E=_[A];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(k,E.key,E)}}function M(k,_,A){return _&&W(k.prototype,_),A&&W(k,A),k}function O(k,_){k.prototype=Object.create(_.prototype),k.prototype.constructor=k,v(k,_)}function v(k,_){return v=Object.setPrototypeOf||function(E,u){return E.__proto__=u,E},v(k,_)}var C=function(k){O(_,k);function _(E){var u;return u=k.call(this,E,"[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,o){this.tracks=o.audioTracks||[]},A.onAudioTrackLoaded=function(u,o){var l=o.id,h=o.details,w=this.tracksInGroup[l];if(!w){this.warn("Invalid audio track id "+l);return}var g=w.details;w.details=o.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,g))},A.onLevelLoading=function(u,o){this.switchLevel(o.level)},A.onLevelSwitching=function(u,o){this.switchLevel(o.level)},A.switchLevel=function(u){var o=this.hls.levels[u];if(!(o!=null&&o.audioGroupIds))return;var l=o.audioGroupIds[o.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,o){if(k.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===H.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},A.setAudioTrack=function(u){var o=this.tracksInGroup;if(u<0||u>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=o[this.trackId];this.log("Now switching to audio-track index "+u);var h=o[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 o=this.trackName,l=this.findTrackId(o)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(u){for(var o=this.tracksInGroup,l=0;l<o.length;l++){var h=o[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},A.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,h=o.groupId,w=o.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"),W=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 v=O.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(k,_){_.fatal&&_.type===W.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},v.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},v.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},v.stopLoad=function(){this.canLoad=!1,this.clearTimer()},v.switchParams=function(k,_){var A=_==null?void 0:_.renditionReports;if(A)for(var E=0;E<A.length;E++){var u=A[E],o=""+u.URI;if(o===k.substr(-o.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)}}},v.loadPlaylist=function(k){},v.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},v.playlistLoaded=function(k,_,A){var E=this,u=_.details,o=_.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.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,a=m?0:f;p?(w=d?x+1:L,g=d?a:f+1):w=x+1;var b=u.age,y=b+u.ageHeader,T=Math.min(y-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 "+b.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,o);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 E.loadPlaylist(h)},X)}else this.clearTimer()},v.getDeliveryDirectives=function(k,_,A,E){var u=Object(N.getSkipValue)(k,A);return _!=null&&_.skip&&k.deltaUpdateFailed&&(A=_.msn,E=_.part,u=N.HlsSkip.No),new N.HlsUrlParameters(A,E,u)},v.retryLoadingOrFail=function(k){var _=this,A=this.hls.config,E=this.retryCount<A.levelLoadingMaxRetry;if(E){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 o=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return _.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return E},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"),W=D("./src/utils/logger.ts"),M=D("./src/events.ts"),O=D("./src/errors.ts"),v=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"),E=D("./src/loader/fragment-loader.ts"),u=D("./src/crypt/decrypter.ts"),o=D("./src/utils/time-ranges.ts"),l=D("./src/types/loader.ts");function h(p,d){for(var a=0;a<d.length;a++){var b=d[a];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function w(p,d,a){return d&&h(p.prototype,d),a&&h(p,a),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(b,y){return b.__proto__=y,b},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(b,y,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=W.logger.log.bind(W.logger,T+":"),I.warn=W.logger.warn.bind(W.logger,T+":"),I.hls=b,I.fragmentLoader=new E.default(b.config),I.fragmentTracker=y,I.config=b.config,I.decrypter=new u.default(b,b.config),b.on(M.Events.KEY_LOADED,I.onKeyLoaded,g(I)),I}var a=d.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(y){},a.stopLoad=function(){this.fragmentLoader.abort();var y=this.fragCurrent;y&&this.fragmentTracker.removeFragment(y),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},a._streamEnded=function(y,T){var I=this.fragCurrent,G=this.fragmentTracker;if(!T.live&&I&&I.sn===T.endSN&&!y.nextStart){var X=G.getState(I);return X===P.FragmentState.PARTIAL||X===P.FragmentState.OK}return!1},a.onMediaAttached=function(y,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)},a.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var y=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,y.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 j=y.maxFragLookUpTolerance,q=T.start-j,ne=T.start+T.duration+j,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()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(y,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)},a.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},a.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)},a.loadKey=function(y,T){this.log("Loading key for "+y.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=x.KEY_LOADING,this.fragCurrent=y,this.hls.trigger(M.Events.KEY_LOADING,{frag:y})},a.loadFragment=function(y,T,I){this._loadFragForPlayback(y,T,I)},a._loadFragForPlayback=function(y,T,I){var G=this,X=function(z){if(G.fragContextChanged(y)){G.warn("Fragment "+y.sn+(z.part?" p: "+z.part.index:"")+" of level "+y.level+" was dropped during download."),G.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(y,T,I,X).then(function(J){if(!J)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(y)){(z===x.FRAG_LOADING||z===x.BACKTRACKING||!G.fragCurrent&&z===x.PARSING)&&(G.fragmentTracker.removeFragment(y),G.state=x.IDLE);return}if("payload"in J&&(G.log("Loaded fragment "+y.sn+" of level "+y.level),G.hls.trigger(M.Events.FRAG_LOADED,J),G.state===x.BACKTRACKING)){G.fragmentTracker.backtrack(y,J),G.resetFragmentLoading(y);return}G._handleFragmentLoadComplete(J)}).catch(function(J){G.warn(J),G.resetFragmentLoading(y)})},a.flushMainBuffer=function(y,T,I){if(I===void 0&&(I=null),!(y-T))return;var G={startOffset:y,endOffset:T,type:I};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(y){var T=this;this._doFragLoad(y).then(function(I){if(!I||T.fragContextChanged(y)||!T.levels)throw new Error("init load aborted");return I}).then(function(I){var G=T.hls,X=I.payload,J=y.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(j){var q=self.performance.now();return G.trigger(M.Events.FRAG_DECRYPTED,{frag:y,payload:j,stats:{tstart:z,tdecrypt:q}}),I.payload=j,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[y.level].details;console.assert(z,"Level details are defined when init segment is loaded");var j=y.stats;T.state=x.IDLE,T.fragLoadError=0,y.data=new Uint8Array(I.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),I.frag===G&&X.trigger(M.Events.FRAG_BUFFERED,{stats:j,frag:G,part:null,id:y.type}),T.tick()}).catch(function(I){T.warn(I),T.resetFragmentLoading(y)})},a.fragContextChanged=function(y){var T=this.fragCurrent;return!y||!T||y.level!==T.level||y.sn!==T.sn||y.urlId!==T.urlId},a.fragBufferedComplete=function(y,T){var I=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+o.default.toString(H.BufferHelper.getBuffered(I))),this.state=x.IDLE,this.tick()},a._handleFragmentLoadComplete=function(y){var T=this.transmuxer;if(!T)return;var I=y.frag,G=y.part,X=y.partsLoaded,J=!X||X.length===0||X.some(function(j){return!j}),z=new v.ChunkMetadata(I.level,I.sn,I.stats.chunkCount+1,0,G?G.index:-1,!J);T.flush(z)},a._handleFragmentLoadProgress=function(y){},a._doFragLoad=function(y,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(y.start,I||0),this.config.lowLatencyMode&&T){var J=T.partList;if(J&&G){I>y.end&&T.fragmentHint&&(y=T.fragmentHint);var z=this.getNextPart(J,y,I);if(z>-1){var j=J[z];return this.log("Loading part sn: "+y.sn+" p: "+j.index+" cc: "+y.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(J.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(I.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=x.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:y,part:J[z],targetBufferTime:I}),this.doFragPartsLoad(y,J,z,G).catch(function(q){return X.handleFragLoadError(q)})}else if(!y.url||this.loadedEndOfParts(J,I))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(I.toFixed(3))),Object(V.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=x.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:y,targetBufferTime:I}),this.fragmentLoader.load(y,G).catch(function(q){return X.handleFragLoadError(q)})},a.doFragPartsLoad=function(y,T,I,G){var X=this;return new Promise(function(J,z){var j=[],q=function ne(ce){var ve=T[ce];X.fragmentLoader.loadPart(y,ve,G).then(function(ke){j[ve.index]=ke;var xe=ke.part;X.hls.trigger(M.Events.FRAG_LOADED,ke);var Ce=T[ce+1];if(Ce&&Ce.fragment===y)ne(ce+1);else return J({frag:y,part:xe,partsLoaded:j})}).catch(z)};q(I)})},a.handleFragLoadError=function(y){var T=y.data;return T&&T.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(M.Events.ERROR,T),null},a._handleTransmuxerFlush=function(y){var T=this.getCurrentContext(y);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,y.partial)},a.getCurrentContext=function(y){var T=this.levels,I=y.level,G=y.sn,X=y.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,j=z?z.fragment:Object(A.getFragmentWithSN)(J,G,this.fragCurrent);return j?{frag:j,part:z,level:J}:null},a.bufferFragmentData=function(y,T,I,G){if(!y||this.state!==x.PARSING)return;var X=y.data1,J=y.data2,z=X;if(X&&J&&(z=Object(C.appendUint8Array)(X,J)),!z||!z.length)return;var j={type:y.type,frag:T,part:I,chunkMeta:G,parent:T.type,data:z};this.hls.trigger(M.Events.BUFFER_APPENDING,j),y.dropped&&y.independent&&!I&&this.flushBufferGap(T)},a.flushBufferGap=function(y){var T=this.media;if(!T)return;if(!H.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,y.start);return}var I=T.currentTime,G=H.BufferHelper.bufferInfo(T,I,0),X=y.duration,J=Math.min(this.config.maxFragLookUpTolerance*2,X*.25),z=Math.max(Math.min(y.start-J,G.end-J),I+J);y.start-z>J&&this.flushMainBuffer(z,y.start)},a.getFwdBufferInfo=function(y,T){var I=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var X=H.BufferHelper.bufferInfo(y,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(y,G,Math.max(X.nextStart,I.maxBufferHole))}return X},a.getMaxBufferLength=function(y){var T=this.config,I;return y?I=Math.max(8*T.maxBufferSize/y,T.maxBufferLength):I=T.maxBufferLength,Math.min(I,T.maxMaxBufferLength)},a.reduceMaxBufferLength=function(y){var T=this.config,I=y||T.maxBufferLength;return T.maxMaxBufferLength>=I?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(y,T){var I,G,X=T.fragments,J=X.length;if(!J)return null;var z=this.config,j=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:y)}else y<=j&&(q=X[0]);if(!q){var ce=z.lowLatencyMode?T.partEnd:T.fragmentEnd;q=this.getFragmentAtPosition(y,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},a.getNextPart=function(y,T,I){for(var G=-1,X=!1,J=!0,z=0,j=y.length;z<j;z++){var q=y[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},a.loadedEndOfParts=function(y,T){var I=y[y.length-1];return I&&T>I.start&&I.loaded},a.getInitialLiveFragment=function(y,T){var I=this.fragPrevious,G=null;if(I){if(y.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>=y.startSN&&X<=y.endSN){var J=T[X-y.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?y.fragmentEnd:y.edge,y))}return G},a.getFragmentAtPosition=function(y,T,I){var G=this.config,X=this.fragPrevious,J=I.fragments,z=I.endSN,j=I.fragmentHint,q=G.maxFragLookUpTolerance,ne=!!(G.lowLatencyMode&&I.partList&&j);ne&&j&&!this.bitrateTest&&(J=J.concat(j),z=j.sn);var ce;if(y<T){var ve=y>T-q?0:q;ce=Object(_.findFragmentByPTS)(X,J,y,ve)}else ce=J[J.length-1];if(ce){var ke=ce.sn-I.startSN,xe=X&&ce.level===X.level,Ce=J[ke+1],Se=this.fragmentTracker.getState(ce);if(Se===P.FragmentState.BACKTRACKED){ce=null;for(var Ee=ke;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},a.synchronizeToLiveEdge=function(y){var T=this.config,I=this.media;if(!I)return;var G=this.hls.liveSyncPosition,X=I.currentTime,J=y.fragments[0].start,z=y.edge,j=X>=J-T.maxFragLookUpTolerance&&X<=z;if(G!==null&&I.duration>G&&(X<G||!j)){var q=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*y.targetduration;(!j&&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))}},a.alignPlaylists=function(y,T){var I=this.levels,G=this.levelLastLoaded,X=this.fragPrevious,J=G!==null?I[G]:null,z=y.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var j=y.fragments[0].start,q=!T,ne=y.alignedSliding&&Object(V.isFiniteNumber)(j);if(q||!ne&&!j){Object(k.alignStream)(X,J,y);var ce=y.fragments[0].start;return this.log("Live playlist sliding: "+ce.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+y.startSN+" prev-sn: "+(X?X.sn:"na")+" fragments: "+z),ce}return j},a.waitForCdnTuneIn=function(y){var T=3;return y.live&&y.canBlockReload&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*T)},a.setStartPosition=function(y,T){var I=this.startPosition;if(I<T&&(I=-1),I===-1||this.lastCurrentTime===-1){var G=y.startTimeOffset;Object(V.isFiniteNumber)(G)?(I=T+G,G<0&&(I+=y.totalduration),I=Math.min(Math.max(T,I),T+y.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+I),this.startPosition=I):y.live?I=this.hls.liveSyncPosition||T:this.startPosition=I=0,this.lastCurrentTime=I}this.nextLoadPosition=I},a.getLoadPosition=function(){var y=this.media,T=0;return this.loadedmetadata&&y?T=y.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},a.handleFragLoadAborted=function(y,T){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(T?" part"+T.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},a.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y))&&(this.state=x.IDLE)},a.onFragmentOrKeyLoadError=function(y,T){if(T.fatal)return;var I=T.frag;if(!I||I.type!==y)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 "+y+" "+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?(y===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(W.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},a.afterBufferFlushed=function(y,T,I){if(!y)return;var G=H.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(T,G,I),this.state===x.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},a.resetLiveStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[y].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(y,T,I,G){var X=this,J=I.details;console.assert(!!J,"level.details must be defined");var z=Object.keys(y.elementaryStreams).reduce(function(j,q){var ne=y.elementaryStreams[q];if(ne){var ce=ne.endPTS-ne.startPTS;if(ce<=0)return X.warn("Could not parse fragment "+y.sn+" "+q+" duration reliably ("+ce+") resetting transmuxer to fallback to playlist timing"),X.resetTransmuxer(),j||!1;var ve=G?0:Object(A.updateFragPTSDTS)(J,y,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:y,start:ne.startPTS,end:ne.endPTS}),!0}return j},!1);z?(this.state=x.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:y,part:T})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},w(d,[{key:"state",get:function(){return this._state},set:function(y){var T=this._state;T!==y&&(this._state=y,this.log(T+"->"+y))}}]),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"),W=D("./src/utils/buffer-helper.ts"),M=D("./src/utils/mediasource-helper.ts"),O=D("./src/loader/fragment.ts"),v=D("./src/controller/buffer-operation-queue.ts"),C=Object(M.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,_=function(){function A(u){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=o.hls,h=o.media,w=o.mediaSource;P.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),l.trigger(N.Events.MEDIA_ATTACHED,{media:h})),w&&w.removeEventListener("sourceopen",o._onMediaSourceOpen),o.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 E=A.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var o=this.hls;o.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(N.Events.BUFFER_RESET,this.onBufferReset,this),o.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(N.Events.BUFFER_EOS,this.onBufferEos,this),o.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(N.Events.FRAG_PARSED,this.onFragParsed,this),o.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(N.Events.BUFFER_RESET,this.onBufferReset,this),o.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(N.Events.BUFFER_EOS,this.onBufferEos,this),o.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(N.Events.FRAG_PARSED,this.onFragParsed,this),o.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(o,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")},E.onMediaAttaching=function(o,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}},E.onMediaDetaching=function(){var o=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),o&&(h&&self.URL.revokeObjectURL(h),o.src===h?(o.removeAttribute("src"),o.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)},E.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var h=o.sourceBuffer[l];try{h&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(h),o.sourceBuffer[l]=void 0)}catch(w){P.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",w)}}),this._initSourceBuffer()},E.onBufferCodecs=function(o,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"),a=(f||x).replace(k,"$1");if(d!==a){var b=p+";codecs="+(f||x);h.appendChangeType(g,b)}}}else h.pendingTracks[g]=l[g]}),w)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},E.appendChangeType=function(o,l){var h=this,w=this.operationQueue,g={execute:function(){var L=h.sourceBuffer[o];L&&(P.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),L.changeType(l)),w.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(L){P.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",L)}};w.append(g,o)},E.onBufferAppending=function(o,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,a=d.buffering[x],b=self.performance.now();a.start=b;var y=f.stats.buffering,T=p?p.stats.buffering:null;y.start===0&&(y.start=b),T&&T.start===0&&(T.start=b);var I=m.audio,G=x==="audio"&&d.id===1&&(I==null?void 0:I.container)==="audio/mpeg",X={execute:function(){if(a.executeStart=self.performance.now(),G){var z=h.sourceBuffer[x];if(z){var j=f.start-z.timestampOffset;Math.abs(j)>=.1&&(P.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+j+") sn: "+f.sn+")"),z.timestampOffset=f.start)}}h.appendExecutor(L,x)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,y.first===0&&(y.first=z),T&&T.first===0&&(T.first=z);var j=h.sourceBuffer,q={};for(var ne in j)q[ne]=W.BufferHelper.getBuffered(j[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 j={type:H.ErrorTypes.MEDIA_ERROR,parent:f.type,details:H.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?j.details=H.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,j.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"),j.fatal=!0)),w.trigger(N.Events.ERROR,j)}};g.append(X,x)},E.onBufferFlushing=function(o,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)})},E.onFragParsed=function(o,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)},E.onFragChanged=function(o,l){this.flushBackBuffer()},E.onBufferEos=function(o,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()})},E.onLevelUpdated=function(o,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},E.flushBackBuffer=function(){var o=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&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.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 a=w[d];if(a){var b=W.BufferHelper.getBuffered(a);b.length>0&&p>b.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),l.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:d}))}})},E.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,h=this.media,w=this.mediaSource,g=o.fragments[0].start+o.totalduration,m=h.duration,L=Object(V.isFiniteNumber)(w.duration)?w.duration:0;o.live&&l.config.liveDurationInfinity?(P.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),w.duration=Infinity,this.updateSeekableRange(o)):(g>L&&g>m||!Object(V.isFiniteNumber)(m))&&(P.logger.log("[buffer-controller]: Updating Media Source duration to "+g.toFixed(3)),w.duration=g)},E.updateSeekableRange=function(o){var l=this.mediaSource,h=o.fragments,w=h.length;if(w&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var g=Math.max(0,h[0].start),m=Math.max(g,g+o.totalduration);l.setLiveSeekableRange(g,m)}},E.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,w=Object.keys(h).length;if(w&&!o||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)})}},E.createSourceBuffers=function(o){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var w=0;for(var g in o)if(!l[g]){var m=o[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})},E._onSBUpdateStart=function(o){var l=this.operationQueue,h=l.current(o);h.onStart()},E._onSBUpdateEnd=function(o){var l=this.operationQueue,h=l.current(o);h.onComplete(),l.shiftAndExecuteNext(o)},E._onSBUpdateError=function(o,l){P.logger.error("[buffer-controller]: "+o+" 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(o);h&&h.onError(l)},E.removeExecutor=function(o,l,h){var w=this.media,g=this.mediaSource,m=this.operationQueue,L=this.sourceBuffer,x=L[o];if(!w||!g||!x){P.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(o);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),a=Math.min(h,f,p);a>d?(P.logger.log("[buffer-controller]: Removing ["+d+","+a+"] from the "+o+" SourceBuffer"),console.assert(!x.updating,o+" sourceBuffer must not be updating"),x.remove(d,a)):m.shiftAndExecuteNext(o)},E.appendExecutor=function(o,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(o)},E.blockBuffers=function(o,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(o);return}var w=this.operationQueue,g=l.map(function(m){return w.appendBlocker(m)});Promise.all(g).then(function(){o(),l.forEach(function(m){var L=h.sourceBuffer[m];(!L||!L.updating)&&w.shiftAndExecuteNext(m)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(o,l,h){var w=this.sourceBuffer[o];if(!w)return;var g=h.bind(this,o);this.listeners[o].push({event:l,listener:g}),w.addEventListener(l,g)},E.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].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(W){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=W}var H=P.prototype;return H.append=function(M,O){var v=this.queues[O];v.push(M),v.length===1&&this.buffers[O]&&this.executeNext(O)},H.insertAbort=function(M,O){var v=this.queues[O];v.unshift(M),this.executeNext(O)},H.appendBlocker=function(M){var O,v=new Promise(function(k){O=k}),C={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(C,M),v},H.executeNext=function(M){var O=this.buffers,v=this.queues,C=O[M],k=v[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(W,M){for(var O=0;O<M.length;O++){var v=M[O];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(W,v.key,v)}}function P(W,M,O){return M&&N(W.prototype,M),O&&N(W,O),W}var H=function(){function W(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=W.prototype;return M.setStreamController=function(v){this.streamController=v},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 v=this.hls;v.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var v=this.hls;v.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(v,C){W.isLevelAllowed(C.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(C.droppedLevel)},M.onMediaAttaching=function(v,C){this.media=C.media instanceof HTMLVideoElement?C.media:null},M.onManifestParsed=function(v,C){var k=this.hls;this.restrictedLevels=[],this.firstLevel=C.firstLevel,k.config.capLevelToPlayerSize&&C.video&&this.startCapping()},M.onBufferCodecs=function(v,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 v=this.hls.levels;if(v.length){var C=this.hls;C.autoLevelCapping=this.getMaxLevel(v.length-1),C.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=C.autoLevelCapping}}},M.getMaxLevel=function(v){var C=this,k=this.hls.levels;if(!k.length)return-1;var _=k.filter(function(A,E){return W.isLevelAllowed(E,C.restrictedLevels)&&E<=v});return this.clientRect=null,W.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 v=this.media,C={width:0,height:0};if(v){var k=v.getBoundingClientRect();C.width=k.width,C.height=k.height,!C.width&&!C.height&&(C.width=k.right-k.left||v.width||0,C.height=k.bottom-k.top||v.height||0)}return this.clientRect=C,C},W.isLevelAllowed=function(v,C){return C===void 0&&(C=[]),C.indexOf(v)===-1},W.getMaxLevelByMediaSize=function(v,C,k){if(!v||!v.length)return-1;for(var _=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},A=v.length-1,E=0;E<v.length;E+=1){var u=v[E];if((u.width>=C||u.height>=k)&&_(u,v[E+1])){A=E;break}}return A},P(W,[{key:"mediaWidth",get:function(){return this.getDimensions().width*W.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*W.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(C){}return v}}]),W}();$.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 W(A,E){for(var u=0;u<E.length;u++){var o=E[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(A,o.key,o)}}function M(A,E,u){return E&&W(A.prototype,E),u&&W(A,u),A}function O(A,E){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=v(A))||E&&A&&typeof A.length=="number"){u&&(A=u);var o=0;return function(){return o>=A.length?{done:!0}:{done:!1,value:A[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(A,E){if(!A)return;if(typeof A=="string")return C(A,E);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,E)}function C(A,E){(E==null||E>A.length)&&(E=A.length);for(var u=0,o=new Array(E);u<E;u++)o[u]=A[u];return o}function k(){return k=Object.assign||function(A){for(var E=1;E<arguments.length;E++){var u=arguments[E];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(A[o]=u[o])}return A},k.apply(this,arguments)}var _=function(){function A(u){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(w){try{o.apply(w,{ot:N.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(g){H.logger.warn("Could not generate manifest CMCD data.",g)}},this.applyFragmentData=function(w){try{var g=w.frag,m=o.hls.levels[g.level],L=o.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=o.getTopBandwidth(L),x.bl=o.getBufferLength(L)),o.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 E=A.prototype;return E.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},E.onBufferCreated=function(o,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},E.createData=function(){var o;return{v:N.CMCDVersion,sf:N.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(o,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;o.headers||(o.headers={}),k(o.headers,w)}else{var g=A.toQuery(l);if(!g)return;o.url=A.appendQueryToUri(o.url,g)}},E.getObjectType=function(o){var l=o.type;return l==="subtitle"?N.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?N.CMCDObjectType.INIT:l==="audio"?N.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},E.getTopBandwidth=function(o){for(var l=0,h=o===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},E.getBufferLength=function(o){var l=this.hls.media,h=o===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},E.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,h=o||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}()},E.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,h=o||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 o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},A.serialize=function(o){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(o||{}).sort(),f=O(x),p;!(p=f()).done;){var d=p.value,a=o[d];if(!h(a))continue;if(d==="v"&&a===1)continue;if(d=="pr"&&a===1)continue;var b=L[d];b&&(a=b(a));var y=typeof a,T=void 0;d==="ot"||d==="sf"||d==="st"?T=d+"="+a:y==="boolean"?T=d:y==="number"?T=d+"="+a:T=d+"="+JSON.stringify(a),l.push(T)}return l.join(",")},A.toHeaders=function(o){for(var l=Object.keys(o),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]=o[f]}for(var d=0;d<g.length;d++){var a=A.serialize(g[d]);a&&(h["CMCD-"+w[d]]=a)}return h},A.toQuery=function(o){return"CMCD="+encodeURIComponent(A.serialize(o))},A.appendQueryToUri=function(o,l){if(!l)return o;var h=o.includes("?")?"&":"?";return""+o+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 W(_,A){for(var E=0;E<A.length;E++){var u=A[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function M(_,A,E){return A&&W(_.prototype,A),E&&W(_,E),_}var O=3,v=function(A,E,u){var o={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),E.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[o]},C=function(A,E,u,o){switch(A){case H.KeySystems.WIDEVINE:return v(E,u,o);default:throw new Error("Unknown key-system: "+A)}},k=function(){function _(E){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=E,this._config=E.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,o,l){var h=this,w=C(u,o,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,o){var l=this;P.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var w=Promise.resolve().then(function(){return o.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(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},A._onNewMediaKeySession=function(u){var o=this;P.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){o._onKeySessionMessage(u,l.message)},!1)},A._onKeySessionMessage=function(u,o){P.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(l){P.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},A.onMediaEncrypted=function(u){var o=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(!o._media)return;o._attemptSetMediaKeys(w),o._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 o=this._mediaKeysList[0];if(!o||!o.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(o.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(u,o){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(!o){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,o).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,o,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,o,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,o,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,o)}catch(L){P.logger.error(L)}h(w)}else{if(P.logger.error("License Request XHR failed ("+o+"). 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,o){switch(u.mediaKeySystemDomain){case H.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},A._requestLicense=function(u,o){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,o);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,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},A.onMediaDetached=function(){var u=this._media,o=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var l=o.levels.map(function(w){return w.audioCodec}).filter(function(w){return!!w}),h=o.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 W=H.prototype;return W.setStreamController=function(O){this.streamController=O},W.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},W.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},W.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},W.onMediaAttaching=function(O,v){var C=this.hls.config;if(C.capLevelOnFPSDrop){var k=v.media instanceof self.HTMLVideoElement?v.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)}},W.checkFPS=function(O,v,C){var k=performance.now();if(v){if(this.lastTime){var _=k-this.lastTime,A=C-this.lastDroppedFrames,E=v-this.lastDecodedFrames,u=1e3*A/_,o=this.hls;if(o.trigger(V.Events.FPS_DROP,{currentDropped:A,currentDecoded:E,totalDroppedFrames:C}),u>0&&A>o.config.fpsDroppedMonitoringThreshold*E){var l=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=l)&&(l=l-1,o.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=C,this.lastDecodedFrames=v}},W.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var v=O.getVideoPlaybackQuality();this.checkFPS(O,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},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 W}),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(v,C,k){if(C===null||!Array.isArray(v)||!v.length||!Object(V.isFiniteNumber)(C))return null;var _=v[0].programDateTime;if(C<(_||0))return null;var A=v[v.length-1].endProgramDateTime;if(C>=(A||0))return null;k=k||0;for(var E=0;E<v.length;++E){var u=v[E];if(M(C,k,u))return u}return null}function H(v,C,k,_){k===void 0&&(k=0),_===void 0&&(_=0);var A=null;if(v?A=C[v.sn-C[0].sn+1]||null:k===0&&C[0].start===0&&(A=C[0]),A&&W(k,_,A)===0)return A;var E=N.default.search(C,W.bind(null,k,_));return E||A}function W(v,C,k){v===void 0&&(v=0),C===void 0&&(C=0);var _=Math.min(C,k.duration+(k.deltaPTS?k.deltaPTS:0));return k.start+k.duration-_<=v?1:k.start-_>v&&k.start?-1:0}function M(v,C,k){var _=Math.min(C,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,A=k.endProgramDateTime||0;return A-_>v}function O(v,C){return N.default.search(v,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 v=O.prototype;return v._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)},v._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)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(k,_){if(_===N.PlaylistLevelType.MAIN){var A=this.activeFragment,E=this.activeParts;if(!A)return null;if(E)for(var u=E.length;u--;){var o=E[u],l=o?o.end:A.appendedPTS;if(o.start<=k&&l!==void 0&&k<=l)return u>9&&(this.activeParts=E.slice(u-9)),o}else if(A.start<=k&&A.appendedPTS!==void 0&&k<=A.appendedPTS)return A}return this.getBufferedFrag(k,_)},v.getBufferedFrag=function(k,_){for(var A=this.fragments,E=Object.keys(A),u=E.length;u--;){var o=A[E[u]];if((o==null?void 0:o.body.type)===_&&o.buffered){var l=o.body;if(l.start<=k&&k<=l.end)return l}}return null},v.detectEvictedFragments=function(k,_,A){var E=this;Object.keys(this.fragments).forEach(function(u){var o=E.fragments[u];if(!o)return;if(!o.buffered){o.body.type===A&&E.removeFragment(o.body);return}var l=o.range[k];if(!l)return;l.time.some(function(h){var w=!E.isTimeBuffered(h.startPTS,h.endPTS,_);return w&&E.removeFragment(o.body),w})})},v.detectPartialFragments=function(k){var _=this,A=this.timeRanges,E=k.frag,u=k.part;if(!A||E.sn==="initSegment")return;var o=M(E),l=this.fragments[o];if(!l)return;Object.keys(A).forEach(function(h){var w=E.elementaryStreams[h];if(!w)return;var g=A[h],m=u!==null||w.partial===!0;l.range[h]=_.getBufferedTimes(E,u,m,g)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},v.fragBuffered=function(k){var _=M(k),A=this.fragments[_];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},v.getBufferedTimes=function(k,_,A,E){for(var u={time:[],partial:A},o=_?_.start:k.start,l=_?_.end:k.end,h=k.minEndPTS||l,w=k.maxStartPTS||o,g=0;g<E.length;g++){var m=E.start(g)-this.bufferPadding,L=E.end(g)+this.bufferPadding;if(w>=m&&h<=L){u.time.push({startPTS:Math.max(o,E.start(g)),endPTS:Math.min(l,E.end(g))});break}else if(o<L&&l>m)u.partial=!0,u.time.push({startPTS:Math.max(o,E.start(g)),endPTS:Math.min(l,E.end(g))});else if(l<=m)break}return u},v.getPartialFragment=function(k){var _=null,A,E,u,o=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(w){var g=h[w];if(!g)return;W(g)&&(E=g.body.start-l,u=g.body.end+l,k>=E&&k<=u&&(A=Math.min(k-E,u-k),o<=A&&(_=g.body,o=A)))}),_},v.getState=function(k){var _=M(k),A=this.fragments[_];return A?A.buffered?W(A)?P.PARTIAL:P.OK:A.backtrack?P.BACKTRACKED:P.APPENDING:P.NOT_LOADED},v.backtrack=function(k,_){var A=M(k),E=this.fragments[A];if(!E||E.backtrack)return null;var u=E.backtrack=_||E.loaded;return E.loaded=null,u},v.getBacktrackData=function(k){var _=M(k),A=this.fragments[_];if(A){var E,u=A.backtrack;if(u!=null&&(E=u.payload)!==null&&E!==void 0&&E.byteLength)return u;this.removeFragment(k)}return null},v.isTimeBuffered=function(k,_,A){for(var E,u,o=0;o<A.length;o++){if(E=A.start(o)-this.bufferPadding,u=A.end(o)+this.bufferPadding,k>=E&&_<=u)return!0;if(_<=E)return!1}return!1},v.onFragLoaded=function(k,_){var A=_.frag,E=_.part;if(A.sn==="initSegment"||A.bitrateTest||E)return;var u=M(A);this.fragments[u]={body:A,loaded:_,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(k,_){var A=this,E=_.frag,u=_.part,o=_.timeRanges;if(E.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=E,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var w=o[h];if(A.detectEvictedFragments(h,w),!u)for(var g=0;g<w.length;g++)E.appendedPTS=Math.max(w.end(g),E.appendedPTS||0)})},v.onFragBuffered=function(k,_){this.detectPartialFragments(_)},v.hasFragment=function(k){var _=M(k);return!!this.fragments[_]},v.removeFragmentsInRange=function(k,_,A){var E=this;Object.keys(this.fragments).forEach(function(u){var o=E.fragments[u];if(!o)return;if(o.buffered){var l=o.body;l.type===A&&l.start<_&&l.end>k&&E.removeFragment(l)}})},v.removeFragment=function(k){var _=M(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[_]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function W(O){var v,C;return O.buffered&&(((v=O.range.video)===null||v===void 0?void 0:v.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 W}),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 v}),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"),W=250,M=2,O=.1,v=.05,C=function(){function k(A,E,u,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=A,this.media=E,this.fragmentTracker=u,this.hls=o}var _=k.prototype;return _.destroy=function(){this.hls=this.fragmentTracker=this.media=null},_.poll=function(E){var u=this.config,o=this.media,l=this.stalled,h=o.currentTime,w=o.seeking,g=this.seeking&&!w,m=!this.seeking&&w;if(this.seeking=w,h!==E){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),o.paused||o.ended||o.playbackRate===0||!V.BufferHelper.getBuffered(o).length)return;var x=V.BufferHelper.bufferInfo(o,h,0),f=x.len>0,p=x.nextStart||0;if(!f&&!p)return;if(w){var d=x.len>M,a=!p||p-h>M&&!this.fragmentTracker.getPartialFragment(h);if(d||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,y=Math.max(p,x.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||((b=T.details)===null||b===void 0)?void 0:b.live,G=I?T.details.targetduration*2:M;if(y>0&&y<=G){this._trySkipBufferHole(null);return}}var X=self.performance.now();if(l===null){this.stalled=X;return}var J=X-l;!w&&J>=W&&this._reportStall(x.len);var z=V.BufferHelper.bufferInfo(o,h,u.maxBufferHole);this._tryFixBufferStall(z,J)},_._tryFixBufferStall=function(E,u){var o=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}E.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(H.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},_._reportStall=function(E){var u=this.hls,o=this.media,l=this.stallReported;l||(this.stallReported=!0,H.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+E+")"),u.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E}))},_._trySkipBufferHole=function(E){for(var u=this.config,o=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+v,l.currentTime+O);return H.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+x),this.moved=!0,this.stalled=null,l.currentTime=x,E&&o.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:E}),x}w=g.end(m)}return 0},_._tryNudgeBuffer=function(){var E=this.config,u=this.hls,o=this.media,l=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<E.nudgeMaxRetry){var w=l+h*E.nudgeOffset;H.logger.warn("Nudging 'currentTime' from "+l+" to "+w),o.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 "+E.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,W=function(){function M(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,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 E=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<A.length;u++){var o=P.getID3Frames(A[u].data);if(o){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<o.length;g++){var m=o[g];if(!P.isTimeStampFrame(m)){var L=new E(l,h,"");L.value=m,this.id3Track.addCue(L)}}}}},O.onBufferFlushing=function(C,k){var _=k.startOffset,A=k.endOffset,E=k.type;if(!E||E==="audio"){var u=this.id3Track;u&&Object(N.removeCuesInRange)(u,_,A)}},M}();$.default=W},"./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,v){for(var C=0;C<v.length;C++){var k=v[C];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(O,k.key,k)}}function W(O,v,C){return v&&H(O.prototype,v),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 v=O.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(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)},v.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)},v.onMediaAttached=function(k,_){this.media=_.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},v.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},v.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},v.onLevelUpdated=function(k,_){var A=_.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(k,_){if(_.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,P.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.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 E=this.config,u=E.lowLatencyMode,o=E.maxLiveSyncPlaybackRate;if(!u||o===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,o)),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)},v.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},v.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},W(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,E=k.targetduration,u=this.config,o=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,w=this.hls.userConfig,g=h&&A||_;(w.liveSyncDuration||w.liveSyncDurationCount||g===0)&&(g=o!==void 0?o:l*E);var m=E,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 E=A.edge,u=k-_-this.edgeStalled,o=E-A.totalduration,l=E-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,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"),W=D("./src/controller/level-helper.ts"),M=D("./src/controller/base-playlist-controller.ts"),O=D("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var w in h)Object.prototype.hasOwnProperty.call(h,w)&&(o[w]=h[w])}return o},v.apply(this,arguments)}function C(o,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(o,w.key,w)}}function k(o,l,h){return l&&C(o.prototype,l),h&&C(o,h),o}function _(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,A(o,l)}function A(o,l){return A=Object.setPrototypeOf||function(w,g){return w.__proto__=g,w},A(o,l)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){_(l,o);function l(w){var g;return g=o.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,o.prototype.destroy.call(this)},h.startLoad=function(){var g=this._levels;g.forEach(function(m){m.loadError=0}),o.prototype.startLoad.call(this)},h.onManifestLoaded=function(g,m){var L=[],x=[],f=[],p,d={},a,b=!1,y=!1,T=!1;if(m.levels.forEach(function(J){var z=J.attrs;b=b||!!(J.width&&J.height),y=y||!!J.videoCodec,T=T||!!J.audioCodec,E&&J.audioCodec&&J.audioCodec.indexOf("mp4a.40.34")!==-1&&(J.audioCodec=void 0);var j=J.bitrate+"-"+J.attrs.RESOLUTION+"-"+J.attrs.CODECS;a=d[j],a?a.url.push(J.url):(a=new V.Level(J),d[j]=a,L.push(a)),z&&(z.AUDIO&&Object(W.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(W.addGroupId)(a,"text",z.SUBTITLES))}),(b||y)&&T&&(L=L.filter(function(J){var z=J.videoCodec,j=J.width,q=J.height;return!!z||!!(j&&q)})),L=L.filter(function(J){var z=J.audioCodec,j=J.videoCodec;return(!z||Object(H.isCodecSupportedInMp4)(z,"audio"))&&(!j||Object(H.isCodecSupportedInMp4)(j,"video"))}),m.audioTracks&&(x=m.audioTracks.filter(function(J){return!J.audioCodec||Object(H.isCodecSupportedInMp4)(J.audioCodec,"audio")}),Object(W.assignTrackIdsByGroup)(x)),m.subtitles&&(f=m.subtitles,Object(W.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&&!y,X={levels:L,audioTracks:x,subtitleTracks:f,firstLevel:this._firstLevel,stats:m.stats,audio:T,video:y,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(o.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 a=this._levels[m.frag.level];a?(a.fragmentError++,a.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 a=p.url.length;if(a>1&&p.loadError<a)g.levelRetry=!0,this.redundantFailover(m);else if(this.manualLevelIndex===-1){var b=m===0?this._levels.length-1:m-1;this.currentLevelIndex!==b&&this._levels[b].loadError===0&&(this.warn(f+": switch to "+b),g.levelRetry=!0,this.hls.nextAutoLevel=b)}}},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(a){a.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 a=v({},d,{level:g,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete a._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,a);var b=d.details;if(!b||b.live){var y=this.switchParams(d.uri,p==null?void 0:p.details);this.loadPlaylist(y)}}},{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 W}),D.d($,"updateFragPTSDTS",function(){return O}),D.d($,"mergeDetails",function(){return v}),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 E}),D.d($,"getFragmentWithSN",function(){return u}),D.d($,"getPartWith",function(){return o});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 W(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,a=h.endPTS;if(Object(V.isFiniteNumber)(d)){var b=Math.abs(d-w);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(b,h.deltaPTS):h.deltaPTS=b,f=Math.max(w,d),w=Math.min(w,d),m=Math.min(m,h.startDTS),p=Math.min(g,a),g=Math.max(g,a),L=Math.max(L,h.endDTS)}h.duration=g-w;var y=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,y}function v(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 a=h.fragments;if(x){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].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),a.length&&(h.totalduration=h.edge-a[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var y=h.advancedDateTime;if(h.advanced&&y){var T=h.edge;h.driftStart||(h.driftStartTime=y,h.driftStart=T),h.driftEndTime=y,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 a=p[x+d],b=f[d];g&&!b&&d<g&&(b=h.fragments[d]=a),a&&b&&w(a,b)}}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 E(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 o(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"),W=D("./src/utils/buffer-helper.ts"),M=D("./src/controller/fragment-tracker.ts"),O=D("./src/types/loader.ts"),v=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"),E=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 o(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,a=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=a.startLevel;b===-1&&(a.config.testBandwidth?(b=0,this.bitrateTest=!0):b=a.nextAutoLevel),this.level=a.nextLoadLevel=b,this.loadedmetadata=!1}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,a=this.level,b=d==null||((p=d[a])===null||p===void 0)?void 0:p.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var y,T=self.performance.now(),I=this.retryDate;(!I||T>=I||(y=this.media)!==null&&y!==void 0&&y.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,a=this.hls,b=this.levelLastLoaded,y=this.levels,T=this.media,I=a.config,G=a.nextLoadLevel;if(b===null||!T&&(this.startFragRequested||!I.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!y||!y[G])return;var X=y[G];this.level=a.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 j=z.len,q=this.getMaxBufferLength(X.maxBitrate);if(j>=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 ke=ve.sn-J.startSN;ke>1&&(ve=J.fragments[ke-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===M.FragmentState.OK&&this.nextLoadPosition>ce){var xe=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.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,a){var b,y=this.fragmentTracker.getState(p);if(this.fragCurrent=p,y===M.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(p);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else y=M.FragmentState.NOT_LOADED}y===M.FragmentState.NOT_LOADED||y===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,a)):y===M.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((b=this.media)===null||b===void 0?void 0:b.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 a,b=this.getAppendedFrag(d.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!d.paused&&p){var y=this.hls.nextLoadLevel,T=p[y],I=this.fragLastKbps;I&&this.fragCurrent?a=this.fragCurrent.duration*T.maxBitrate/(1e3*I)+1:a=0}else a=0;var G=this.getBufferedFrag(d.currentTime+a);if(G){var X=this.followingBufferedFrag(G);if(X){this.abortCurrentFrag();var J=X.maxStartPTS?X.maxStartPTS:X.start,z=X.duration,j=Math.max(G.end,J+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(j,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 a=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new _.default(this.config,a,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 a=!1,b=!1,y;d.levels.forEach(function(T){y=T.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(a=!0),y.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!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 a=this.levels;if(!a||this.state!==N.State.IDLE)return;var b=a[d.level];(!b.details||b.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(b.details))&&(this.state=N.State.WAITING_LEVEL)},x.onLevelLoaded=function(p,d){var a,b=this.levels,y=d.level,T=d.details,I=T.totalduration;if(!b){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" 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=b[y],J=0;if(T.live||(a=X.details)!==null&&a!==void 0&&a.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;J=this.alignPlaylists(T,X.details)}if(X.details=T,this.levelLastLoaded=y,this.hls.trigger(H.Events.LEVEL_UPDATED,{details:T,level:y}),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,a=p.frag,b=p.part,y=p.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var I=T[a.level],G=I.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var X=I.videoCodec,J=G.PTSKnown||!G.live,z=(d=a.initSegment)===null||d===void 0?void 0:d.data,j=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=b?b.index:-1,ce=ne!==-1,ve=new k.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,y.byteLength,ne,ce),ke=this.initPTS[a.cc];q.push(y,z,j,X,a,b,G.totalduration,J,ve,ke)},x.onAudioTrackSwitching=function(p,d){var a=this.altAudio,b=!!d.url,y=d.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var 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;a&&I.trigger(H.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),I.trigger(H.Events.AUDIO_TRACK_SWITCHED,{id:y})}},x.onAudioTrackSwitched=function(p,d){var a=d.id,b=!!this.hls.audioTracks[a].url;if(b){var y=this.videoBuffer;y&&this.mediaBuffer!==y&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=y)}this.altAudio=b,this.tick()},x.onBufferCreated=function(p,d){var a=d.tracks,b,y,T=!1;for(var I in a){var G=a[I];if(G.id==="main"){if(y=I,b=G,I==="video"){var X=a[I];X&&(this.videoBuffer=X.buffer)}}else T=!0}T&&b?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(p,d){var a=d.frag,b=d.part;if(a&&a.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var y=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*y.total/(y.buffering.end-y.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},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 a=!0,b=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var p=this.media,d=this.gapController;if(!p||!d||!p.readyState)return;var a=W.BufferHelper.getBuffered(p);!this.loadedmetadata&&a.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 a=d.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,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,a=this.startPosition;if(a>=0&&d<a){if(p.seeking){E.logger.log("could not seek to "+a+", already seeking at "+d);return}var b=W.BufferHelper.getBuffered(p),y=b.length?b.start(0):0,T=y-a;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(E.logger.log("adjusting start position by "+T+" to match buffer start"),a+=T,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+d),p.currentTime=a}},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(a){var b=d.hls;if(!a||b.nextLoadLevel||d.fragContextChanged(p))return;d.fragLoadError=0,d.state=N.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var y=p.stats;y.parsing.start=y.parsing.end=y.buffering.start=y.buffering.end=self.performance.now(),b.trigger(H.Events.FRAG_LOADED,a)})},x._handleTransmuxComplete=function(p){var d,a="main",b=this.hls,y=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=y.video,j=y.text,q=y.id3,ne=y.initSegment,ce=this.altAudio?void 0:y.audio;if(this.fragContextChanged(G))return;if(this.state=N.State.PARSING,ne){ne.tracks&&(this._bufferInitSegment(J,ne.tracks,G,T),b.trigger(H.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ne.tracks}));var ve=ne.initPTS,ke=ne.timescale;Object(V.isFiniteNumber)(ve)&&(this.initPTS[G.cc]=ve,b.trigger(H.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:ve,timescale:ke}))}if(z&&y.independent!==!1){if(J.details){var xe=z.startPTS,Ce=z.endPTS,Se=z.startDTS,Ee=z.endDTS;if(X)X.elementaryStreams[z.type]={startPTS:xe,endPTS:Ce,startDTS:Se,endDTS:Ee};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var me=this.getLoadPosition()+this.config.maxBufferHole;if(me<xe){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Ce,G.start,Ee,!0)}G.setElementaryStreamInfo(z.type,xe,Ce,Se,Ee),this.bufferFragmentData(z,G,X,T)}}else if(y.independent===!1){this.backtrack(G);return}if(ce){var se=ce.startPTS,De=ce.endPTS,ze=ce.startDTS,He=ce.endDTS;X&&(X.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:De,startDTS:ze,endDTS:He}),G.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,se,De,ze,He),this.bufferFragmentData(ce,G,X,T)}if(q!=null&&(d=q.samples)!==null&&d!==void 0&&d.length){var qe={frag:G,id:a,samples:q.samples};b.trigger(H.Events.FRAG_PARSING_METADATA,qe)}if(j){var Ke={frag:G,id:a,samples:j.samples};b.trigger(H.Events.FRAG_PARSING_USERDATA,Ke)}},x._bufferInitSegment=function(p,d,a,b){var y=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 j=d[z],q=j.initSegment;q!=null&&q.byteLength&&y.hls.trigger(H.Events.BUFFER_APPENDING,{type:z,data:q,frag:a,part:null,chunkMeta:b,parent:a.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 a=p.currentTime;if(W.BufferHelper.isBuffered(p,a)?d=this.getAppendedFrag(a):W.BufferHelper.isBuffered(p,a+.1)&&(d=this.getAppendedFrag(a+.1)),d){var b=this.fragPlaying,y=d.level;(!b||d.sn!==b.sn||b.level!==y||d.urlId!==b.urlId)&&(this.hls.trigger(H.Events.FRAG_CHANGED,{frag:d}),(!b||b.level!==y)&&this.hls.trigger(H.Events.LEVEL_SWITCHED,{level:y}),this.fragPlaying=d)}}},o(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"),W=D("./src/utils/discontinuities.ts"),M=D("./src/controller/level-helper.ts"),O=D("./src/controller/fragment-tracker.ts"),v=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 E(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 o=500,l=function(h){E(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=v.State.IDLE,this.setInterval(o),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=v.State.IDLE,!p)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var a,b=f.start,y=0;y<d.length;y++)if(b>=d[y].start&&b<=d[y].end){a=d[y];break}var T=f.start+f.duration;a?a.end=T:(a={start:b,end:T},d.push(a)),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,a=this.levels;if(!a.length||!a[d]||!a[d].details)return;var b=a[d].details,y=b.targetduration,T=p-y;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=v.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(o)},g.onSubtitleTrackLoaded=function(L,x){var f,p=x.details,d=x.id,a=this.currentTrackId,b=this.levels;if(!b.length)return;var y=b[a];if(d>=b.length||d!==a||!y)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=y.details)!==null&&f!==void 0&&f.live){var T=this.mainDetails;if(p.deltaUpdateFailed||!T)return;var I=T.fragments[0];if(!y.details)p.hasProgramDateTime&&T.hasProgramDateTime?Object(W.alignMediaPlaylistByPDT)(p,T):I&&Object(M.addSliding)(p,I.start);else{var G=this.alignPlaylists(p,y.details);G===0&&I&&Object(M.addSliding)(p,I.start)}}if(y.details=p,this.levelLastLoaded=d,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var X=Object(H.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);X||(this.warn("Subtitle playlist not aligned with playback"),y.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 a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(b){var y=performance.now();d.trigger(V.Events.FRAG_DECRYPTED,{frag:x,payload:b,stats:{tstart:a,tdecrypt:y}})})}},g.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.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,a=this.config,b=this.media,y=P.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-d,a.maxBufferHole),T=y.end,I=y.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,j,q=this.fragPrevious;if(T<z){var ne=a.maxFragLookUpTolerance;q&&p.hasProgramDateTime&&(j=Object(H.findFragmentByPDT)(X,q.endProgramDateTime,ne)),j||(j=Object(H.findFragmentByPTS)(q,X,T,ne),!j&&q&&q.start<X[0].start&&(j=X[0]))}else j=X[J-1];(L=j)!==null&&L!==void 0&&L.encrypted?(N.logger.log("Loading key for "+j.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:j})):j&&this.fragmentTracker.getState(j)===O.FragmentState.NOT_LOADED&&this.loadFragment(j,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}(v.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 W(_,A){for(var E=0;E<A.length;E++){var u=A[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(_,u.key,u)}}function M(_,A,E){return A&&W(_.prototype,A),E&&W(_,E),_}function O(_,A){_.prototype=Object.create(A.prototype),_.prototype.constructor=_,v(_,A)}function v(_,A){return v=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},v(_,A)}var C=function(_){O(A,_);function A(u){var o;return o=_.call(this,u,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var E=A.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,_.prototype.destroy.call(this)},E.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(V.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(V.Events.ERROR,this.onError,this)},E.onMediaAttached=function(o,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},E.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},E.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=k(this.media.textTracks);o.forEach(function(l){Object(N.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},E.onSubtitleTrackLoaded=function(o,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))},E.onLevelLoading=function(o,l){this.switchLevel(l.level)},E.onLevelSwitching=function(o,l){this.switchLevel(l.level)},E.switchLevel=function(o){var l=this.hls.levels[o];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)}},E.findTrackId=function(o){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var w=l[h];if((!this.selectDefaultTrack||w.default)&&(!o||o===w.name))return w.id}return-1},E.onError=function(o,l){if(_.prototype.onError.call(this,o,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)},E.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,w=l.groupId,g=l.url;if(o)try{g=o.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:o||null})}},E.toggleTrackModes=function(o){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(o===-1)[].slice.call(m).forEach(function(p){p.mode="disabled"});else{var x=L[g];x&&(x.mode="disabled")}var f=L[o];f&&(f.mode=w?"showing":"hidden")},E.setSubtitleTrack=function(o,l){var h,w=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(h=w[o])!==null&&h!==void 0&&h.details)||o<-1||o>=w.length)return;this.clearTimer();var g=w[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,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 a=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:o})},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,l=k(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")o=h;else if(l[h].mode==="showing"){o=h;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},M(A,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,l)}}]),A}(P.default);function k(_){for(var A=[],E=0;E<_.length;E++){var u=_[E];u.kind==="subtitles"&&u.label&&A.push(_[E])}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"),W=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),O=D("./src/utils/imsc1-ttml-parser.ts"),v=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=E(),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 o=u.prototype;return o.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},o.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 a=this.captionsTracks[h];this.Cues.newCue(a,w,g,m)}else{var b=this.Cues.newCue(null,w,g,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:b,track:h})}},o.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)}))},o.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},o.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},o.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)}},o.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]})},o.createTextTrack=function(h,w,g){var m=this.media;return m?m.addTextTrack(h,w,g):void 0},o.onMediaAttaching=function(h,w){this.media=w.media,this._cleanTracks()},o.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(w){Object(M.clearCurrentCues)(h[w]),delete h[w]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=E(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var 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])},o.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,a){var b;if(a<f.length){for(var y=null,T=0;T<f.length;T++)if(_(f[T],d)){y=f[T];break}y&&(b=y)}b?Object(M.clearCurrentCues)(b):(b=g.createTextTrack("subtitles",d.name,d.lang),b&&(b.mode="disabled")),b&&(b.groupId=d.groupId,g.textTracks.push(b))})}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})}}},o.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})},o.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===v.PlaylistLevelType.MAIN){var f,p,d=w.frag.sn,a=(f=w==null||((p=w.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;d===L+1||d===L&&a===x+1||(g.reset(),m.reset()),this.lastSn=d,this.lastPartIndex=a}},o.onFragLoaded=function(h,w){var g=w.frag,m=w.payload,L=this.initPTS,x=this.unparsedVttFrags;if(g.type===v.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")})},o._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})})},o._parseVTTs=function(h,w,g){var m=this,L=this.hls;Object(W.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})})},o._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"})},o._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})}},o.onFragDecrypted=function(h,w){var g=w.frag;if(g.type===v.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[g.cc])){this.unparsedVttFrags.push(w);return}this.onFragLoaded(N.Events.FRAG_LOADED,w)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.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])}}},o.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(a){return Object(M.removeCuesInRange)(p[a],g,m)})}if(this.config.renderTextTracksNatively&&(g===0&&L!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(a){return Object(M.removeCuesInRange)(d[a],g,L)})}},o.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,a=3&x;if(f===0&&p===0)continue;d&&((a===0||a===1)&&(m[a].push(f),m[a].push(p)))}return m},u}();function _(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function A(u,o,l,h){return Math.min(o,h)-Math.max(u,l)}function E(){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,W){this.subtle=void 0,this.aesIV=void 0,this.subtle=H,this.aesIV=W}var P=N.prototype;return P.decrypt=function(W,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,W)},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 W=H.byteLength,M=W&&new DataView(H.buffer).getUint8(W-1);return M?Object(V.sliceUint8)(H,0,W-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 W=H.prototype;return W.uint8ArrayToUint32Array_=function(O){for(var v=new DataView(O),C=new Uint32Array(4),k=0;k<4;k++)C[k]=v.getUint32(k*4);return C},W.initTable=function(){var O=this.sBox,v=this.invSBox,C=this.subMix,k=C[0],_=C[1],A=C[2],E=C[3],u=this.invSubMix,o=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,v[f]=m;var p=g[m],d=g[p],a=g[d],b=g[f]*257^f*16843008;k[m]=b<<24|b>>>8,_[m]=b<<16|b>>>16,A[m]=b<<8|b>>>24,E[m]=b,b=a*16843009^d*65537^p*257^m*16843008,o[f]=b<<24|b>>>8,l[f]=b<<16|b>>>16,h[f]=b<<8|b>>>24,w[f]=b,m?(m=p^g[g[g[a^p]]],L^=g[g[L]]):m=L=1}},W.expandKey=function(O){for(var v=this.uint8ArrayToUint32Array_(O),C=!0,k=0;k<v.length&&C;)C=v[k]===this.key[k],k++;if(C)return;this.key=v;var _=this.keySize=v.length;if(_!==4&&_!==6&&_!==8)throw new Error("Invalid aes key size="+_);var A=this.ksRows=(_+6+1)*4,E,u,o=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(E=0;E<A;E++){if(E<_){p=o[E]=v[E];continue}d=p,E%_===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[E/_|0]<<24):_>6&&E%_===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),o[E]=p=(o[E-_]^d)>>>0}for(u=0;u<A;u++)E=A-u,u&3?d=o[E]:d=o[E-4],u<4||E<=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},W.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},W.decrypt=function(O,v,C){for(var k=this.keySize+6,_=this.invKeySchedule,A=this.invSBox,E=this.invSubMix,u=E[0],o=E[1],l=E[2],h=E[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,a,b,y,T,I,G,X,J,z,j,q,ne,ce,ve=this.networkToHostOrderSwap;v<f.length;){for(J=ve(f[v]),z=ve(f[v+1]),j=ve(f[v+2]),q=ve(f[v+3]),T=J^_[0],I=q^_[1],G=j^_[2],X=z^_[3],ne=4,ce=1;ce<k;ce++)d=u[T>>>24]^o[I>>16&255]^l[G>>8&255]^h[X&255]^_[ne],a=u[I>>>24]^o[G>>16&255]^l[X>>8&255]^h[T&255]^_[ne+1],b=u[G>>>24]^o[X>>16&255]^l[T>>8&255]^h[I&255]^_[ne+2],y=u[X>>>24]^o[T>>16&255]^l[I>>8&255]^h[G&255]^_[ne+3],T=d,I=a,G=b,X=y,ne=ne+4;d=A[T>>>24]<<24^A[I>>16&255]<<16^A[G>>8&255]<<8^A[X&255]^_[ne],a=A[I>>>24]<<24^A[G>>16&255]<<16^A[X>>8&255]<<8^A[T&255]^_[ne+1],b=A[G>>>24]<<24^A[X>>16&255]<<16^A[T>>8&255]<<8^A[I&255]^_[ne+2],y=A[X>>>24]<<24^A[T>>16&255]<<16^A[I>>8&255]<<8^A[G&255]^_[ne+3],p[v]=ve(d^g),p[v+1]=ve(y^m),p[v+2]=ve(b^L),p[v+3]=ve(a^x),g=J,m=z,L=j,x=q,v=v+4}return p.buffer},H}()},"./src/crypt/decrypter.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return v});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"),W=D("./src/utils/mp4-tools.ts"),M=D("./src/utils/typed-array.ts"),O=16,v=function(){function C(_,A,E){var u=E===void 0?{}:E,o=u.removePKCS7Padding,l=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=_,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 E=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(P.removePadding)(E):E},k.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},k.decrypt=function(A,E,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),E,u);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),E,u).then(o)},k.softwareDecrypt=function(A,E,u){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(A=Object(W.appendUint8Array)(h,A),this.remainderData=null);var w=this.getValidChunk(A);if(!w.length)return null;o&&(u=o);var g=this.softwareDecrypter;g||(g=this.softwareDecrypter=new P.default),g.expandKey(E);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,E,u){var o=this,l=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new N.default(l,E)),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 o.onWebCryptoError(h,A,E,u)})},k.onWebCryptoError=function(A,E,u,o){return H.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,u,o)},k.getValidChunk=function(A){var E=A,u=A.length-A.length%O;return u!==A.length&&(E=Object(M.sliceUint8)(A,0,u),this.remainderData=Object(M.sliceUint8)(A,u)),E},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,W){this.subtle=void 0,this.key=void 0,this.subtle=H,this.key=W}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 W(v,C){v.prototype=Object.create(C.prototype),v.prototype.constructor=v,M(v,C)}function M(v,C){return M=Object.setPrototypeOf||function(_,A){return _.__proto__=A,_},M(v,C)}var O=function(v){W(C,v);function C(_,A){var E;return E=v.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=_,E.config=A,E}var k=C.prototype;return k.resetInitSegment=function(A,E,u){v.prototype.resetInitSegment.call(this,A,E,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 E=H.getID3Data(A,0)||[],u=E.length,o=A.length;u<o;u++)if(N.probe(A,u))return P.logger.log("ADTS sync word found !"),!0;return!1},k.canParse=function(A,E){return N.canParse(A,E)},k.appendFrame=function(A,E,u){N.initTrackConfig(A,this.observer,E,u,A.manifestCodec);var o=N.appendFrame(A,E,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},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 W}),D.d($,"getHeaderLength",function(){return M}),D.d($,"getFullFrameLength",function(){return O}),D.d($,"canGetFrameLength",function(){return v}),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 E}),D.d($,"parseFrameHeader",function(){return u}),D.d($,"appendFrame",function(){return o});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,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((h[w+2]&192)>>>6)+1;var b=(h[w+2]&60)>>>2;if(b>a.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:"+b});return}return x=(h[w+2]&1)<<2,x|=(h[w+3]&192)>>>6,V.logger.log("manifest codec:"+g+", ADTS type:"+m+", samplingIndex:"+b),/firefox/i.test(p)?b>=6?(m=5,f=new Array(4),L=b-3):(m=2,f=new Array(2),L=b):p.indexOf("android")!==-1?(m=2,f=new Array(2),L=b):(m=5,f=new Array(4),g&&(g.indexOf("mp4a.40.29")!==-1||g.indexOf("mp4a.40.5")!==-1)||!g&&b>=6?L=b-3:((g&&g.indexOf("mp4a.40.2")!==-1&&(b>=6&&x===1||/vivaldi/i.test(p))||!g&&x===1)&&(m=2,f=new Array(2)),L=b)),f[0]=m<<3,f[0]|=(b&14)>>1,f[1]|=(b&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:a[b],channelCount:x,codec:"mp4a.40."+m,manifestCodec:d}}function W(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 v(l,h){return h+5<l.length}function C(l,h){return h+1<l.length&&W(l,h)}function k(l,h){return v(l,h)&&W(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 E(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 o(l,h,w,g,m){var L=E(l.samplerate),x=u(h,w,g,m,L);if(x){var f=x.frameLength,p=x.headerLength,d=x.stamp,a=p+f,b=Math.max(0,w+a-h.length),y;b?(y=new Uint8Array(a-p),y.set(h.subarray(w+p,h.length),0)):y=h.subarray(w+p,w+a);var T={unit:y,pts:d};return b||l.samples.push(T),{sample:T,length:a,missing:b}}}},"./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"),W=D("./src/utils/typed-array.ts"),M=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var C=v.prototype;return C.resetInitSegment=function(_,A,E){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,E){},C.demux=function(_,A){this.cachedData&&(_=Object(H.appendUint8Array)(this.cachedData,_),this.cachedData=null);var E=N.getID3Data(_,0),u=E?E.length:0,o,l,h=this._audioTrack,w=this._id3Track,g=E?N.getTimeStamp(E):void 0,m=_.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(g,A)),E&&E.length>0&&w.samples.push({pts:this.initPTS,dts:this.initPTS,data:E}),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,o=u):u=m}else N.canParse(_,u)?(E=N.getID3Data(_,u),w.samples.push({pts:l,dts:l,data:E}),u+=E.length,o=u):u++;if(u===m&&o!==m){var x=Object(W.sliceUint8)(_,o);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,E){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(){},v}(),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,v;if(M.length)M.length===1?v=M[0]:v=N(M,O);else return new Uint8Array(0);return this.reset(),v},H.reset=function(){this.chunks.length=0,this.dataLength=0},P}();function N(P,H){for(var W=new Uint8Array(H),M=0,O=0;O<P.length;O++){var v=P[O];W.set(v,M),M+=v.length}return W}},"./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(W){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=W,this.bytesAvailable=W.byteLength,this.word=0,this.bitsAvailable=0}var H=P.prototype;return H.loadWord=function(){var M=this.data,O=this.bytesAvailable,v=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(v,v+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),v=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?v<<O|this.readBits(O):v},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,v=8,C,k=0;k<M;k++)v!==0&&(C=this.readEG(),v=(O+C+256)%256),O=v===0?O:v},H.readSPS=function(){var M=0,O=0,v=0,C=0,k,_,A,E=this.readUByte.bind(this),u=this.readBits.bind(this),o=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);E();var L=E();if(u(5),h(3),E(),g(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var x=o();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=o();if(f===0)o();else if(f===1)for(h(1),w(),w(),k=o(),A=0;A<k;A++)w();g(),h(1);var p=o(),d=o(),a=u(1);a===0&&h(1),h(1),l()&&(M=o(),O=o(),v=o(),C=o());var b=[1,1];if(l()&&l()){var y=E();switch(y){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((p+1)*16-M*2-O*2),height:(2-a)*(d+1)*16-(a?2:4)*(v+C),pixelRatio:b}},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 W}),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 o}),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},W=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"},v=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=v(m.subarray(L)),a=k(d);a&&x.push(a),L+=d.size+10}N(m,L)&&(L+=10)}return x},k=function(m){return m.type==="PRIV"?_(m):m.type[0]==="W"?E(m):A(m)},_=function(m){if(m.size<2)return;var L=o(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=o(m.data.subarray(L),!0);L+=x.length+1;var f=o(m.data.subarray(L));return{key:m.type,info:x,data:f}}var p=o(m.data.subarray(1));return{key:m.type,data:p}},E=function(m){if(m.type==="WXXX"){if(m.size<2)return;var L=1,x=o(m.data.subarray(L),!0);L+=x.length+1;var f=o(m.data.subarray(L));return{key:m.type,info:x,data:f}}var p=o(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},o=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,a,b,y,T="",I=0;I<d;){if(a=m[I++],a===0&&L)return T;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(a);break;case 12:case 13:b=m[I++],T+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=m[I++],y=m[I++],T+=String.fromCharCode((a&15)<<12|(b&63)<<6|(y&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 W(v,C){v.prototype=Object.create(C.prototype),v.prototype.constructor=v,M(v,C)}function M(v,C){return M=Object.setPrototypeOf||function(_,A){return _.__proto__=A,_},M(v,C)}var O=function(v){W(C,v);function C(){return v.apply(this,arguments)||this}var k=C.prototype;return k.resetInitSegment=function(A,E,u){v.prototype.resetInitSegment.call(this,A,E,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 E=N.getID3Data(A,0)||[],u=E.length,o=A.length;u<o;u++)if(H.probe(A,u))return P.logger.log("MPEG Audio sync word found !"),!0;return!1},k.canParse=function(A,E){return H.canParse(A,E)},k.appendFrame=function(A,E,u){return this.initPTS===null?void 0:H.appendFrame(A,E,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 W=H.prototype;return W.resetTimeStamp=function(){},W.resetInitSegment=function(){},W.resetContiguity=function(){},H.probe=function(O){return Object(V.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},W.demux=function(O){var v=O,C=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(V.appendUint8Array)(this.remainderData,O));var k=Object(V.segmentValidRange)(v);this.remainderData=k.remainder,C.samples=k.valid||new Uint8Array}else C.samples=v;return{audioTrack:Object(N.dummyTrack)(),avcTrack:C,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},W.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)()}},W.demuxSampleAes=function(O,v,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},W.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 v}),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]],W=[0,1,1,4];function M(A,E,u,o,l){if(u+24>E.length)return;var h=O(E,u);if(h&&u+h.frameLength<=E.length){var w=h.samplesPerFrame*9e4/h.sampleRate,g=o+l*w,m={unit:E.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,E){var u=A[E+1]>>3&3,o=A[E+1]>>1&3,l=A[E+2]>>4&15,h=A[E+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var w=A[E+2]>>1&1,g=A[E+3]>>6,m=u===3?3-o:o===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][o],a=W[o],b=d*8*a,y=Math.floor(d*L/f+w)*a;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&&o===2&&L>=224e3&&g===0&&(A[E+3]=A[E+3]|128),{sampleRate:f,channelCount:p,frameLength:y,samplesPerFrame:b}}}function v(A,E){return A[E]===255&&(A[E+1]&224)===224&&(A[E+1]&6)!==0}function C(A,E){return E+1<A.length&&v(A,E)}function k(A,E){var u=4;return v(A,E)&&u<=A.length-E}function _(A,E){if(E+1<A.length&&v(A,E)){var u=4,o=O(A,E),l=u;o!=null&&o.frameLength&&(l=o.frameLength);var h=E+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,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new V.default(M,O,{removePKCS7Padding:!1})}var W=H.prototype;return W.decryptBuffer=function(O,v){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,v)},W.decryptAacSample=function(O,v,C,k){var _=O[v].unit,A=_.subarray(16,_.length-_.length%16),E=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),u=this;this.decryptBuffer(E,function(o){var l=new Uint8Array(o);_.set(l,16),k||u.decryptAacSamples(O,v+1,C)})},W.decryptAacSamples=function(O,v,C){for(;;v++){if(v>=O.length){C();return}if(O[v].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(O,v,C,k),!k)return}},W.getAvcEncryptedData=function(O){for(var v=Math.floor((O.length-48)/160)*16+16,C=new Int8Array(v),k=0,_=32;_<=O.length-16;_+=160,k+=16)C.set(O.subarray(_,_+16),k);return C},W.getAvcDecryptedUnit=function(O,v){for(var C=new Uint8Array(v),k=0,_=32;_<=O.length-16;_+=160,k+=16)O.set(C.subarray(k,k+16),_);return O},W.decryptAvcSample=function(O,v,C,k,_,A){var E=Object(N.discardEPB)(_.data),u=this.getAvcEncryptedData(E),o=this;this.decryptBuffer(u.buffer,function(l){_.data=o.getAvcDecryptedUnit(E,l),A||o.decryptAvcSamples(O,v,C+1,k)})},W.decryptAvcSamples=function(O,v,C,k){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,C=0){if(v>=O.length){k();return}for(var _=O[v].units;!(C>=_.length);C++){var A=_[C];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var E=this.decrypter.isSync();if(this.decryptAvcSample(O,v,C,k,A,E),!E)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"),W=D("./src/utils/logger.ts"),M=D("./src/errors.ts"),O=D("./src/utils/mediasource-helper.ts"),v=D("./node_modules/eventemitter3/index.js"),C=D.n(v),k=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},_=function(){function A(u,o,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=o,this.onTransmuxComplete=l,this.onFlush=h;var g=u.config,m=function(d,a){a=a||{},a.frag=w.frag,a.id=w.id,u.trigger(d,a)};this.observer=new v.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"){W.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:o,config:JSON.stringify(g)})}catch(p){W.logger.warn("Error in worker:",p),W.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,o),this.worker=null}}else this.transmuxer=new H.default(this.observer,L,g,x,o)}var E=A.prototype;return E.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},E.push=function(o,l,h,w,g,m,L,x,f,p){var d=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,y=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,j=!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||!j)&&(m.stats.parsing.start=q);var ne=new H.TransmuxState(G,j,x,X,y);if(!j||G){W.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: `+j+`
|
|
accurateTimeOffset: `+x+`
|
|
timeOffset: `+y);var ce=new H.TransmuxConfig(h,w,l,L,p);this.configureTransmuxer(ce)}if(this.frag=g,this.part=m,b)b.postMessage({cmd:"demux",data:o,decryptdata:T,chunkMeta:f,state:ne},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,T,f,ne);Object(H.isPromise)(ve)?ve.then(function(ke){d.handleTransmuxComplete(ke)}):this.handleTransmuxComplete(ve)}},E.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,w=this.worker;if(w)w.postMessage({cmd:"flush",chunkMeta:o});else if(h){var g=h.flush(o);Object(H.isPromise)(g)?g.then(function(m){l.handleFlushResult(m,o)}):this.handleFlushResult(g,o)}},E.handleFlushResult=function(o,l){var h=this;o.forEach(function(w){h.handleTransmuxComplete(w)}),this.onFlush(l)},E.onWorkerMessage=function(o){var l=o.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}}},E.configureTransmuxer=function(o){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},E.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},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"),W=D.n(H);function M(_){var A=new H.EventEmitter,E=function(o,l){_.postMessage({event:o,data:l})};A.on(N.Events.FRAG_DECRYPTED,E),A.on(N.Events.ERROR,E),_.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);_.transmuxer=new V.default(A,o.typeSupported,l,o.vendor,o.id),Object(P.enableLogs)(l.debug),E("init",null);break}case"configure":{_.transmuxer.configure(o.config);break}case"demux":{var h=_.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(V.isPromise)(h)?h.then(function(m){O(_,m)}):O(_,h);break}case"flush":{var w=o.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 E=[],u=A.remuxResult,o=u.audio,l=u.video;o&&v(E,o),l&&v(E,l),_.postMessage({event:"transmuxComplete",data:A},E)}function v(_,A){A.data1&&_.push(A.data1.buffer),A.data2&&_.push(A.data2.buffer)}function C(_,A,E){A.forEach(function(u){O(_,u)}),_.postMessage({event:"flush",data:E})}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"),W=D("./src/demux/mp4demuxer.ts"),M=D("./src/demux/tsdemuxer.ts"),O=D("./src/demux/mp3demuxer.ts"),v=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"),E;try{E=self.performance.now.bind(self.performance)}catch(x){A.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var u=[{demux:M.default,remux:v.default},{demux:W.default,remux:C.default},{demux:H.default,remux:v.default},{demux:O.default,remux:v.default}],o=1024;u.forEach(function(x){var f=x.demux;o=Math.max(o,f.minProbeByteLength)});var l=function(){function x(p,d,a,b,y){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=a,this.vendor=b,this.id=y}var f=x.prototype;return f.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},f.push=function(d,a,b,y){var T=this,I=b.transmuxing;I.executeStart=E();var G=new Uint8Array(d),X=this.cache,J=this.config,z=this.currentTransmuxState,j=this.transmuxConfig;y&&(this.currentTransmuxState=y);var q=h(G,a);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=E(),w(b);G=new Uint8Array(ce)}else return this.decryptionPromise=ne.webCryptoDecrypt(G,q.key.buffer,q.iv.buffer).then(function(Pe){var je=T.push(Pe,null,b);return T.decryptionPromise=null,je}),this.decryptionPromise}var ve=y||z,ke=ve.contiguous,xe=ve.discontinuity,Ce=ve.trackSwitch,Se=ve.accurateTimeOffset,Ee=ve.timeOffset,me=j.audioCodec,se=j.videoCodec,De=j.defaultInitPts,ze=j.duration,He=j.initSegmentData;if((xe||Ce)&&this.resetInitSegment(He,me,se,ze),xe&&this.resetInitialTimestamp(De),ke||this.resetContiguity(),this.needsProbing(G,xe,Ce)){if(X.dataLength){var qe=X.flush();G=Object(_.appendUint8Array)(qe,G)}this.configureTransmuxer(G,j)}var Ke=this.transmux(G,q,Ee,Se,b),Le=this.currentTransmuxState;return Le.contiguous=!0,Le.discontinuity=!1,Le.trackSwitch=!1,I.executeEnd=E(),Ke},f.flush=function(d){var a=this,b=d.transmuxing;b.executeStart=E();var y=this.decrypter,T=this.cache,I=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(d)});var X=[],J=I.timeOffset;if(y){var z=y.flush();z&&X.push(this.push(z,null,d))}var j=T.dataLength;T.reset();var q=this.demuxer,ne=this.remuxer;if(!q||!ne)return j>=o&&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"}),b.executeEnd=E(),[w(d)];var ce=q.flush(J);return g(ce)?ce.then(function(ve){return a.flushRemux(X,ve,d),X}):(this.flushRemux(X,ce,d),X)},f.flushRemux=function(d,a,b){var y=a.audioTrack,T=a.avcTrack,I=a.id3Track,G=a.textTrack,X=this.currentTransmuxState,J=X.accurateTimeOffset,z=X.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var j=this.remuxer.remux(y,T,I,G,z,J,!0,this.id);d.push({remuxResult:j,chunkMeta:b}),b.transmuxing.executeEnd=E()},f.resetInitialTimestamp=function(d){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(d),b.resetTimeStamp(d)},f.resetContiguity=function(){var d=this.demuxer,a=this.remuxer;if(!d||!a)return;d.resetContiguity(),a.resetNextTimestamp()},f.resetInitSegment=function(d,a,b,y){var T=this.demuxer,I=this.remuxer;if(!T||!I)return;T.resetInitSegment(a,b,y),I.resetInitSegment(d,a,b)},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,a,b,y,T){var I;return a&&a.method==="SAMPLE-AES"?I=this.transmuxSampleAes(d,a,b,y,T):I=this.transmuxUnencrypted(d,b,y,T),I},f.transmuxUnencrypted=function(d,a,b,y){var T=this.demuxer.demux(d,a,!1,!this.config.progressive),I=T.audioTrack,G=T.avcTrack,X=T.id3Track,J=T.textTrack,z=this.remuxer.remux(I,G,X,J,a,b,!1,this.id);return{remuxResult:z,chunkMeta:y}},f.transmuxSampleAes=function(d,a,b,y,T){var I=this;return this.demuxer.demuxSampleAes(d,a,b).then(function(G){var X=I.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,b,y,!1,I.id);return{remuxResult:X,chunkMeta:T}})},f.configureTransmuxer=function(d,a){for(var b=this.config,y=this.observer,T=this.typeSupported,I=this.vendor,G=a.audioCodec,X=a.defaultInitPts,J=a.duration,z=a.initSegmentData,j=a.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:W.default,remux:C.default});var ve=this.demuxer,ke=this.remuxer,xe=q.remux,Ce=q.demux;(!ke||!(ke instanceof xe))&&(this.remuxer=new xe(y,b,T,I)),(!ve||!(ve instanceof Ce))&&(this.demuxer=new Ce(y,b,T),this.probe=Ce.probe),this.resetInitSegment(z,G,j,J),this.resetInitialTimestamp(X)},f.needsProbing=function(d,a,b){return!this.demuxer||!this.remuxer||a||b},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,a,b){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=a,this.defaultInitPts=b},L=function(f,p,d,a,b){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=a,this.timeOffset=b}},"./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"),W=D("./src/demux/sample-aes.ts"),M=D("./src/events.ts"),O=D("./src/utils/mp4-tools.ts"),v=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&&v.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 a,b=this._avcTrack,y=this._audioTrack,T=this._id3Track,I=b.pid,G=b.pesData,X=y.pid,J=T.pid,z=y.pesData,j=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:y,avcTrack:b,id3Track:T,textTrack:this._txtTrack};var ke=Math.max(0,g.syncOffset(x));ve-=(ve+ke)%188,ve<x.byteLength&&!d&&(this.remainderData=new Uint8Array(x.buffer,ve,x.buffer.byteLength-ve));for(var xe=ke;xe<ve;xe+=188)if(x[xe]===71){var Ce=!!(x[xe+1]&64),Se=((x[xe+1]&31)<<8)+x[xe+2],Ee=(x[xe+3]&48)>>4,me=void 0;if(Ee>1){if(me=xe+5+x[xe+4],me===xe+188)continue}else me=xe+4;switch(Se){case I:Ce&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(x.subarray(me,xe+188)),G.size+=xe+188-me);break;case X:Ce&&(z&&(a=o(z))&&(y.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(x.subarray(me,xe+188)),z.size+=xe+188-me);break;case J:Ce&&(j&&(a=o(j))&&this.parseID3PES(a),j={data:[],size:0}),j&&(j.data.push(x.subarray(me,xe+188)),j.size+=xe+188-me);break;case 0:Ce&&(me+=x[me]+1),ce=this._pmtId=E(x,me);break;case ce:{Ce&&(me+=x[me]+1);var se=u(x,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);I=se.avc,I>0&&(b.pid=I),X=se.audio,X>0&&(y.pid=X,y.isAAC=se.isAAC),J=se.id3,J>0&&(T.pid=J),q&&!ne&&(v.logger.log("reparse from beginning"),q=!1,xe=ke-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"});b.pesData=G,y.pesData=z,T.pesData=j;var De={audioTrack:y,avcTrack:b,id3Track:T,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(De),De},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,a=p.pesData,b=f.pesData,y=d.pesData,T;a&&(T=o(a))?(this.parseAVCPES(T,!0),p.pesData=null):p.pesData=a,b&&(T=o(b))?(f.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),f.pesData=null):(b!=null&&b.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=b),y&&(T=o(y))?(this.parseID3PES(T),d.pesData=null):d.pesData=y},m.demuxSampleAes=function(x,f,p){var d=this.demux(x,p,!0,!this.config.progressive),a=this.sampleAes=new W.default(this.observer,this.config,f);return this.decrypt(d,a)},m.decrypt=function(x,f){return new Promise(function(p){var d=x.audioTrack,a=x.avcTrack;d.samples&&d.isAAC?f.decryptAacSamples(d.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){p(x)}):p(x)}):a.samples&&f.decryptAvcSamples(a.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,a=this.parseAVCNALu(x.data),b=!1,y=this.avcSample,T,I=!1;x.data=null,y&&a.length&&!d.audFound&&(l(y,d),y=this.avcSample=A(!1,x.pts,x.dts,"")),a.forEach(function(G){switch(G.type){case 1:{T=!0,y||(y=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(y.debug+="NDR "),y.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)&&(y.key=!0)}break}case 5:T=!0,y||(y=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{T=!0,b&&y&&(y.debug+="SEI ");var z=new P.default(w(G.data));z.readUByte();for(var j=0,q=0,ne=!1,ce=0;!ne&&z.bytesAvailable>1;){j=0;do ce=z.readUByte(),j+=ce;while(ce===255);q=0;do ce=z.readUByte(),q+=ce;while(ce===255);if(j===4&&z.bytesAvailable!==0){ne=!0;var ve=z.readUByte();if(ve===181){var ke=z.readUShort();if(ke===49){var xe=z.readUInt();if(xe===1195456820){var Ce=z.readUByte();if(Ce===3){for(var Se=z.readUByte(),Ee=z.readUByte(),me=31&Se,se=[Se,Ee],De=0;De<me;De++)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(j===5&&z.bytesAvailable!==0){if(ne=!0,q>16){for(var ze=[],He=0;He<16;He++)ze.push(z.readUByte().toString(16)),(He===3||He===5||He===7||He===9)&&ze.push("-");for(var qe=q-16,Ke=new Uint8Array(qe),Le=0;Le<qe;Le++)Ke[Le]=z.readUByte();h(p._txtTrack.samples,{pts:x.pts,payloadType:j,uuid:ze.join(""),userData:Object(H.utf8ArrayToStr)(Ke),userDataBytes:Ke})}}else if(q<z.bytesAvailable)for(var Pe=0;Pe<q;Pe++)z.readUByte()}break}case 7:if(T=!0,I=!0,b&&y&&(y.debug+="SPS "),!d.sps){var je=new P.default(G.data),Xe=je.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),Me="avc1.",Ne=0;Ne<3;Ne++){var Qe=Ge[Ne].toString(16);Qe.length<2&&(Qe="0"+Qe),Me+=Qe}d.codec=Me}break;case 8:T=!0,b&&y&&(y.debug+="PPS "),d.pps||(d.pps=[G.data]);break;case 9:T=!1,d.audFound=!0,y&&l(y,d),y=p.avcSample=A(!1,x.pts,x.dts,b?"AUD ":"");break;case 12:T=!1;break;default:T=!1,y&&(y.debug+="unknown NAL "+G.type+" ");break}if(y&&T){var Je=y.units;Je.push(G)}}),f&&y&&(l(y,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 a=f.units;p=a[a.length-1]}return p},m.parseAVCNALu=function(x){var f=x.byteLength,p=this._avcTrack,d=p.naluState||0,a=d,b=[],y=0,T,I,G,X=-1,J=0;for(d===-1&&(X=0,J=x[0]&31,d=0,y=1);y<f;){if(T=x[y++],!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,y-d-1),type:J};b.push(z)}else{var j=this.getLastNalUnit();if(j&&(a&&y<=4-a&&(j.state&&(j.data=j.data.subarray(0,j.data.byteLength-a))),I=y-d-1,I>0)){var q=new Uint8Array(j.data.byteLength+I);q.set(j.data,0),q.set(x.subarray(0,I),j.data.byteLength),j.data=q,j.state=0}}y<f?(G=x[y]&31,X=y,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};b.push(ne)}if(b.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,b},m.parseAACPES=function(x){var f=0,p=this._audioTrack,d=this.aacOverFlow,a=x.data;if(d){this.aacOverFlow=null;var b=d.sample.unit.byteLength,y=Math.min(d.missing,b),T=b-y;d.sample.unit.set(a.subarray(0,y),T),p.samples.push(d.sample),f=d.missing}var I,G;for(I=f,G=a.length;I<G-1&&!V.isHeader(a,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),v.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,a,I,this.audioCodec);var z;if(x.pts!==void 0)z=x.pts;else if(d){var j=V.getFrameDuration(p.samplerate);z=d.sample.pts+j}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;I<G;)if(V.isHeader(a,I)){if(I+5<G){var ne=V.appendFrame(p,a,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,a=0,b=x.pts;if(b===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<p;)if(N.isHeader(f,a)){var y=N.appendFrame(this._audioTrack,f,a,b,d);if(y)a+=y.length,d++;else break}else a++},m.parseID3PES=function(x){if(x.pts===void 0){v.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 E(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,a=(g[m+10]&15)<<8|g[m+11];for(m+=12+a;m<d;){var b=(g[m+1]&31)<<8|g[m+2];switch(g[m]){case 207:if(!x){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=b);break;case 21:f.id3===-1&&(f.id3=b);break;case 219:if(!x){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=b);break;case 3:case 4:L?f.audio===-1&&(f.audio=b,f.isAAC=!1):v.logger.log("MPEG audio found, not supported in this browser");break;case 36:v.logger.warn("Unsupported HEVC stream type found");break;default:break}m+=((g[m+3]&15)<<8|g[m+4])+5}return f}function o(g){var m=0,L,x,f,p,d,a=g.data;if(!g||g.size===0)return null;for(;a[0].length<19&&a.length>1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}L=a[0];var y=(L[0]<<16)+(L[1]<<8)+L[2];if(y===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&&(v.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=a.length;X<J;X++){L=a[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&&v.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"),W=D("./src/controller/id3-track-controller.ts"),M=D("./src/controller/latency-controller.ts"),O=D("./src/controller/level-controller.ts"),v=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"),E=D("./node_modules/eventemitter3/index.js"),u=D.n(E),o=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 E.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,a=f.capLevelController,b=f.fpsController,y=this.abrController=new p(this),T=this.bufferController=new d(this),I=this.capLevelController=new a(this),G=new b(this),X=new P.default(this),J=new H.default(this),z=new W.default(this),j=this.levelController=new O.default(this),q=new v.FragmentTracker(this),ne=this.streamController=new C.default(this,q);I.setStreamController(ne),G.setStreamController(ne);var ce=[j,ne];this.networkControllers=ce;var ve=[X,J,y,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 a=p?new f(this,p):new f(this);return d&&d.push(a),a}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,a){d===void 0&&(d=this),this._emitter.off(f,p,d,a)},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(o.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(o.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(o.Events.MEDIA_ATTACHING,{media:f})},L.detachMedia=function(){_.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(f){this.stopLoad();var p=this.media,d=this.url,a=this.url=V.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});_.logger.log("loadSource:"+a),p&&d&&d!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(o.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,a=0;a<d;a++)if(f[a].maxBitrate>p)return a;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 o.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 W=Object(V.getMediaSource)();if(!W)return!1;var M=N(),O=W&&typeof W.isTypeSupported=="function"&&W.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!O&&!!v}function H(){var W,M=N();return typeof(M==null||((W=M.prototype)===null||W===void 0)?void 0:W.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ie,$,D){"use strict";D.r($),D.d($,"default",function(){return _}),D.d($,"LoadError",function(){return E});var V=D("./src/polyfills/number.ts"),N=D("./src/errors.ts");function P(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,v(u,o)}function H(u){var o=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 o!="undefined"){if(o.has(h))return o.get(h);o.set(h,w)}function w(){return W(h,arguments,C(this).constructor)}return w.prototype=Object.create(h.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v(w,h)},H(u)}function W(u,o,l){return M()?W=Reflect.construct:W=function(w,g,m){var L=[null];L.push.apply(L,g);var x=Function.bind.apply(w,L),f=new x;return m&&v(f,m.prototype),f},W.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 v(u,o){return v=Object.setPrototypeOf||function(h,w){return h.__proto__=w,h},v(u,o)}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 o=u.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(h,w){var g=this,m=h.url;if(!m)return Promise.reject(new E({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 a=g.loader=h.loader=x?new x(L):new f(L),b=A(h),y={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};h.stats=a.stats,a.load(b,y,{onSuccess:function(I,G,X,J){g.resetLoader(h,a),p({frag:h,part:null,payload:I.data,networkDetails:J})},onError:function(I,G,X){g.resetLoader(h,a),d(new E({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,a),d(new E({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:X}))},onTimeout:function(I,G,X){g.resetLoader(h,a),d(new E({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})}})})},o.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 a=m.loader=h.loader=x?new x(L):new f(L),b=A(h,w),y={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};w.stats=a.stats,a.load(b,y,{onSuccess:function(I,G,X,J){m.resetLoader(h,a),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,a),d(new E({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,a),d(new E({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,a),d(new E({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:w,networkDetails:X}))}})})},o.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 a=g.loading,b=m.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(h,w){h.loader=null,this.loader===w&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),w.destroy()},u}();function A(u,o){o===void 0&&(o=null);var l=o||u,h={frag:u,part:o,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 E=function(u){P(o,u);function o(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 o}(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 E}),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"),W=D("./src/loader/level-key.ts"),M=D("./src/loader/load-stats.ts");function O(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,v(o,l)}function v(o,l){return v=Object.setPrototypeOf||function(w,g){return w.__proto__=g,w},v(o,l)}function C(o,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(o,w.key,w)}}function k(o,l,h){return l&&C(o.prototype,l),h&&C(o,h),o}var _;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(_||(_={}));var A=function(){function o(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=o.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(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(w){this._url=w}}]),o}(),E=function(o){O(l,o);function l(w,g){var m;return m=o.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=W.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,a=d[g];if(!a){d[g]={startPTS:m,endPTS:L,startDTS:x,endDTS:f,partial:p};return}a.startPTS=Math.min(a.startPTS,m),a.endPTS=Math.max(a.endPTS,L),a.startDTS=Math.min(a.startDTS,x),a.endDTS=Math.max(a.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(o){O(l,o);function l(h,w,g,m,L){var x;x=o.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 W(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var M=W.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 v in this.loaders){var C=this.loaders[v];C&&C.destroy()}this.loaders={}},M.onKeyLoading=function(v,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 E=k.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(A&&(P.logger.warn("abort previous key loader for type:"+_),A.abort()),!E){P.logger.warn("key uri is falsy");return}var o=u.loader,l=k.loader=this.loaders[_]=new o(u);this.decrypturl=E,this.decryptkey=null;var h={url:E,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(v,C,k){var _=k.frag;if(!_.decryptdata){P.logger.error("after key load, decryptdata unset");return}this.decryptkey=_.decryptdata.key=new Uint8Array(v.data),_.loader=null,delete this.loaders[_.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:_})},M.loaderror=function(v,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:v})},M.loadtimeout=function(v,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})},W}()},"./src/loader/level-details.ts":function(ie,$,D){"use strict";D.r($),D.d($,"LevelDetails",function(){return W});var V=D("./src/polyfills/number.ts");function N(M,O){for(var v=0;v<O.length;v++){var C=O[v];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(M,C.key,C)}}function P(M,O,v){return O&&N(M.prototype,O),v&&N(M,v),M}var H=10,W=function(){function M(v){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=v}var O=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 W});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(V);function P(M,O){for(var v=0;v<O.length;v++){var C=O[v];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(M,C.key,C)}}function H(M,O,v){return O&&P(M.prototype,O),v&&P(M,v),M}var W=function(){M.fromURL=function(v,C){return new M(v,C)},M.fromURI=function(v){return new M(v)};function M(O,v){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,v?this._uri=Object(V.buildAbsoluteURL)(O,v,{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"),W=D("./src/loader/level-details.ts"),M=D("./src/loader/level-key.ts"),O=D("./src/utils/attr-list.ts"),v=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"),E=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(L){var 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 a=f[d];if(a.id===p)return a}},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=[],a={},b=!1;k.lastIndex=0;for(var y;(y=k.exec(f))!=null;)if(y[1]){var T=new O.AttrList(y[1]),I={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:L.resolve(y[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(y[3]){var X=new O.AttrList(y[3]);X["DATA-ID"]&&(b=!0,a[X["DATA-ID"]]=X)}return{levels:d,sessionData:b?a:null}},L.parseMasterPlaylistMedia=function(f,p,d,a){a===void 0&&(a=[]);var b,y=[],T=0;for(_.lastIndex=0;(b=_.exec(f))!==null;){var I=new O.AttrList(b[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(a.length){var X=L.findGroup(a,G.groupId)||a[0];w(G,X,"audioCodec"),w(G,X,"textCodec")}y.push(G)}}return y},L.parseLevelPlaylist=function(f,p,d,a,b){var y=new W.LevelDetails(p),T=y.fragments,I=null,G=0,X=0,J=0,z=0,j=null,q=new H.Fragment(a,p),ne,ce,ve,ke=-1,xe=!1;for(A.lastIndex=0,y.m3u8=f;(ne=A.exec(f))!==null;){xe&&(xe=!1,q=new H.Fragment(a,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 Se=(" "+ne[2]).slice(1);q.title=Se||null,q.tagList.push(Se?["INF",Ce,Se]:["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=b,T.push(q),q.relurl=(" "+ne[3]).slice(1),m(q,j),j=q,J+=q.duration,G++,X=0,xe=!0);else if(ne[4]){var Ee=(" "+ne[4]).slice(1);j?q.setByteRange(Ee,j):q.setByteRange(Ee)}else if(ne[5])q.rawProgramDateTime=(" "+ne[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),ke===-1&&(ke=T.length);else{if(ne=ne[0].match(E),!ne){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ce=1;ce<ne.length&&!(typeof ne[ce]!="undefined");ce++);var me=(" "+ne[ce]).slice(1),se=(" "+ne[ce+1]).slice(1),De=ne[ce+2]?(" "+ne[ce+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":y.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":G=y.startSN=parseInt(se);break;case"SKIP":{var ze=new O.AttrList(se),He=ze.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(He)){y.skippedSegments=He;for(var qe=He;qe--;)T.unshift(null);G+=He}var Ke=ze.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ke&&(y.recentlyRemovedDateranges=Ke.split(" "));break}case"TARGETDURATION":y.targetduration=parseFloat(se);break;case"VERSION":y.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(se||De)&&q.tagList.push(De?[se,De]:[se]);break;case"DIS":z++;case"GAP":q.tagList.push([me]);break;case"BITRATE":q.tagList.push([me,se]);break;case"DISCONTINUITY-SEQ":z=parseInt(se);break;case"KEY":{var Le,Pe=new O.AttrList(se),je=Pe.enumeratedString("METHOD"),Xe=Pe.URI,Ge=Pe.hexadecimalInteger("IV"),Me=Pe.enumeratedString("KEYFORMATVERSIONS"),Ne=Pe.enumeratedString("KEYID"),Qe=(Le=Pe.enumeratedString("KEYFORMAT"))!=null?Le:"identity",Je=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Je.indexOf(Qe)>-1){v.logger.warn("Keyformat "+Qe+" is not supported from the manifest");continue}else if(Qe!=="identity")continue;je&&(ve=M.LevelKey.fromURL(p,Xe),Xe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(je)>=0&&(ve.method=je,ve.keyFormat=Qe,Ne&&(ve.keyID=Ne),Me&&(ve.keyFormatVersions=Me),ve.iv=Ge));break}case"START":{var Ye=new O.AttrList(se),it=Ye.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(it)&&(y.startTimeOffset=it);break}case"MAP":{var st=new O.AttrList(se);q.relurl=st.URI,st.BYTERANGE&&q.setByteRange(st.BYTERANGE),q.level=d,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,I=q,xe=!0;break}case"SERVER-CONTROL":{var et=new O.AttrList(se);y.canBlockReload=et.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=et.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&et.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=et.optionalFloat("PART-HOLD-BACK",0),y.holdBack=et.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var tt=new O.AttrList(se);y.partTarget=tt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=y.partList;we||(we=y.partList=[]);var ut=X>0?we[we.length-1]:void 0,nt=X++,Ae=new H.Part(new O.AttrList(se),q,p,nt,ut);we.push(Ae),q.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Ue=new O.AttrList(se);y.preloadHint=Ue;break}case"RENDITION-REPORT":{var ge=new O.AttrList(se);y.renditionReports=y.renditionReports||[],y.renditionReports.push(ge);break}default:v.logger.warn("line parsed but not handled: "+ne);break}}}j&&!j.relurl?(T.pop(),J-=j.duration,y.partList&&(y.fragmentHint=j)):y.partList&&(m(q,j),q.cc=z,y.fragmentHint=q);var de=T.length,fe=T[0],ee=T[de-1];if(J+=y.skippedSegments*y.targetduration,J>0&&de&&ee){y.averagetargetduration=J/de;var te=ee.sn;y.endSN=te!=="initSegment"?te:0,fe&&(y.startCC=fe.cc,fe.initSegment||y.fragments.every(function(ae){return ae.relurl&&o(ae.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new H.Fragment(a,p),q.relurl=ee.relurl,q.level=d,q.sn="initSegment",fe.initSegment=q,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(J+=y.fragmentHint.duration),y.totalduration=J,y.endCC=z,ke>0&&g(T,ke),y},L}();function h(L,x){["video","audio","text"].forEach(function(f){var p=L.filter(function(a){return Object(C.isCodecType)(a,f)});if(p.length){var d=p.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});x[f+"Codec"]=d.length>0?d[0]:p[0],L=L.filter(function(a){return p.indexOf(a)===-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"),W=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/m3u8-parser.ts"),O=D("./src/types/loader.ts"),v=D("./src/utils/attr-list.ts");function C(A){var E=A.type;switch(E){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,E){var u=A.url;return(u===void 0||u.indexOf("data:")===0)&&(u=E.url),u}var _=function(){function A(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var E=A.prototype;return E.registerListeners=function(){var o=this.hls;o.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(o){var l=this.hls.config,h=l.pLoader,w=l.loader,g=h||w,m=new g(l);return o.loader=m,this.loaders[o.type]=m,m},E.getInternalLoader=function(o){return this.loaders[o.type]},E.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},E.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(o,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},E.onLevelLoading=function(o,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})},E.onAudioTrackLoading=function(o,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})},E.onSubtitleTrackLoading=function(o,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})},E.load=function(o){var l,h=this.hls.config,w=this.getInternalLoader(o);if(w){var g=w.context;if(g&&g.url===o.url){H.logger.trace("[playlist-loader]: playlist request ongoing");return}H.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),w.abort()}var m,L,x,f;switch(o.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(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var p;if(o.type===O.PlaylistContextType.LEVEL&&o.level!==null?p=this.hls.levels[o.level].details:o.type===O.PlaylistContextType.AUDIO_TRACK&&o.id!==null?p=this.hls.audioTracks[o.id].details:o.type===O.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(p=this.hls.subtitleTracks[o.id].details),p){var d=p.partTarget,a=p.targetduration;d&&a&&(L=Math.min(Math.max(d*3,a*.8)*1e3,L))}}var b={timeout:L,maxRetry:m,retryDelay:x,maxRetryDelay:f,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};w.load(o,b,y)},E.loadsuccess=function(o,l,h,w){if(w===void 0&&(w=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,l,h,w);return}this.resetInternalLoader(h.type);var g=o.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",w);return}l.parsing.start=performance.now(),g.indexOf("#EXTINF:")>0||g.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,h,w):this.handleMasterPlaylist(o,l,h,w)},E.loaderror=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,o)},E.loadtimeout=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},E.handleMasterPlaylist=function(o,l,h,w){var g=this.hls,m=o.data,L=k(o,h),x=M.default.parseMasterPlaylist(m,L),f=x.levels,p=x.sessionData;if(!f.length){this.handleManifestParsingError(o,h,"no level found in manifest",w);return}var d=f.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=f.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),b=M.default.parseMasterPlaylistMedia(m,L,"AUDIO",d),y=M.default.parseMasterPlaylistMedia(m,L,"SUBTITLES",a),T=M.default.parseMasterPlaylistMedia(m,L,"CLOSED-CAPTIONS");if(b.length){var I=b.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"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}g.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:b,subtitles:y,captions:T,url:L,stats:l,networkDetails:w,sessionData:p})},E.handleTrackOrLevelPlaylist=function(o,l,h,w){var g=this.hls,m=h.id,L=h.level,x=h.type,f=k(o,h),p=Object(V.isFiniteNumber)(m)?m:0,d=Object(V.isFiniteNumber)(L)?L:p,a=C(h),b=M.default.parseLevelPlaylist(o.data,f,d,a,p);if(!b.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 y={attrs:new v.AttrList({}),bitrate:0,details:b,name:"",url:f};g.trigger(N.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:f,stats:l,networkDetails:w,sessionData:null})}if(l.parsing.end=performance.now(),b.needSidxRanges){var T,I=(T=b.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:I,isSidxRequest:!0,type:x,level:L,levelDetails:b,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=b,this.handlePlaylistLoaded(o,l,h,w)},E.handleSidxRequest=function(o,l){var h=Object(W.parseSegmentIndex)(new Uint8Array(o.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")})},E.handleManifestParsingError=function(o,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:o.url,reason:h,response:o,context:l,networkDetails:w})},E.handleNetworkError=function(o,l,h,w){h===void 0&&(h=!1),H.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var g=P.ErrorDetails.UNKNOWN,m=!1,L=this.getInternalLoader(o);switch(o.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(o.type);var x={type:P.ErrorTypes.NETWORK_ERROR,details:g,fatal:m,url:o.url,loader:L,context:o,networkDetails:l};w&&(x.response=w),this.hls.trigger(N.Events.ERROR,x)},E.handlePlaylistLoaded=function(o,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(o,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,W){switch(H){case"mp4a.40.2":if(W===1)return new Uint8Array([0,200,0,128,35,128]);if(W===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(W===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(W===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(W===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(W===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(W===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(W===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(W===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},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 W;for(W in P.types)P.types.hasOwnProperty(W)&&(P.types[W]=[W.charCodeAt(0),W.charCodeAt(1),W.charCodeAt(2),W.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 v=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,v))},P.box=function(W){for(var M=8,O=arguments.length,v=new Array(O>1?O-1:0),C=1;C<O;C++)v[C-1]=arguments[C];for(var k=v.length,_=k;k--;)M+=v[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(W,4),k=0,M=8;k<_;k++)A.set(v[k],M),M+=v[k].byteLength;return A},P.hdlr=function(W){return P.box(P.types.hdlr,P.HDLR_TYPES[W])},P.mdat=function(W){return P.box(P.types.mdat,W)},P.mdhd=function(W,M){M*=W;var O=Math.floor(M/(V+1)),v=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,W>>24&255,W>>16&255,W>>8&255,W&255,O>>24,O>>16&255,O>>8&255,O&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},P.mdia=function(W){return P.box(P.types.mdia,P.mdhd(W.timescale,W.duration),P.hdlr(W.type),P.minf(W))},P.mfhd=function(W){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,W>>24,W>>16&255,W>>8&255,W&255]))},P.minf=function(W){return W.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(W)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(W))},P.moof=function(W,M,O){return P.box(P.types.moof,P.mfhd(W),P.traf(O,M))},P.moov=function(W){for(var M=W.length,O=[];M--;)O[M]=P.trak(W[M]);return P.box.apply(null,[P.types.moov,P.mvhd(W[0].timescale,W[0].duration)].concat(O).concat(P.mvex(W)))},P.mvex=function(W){for(var M=W.length,O=[];M--;)O[M]=P.trex(W[M]);return P.box.apply(null,[P.types.mvex].concat(O))},P.mvhd=function(W,M){M*=W;var O=Math.floor(M/(V+1)),v=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,W>>24&255,W>>16&255,W>>8&255,W&255,O>>24,O>>16&255,O>>8&255,O&255,v>>24,v>>16&255,v>>8&255,v&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return P.box(P.types.mvhd,C)},P.sdtp=function(W){var M=W.samples||[],O=new Uint8Array(4+M.length),v,C;for(v=0;v<M.length;v++)C=M[v].flags,O[v+4]=C.dependsOn<<4|C.isDependedOn<<2|C.hasRedundancy;return P.box(P.types.sdtp,O)},P.stbl=function(W){return P.box(P.types.stbl,P.stsd(W),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(W){var M=[],O=[],v,C,k;for(v=0;v<W.sps.length;v++)C=W.sps[v],k=C.byteLength,M.push(k>>>8&255),M.push(k&255),M=M.concat(Array.prototype.slice.call(C));for(v=0;v<W.pps.length;v++)C=W.pps[v],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|W.sps.length].concat(M).concat([W.pps.length]).concat(O))),A=W.width,E=W.height,u=W.pixelRatio[0],o=W.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,E>>8&255,E&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,o>>24,o>>16&255,o>>8&255,o&255])))},P.esds=function(W){var M=W.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(W.config).concat([6,1,2]))},P.mp4a=function(W){var M=W.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,W.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),P.box(P.types.esds,P.esds(W)))},P.mp3=function(W){var M=W.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,W.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},P.stsd=function(W){return W.type==="audio"?!W.isAAC&&W.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(W)):P.box(P.types.stsd,P.STSD,P.mp4a(W)):P.box(P.types.stsd,P.STSD,P.avc1(W))},P.tkhd=function(W){var M=W.id,O=W.duration*W.timescale,v=W.width,C=W.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,v>>8&255,v&255,0,0,C>>8&255,C&255,0,0]))},P.traf=function(W,M){var O=P.sdtp(W),v=W.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,v>>24,v>>16&255,v>>8&255,v&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(W,O.length+16+20+8+16+8+8),O)},P.trak=function(W){return W.duration=W.duration||4294967295,P.box(P.types.trak,P.tkhd(W),P.mdia(W))},P.trex=function(W){var M=W.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(W,M){var O=W.samples||[],v=O.length,C=12+16*v,k=new Uint8Array(C),_,A,E,u,o,l;for(M+=8+C,k.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),_=0;_<v;_++)A=O[_],E=A.duration,u=A.size,o=A.flags,l=A.cts,k.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*_);return P.box(P.types.trun,k)},P.initSegment=function(W){P.types||P.init();var M=P.moov(W),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"),W=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),O=D("./src/types/loader.ts"),v=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,E=null,u=null,o=!1,l=function(){function L(f,p,d,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=p,this.typeSupported=d,this.ISGenerated=!1,E===null){var b=navigator.userAgent||"",y=b.match(/Chrome\/(\d+)/i);E=y?parseInt(y[1]):0}if(u===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);u=T?parseInt(T[1]):0}o=!!E&&E<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,a=p.reduce(function(b,y){var T=y.pts-b;return T<-4294967296?(d=!0,h(b,y.pts)):T>0?b:y.pts},p[0].pts);return d&&M.logger.debug("PTS rollover detected"),a},x.remux=function(p,d,a,b,y,T,I,G){var X,J,z,j,q,ne,ce=y,ve=y,ke=p.pid>-1,xe=d.pid>-1,Ce=d.samples.length,Se=p.samples.length>0,Ee=Ce>1,me=(!ke||Se)&&(!xe||Ee)||this.ISGenerated||I;if(me){this.ISGenerated||(z=this.generateIS(p,d,y));var se=this.isVideoContiguous,De=-1;if(Ee&&(De=w(d.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(ne=!0,De>0){M.logger.warn("[mp4-remuxer]: Dropped "+De+" out of "+Ce+" video samples due to a missing keyframe");var ze=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(De),d.dropped+=De,ve+=(d.samples[0].pts-ze)/(d.timescale||9e4)}else De===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ne=!1);if(this.ISGenerated){if(Se&&Ee){var He=this.getVideoStartPts(d.samples),qe=h(p.samples[0].pts,He)-He,Ke=qe/d.inputTimeScale;ce+=Math.max(0,Ke),ve+=Math.max(0,-Ke)}if(Se){if(p.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(p,d,y)),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,y)),X=this.remuxVideo(d,ve,se,Le)}}else Ee&&(X=this.remuxVideo(d,ve,se,0));X&&(X.firstKeyFrame=De,X.independent=De!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,y)),b.samples.length&&(j=this.remuxText(b,y))),{audio:J,video:X,initSegment:z,independent:ne,text:j,id3:q}},x.generateIS=function(p,d,a){var b=p.samples,y=d.samples,T=this.typeSupported,I={},G=!Object(V.isFiniteNumber)(this._initPTS),X="audio/mp4",J,z,j;if(G&&(J=z=Infinity),p.config&&b.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&&(j=p.inputTimeScale,J=z=b[0].pts-Math.round(j*a))),d.sps&&d.pps&&y.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)){j=d.inputTimeScale;var q=this.getVideoStartPts(y),ne=Math.round(j*a);z=Math.min(z,h(y[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:j}},x.remuxVideo=function(p,d,a,b){var y=p.inputTimeScale,T=p.samples,I=[],G=T.length,X=this._initPTS,J=this.nextAvcDts,z=8,j,q,ne,ce=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,ke=0,xe=!1;if(!a||J===null){var Ce=d*y,Se=T[0].pts-h(T[0].dts,T[0].pts);J=Ce-Se}for(var Ee=0;Ee<G;Ee++){var me=T[Ee];if(me.pts=h(me.pts-X,J),me.dts=h(me.dts-X,J),me.dts>me.pts){var se=9e4*.2;ke=Math.max(Math.min(ke,me.pts-me.dts),-1*se)}me.dts<T[Ee>0?Ee-1:Ee].dts&&(xe=!0)}xe&&T.sort(function(Lt,Tt){var ht=Lt.dts-Tt.dts,Bt=Lt.pts-Tt.pts;return ht||Bt}),q=T[0].dts,ne=T[T.length-1].dts;var De=Math.round((ne-q)/(G-1));if(ke<0){if(ke<De*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-De,!0)+" ms");for(var ze=ke,He=0;He<G;He++)T[He].dts=ze=Math.max(ze,T[He].pts-De),T[He].pts=Math.max(ze,T[He].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(ke,!0)+" ms to overcome this issue");for(var qe=0;qe<G;qe++)T[qe].dts=T[qe].dts+ke}q=T[0].dts}if(a){var Ke=q-J,Le=Ke>De,Pe=Ke<-1;if(Le||Pe){Le?M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(Ke,!0)+" ms ("+Ke+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-Ke,!0)+" ms ("+Ke+"dts) overlapping between fragments detected"),q=J;var je=T[0].pts-Ke;T[0].dts=q,T[0].pts=je,M.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(je,!0)+"/"+Object(v.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(Ke,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Xe=0,Ge=0,Me=0;Me<G;Me++){for(var Ne=T[Me],Qe=Ne.units,Je=Qe.length,Ye=0,it=0;it<Je;it++)Ye+=Qe[it].data.length;Ge+=Ye,Xe+=Je,Ne.length=Ye,Ne.dts=Math.max(Ne.dts,q),Ne.pts=Math.max(Ne.pts,Ne.dts,0),ce=Math.min(Ne.pts,ce),ve=Math.max(Ne.pts,ve)}ne=T[G-1].dts;var st=Ge+4*Xe+8,et;try{et=new Uint8Array(st)}catch(Lt){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:st,reason:"fail allocating video mdat "+st});return}var tt=new DataView(et.buffer);tt.setUint32(0,st),et.set(P.default.types.mdat,4);for(var we=0;we<G;we++){for(var ut=T[we],nt=ut.units,Ae=0,Ue=0,ge=nt.length;Ue<ge;Ue++){var de=nt[Ue],fe=de.data,ee=de.data.byteLength;tt.setUint32(z,ee),z+=4,et.set(fe,z),z+=ee,Ae+=4+ee}if(we<G-1)j=T[we+1].dts-ut.dts;else{var te=this.config,ae=ut.dts-T[we>0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(te.maxBufferHole*y),pe=(b?ce+b*y:this.nextAudioPts)-ut.pts;pe>ue?(j=pe-ae,j<0&&(j=ae),M.logger.log("[mp4-remuxer]: It is approximately "+pe/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=ae}else j=ae}var Te=Math.round(ut.pts-ut.dts);I.push(new g(ut.key,j,Ae,Te))}if(I.length&&E&&E<70){var Oe=I[0].flags;Oe.dependsOn=2,Oe.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=J=ne+j,this.isVideoContiguous=!0;var rt=P.default.moof(p.sequenceNumber++,q,C({},p,{samples:I})),pt="video",dt={data1:rt,data2:et,startPTS:ce/y,endPTS:(ve+j)/y,startDTS:q/y,endDTS:J/y,type:pt,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(et.length,"MDAT length must not be zero"),dt},x.remuxAudio=function(p,d,a,b,y){var T=p.inputTimeScale,I=p.samplerate?p.samplerate:T,G=T/I,X=p.isAAC?_:A,J=X*G,z=this._initPTS,j=!p.isAAC&&this.typeSupported.mpeg,q=[],ne=p.samples,ce=j?0:8,ve=this.nextAudioPts||-1,ke=d*T;if(this.isAudioContiguous=a=a||ne.length&&ve>0&&(b&&Math.abs(ke-ve)<9e3||Math.abs(h(ne[0].pts-z,ke)-ve)<20*J),ne.forEach(function(fe){fe.pts=h(fe.pts-z,ke)}),!a||ve<0){if(ne=ne.filter(function(fe){return fe.pts>=0}),!ne.length)return;y===0?ve=0:b?ve=Math.max(0,ke):ve=ne[0].pts}if(p.isAAC)for(var xe=y!==void 0,Ce=this.config.maxAudioFramesDrift,Se=0,Ee=ve;Se<ne.length;Se++){var me=ne[Se],se=me.pts,De=se-Ee,ze=Math.abs(1e3*De/T);if(De<=-Ce*J&&xe)Se===0&&(M.logger.warn("Audio frame @ "+(se/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*De/T)+" ms."),this.nextAudioPts=ve=Ee=se);else if(De>=Ce*J&&ze<k&&xe){var He=Math.round(De/J);Ee=se-He*J,Ee<0&&(He--,Ee+=J),Se===0&&(this.nextAudioPts=ve=Ee),M.logger.warn("[mp4-remuxer]: Injecting "+He+" audio frame @ "+(Ee/T).toFixed(3)+"s due to "+Math.round(1e3*De/T)+" ms gap.");for(var qe=0;qe<He;qe++){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=me.unit.subarray()),ne.splice(Se,0,{unit:Le,pts:Ke}),Ee+=J,Se++}}me.pts=Ee,Ee+=J}for(var Pe=null,je=null,Xe,Ge=0,Me=ne.length;Me--;)Ge+=ne[Me].unit.byteLength;for(var Ne=0,Qe=ne.length;Ne<Qe;Ne++){var Je=ne[Ne],Ye=Je.unit,it=Je.pts;if(je!==null){var st=q[Ne-1];st.duration=Math.round((it-je)/G)}else if(a&&p.isAAC&&(it=ve),Pe=it,Ge>0){Ge+=ce;try{Xe=new Uint8Array(Ge)}catch(fe){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ge,reason:"fail allocating audio mdat "+Ge});return}if(!j){var et=new DataView(Xe.buffer);et.setUint32(0,Ge),Xe.set(P.default.types.mdat,4)}}else return;Xe.set(Ye,ce);var tt=Ye.byteLength;ce+=tt,q.push(new g(!0,X,tt,0)),je=it}var we=q.length;if(!we)return;var ut=q[q.length-1];this.nextAudioPts=ve=je+G*ut.duration;var nt=j?new Uint8Array(0):P.default.moof(p.sequenceNumber++,Pe/G,C({},p,{samples:q}));p.samples=[];var Ae=Pe/T,Ue=ve/T,ge="audio",de={data1:nt,data2:Xe,startPTS:Ae,endPTS:Ue,startDTS:Ae,endDTS:Ue,type:ge,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,a,b){var y=p.inputTimeScale,T=p.samplerate?p.samplerate:y,I=y/T,G=this.nextAudioPts,X=(G!==null?G:b.startDTS*y)+this._initDTS,J=b.endDTS*y+this._initDTS,z=I*_,j=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<j;ce++){var ve=X+ce*z;ne.push({unit:q,pts:ve,dts:ve})}return p.samples=ne,this.remuxAudio(p,d,a,!1)},x.remuxID3=function(p,d){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,y=this._initPTS,T=this._initDTS,I=0;I<a;I++){var G=p.samples[I];G.pts=h(G.pts-y,d*b)/b,G.dts=h(G.dts-T,d*b)/b}var X=p.samples;return p.samples=[],{samples:X}},x.remuxText=function(p,d){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,y=this._initPTS,T=0;T<a;T++){var I=p.samples[T];I.pts=h(I.pts-y,d*b)/b}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"),W=function(){function v(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var C=v.prototype;return C.destroy=function(){},C.resetTimeStamp=function(_){this.initPTS=_,this.lastEndDTS=null},C.resetNextTimestamp=function(){this.lastEndDTS=null},C.resetInitSegment=function(_,A,E){this.audioCodec=A,this.videoCodec=E,this.generateInitSegment(_),this.emitInitSegment=!0},C.generateInitSegment=function(_){var A=this.audioCodec,E=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)),E||(E=O(u.video,P.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:A+","+E,initSegment:_,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:A,initSegment:_,id:"audio"}:u.video?o.video={container:"video/mp4",codec:E,initSegment:_,id:"main"}:H.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},C.remux=function(_,A,E,u,o){var l=this.initPTS,h=this.lastEndDTS,w={audio:void 0,video:void 0,text:u,id3:E,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=o||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,a=!!L.video,b="";d&&(b+="audio"),a&&(b+="video");var y={data1:g,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:b,hasAudio:d,hasVideo:a,nb:1,dropped:0};return w.audio=y.type==="audio"?y:void 0,w.video=y.type!=="audio"?y:void 0,w.text=u,w.id3=E,w.initSegment=m,w},v}(),M=function(C,k,_){return Object(N.getStartDTS)(C,k)-_};function O(v,C){var k=v==null?void 0:v.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=W},"./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(W){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,W),!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(W){W.MANIFEST="m",W.AUDIO="a",W.VIDEO="v",W.MUXED="av",W.INIT="i",W.CAPTION="c",W.TIMED_TEXT="tt",W.KEY="k",W.OTHER="o"})(N||(N={}));var P;(function(W){W.DASH="d",W.HLS="h",W.SMOOTH="s",W.OTHER="o"})(P||(P={}));var H;(function(W){W.VOD="v",W.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 W}),D.d($,"Level",function(){return M});function V(O,v){for(var C=0;C<v.length;C++){var k=v[C];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(O,k.key,k)}}function N(O,v,C){return v&&V(O.prototype,v),C&&V(O,C),O}var P;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(P||(P={}));function H(O,v){var C=O.canSkipUntil,k=O.canSkipDateRanges,_=O.endSN,A=v!==void 0?v-_:0;return C&&A<C?k?P.v2:P.Yes:P.No}var W=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 v=O.prototype;return v.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(v){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[v.url],this.attrs=v.attrs,this.bitrate=v.bitrate,v.details&&(this.details=v.details),this.id=v.id||0,this.name=v.name,this.width=v.width||0,this.height=v.height||0,this.audioCodec=v.audioCodec,this.videoCodec=v.videoCodec,this.unknownCodecs=v.unknownCodecs,this.codecSet=[v.videoCodec,v.audioCodec].filter(function(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,W,M,O,v,C){O===void 0&&(O=0),v===void 0&&(v=-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=W,this.id=M,this.size=O,this.part=v,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 W=H.prototype;return W.decimalInteger=function(O){var v=parseInt(this[O],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},W.hexadecimalInteger=function(O){if(this[O]){var v=(this[O]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var C=new Uint8Array(v.length/2),k=0;k<v.length/2;k++)C[k]=parseInt(v.slice(k*2,k*2+2),16);return C}else return null},W.hexadecimalIntegerAsNumber=function(O){var v=parseInt(this[O],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},W.decimalFloatingPoint=function(O){return parseFloat(this[O])},W.optionalFloat=function(O,v){var C=this[O];return C?parseFloat(C):v},W.enumeratedString=function(O){return this[O]},W.bool=function(O){return this[O]==="YES"},W.decimalResolution=function(O){var v=V.exec(this[O]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},H.parseAttrList=function(O){var v,C={},k='"';for(N.lastIndex=0;(v=N.exec(O))!==null;){var _=v[2];_.indexOf(k)===0&&_.lastIndexOf(k)===_.length-1&&(_=_.slice(1,-1)),C[v[1]]=_}return C},H}()},"./src/utils/binary-search.ts":function(ie,$,D){"use strict";D.r($);var V={search:function(P,H){for(var W=0,M=P.length-1,O=null,v=null;W<=M;){O=(W+M)/2|0,v=P[O];var C=H(v);if(C>0)W=O+1;else if(C<0)M=O-1;else return v}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 v=H.getBuffered(M),C=0;C<v.length;C++)if(O>=v.start(C)&&O<=v.end(C))return!0}}catch(k){}return!1},H.bufferInfo=function(M,O,v){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,v)}}catch(A){}return{len:0,start:O,end:O,nextStart:void 0}},H.bufferedInfo=function(M,O,v){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(v)for(var k=0;k<M.length;k++){var _=C.length;if(_){var A=C[_-1].end;M[k].start-A<v?M[k].end>A&&(C[_-1].end=M[k].end):C.push(M[k])}else C.push(M[k])}else C=M;for(var E=0,u,o=O,l=O,h=0;h<C.length;h++){var w=C[h].start,g=C[h].end;if(O+v>=w&&O<g)o=w,l=g,E=l-O;else if(O+v<w){u=w;break}}return{len:E,start:o||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,W=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},v={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(a,b){this.verboseLevel>=a&&V.logger.log(this.time+" ["+a+"] "+b)},f}(),E=function(p){for(var d=[],a=0;a<p.length;a++)d.push(p[a].toString(16));return d},u=function(){function f(d,a,b,y,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=a||!1,this.italics=b||!1,this.background=y||"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(a){for(var b=["foreground","underline","italics","background","flash"],y=0;y<b.length;y++){var T=b[y];a.hasOwnProperty(T)&&(this[T]=a[T])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},p.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),o=function(){function f(d,a,b,y,T,I){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(a,b,y,T,I)}var p=f.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(a,b){this.uchar=a,this.penState.copy(b)},p.setPenState=function(a){this.penState.copy(a)},p.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},p.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.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 a=0;a<W;a++)this.chars.push(new o);this.logger=d,this.pos=0,this.currPenState=new u}var p=f.prototype;return p.equals=function(a){for(var b=!0,y=0;y<W;y++)if(!this.chars[y].equals(a.chars[y])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<W;b++)this.chars[b].copy(a.chars[b])},p.isEmpty=function(){for(var a=!0,b=0;b<W;b++)if(!this.chars[b].isEmpty()){a=!1;break}return a},p.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(_.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>W&&(this.logger.log(_.DEBUG,"Too large cursor position "+this.pos),this.pos=W)},p.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var y=this.pos+1;y<b+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(b)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(a){a>=144&&this.backSpace();var b=P(a);if(this.pos>=W){this.logger.log(_.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(a){var b;for(b=a;b<W;b++)this.chars[b].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 a=[],b=!0,y=0;y<W;y++){var T=this.chars[y].uchar;T!==" "&&(b=!1),a.push(T)}return b?"":a.join("")},p.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.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 a=0;a<H;a++)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 a=0;a<H;a++)this.rows[a].clear();this.currRow=H-1},p.equals=function(a){for(var b=!0,y=0;y<H;y++)if(!this.rows[y].equals(a.rows[y])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<H;b++)this.rows[b].copy(a.rows[b])},p.isEmpty=function(){for(var a=!0,b=0;b<H;b++)if(!this.rows[b].isEmpty()){a=!1;break}return a},p.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},p.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},p.insertChar=function(a){var b=this.rows[this.currRow];b.insertChar(a)},p.setPen=function(a){var b=this.rows[this.currRow];b.setPenStyles(a)},p.moveCursor=function(a){var b=this.rows[this.currRow];b.moveCursor(a)},p.setCursor=function(a){this.logger.log(_.INFO,"setCursor: "+a);var b=this.rows[this.currRow];b.setCursor(a)},p.setPAC=function(a){this.logger.log(_.INFO,"pacData = "+JSON.stringify(a));var b=a.row-1;if(this.nrRollUpRows&&b<this.nrRollUpRows-1&&(b=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==b){for(var y=0;y<H;y++)this.rows[y].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[b-this.nrRollUpRows+J+1].copy(I.rows[T+J])}}this.currRow=b;var z=this.rows[this.currRow];if(a.indent!==null){var j=a.indent,q=Math.max(j-1,0);z.setCursor(a.indent),a.color=z.chars[q].penState.foreground}var ne={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ne)},p.setBkgData=function(a){this.logger.log(_.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},p.setRollUpRows=function(a){this.nrRollUpRows=a},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 a=this.currRow+1-this.nrRollUpRows,b=this.rows.splice(a,1)[0];b.clear(),this.rows.splice(this.currRow,0,b),this.logger.log(_.INFO,"Rolling up")},p.getDisplayText=function(a){a=a||!1;for(var b=[],y="",T=-1,I=0;I<H;I++){var G=this.rows[I].getTextString();G&&(T=I+1,a?b.push("Row "+T+": '"+G+"'"):b.push(G.trim()))}return b.length>0&&(a?y="["+b.join(" | ")+"]":y=b.join(`
|
|
`)),y},p.getTextAndFormat=function(){return this.rows},f}(),w=function(){function f(d,a,b){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=d,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(b),this.nonDisplayedMemory=new h(b),this.lastOutputScreen=new h(b),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}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(a){this.outputFilter=a},p.setPAC=function(a){this.writeScreen.setPAC(a)},p.setBkgData=function(a){this.writeScreen.setBkgData(a)},p.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(_.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},p.insertChars=function(a){for(var b=0;b<a.length;b++)this.writeScreen.insertChar(a[b]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(_.INFO,y+": "+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(a){this.logger.log(_.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},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 a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(_.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(a){this.logger.log(_.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},p.ccMIDROW=function(a){var b={flash:!1};if(b.underline=a%2===1,b.italics=a>=46,b.italics)b.foreground="white";else{var y=Math.floor(a/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=T[y]}this.logger.log(_.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},p.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),g=function(){function f(d,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new A;this.channels=[null,new w(d,a,y),new w(d+1,b,y)],this.cmdHistory=x(),this.logger=y}var p=f.prototype;return p.getHandler=function(a){return this.channels[a].getHandler()},p.setHandler=function(a,b){this.channels[a].setHandler(b)},p.addData=function(a,b){var y,T,I,G=!1;this.logger.time=a;for(var X=0;X<b.length;X+=2){if(T=b[X]&127,I=b[X+1]&127,T===0&&I===0)continue;if(this.logger.log(_.DATA,"["+E([b[X],b[X+1]])+"] -> ("+E([T,I])+")"),y=this.parseCmd(T,I),y||(y=this.parseMidrow(T,I)),y||(y=this.parsePAC(T,I)),y||(y=this.parseBackgroundAttributes(T,I)),!y&&(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?")}!y&&!G&&this.logger.log(_.WARNING,"Couldn't parse cleaned data "+E([T,I])+" orig: "+E([b[X],b[X+1]]))}},p.parseCmd=function(a,b){var y=this.cmdHistory,T=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,I=(a===23||a===31)&&b>=33&&b<=35;if(!(T||I))return!1;if(L(a,b,y))return m(null,null,y),this.logger.log(_.DEBUG,"Repeated command ("+E([a,b])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,X=this.channels[G];return a===20||a===21||a===28||a===29?b===32?X.ccRCL():b===33?X.ccBS():b===34?X.ccAOF():b===35?X.ccAON():b===36?X.ccDER():b===37?X.ccRU(2):b===38?X.ccRU(3):b===39?X.ccRU(4):b===40?X.ccFON():b===41?X.ccRDC():b===42?X.ccTR():b===43?X.ccRTD():b===44?X.ccEDM():b===45?X.ccCR():b===46?X.ccENM():b===47&&X.ccEOC():X.ccTO(b-32),m(a,b,y),this.currentChannel=G,!0},p.parseMidrow=function(a,b){var y=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(_.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[y];return T?(T.ccMIDROW(b),this.logger.log(_.DEBUG,"MIDROW ("+E([a,b])+")"),!0):!1}return!1},p.parsePAC=function(a,b){var y,T=this.cmdHistory,I=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,G=(a===16||a===24)&&b>=64&&b<=95;if(!(I||G))return!1;if(L(a,b,T))return m(null,null,T),!0;var X=a<=23?1:2;b>=64&&b<=95?y=X===1?M[a]:v[a]:y=X===1?O[a]:C[a];var J=this.channels[X];return J?(J.setPAC(this.interpretPAC(y,b)),m(a,b,T),this.currentChannel=X,!0):!1},p.interpretPAC=function(a,b){var y,T={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?y=b-96:y=b-64,T.underline=(y&1)===1,y<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((y-16)/2)*4,T},p.parseChars=function(a,b){var y,T=null,I=null;if(a>=25?(y=2,I=a-8):(y=1,I=a),I>=17&&I<=19){var G;I===17?G=b+80:I===18?G=b+112:G=b+144,this.logger.log(_.INFO,"Special char '"+P(G)+"' in channel "+y),T=[G]}else a>=32&&a<=127&&(T=b===0?[a]:[a,b]);if(T){var X=E(T);this.logger.log(_.DEBUG,"Char codes = "+X.join(",")),m(a,b,this.cmdHistory)}return T},p.parseBackgroundAttributes=function(a,b){var y=(a===16||a===24)&&b>=32&&b<=47,T=(a===23||a===31)&&b>=45&&b<=47;if(!(y||T))return!1;var I,G={};a===16||a===24?(I=Math.floor((b-32)/2),G.background=k[I],b%2===1&&(G.background=G.background+"_semi")):b===45?G.background="transparent":(G.foreground="black",b===47&&(G.underline=!0));var X=a<=23?1:2,J=this.channels[X];return J.setBkgData(G),m(a,b,this.cmdHistory),!0},p.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var b=this.channels[a];b&&b.reset()}this.cmdHistory=x()},p.cueSplitAtTime=function(a){for(var b=0;b<this.channels.length;b++){var y=this.channels[b];y&&y.cueSplitAtTime(a)}},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,W){var M=V[W];return!!M&&M[H.slice(0,4)]===!0}function P(H,W){return MediaSource.isTypeSupported((W||"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/,W={newCue:function(O,v,C,k){for(var _=[],A,E,u,o,l,h=self.VTTCue||self.TextTrackCue,w=0;w<k.rows.length;w++)if(A=k.rows[w],u=!0,o=0,l="",!A.isEmpty()){for(var g=0;g<A.chars.length;g++)H.test(A.chars[g].uchar)&&u?o++:(l+=A.chars[g].uchar,u=!1);A.cueStartTime=v,v===C&&(C+=1e-4),o>=16?o--:o++;var m=Object(V.fixLineBreaks)(l.trim()),L=Object(N.generateCueId)(v,C,m);(!O||!O.cues||!O.cues.getCueById(L))&&(E=new h(v,C,m),E.id=L,E.line=w+1,E.align="left",E.position=10+Math.min(80,Math.floor(o*8/32)*10),_.push(E))}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=W},"./src/utils/discontinuities.ts":function(ie,$,D){"use strict";D.r($),D.d($,"findFirstFragWithCC",function(){return H}),D.d($,"shouldAlignOnDiscontinuities",function(){return W}),D.d($,"findDiscontinuousReferenceFrag",function(){return M}),D.d($,"adjustSlidingStart",function(){return v}),D.d($,"alignStream",function(){return C}),D.d($,"alignPDT",function(){return _}),D.d($,"alignFragmentByPDTDelta",function(){return A}),D.d($,"alignMediaPlaylistByPDT",function(){return E});var V=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts"),P=D("./src/controller/level-helper.ts");function H(u,o){for(var l=null,h=0,w=u.length;h<w;h++){var g=u[h];if(g&&g.cc===o){l=g;break}}return l}function W(u,o,l){return!!(o.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function M(u,o){var l=u.fragments,h=o.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,o){if(u){var l=u.start+o;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function v(u,o){for(var l=o.fragments,h=0,w=l.length;h<w;h++)O(l[h],u);o.fragmentHint&&O(o.fragmentHint,u),o.alignedSliding=!0}function C(u,o,l){if(!o)return;k(u,l,o),!l.alignedSliding&&o.details&&_(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(P.adjustSliding)(o.details,l)}function k(u,o,l){if(W(u,l,o)){var h=M(l.details,o);h&&Object(V.isFiniteNumber)(h.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(h.start,o))}}function _(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=u.fragments[0].programDateTime,w=(h-l)/1e3+o.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+" "),v(w,u))}function A(u,o){var l=u.programDateTime;if(!l)return;var h=(l-o)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function E(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=o.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(W,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(W),this.fast_=new V.default(M)}var H=P.prototype;return H.update=function(M,O){var v=this.slow_,C=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new V.default(M,v.getEstimate(),v.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 v=8*O,C=M/1e3,k=v/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,W,M){W===void 0&&(W=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_=W,this.totalWeight_=M}var P=N.prototype;return P.sample=function(W,M){var O=Math.pow(this.alpha_,W);this.estimate_=M*(1-O)+O*this.estimate_,this.totalWeight_+=W},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var W=1-Math.pow(this.alpha_,this.totalWeight_);if(W)return this.estimate_/W}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 W(h){var w=typeof Map=="function"?new Map:void 0;return W=function(m){if(m===null||!v(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)},W(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),a=new d;return f&&C(a,f.prototype),a},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 v(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 E=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||o,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),a=x.onProgress,b=m.responseType==="arraybuffer",y=b?"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"),a&&Object(V.isFiniteNumber)(L.highWaterMark)?f.loadProgressively(T,p,m,L.highWaterMark,a):b?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[y];var G={url:I.url,data:T};a&&!Object(V.isFiniteNumber)(L.highWaterMark)&&a(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,a=m.body.getReader(),b=function y(){return a.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),y()}).catch(function(){return Promise.reject()})};return b()},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 o(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}(W(Error));$.default=E},"./src/utils/imsc1-ttml-parser.ts":function(ie,$,D){"use strict";D.r($),D.d($,"IMSC1_CODEC",function(){return v}),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"),W=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 a in d)Object.prototype.hasOwnProperty.call(d,a)&&(f[a]=d[a])}return f},O.apply(this,arguments)}var v="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,a,b){var y=Object(V.findBox)(new Uint8Array(f),["mdat"]);if(y.length===0){b(new Error("Could not parse IMSC1 mdat"));return}var T=y[0],I=Object(H.utf8ArrayToStr)(new Uint8Array(f,T.start,T.end-T.start)),G=Object(W.toTimescaleFromScale)(p,1,d);try{a(E(I,G))}catch(X){b(X)}}function E(f,p){var d=new DOMParser,a=d.parseFromString(f,"text/xml"),b=a.getElementsByTagName("tt")[0];if(!b)throw new Error("Invalid ttml");var y={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(y).reduce(function(z,j){return z[j]=b.getAttribute("ttp:"+j)||y[j],z},{}),I=b.getAttribute("xml:space")!=="preserve",G=o(u(b,"styling","style")),X=o(u(b,"layout","region")),J=u(b,"body","[begin]");return[].map.call(J,function(z){var j=l(z,I);if(!j||!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,j);ve.id=Object(M.generateCueId)(ve.startTime,ve.endTime,ve.text);var ke=X[z.getAttribute("region")],xe=G[z.getAttribute("style")];ve.position=10,ve.size=80;var Ce=h(ke,xe),Se=Ce.textAlign;if(Se){var Ee=_[Se];Ee&&(ve.lineAlign=Ee),ve.align=Se}return O(ve,Ce),ve}).filter(function(z){return z!==null})}function u(f,p,d){var a=f.getElementsByTagName(p)[0];return a?[].slice.call(a.querySelectorAll(d)):[]}function o(f){return f.reduce(function(p,d){var a=d.getAttribute("xml:id");return a&&(p[a]=d),p},{})}function l(f,p){return[].slice.call(f.childNodes).reduce(function(d,a,b){var y;return a.nodeName==="br"&&b?d+`
|
|
`:(y=a.childNodes)!==null&&y!==void 0&&y.length?l(a,p):p?d+a.textContent.trim().replace(/\s+/g," "):d+a.textContent},"")}function h(f,p){var d="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(b,y){var T=w(p,d,y)||w(f,d,y);return T&&(b[y]=T),b},{})}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),a=(d[4]|0)+(d[5]|0)/p.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+a/p.frameRate}function x(f,p){var d=k.exec(f),a=Number(d[1]),b=d[2];switch(b){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/p.frameRate;case"t":return a/p.tickRate}return a}},"./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(v){var C=self.console[v];return C?C.bind(self.console,"["+v+"] >"):V}function W(v){for(var C=arguments.length,k=new Array(C>1?C-1:0),_=1;_<C;_++)k[_-1]=arguments[_];k.forEach(function(A){P[A]=v[A]?v[A].bind(v):H(A)})}function M(v){if(self.console&&v===!0||typeof v=="object"){W(v,"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 W}),D.d($,"readUint16",function(){return M}),D.d($,"readUint32",function(){return O}),D.d($,"writeUint32",function(){return v}),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 E}),D.d($,"computeRawDurationFromSamples",function(){return u}),D.d($,"offsetStartDTS",function(){return o}),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 W(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 v(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),a=W(L.subarray(p+4,p+8)),b=d>1?p+d:f;if(a===g[0])if(g.length===1)m.push({data:L,start:p+8,end:b});else{var y=C({data:L,start:p+8,end:b},g.slice(1));y.length&&H.apply(m,y)}p=b}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],a=d===0?8:16,b=O(p,a);a+=4;var y=0,T=0;d===0?a+=8:a+=16,a+=2;var I=p.end+T,G=M(p,a);a+=2;for(var X=0;X<G;X++){var J=a,z=O(p,J);J+=4;var j=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:j,subsegmentDuration:ne,info:{duration:ne/b,start:I,end:I+j-1}}),I+=j,J+=4,a=J}return{earliestPresentationTime:y,timescale:b,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,a=O(f,d),b=C(x,["mdia","mdhd"])[0];if(b){p=b.data[b.start],d=p===0?12:20;var y=O(b,d),T=C(x,["mdia","hdlr"])[0];if(T){var I=W(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=W(X.data.subarray(X.start+12,X.start+16))),g[a]={timescale:y,type:G},g[G]={timescale:y,id:a,codec:J}}}}}}var z=C(w,["moov","mvex","trex"]);return z.forEach(function(j){var q=O(j,4),ne=g[q];ne&&(ne.default={duration:O(j,12),flags:O(j,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,a){var b=O(a,4),y=w[b];if(y){var T=O(x,4);f===1&&(T*=Math.pow(2,32),T+=O(x,8));var I=y.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 E(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],a=C(d,["tfhd"])[0],b=O(a,4),y=g[b];if(!y)continue;var T=y.default,I=O(a,0)|(T==null?void 0:T.flags),G=T==null?void 0:T.duration;I&8&&(I&2?G=O(a,12):G=O(a,8));for(var X=y.timescale||9e4,J=C(d,["trun"]),z=0;z<J.length;z++){if(G){var j=O(J[z],4);m=G*j}else m=u(J[z]);y.type===N.ElementaryStreamTypes.VIDEO?L+=m/X:y.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 o(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(a){var b=a.data[a.start],y=O(a,4);if(b===0)v(a,4,y-m*d);else{y*=Math.pow(2,32),y+=O(a,8),y-=m*d,y=Math.max(y,0);var T=Math.floor(y/(P+1)),I=Math.floor(y%(P+1));v(a,4,T),v(a,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,W){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=H,this.trackName=W}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(W,M,O){(this.startTime===null||this.startTime>W)&&(this.startTime=W),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 W}),D.d($,"getCuesInRange",function(){return O});var V=D("./src/utils/logger.ts");function N(v,C){var k;try{k=new Event("addtrack")}catch(_){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=v,C.dispatchEvent(k)}function P(v,C){var k=v.mode;if(k==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(C.id))try{if(v.addCue(C),!v.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,v.addCue(_)}k==="disabled"&&(v.mode=k)}function H(v){var C=v.mode;if(C==="disabled"&&(v.mode="hidden"),v.cues)for(var k=v.cues.length;k--;)v.removeCue(v.cues[k]);C==="disabled"&&(v.mode=C)}function W(v,C,k){var _=v.mode;if(_==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var A=O(v.cues,C,k),E=0;E<A.length;E++)v.removeCue(A[E]);_==="disabled"&&(v.mode=_)}function M(v,C){if(C<v[0].startTime)return 0;var k=v.length-1;if(C>v[k].endTime)return-1;for(var _=0,A=k;_<=A;){var E=Math.floor((A+_)/2);if(C<v[E].startTime)A=E-1;else if(C>v[E].startTime&&_<k)_=E+1;else return E}return v[_].startTime-C<C-v[A].startTime?_:A}function O(v,C,k){var _=[],A=M(v,C);if(A>-1)for(var E=A,u=v.length;E<u;E++){var o=v[E];if(o.startTime>=C&&o.endTime<=k)_.push(o);else if(o.startTime>k)return _}return _}},"./src/utils/time-ranges.ts":function(ie,$,D){"use strict";D.r($);var V={toString:function(P){for(var H="",W=P.length,M=0;M<W;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 W});var V=9e4;function N(M,O,v,C){v===void 0&&(v=1),C===void 0&&(C=!1);var k=M*O*v;return C?Math.round(k):k}function P(M,O,v,C){return v===void 0&&(v=1),C===void 0&&(C=!1),N(M,O,1/v,C)}function H(M,O){return O===void 0&&(O=!1),N(M,1e3,1/V,O)}function W(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(v,C){if(typeof C!="string")return!1;if(!Array.isArray(v))return!1;var k=C.toLowerCase();return~v.indexOf(k)?k:!1}function H(v){return P(V,v)}function W(v){return P(N,v)}function M(v){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 E=arguments[A];for(var u in E)v[u]=E[u]}return v}function O(v,C,k){var _=this,A={enumerable:!0};_.hasBeenReset=!1;var E="",u=!1,o=v,l=C,h=k,w=null,g="",m=!0,L="auto",x="start",f=50,p="middle",d=50,a="middle";Object.defineProperty(_,"id",M({},A,{get:function(){return E},set:function(y){E=""+y}})),Object.defineProperty(_,"pauseOnExit",M({},A,{get:function(){return u},set:function(y){u=!!y}})),Object.defineProperty(_,"startTime",M({},A,{get:function(){return o},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");o=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",M({},A,{get:function(){return l},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");l=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",M({},A,{get:function(){return h},set:function(y){h=""+y,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",M({},A,{get:function(){return w},set:function(y){w=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",M({},A,{get:function(){return g},set:function(y){var T=H(y);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(y){m=!!y,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",M({},A,{get:function(){return L},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",M({},A,{get:function(){return x},set:function(y){var T=W(y);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(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");f=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",M({},A,{get:function(){return p},set:function(y){var T=W(y);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(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");d=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",M({},A,{get:function(){return a},set:function(y){var T=W(y);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");a=T,this.hasBeenReset=!0}})),_.displayState=void 0}return O.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.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,o){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},_}();function P(_){function A(u,o,l,h){return(u|0)*3600+(o|0)*60+(l|0)+parseFloat(h||0)}var E=_.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?A(E[2],E[3],0,E[4]):A(E[1],E[2],E[3],E[4]):null}var H=function(){function _(){this.values=Object.create(null)}var A=_.prototype;return A.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},A.get=function(u,o,l){return l?this.has(u)?this.values[u]:o[l]:this.has(u)?this.values[u]:o},A.has=function(u){return u in this.values},A.alt=function(u,o,l){for(var h=0;h<l.length;++h)if(o===l[h]){this.set(u,o);break}},A.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},A.percent=function(u,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var l=parseFloat(o);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},_}();function W(_,A,E,u){var o=u?_.split(u):[_];for(var l in o){if(typeof o[l]!="string")continue;var h=o[l].split(E);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 v(_,A,E){var u=_;function o(){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;W(w,function(f,p){var d;switch(f){case"region":for(var a=E.length-1;a>=0;a--)if(E[a].id===p){m.set(f,E[a].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=o(),h(),_.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);_=_.substr(3),h(),A.endTime=o(),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 o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function l(){var x=o.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,o.buffer=x.substr(f),p}function h(x){W(x,function(f,p){},/:/)}try{var w="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;w=l();var g=w.match(/^()?WEBVTT([ \t].*)?$/);if(!g||!g[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var m=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;m?m=!1:w=l();switch(o.state){case"HEADER":/:/.test(w)?h(w):w||(o.state="ID");continue;case"NOTE":w||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(w)){o.state="NOTE";break}if(!w)continue;if(o.cue=new V.default(0,0,""),o.state="CUE",w.indexOf("-->")===-1){o.cue.id=w;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(w,o.cue,o.regionList)}catch(x){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var L=w.indexOf("-->")!==-1;if(!w||L&&(m=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=w}continue;case"BADCUE":w||(o.state="ID")}}}catch(x){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.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(o){u.onparsingerror&&u.onparsingerror(o)}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"),W=D("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,O=function(u,o,l){return l===void 0&&(l=0),u.substr(l,o.length)===o},v=function(u){var o=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)(o)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(w))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*l,o+=60*1e3*h,o+=60*60*1e3*w,o},C=function(u){for(var o=5381,l=u.length;l;)o=o*33^u.charCodeAt(--l);return(o>>>0).toString()};function k(E,u,o){return C(E.toString())+C(u.toString())+C(o)}var _=function(u,o,l){var h=u[o],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(E,u,o,l,h,w,g,m){var L=new N.VTTParser,x=Object(P.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(M,`
|
|
`).split(`
|
|
`),f=[],p=Object(H.toMpegTsClockFromTimescale)(u,o),d="00:00.000",a=0,b=0,y,T=!0,I=!1;L.oncue=function(G){var X=l[h],J=l.ccOffset,z=(a-p)/9e4;if(X!=null&&X.new&&(b!==void 0?J=l.ccOffset=X.start:_(l,h,z)),z&&(J=z-l.presentationOffset),I){var j=G.endTime-G.startTime,q=Object(W.normalizePts)((G.startTime+J-b)*9e4,w*9e4)/9e4;G.startTime=q,G.endTime=q+j}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){y=G},L.onflush=function(){if(y){m(y);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:")&&(a=parseInt(X.substr(7)))});try{b=v(d)/1e3}catch(X){I=!1,y=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 W(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=W.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var v=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),v&&(v.onreadystatechange=null,v.onprogress=null,v.readyState!==4&&(this.stats.aborted=!0,v.abort()))},M.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(v,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=v,this.config=C,this.callbacks=k,this.retryDelay=C.retryDelay,this.loadInternal()},M.loadInternal=function(){var v=this.config,C=this.context;if(!v)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(o){k.open("GET",C.url,!0),A(k,C.url)}k.readyState||k.open("GET",C.url,!0);var E=this.context.headers;if(E)for(var u in E)k.setRequestHeader(u,E[u])}catch(o){this.callbacks.onError({code:k.status,text:o.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),v.timeout),k.send()},M.readystatechange=function(){var v=this.context,C=this.loader,k=this.stats;if(!v||!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 E=C.status;if(E>=200&&E<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var u,o;if(v.responseType==="arraybuffer"?(u=C.response,o=u.byteLength):(u=C.responseText,o=u.length),k.loaded=k.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(k,v,u,C),!this.callbacks)return;var h={url:C.responseURL,data:u};this.callbacks.onSuccess(h,k,v,C)}else k.retry>=A.maxRetry||E>=400&&E<499?(V.logger.error(E+" while loading "+v.url),this.callbacks.onError({code:E,text:C.statusText},v,C)):(V.logger.warn(E+" while loading "+v.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,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 v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(v){var C=this.stats;C.loaded=v.loaded,v.lengthComputable&&(C.total=v.total)},M.getCacheAge=function(){var v=null;if(this.loader&&P.test(this.loader.getAllResponseHeaders())){var C=this.loader.getResponseHeader("age");v=C?parseFloat(C):null}return v},W}();$.default=H}}).default})},vHTk:function(Et,at,re){Et.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|