(window.webpackJsonp=window.webpackJsonp||[]).push([[143,5,7],{"+NIl":function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){"use strict";ae.defineMode("stex",function(Z,R){"use strict";function X(A,E){A.cmdState.push(E)}function I(A){return A.cmdState.length>0?A.cmdState[A.cmdState.length-1]:null}function D(A){var E=A.cmdState.pop();E&&E.closeBracket()}function H(A){for(var E=A.cmdState,w=E.length-1;w>=0;w--){var d=E[w];if(d.name=="DEFAULT")continue;return d}return{styleIdentifier:function(){return null}}}function F(A,E,w){return function(){this.name=A,this.bracketNo=0,this.style=E,this.styles=w,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var M={};M.importmodule=F("importmodule","tag",["string","builtin"]),M.documentclass=F("documentclass","tag",["","atom"]),M.usepackage=F("usepackage","tag",["atom"]),M.begin=F("begin","tag",["atom"]),M.end=F("end","tag",["atom"]),M.label=F("label","tag",["atom"]),M.ref=F("ref","tag",["atom"]),M.eqref=F("eqref","tag",["atom"]),M.cite=F("cite","tag",["atom"]),M.bibitem=F("bibitem","tag",["atom"]),M.Bibitem=F("Bibitem","tag",["atom"]),M.RBibitem=F("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(A,E){A.f=E}function v(A,E){var w;if(A.match(/^\\[a-zA-Z@]+/)){var d=A.current().slice(1);return w=M.hasOwnProperty(d)?M[d]:M.DEFAULT,w=new w,X(E,w),O(E,k),w.style}if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/\\]/))return"tag";if(A.match("\\["))return O(E,function(l,h){return C(l,h,"\\]")}),"keyword";if(A.match("\\("))return O(E,function(l,h){return C(l,h,"\\)")}),"keyword";if(A.match("$$"))return O(E,function(l,h){return C(l,h,"$$")}),"keyword";if(A.match("$"))return O(E,function(l,h){return C(l,h,"$")}),"keyword";var o=A.next();if(o=="%")return A.skipToEnd(),"comment";if(o=="}"||o=="]"){if(w=I(E),w)w.closeBracket(o),O(E,k);else return"error";return"bracket"}else return o=="{"||o=="["?(w=M.DEFAULT,w=new w,X(E,w),"bracket"):/\d/.test(o)?(A.eatWhile(/[\w.%]/),"atom"):(A.eatWhile(/[\w\-_]/),w=H(E),w.name=="begin"&&(w.argument=A.current()),w.styleIdentifier())}function C(A,E,w){if(A.eatSpace())return null;if(w&&A.match(w))return O(E,v),"keyword";if(A.match(/^\\[a-zA-Z@]+/))return"tag";if(A.match(/^[a-zA-Z]+/))return"variable-2";if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/]/))return"tag";if(A.match(/^[\^_&]/))return"tag";if(A.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(A.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var d=A.next();return d=="{"||d=="}"||d=="["||d=="]"||d=="("||d==")"?"bracket":d=="%"?(A.skipToEnd(),"comment"):"error"}function k(A,E){var w=A.peek(),d;return w=="{"||w=="["?(d=I(E),d.openBracket(w),A.eat(w),O(E,v),"bracket"):/[ \t\r]/.test(w)?(A.eat(w),null):(O(E,v),D(E),v(A,E))}return{startState:function(){var A=R.inMathMode?function(E,w){return C(E,w)}:v;return{cmdState:[],f:A}},copyState:function(A){return{cmdState:A.cmdState.slice(),f:A.f}},token:function(A,E){return E.f(A,E)},blankLine:function(A){A.f=v,A.cmdState.length=0},lineComment:"%"}}),ae.defineMIME("text/x-stex","stex"),ae.defineMIME("text/x-latex","stex")})},"19Vz":function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){ae.defineOption("placeholder","",function(F,M,O){var v=O&&O!=ae.Init;if(M&&!v)F.on("blur",I),F.on("change",D),F.on("swapDoc",D),ae.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){X(F)}),D(F);else if(!M&&v){F.off("blur",I),F.off("change",D),F.off("swapDoc",D),ae.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),Z(F);var C=F.getWrapperElement();C.className=C.className.replace(" CodeMirror-empty","")}M&&!F.hasFocus()&&I(F)});function Z(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function R(F){Z(F);var M=F.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=F.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var O=F.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),M.appendChild(O),F.display.lineSpace.insertBefore(M,F.display.lineSpace.firstChild)}function X(F){setTimeout(function(){var M=!1,O=F.getInputField();O.nodeName=="TEXTAREA"?M=!O.value:F.lineCount()==1&&(M=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),M?R(F):Z(F)},20)}function I(F){H(F)&&R(F)}function D(F){var M=F.getWrapperElement(),O=H(F);M.className=M.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?R(F):Z(F)}function H(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){"use strict";var Z={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},R={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ae.defineMode("xml",function(X,I){var D=X.indentUnit,H={},F=I.htmlMode?Z:R;for(var M in F)H[M]=F[M];for(var M in I)H[M]=I[M];var O,v;function C(a,x){function y(G){return x.tokenize=G,G(a,x)}var S=a.next();if(S=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?y(E("atom","]]>")):null:a.match("--")?y(E("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),y(w(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),x.tokenize=E("meta","?>"),"meta"):(O=a.eat("/")?"closeTag":"openTag",x.tokenize=k,"tag bracket");if(S=="&"){var P;return a.eat("#")?a.eat("x")?P=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):P=a.eatWhile(/[\d]/)&&a.eat(";"):P=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),P?"atom":"error"}else return a.eatWhile(/[^&<]/),null}C.isInText=!0;function k(a,x){var y=a.next();if(y==">"||y=="/"&&a.eat(">"))return x.tokenize=C,O=y==">"?"endTag":"selfcloseTag","tag bracket";if(y=="=")return O="equals",null;if(y=="<"){x.tokenize=C,x.state=h,x.tagName=x.tagStart=null;var S=x.tokenize(a,x);return S?S+" tag error":"tag error"}else return/[\'\"]/.test(y)?(x.tokenize=A(y),x.stringStartCol=a.column(),x.tokenize(a,x)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function A(a){var x=function(y,S){for(;!y.eol();)if(y.next()==a){S.tokenize=k;break}return"string"};return x.isInAttribute=!0,x}function E(a,x){return function(y,S){for(;!y.eol();){if(y.match(x)){S.tokenize=C;break}y.next()}return a}}function w(a){return function(x,y){for(var S;(S=x.next())!=null;){if(S=="<")return y.tokenize=w(a+1),y.tokenize(x,y);if(S==">")if(a==1){y.tokenize=C;break}else return y.tokenize=w(a-1),y.tokenize(x,y)}return"meta"}}function d(a,x,y){this.prev=a.context,this.tagName=x,this.indent=a.indented,this.startOfLine=y,(H.doNotIndent.hasOwnProperty(x)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,x){for(var y;;){if(!a.context)return;if(y=a.context.tagName,!H.contextGrabbers.hasOwnProperty(y)||!H.contextGrabbers[y].hasOwnProperty(x))return;o(a)}}function h(a,x,y){return a=="openTag"?(y.tagStart=x.column(),L):a=="closeTag"?f:h}function L(a,x,y){return a=="word"?(y.tagName=x.current(),v="tag",b):H.allowMissingTagName&&a=="endTag"?(v="tag bracket",b(a,x,y)):(v="error",L)}function f(a,x,y){if(a=="word"){var S=x.current();return y.context&&y.context.tagName!=S&&H.implicitlyClosed.hasOwnProperty(y.context.tagName)&&o(y),y.context&&y.context.tagName==S||H.matchClosing===!1?(v="tag",p):(v="tag error",_)}else return H.allowMissingTagName&&a=="endTag"?(v="tag bracket",p(a,x,y)):(v="error",_)}function p(a,x,y){return a!="endTag"?(v="error",p):(o(y),h)}function _(a,x,y){return v="error",p(a,x,y)}function b(a,x,y){if(a=="word")return v="attribute",g;if(a=="endTag"||a=="selfcloseTag"){var S=y.tagName,P=y.tagStart;return y.tagName=y.tagStart=null,a=="selfcloseTag"||H.autoSelfClosers.hasOwnProperty(S)?l(y,S):(l(y,S),y.context=new d(y,S,P==y.indented)),h}return v="error",b}function g(a,x,y){return a=="equals"?c:(H.allowMissing||(v="error"),b(a,x,y))}function c(a,x,y){return a=="string"?u:a=="word"&&H.allowUnquoted?(v="string",b):(v="error",b(a,x,y))}function u(a,x,y){return a=="string"?u:b(a,x,y)}return{startState:function(a){var x={tokenize:C,state:h,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(x.baseIndent=a),x},token:function(a,x){if(!x.tagName&&a.sol()&&(x.indented=a.indentation()),a.eatSpace())return null;O=null;var y=x.tokenize(a,x);return(y||O)&&y!="comment"&&(v=null,x.state=x.state(O||y,a,x),v&&(y=v=="error"?y+" error":v)),y},indent:function(a,x,y){var S=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+D;if(S&&S.noIndent)return ae.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+D*(H.multilineTagIndentFactor||1);if(H.alignCDATA&&/$/,blockCommentStart:"",configuration:H.htmlMode?"html":"xml",helperType:H.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=b)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var x=[],y=a.context;y;y=y.prev)y.tagName&&x.push(y.tagName);return x.reverse()}}}),ae.defineMIME("text/xml","xml"),ae.defineMIME("application/xml","xml"),ae.mimeModes.hasOwnProperty("text/html")||ae.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return l}),ie.d(dt,"b",function(){return b});var ae=ie("Ty5D"),Z=ie("dI71"),R=ie("q1tI"),X=ie.n(R),I=ie("YS25"),D=ie("17x9"),H=ie.n(D),F=ie("wx14"),M=ie("zLVn"),O=ie("9R94"),v=function(c){Object(Z.a)(u,c);function u(){for(var x,y=arguments.length,S=new Array(y),P=0;P1&&arguments[1]!==void 0?arguments[1]:0,E=(H[k[A+0]]+H[k[A+1]]+H[k[A+2]]+H[k[A+3]]+"-"+H[k[A+4]]+H[k[A+5]]+"-"+H[k[A+6]]+H[k[A+7]]+"-"+H[k[A+8]]+H[k[A+9]]+"-"+H[k[A+10]]+H[k[A+11]]+H[k[A+12]]+H[k[A+13]]+H[k[A+14]]+H[k[A+15]]).toLowerCase();if(!D(E))throw TypeError("Stringified UUID is invalid");return E}var O=M;function v(k,A,E){k=k||{};var w=k.random||(k.rng||R)();if(w[6]=w[6]&15|64,w[8]=w[8]&63|128,A){E=E||0;for(var d=0;d<16;++d)A[E+d]=w[d];return A}return O(w)}var C=dt.a=v},"7ahc":function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return L});var ae=ie("k1fw"),Z=ie("0Owb"),R=ie("+L6B"),X=ie("2/Rp"),I=ie("y8nQ"),D=ie("Vl3Y"),H=ie("tJVT"),F=ie("OaEy"),M=ie("2fM7"),O=ie("q1tI"),v=ie.n(O),C=ie("VrN/"),k=ie.n(C),A=ie("p77/"),E=ie.n(A),w=ie("c5Ni"),d=ie.n(w),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"]};dt.b=function(f){var p=f.callback,_=f.onCancel,b=Object(O.useState)("python"),g=Object(H.a)(b,2),c=g[0],u=g[1];function a(y){u(h[y][1])}function x(y){p(y)}return v.a.createElement(D.a,Object(Z.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:x}),v.a.createElement(D.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(D.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(L,{mode:c})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement(X.a,{type:"ghost",onClick:_},"\u53D6\u6D88")))};function L(f){var p=f.value,_=f.onChange,b=f.mode,g=f.options,c=g===void 0?{}:g,u=Object(O.useRef)(),a=Object(O.useState)(),x=Object(H.a)(a,2),y=x[0],S=x[1];return Object(O.useEffect)(function(){if(y){function P(G){var Y=G.getValue();_&&_(Y)}return y.on("change",P),function(){y.off("change",P)}}},[y,_]),Object(O.useEffect)(function(){y&&y.setOption("mode",b)},[y,b]),Object(O.useEffect)(function(){y&&((p!==y.getValue()||p==="")&&setTimeout(function(){y.setValue(p||" ")},300))},[y,p]),Object(O.useEffect)(function(){if(u.current&&!y){var P=k.a.fromTextArea(u.current,Object(ae.a)({mode:b,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));S(P)}},[u.current,y]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:u}))}},"8EBN":function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){"use strict";ae.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var Z=0;Z-1&&X.substring(H+1,X.length);if(F)return ae.findModeByExtension(F)},ae.findModeByName=function(X){X=X.toLowerCase();for(var I=0;I=U.length?K.slice(U.length):K}).join(` `)}var d=[],o=["
    "],l=new A.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function L(){d.length=0,o=["
      "]}var f={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(W,s,m,U){if(s>=W.length||W[s].level<=m)return s;var K=W[s];U.push("
    • "+K.text+""),s++;var B=[];return s=p(W,s,K.level,B),B.length>0&&(U.push("
        "),B.forEach(function(ce){U.push(ce)}),U.push("
      ")),U.push("
    • "),s=p(W,s,m,U),s}function _(){return p(d,0,0,o),o.push("
    "),o.join("")}var b={heading:function(s){var m=h.exec(s);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(s){var m=this.rules.block.fences.exec(s);if(m){var U=m[0],K=w(U,m[3]||""),B=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(B)>=0){var ce=u(),Oe=K;K=ce,a[ce]={type:"block",expression:Oe}}return{type:"code",raw:U,lang:B,text:K}}}},g=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,u=function(){return"__special_katext_id_".concat(c++,"__")},a={};function x(){return a}function y(){c=0,a={}}function S(W){return W=W.replace(g,function(s,m){var U=u();return a[U]={type:"inline",expression:m},U}),W}var P=l.listitem;l.listitem=function(W){return P(S(W))};var G=l.paragraph;l.paragraph=function(W){return G(S(W))};var Y=l.tablecell;l.tablecell=function(W,s){return Y(S(W),s)},l.code=function(W,s,m){var U=(s||"").match(/\S*/)[0];return U?["latex","katex","math"].indexOf(U)>=0?"

    ".concat(W,"

    "):'
    ').concat(m?W:Object(E.escape)(W,!0),`
    `):'
    '+(m?W:Object(E.escape)(W,!0))+"
    "},l.heading=function(W,s,m){var U=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return d.push({anchor:U,level:s,text:W}),"'+W+""},A.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),A.a.use({tokenizer:b,renderer:l});var Q=A.a,z=ie("SJMd"),j=ie("ulZh"),ee=ie.n(j),oe=ie("m3rI"),fe=ie("Oy/b"),ve=ie("p5ED"),Re=ie("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 Ee=function(W,s){return(Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,U){m.__proto__=U}||function(m,U){for(var K in U)Object.prototype.hasOwnProperty.call(U,K)&&(m[K]=U[K])})(W,s)};function Se(W,s){function m(){this.constructor=W}Ee(W,s),W.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function we(W,s,m,U){return new(m||(m=Promise))(function(K,B){function ce(pt){try{rt(U.next(pt))}catch(Ue){B(Ue)}}function Oe(pt){try{rt(U.throw(pt))}catch(Ue){B(Ue)}}function rt(pt){var Ue;pt.done?K(pt.value):(Ue=pt.value,Ue instanceof m?Ue:new m(function(wt){wt(Ue)})).then(ce,Oe)}rt((U=U.apply(W,s||[])).next())})}function Te(W,s){var m,U,K,B,ce={label:0,sent:function(){if(1&K[0])throw K[1];return K[1]},trys:[],ops:[]};return B={next:Oe(0),throw:Oe(1),return:Oe(2)},typeof Symbol=="function"&&(B[Symbol.iterator]=function(){return this}),B;function Oe(rt){return function(pt){return function(Ue){if(m)throw new TypeError("Generator is already executing.");for(;ce;)try{if(m=1,U&&(K=2&Ue[0]?U.return:Ue[0]?U.throw||((K=U.return)&&K.call(U),0):U.next)&&!(K=K.call(U,Ue[1])).done)return K;switch(U=0,K&&(Ue=[2&Ue[0],K.value]),Ue[0]){case 0:case 1:K=Ue;break;case 4:return ce.label++,{value:Ue[1],done:!1};case 5:ce.label++,U=Ue[1],Ue=[0];continue;case 7:Ue=ce.ops.pop(),ce.trys.pop();continue;default:if(!(K=ce.trys,(K=K.length>0&&K[K.length-1])||Ue[0]!==6&&Ue[0]!==2)){ce=0;continue}if(Ue[0]===3&&(!K||Ue[1]>K[0]&&Ue[1]',"select"),this.addActionButton(U,'',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(U,'',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(U,'',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(U,'',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(U,'',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(U,'',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(U,'',"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(B){var ce=document.createElement("div");ce.className=""+m.toolbarButtonStyleClass.name,ce.setAttribute("data-type-name",B.typeName),ce.innerHTML=B.icon,ce.addEventListener("click",function(){m.markerToolbarButtonClicked(ce,B)}),m.buttons.push(ce),m.markerButtons.push(ce)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var K=document.createElement("div");K.className=this.toolbarBlockStyleClass.name,K.style.whiteSpace="nowrap",K.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(K),this.addActionButton(K,'',"render"),this.addActionButton(K,'',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},W.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},W.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var m=0;m0&&this.buttonClickListeners.forEach(function(U){return U("marker",m)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(s,m){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(U){return U("action",m)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.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)},W.prototype.setActiveMarkerButton=function(s){var m=this.markerButtons.find(function(U){return U.getAttribute("data-type-name")===s});m&&this.setActiveButton(m)},W.prototype.setCurrentMarker=function(s){var m=this;this.currentMarker=s,this.buttons.filter(function(U){return/delete|notes/.test(U.getAttribute("data-action"))}).forEach(function(U){m.currentMarker===void 0?(U.style.fillOpacity="0.4",U.style.pointerEvents="none"):(U.style.fillOpacity="1",U.style.pointerEvents="all")})},W}(),je=function(){function W(s,m,U,K){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=m,this.uiStyleSettings=U,this.styles=K,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Ae("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 Ae("toolbox_colors",` color: `+this.uiStyleSettings.toolboxColor+`; `));var m=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Ae("toolbox-button-row",` display: flex; cursor: default; box-sizing: content-box; `)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Ae("toolbox-button-row_colors",` background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`; `)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Ae("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 Ae("toolbox-panel-row_colors",` background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`; `)),this.toolboxButtonStyleClass=this.styles.addClass(new Ae("toolbox_button",` display: inline-block; width: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px; height: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px; padding: `+m+`px; box-sizing: content-box; `)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Ae("toolbox-button_colors",` fill: `+this.uiStyleSettings.toolbarColor+`; `)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Ae("toolbox-active-button_colors",` background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`; fill: `+this.uiStyleSettings.toolbarColor+`; `)),this.styles.addRule(new Ye("."+this.toolboxButtonStyleColorsClass.name+":hover",` background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+` `)),this.styles.addRule(new Ye("."+this.toolboxButtonStyleClass.name+" svg",` height: `+this.uiStyleSettings.toolbarHeight/2+`px; `))},W.prototype.show=function(s){var m;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((m=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(s){var m,U,K=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((m=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((U=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&U!==void 0?U:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(B){var ce;B.uiStyleSettings=K.uiStyleSettings;var Oe=document.createElement("div");Oe.className=K.toolboxButtonStyleClass.name+" "+((ce=K.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ce!==void 0?ce:K.toolboxButtonStyleColorsClass.name),Oe.innerHTML=B.icon,Oe.title=B.title,Oe.addEventListener("click",function(){K.panelButtonClick(B)}),K.panelButtons.push(Oe),K.buttonRow.appendChild(Oe)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(s){var m=this,U=-1;if(s!==this.activePanel){U=this.panels.indexOf(s),this.panelRow.innerHTML="";var K=s.getUi();K.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(K),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){m.displayMode==="inline"?m.panelRow.style.display="none":m.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(B,ce){var Oe,rt;B.className=m.toolboxButtonStyleClass.name+" "+(ce===U?""+((Oe=m.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Oe!==void 0?Oe:m.toolboxActiveButtonStyleColorsClass.name):""+((rt=m.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&rt!==void 0?rt:m.toolboxButtonStyleColorsClass.name))})},W}(),et=function(W,s){this.title=W,this.icon=s},Xe=function(W){function s(m,U,K,B){var ce=W.call(this,m,B||'')||this;return ce.colors=[],ce.addTransparent=!1,ce.colorBoxes=[],ce.colors=U,ce.currentColor=K,ce.setCurrentColor=ce.setCurrentColor.bind(ce),ce.getColorBox=ce.getColorBox.bind(ce),ce}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");return U.style.overflow="hidden",U.style.whiteSpace="nowrap",this.colors.forEach(function(K){var B=m.getColorBox(K);U.appendChild(B),m.colorBoxes.push(B)}),U},s.prototype.getColorBox=function(m){var U=this,K=this.uiStyleSettings.toolbarHeight/4,B=this.uiStyleSettings.toolbarHeight-K,ce=document.createElement("div");ce.style.display="inline-block",ce.style.boxSizing="content-box",ce.style.width=B-2+"px",ce.style.height=B-2+"px",ce.style.padding="1px",ce.style.marginRight="2px",ce.style.marginBottom="2px",ce.style.borderWidth="2px",ce.style.borderStyle="solid",ce.style.borderRadius=(B+2)/2+"px",ce.style.borderColor=m===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ce.addEventListener("click",function(){U.setCurrentColor(m,ce)});var Oe=document.createElement("div");return Oe.style.display="inline-block",Oe.style.width=B-2+"px",Oe.style.height=B-2+"px",Oe.style.backgroundColor=m,Oe.style.borderRadius=B/2+"px",m==="transparent"&&(Oe.style.fill=this.uiStyleSettings.toolboxAccentColor,Oe.innerHTML=` `),ce.appendChild(Oe),ce},s.prototype.setCurrentColor=function(m,U){var K=this;this.currentColor=m,this.colorBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(m)},s}(et),Ne=function(){function W(s,m,U){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=m,this.globalSettings=U,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(W.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),W.prototype.ownsTarget=function(s){return!1},Object.defineProperty(W.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),W.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},W.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},W.prototype.pointerDown=function(s,m){},W.prototype.dblClick=function(s,m){},W.prototype.manipulate=function(s){},W.prototype.pointerUp=function(s){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},W.prototype.scale=function(s,m){},W.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},W.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},W.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)}},W.typeName="MarkerBase",W}(),Be=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.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},W}(),ht=function(){function W(){this.GRIP_SIZE=10,this.visual=de.createGroup(),this.visual.appendChild(de.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(de.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},W}(),We=function(){function W(){}return W.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},W.toSVGMatrix=function(s,m){return s.a=m.a,s.b=m.b,s.c=m.c,s.d=m.d,s.e=m.e,s.f=m.f,s},W}(),Pe=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.left=0,B.top=0,B.width=0,B.height=0,B.defaultSize={x:50,y:20},B.offsetX=0,B.offsetY=0,B.rotationAngle=0,B.CB_DISTANCE=10,B._suppressMarkerCreateEvent=!1,B.container.transform.baseVal.appendItem(de.createTransform()),B.setupControlBox(),B}return Se(s,W),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(m){this._visual=m;var U=de.createTransform();this._visual.transform.baseVal.appendItem(U)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!!W.prototype.ownsTarget.call(this,m)||!!(this.controlGrips.findGripByVisual(m)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(m))},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.state==="new"&&(this.left=m.x,this.top=m.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var K=this.unrotatePoint(m);if(this.manipulationStartX=K.x,this.manipulationStartY=K.y,this.offsetX=K.x-this.left,this.offsetY=K.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(U),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(U)){this.activeGrip=this.rotatorGrip;var B=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=B.x-this.width/2,this.top=B.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ce=this.container.transform.baseVal.getItem(0);ce.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ce,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(m){var U=this.state;W.prototype.pointerUp.call(this,m),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(m),this._state="select",U==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(m){this.visual.style.transform="translate("+m.x+"px, "+m.y+"px)"},s.prototype.manipulate=function(m){var U=this.unrotatePoint(m);this.state==="creating"?this.resize(m):this.state==="move"?(this.left=this.manipulationStartLeft+(U.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(U.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(U):this.state==="rotate"&&this.rotate(m)},s.prototype.resize=function(m){var U=this.manipulationStartLeft,K=this.manipulationStartWidth,B=this.manipulationStartTop,ce=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:U=this.manipulationStartLeft+m.x-this.manipulationStartX,K=this.manipulationStartWidth+this.manipulationStartLeft-U;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:K=this.manipulationStartWidth+m.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:B=this.manipulationStartTop+m.y-this.manipulationStartY,ce=this.manipulationStartHeight+this.manipulationStartTop-B;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ce=this.manipulationStartHeight+m.y-this.manipulationStartY}K>=0?(this.left=U,this.width=K):(this.left=U+K,this.width=-K),ce>=0?(this.top=B,this.height=ce):(this.top=B+ce,this.height=-ce),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(m){if(Math.abs(m.x-this.centerX)>.1){var U=Math.sign(m.x-this.centerX);this.rotationAngle=180*Math.atan((m.y-this.centerY)/(m.x-this.centerX))/Math.PI+90*U,this.applyRotation()}},s.prototype.applyRotation=function(){var m=this.container.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(m,0)},s.prototype.rotatePoint=function(m){if(this.rotationAngle===0)return m;var U=this.container.getCTM(),K=de.createPoint(m.x,m.y);return{x:(K=K.matrixTransform(U)).x,y:K.y}},s.prototype.unrotatePoint=function(m){if(this.rotationAngle===0)return m;var U=this.container.getCTM();U=U.inverse();var K=de.createPoint(m.x,m.y);return{x:(K=K.matrixTransform(U)).x,y:K.y}},s.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=de.createGroup();var m=de.createTransform();m.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(m),this.container.appendChild(this.controlBox),this.controlRect=de.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=de.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Be,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var m=this.controlBox.transform.baseVal.getItem(0);m.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(m,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var m=new ht;return m.visual.transform.baseVal.appendItem(de.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.controlGrips.topLeft.GRIP_SIZE,U=-m/2,K=U,B=(this.width+this.CB_DISTANCE)/2-m/2,ce=(this.height+this.CB_DISTANCE)/2-m/2,Oe=this.height+this.CB_DISTANCE-m/2,rt=this.width+this.CB_DISTANCE-m/2;this.positionGrip(this.controlGrips.topLeft.visual,U,K),this.positionGrip(this.controlGrips.topCenter.visual,B,K),this.positionGrip(this.controlGrips.topRight.visual,rt,K),this.positionGrip(this.controlGrips.centerLeft.visual,U,ce),this.positionGrip(this.controlGrips.centerRight.visual,rt,ce),this.positionGrip(this.controlGrips.bottomLeft.visual,U,Oe),this.positionGrip(this.controlGrips.bottomCenter.visual,B,Oe),this.positionGrip(this.controlGrips.bottomRight.visual,rt,Oe),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,B,K-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(m,U,K){var B=m.transform.baseVal.getItem(0);B.setTranslate(U,K),m.transform.baseVal.replaceItem(B,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:We.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:We.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var U=m;this.left=U.left,this.top=U.top,this.width=U.width,this.height=U.height,this.rotationAngle=U.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(We.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,U.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(We.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,U.containerTransformMatrix))},s.prototype.scale=function(m,U){W.prototype.scale.call(this,m,U);var K=this.rotatePoint({x:this.left,y:this.top}),B=this.unrotatePoint({x:K.x*m,y:K.y*U});this.left=B.x,this.top=B.y,this.width=this.width*m,this.height=this.height*U,this.adjustControlBox()},s}(Ne),Ke=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.fillColor="transparent",B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.opacity=1,B.setStrokeColor=B.setStrokeColor.bind(B),B.setFillColor=B.setFillColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.createVisual=B.createVisual.bind(B),B}return Se(s,W),s.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=de.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){W.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){W.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){W.prototype.setSize.call(this),de.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){W.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&de.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&de.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&de.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&de.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},W.prototype.getState.call(this))},s.prototype.restoreState=function(m){var U=m;this.fillColor=U.fillColor,this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.opacity=U.opacity,this.createVisual(),W.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,U){W.prototype.scale.call(this,m,U),this.setSize()},s.title="Rectangle marker",s}(Pe),qe=function(W){function s(m,U,K,B){var ce=W.call(this,m,B||'')||this;return ce.widths=[],ce.widthBoxes=[],ce.widths=U,ce.currentWidth=K,ce.setCurrentWidth=ce.setCurrentWidth.bind(ce),ce}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",this.widths.forEach(function(K){var B=document.createElement("div");B.style.display="flex",B.style.flexGrow="2",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.borderColor=K===m.currentWidth?m.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){m.setCurrentWidth(K,B)}),U.appendChild(B);var ce=document.createElement("div");ce.innerText=K.toString(),ce.style.marginRight="5px",B.appendChild(ce);var Oe=document.createElement("div");Oe.style.minHeight="20px",Oe.style.flexGrow="2",Oe.style.display="flex",Oe.style.alignItems="center";var rt=document.createElement("hr");rt.style.minWidth="20px",rt.style.border="0px",rt.style.borderTop=K+"px solid "+m.uiStyleSettings.toolboxColor,rt.style.flexGrow="2",Oe.appendChild(rt),B.appendChild(Oe),m.widthBoxes.push(B)}),U},s.prototype.setCurrentWidth=function(m,U){var K=this;this.currentWidth=m,this.widthBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(et),Ve=function(W){function s(m,U,K,B){var ce=W.call(this,m,B||'')||this;return ce.styles=[],ce.styleBoxes=[],ce.styles=U,ce.currentStyle=K,ce.setCurrentStyle=ce.setCurrentStyle.bind(ce),ce}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",this.styles.forEach(function(K){var B=document.createElement("div");B.style.display="flex",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.overflow="hidden",B.style.maxWidth=100/m.styles.length-5+"%",B.style.borderColor=K===m.currentStyle?m.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){m.setCurrentStyle(K,B)}),U.appendChild(B);var ce=document.createElement("div");ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.overflow="hidden";var Oe=` `;ce.innerHTML=Oe,B.appendChild(ce),m.styleBoxes.push(B)}),U},s.prototype.setCurrentStyle=function(m,U){var K=this;this.currentStyle=m,this.styleBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(et),it=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.strokeColor=K.defaultColor,B.strokeWidth=K.defaultStrokeWidth,B.strokeDasharray=K.defaultStrokeDasharray,B.strokePanel=new Xe("Line color",K.defaultColorSet,K.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new qe("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new Ve("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Se(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="FrameMarker",s.title="Frame marker",s.icon='',s}(Ke),Ce=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},tt=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.x1=0,B.y1=0,B.x2=0,B.y2=0,B.defaultLength=50,B.manipulationStartX=0,B.manipulationStartY=0,B.manipulationStartX1=0,B.manipulationStartY1=0,B.manipulationStartX2=0,B.manipulationStartY2=0,B.setupControlBox(),B}return Se(s,W),s.prototype.ownsTarget=function(m){return!!W.prototype.ownsTarget.call(this,m)||!(!this.grip1.ownsTarget(m)&&!this.grip2.ownsTarget(m))},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.manipulationStartX=m.x,this.manipulationStartY=m.y,this.state==="new"&&(this.x1=m.x,this.y1=m.y,this.x2=m.x,this.y2=m.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(U)?this.activeGrip=this.grip1:this.grip2.ownsTarget(U)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(m){var U=this.state;W.prototype.pointerUp.call(this,m),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(m),this._state="select",U==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(m){this.state==="creating"?this.resize(m):this.state==="move"?(this.x1=this.manipulationStartX1+m.x-this.manipulationStartX,this.y1=this.manipulationStartY1+m.y-this.manipulationStartY,this.x2=this.manipulationStartX2+m.x-this.manipulationStartX,this.y2=this.manipulationStartY2+m.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(m)},s.prototype.resize=function(m){switch(this.activeGrip){case this.grip1:this.x1=m.x,this.y1=m.y;break;case this.grip2:case void 0:this.x2=m.x,this.y2=m.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=de.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var m=new ht;return m.visual.transform.baseVal.appendItem(de.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-m/2,this.y1-m/2),this.positionGrip(this.grip2.visual,this.x2-m/2,this.y2-m/2)},s.prototype.positionGrip=function(m,U,K){var B=m.transform.baseVal.getItem(0);B.setTranslate(U,K),m.transform.baseVal.replaceItem(B,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var U=m;this.x1=U.x1,this.y1=U.y1,this.x2=U.x2,this.y2=U.y2},s.prototype.scale=function(m,U){W.prototype.scale.call(this,m,U),this.x1=this.x1*m,this.y1=this.y1*U,this.x2=this.x2*m,this.y2=this.y2*U,this.adjustVisual(),this.adjustControlBox()},s}(Ne),nt=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.setStrokeColor=B.setStrokeColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.strokeColor=K.defaultColor,B.strokeWidth=K.defaultStrokeWidth,B.strokeDasharray=K.defaultStrokeDasharray,B.strokePanel=new Xe("Line color",K.defaultColorSet,K.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new qe("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new Ve("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Se(s,W),s.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorLine&&m!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=de.createGroup(),this.selectorLine=de.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=de.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),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()),de.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),de.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),de.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var U=m;this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='',s}(tt),Le=function(W){function s(m,U,K,B){var ce=W.call(this,m,B||'')||this;return ce.fonts=[],ce.fontBoxes=[],ce.fonts=U,ce.currentFont=K,ce.setCurrentFont=ce.setCurrentFont.bind(ce),ce}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");return U.style.overflow="hidden",U.style.flexGrow="2",this.fonts.forEach(function(K){var B=document.createElement("div");B.style.display="inline-block",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.overflow="hidden",B.style.maxWidth=100/m.fonts.length-5+"%",B.style.borderColor=K===m.currentFont?m.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){m.setCurrentFont(K,B)}),U.appendChild(B);var ce=document.createElement("div");ce.style.display="flex",ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.fontFamily=K,ce.style.overflow="hidden";var Oe=document.createElement("div");Oe.style.whiteSpace="nowrap",Oe.style.overflow="hidden",Oe.style.textOverflow="ellipsis",Oe.innerHTML="The quick brown fox jumps over the lazy dog",ce.appendChild(Oe),B.appendChild(ce),m.fontBoxes.push(B)}),U},s.prototype.setCurrentFont=function(m,U){var K=this;this.currentFont=m,this.fontBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(et),Ie=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.color="transparent",B.padding=5,B.DEFAULT_TEXT="your text here",B.text=B.DEFAULT_TEXT,B.isMoved=!1,B.color=K.defaultColor,B.fontFamily=K.defaultFontFamily,B.defaultSize={x:100,y:30},B.setColor=B.setColor.bind(B),B.setFont=B.setFont.bind(B),B.renderText=B.renderText.bind(B),B.sizeText=B.sizeText.bind(B),B.textEditDivClicked=B.textEditDivClicked.bind(B),B.showTextEditor=B.showTextEditor.bind(B),B.setSize=B.setSize.bind(B),B.positionTextEditor=B.positionTextEditor.bind(B),B.colorPanel=new Xe("Color",K.defaultColorSet,K.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.fontFamilyPanel=new Le("Font",K.defaultFontFamilies,K.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B}return Se(s,W),s.prototype.ownsTarget=function(m){if(W.prototype.ownsTarget.call(this,m)||m===this.visual||m===this.textElement||m===this.bgRectangle)return!0;var U=!1;return this.textElement.childNodes.forEach(function(K){K===m&&(U=!0)}),U},s.prototype.createVisual=function(){this.visual=de.createGroup(),this.bgRectangle=de.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=de.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(de.createTransform()),this.textElement.transform.baseVal.appendItem(de.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.isMoved=!1,this.pointerDownPoint=m,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.renderText=function(){var m=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(U){m.textElement.appendChild(de.createTSpan(U.trim()===""?" ":U.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var m=this.textElement.getBBox(),U=1;if(m.width>0&&m.height>0){var K=(1*this.width-this.width*this.padding*2/100)/m.width,B=(1*this.height-this.height*this.padding*2/100)/m.height;U=Math.min(K,B)}return U},s.prototype.getTextPosition=function(m){var U=this.textElement.getBBox(),K=0,B=0;return U.width>0&&U.height>0&&(K=(this.width-U.width*m)/2,B=this.height/2-U.height*m/2),{x:K,y:B}},s.prototype.sizeText=function(){var m=this.textElement.getBBox(),U=this.getTextScale(),K=this.getTextPosition(U);K.y-=m.y*U,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+K.x+"px, "+K.y+"px) scale("+U+", "+U+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(K.x,K.y),this.textElement.transform.baseVal.getItem(1).setScale(U,U))},s.prototype.manipulate=function(m){W.prototype.manipulate.call(this,m),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(m.x-this.pointerDownPoint.x)>5||Math.abs(m.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(m){W.prototype.resize.call(this,m),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(de.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),de.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(m){var U=this.state;U==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,m),this.setSize(),(U==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var m=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(U){U.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var U=Number.parseFloat(m.textEditor.style.fontSize);m.textEditor.clientWidth>=Number.parseInt(m.textEditor.style.maxWidth)&&U>.9;)U-=.1,m.textEditor.style.fontSize=Math.max(U,.9)+"em"}),this.textEditor.addEventListener("keyup",function(U){U.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(U){if(U.clipboardData){var K=U.clipboardData.getData("text"),B=window.getSelection();if(!B.rangeCount)return!1;B.deleteFromDocument(),B.getRangeAt(0).insertNode(document.createTextNode(K)),U.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){m.textEditDivClicked(m.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var m=this.getTextScale(),U=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),K=this.textElement.getBBox(),B={x:K.width*m,y:K.height*m};U.x-=B.x/2,U.y-=B.y/2,this.textEditor.style.top=U.y+"px",this.textEditor.style.left=U.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-U.x+"px",this.textEditor.style.fontSize=Math.max(16*m,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(m){this.text=m.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},s.prototype.dblClick=function(m,U){W.prototype.dblClick.call(this,m,U),this.showTextEditor()},s.prototype.setColor=function(m){this.textElement&&de.setAttributes(this.textElement,[["fill",m]]),this.color=m,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(m)},s.prototype.setFont=function(m){this.textElement&&de.setAttributes(this.textElement,[["font-family",m]]),this.fontFamily=m,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var U=m;this.color=U.color,this.fontFamily=U.fontFamily,this.padding=U.padding,this.text=U.text,this.createVisual(),W.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,U){W.prototype.scale.call(this,m,U),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.icon='',s}(Pe),pe=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.color="transparent",B.lineWidth=3,B.drawing=!1,B.pixelRatio=1,B.color=K.defaultColor,B.lineWidth=K.defaultStrokeWidth,B.pixelRatio=K.freehandPixelRatio,B.setColor=B.setColor.bind(B),B.addCanvas=B.addCanvas.bind(B),B.finishCreation=B.finishCreation.bind(B),B.setLineWidth=B.setLineWidth.bind(B),B.colorPanel=new Xe("Color",K.defaultColorSet,K.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.lineWidthPanel=new qe("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),B.lineWidthPanel.onWidthChanged=B.setLineWidth,B}return Se(s,W),s.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=de.createGroup(),this.drawingImage=de.createImage(),this.visual.appendChild(this.drawingImage);var m=de.createTransform();this.visual.transform.baseVal.appendItem(m),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,U){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(m.x,m.y),this.drawing=!0):W.prototype.pointerDown.call(this,m,U)},s.prototype.manipulate=function(m){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(m.x,m.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){W.prototype.resize.call(this,m),de.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),de.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,m)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var m=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),U=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],K=U[0],B=U[1],ce=U[2],Oe=U[3],rt=!1,pt=0;pt0&&(rt=!0,ptOe&&(Oe=pt),Ue>ce&&(ce=Ue));if(rt){this.left=K/this.pixelRatio,this.top=B/this.pixelRatio,this.width=(ce-K)/this.pixelRatio,this.height=(Oe-B)/this.pixelRatio;var wt=document.createElement("canvas");wt.width=ce-K,wt.height=Oe-B,wt.getContext("2d").putImageData(this.canvasContext.getImageData(K,B,ce-K,Oe-B),0,0),this.drawingImgUrl=wt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){de.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),de.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(m){this.color=m,this.colorChanged(m)},s.prototype.setLineWidth=function(m){this.lineWidth=m},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){this.createVisual(),W.prototype.restoreState.call(this,m),this.drawingImgUrl=m.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(m,U){W.prototype.scale.call(this,m,U),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.icon='',s}(Pe),le=function(W){function s(m,U,K){var B=W.call(this,m,K||'')||this;return B.typeBoxes=[],B.currentType=U,B.setCurrentType=B.setCurrentType.bind(B),B}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2";for(var K=function(Oe){var rt="both";switch(Oe){case 0:rt="both";break;case 1:rt="start";break;case 2:rt="end";break;case 3:rt="none"}var pt=document.createElement("div");if(pt.style.display="flex",pt.style.flexGrow="2",pt.style.alignItems="center",pt.style.justifyContent="space-between",pt.style.padding="5px",pt.style.borderWidth="2px",pt.style.borderStyle="solid",pt.style.borderColor=rt===B.currentType?B.uiStyleSettings.toolboxAccentColor:"transparent",pt.addEventListener("click",function(){m.setCurrentType(rt,pt)}),U.appendChild(pt),rt==="both"||rt==="start"){var Ue=document.createElement("div");Ue.style.display="flex",Ue.style.alignItems="center",Ue.style.minHeight="20px",Ue.innerHTML=` `,Ue.style.marginLeft="5px",pt.appendChild(Ue)}var wt=document.createElement("div");wt.style.display="flex",wt.style.alignItems="center",wt.style.minHeight="20px",wt.style.flexGrow="2";var It=document.createElement("hr");if(It.style.minWidth="20px",It.style.border="0px",It.style.borderTop="3px solid "+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee"),It.style.flexGrow="2",wt.appendChild(It),pt.appendChild(wt),rt==="both"||rt==="end"){var $t=document.createElement("div");$t.style.display="flex",$t.style.alignItems="center",$t.style.minHeight="20px",$t.innerHTML=` `,$t.style.marginRight="5px",pt.appendChild($t)}B.typeBoxes.push(pt)},B=this,ce=0;ce<4;ce++)K(ce);return U},s.prototype.setCurrentType=function(m,U){var K=this;this.currentType=m,this.typeBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings!==void 0?K.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(et),ue=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.arrowType="end",B.arrowBaseHeight=10,B.arrowBaseWidth=10,B.getArrowPoints=B.getArrowPoints.bind(B),B.setArrowType=B.setArrowType.bind(B),B.arrowTypePanel=new le("Arrow type","end"),B.arrowTypePanel.onArrowTypeChanged=B.setArrowType,B}return Se(s,W),s.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.arrow1&&m!==this.arrow2)},s.prototype.getArrowPoints=function(m,U){var K=this.arrowBaseWidth+2*this.strokeWidth,B=this.arrowBaseHeight+2*this.strokeWidth;return m-K/2+","+(U+B/2)+" "+m+","+(U-B/2)+" "+(m+K/2)+","+(U+B/2)},s.prototype.createTips=function(){this.arrow1=de.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(de.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=de.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(de.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(W.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",de.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),de.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),U=this.arrow1.transform.baseVal.getItem(0);U.setRotate(m,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(U,0);var K=this.arrow2.transform.baseVal.getItem(0);K.setRotate(m+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(K,0)}},s.prototype.setArrowType=function(m){this.arrowType=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var U=m;this.arrowType=U.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='',s}(nt),te=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.fillColor=K.defaultFillColor,B.strokeWidth=0,B.fillPanel=new Xe("Color",K.defaultColorSet,K.defaultFillColor),B.fillPanel.onColorChanged=B.setFillColor,B}return Se(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="CoverMarker",s.title="Cover marker",s.icon='',s}(Ke),q=function(W){function s(m,U,K,B){var ce=W.call(this,m,B||'')||this;return ce.opacities=[],ce.opacityBoxes=[],ce.opacities=U,ce.currentOpacity=K,ce.setCurrentOpacity=ce.setCurrentOpacity.bind(ce),ce}return Se(s,W),s.prototype.getUi=function(){var m=this,U=document.createElement("div");return U.style.display="flex",U.style.overflow="hidden",U.style.flexGrow="2",U.style.justifyContent="space-between",this.opacities.forEach(function(K){var B=document.createElement("div");B.style.display="flex",B.style.alignItems="center",B.style.justifyContent="center",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.borderColor=K===m.currentOpacity?m.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){m.setCurrentOpacity(K,B)}),U.appendChild(B);var ce=document.createElement("div");ce.innerText=100*K+"%",B.appendChild(ce),m.opacityBoxes.push(B)}),U},s.prototype.setCurrentOpacity=function(m,U){var K=this;this.currentOpacity=m,this.opacityBoxes.forEach(function(B){B.style.borderColor=B===U?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(et),re=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.setOpacity=B.setOpacity.bind(B),B.fillColor=K.defaultHighlightColor,B.strokeWidth=0,B.opacity=K.defaultHighlightOpacity,B.fillPanel=new Xe("Color",K.defaultColorSet,B.fillColor),B.fillPanel.onColorChanged=B.setFillColor,B.opacityPanel=new q("Opacity",K.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return Se(s,W),s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&de.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='',s}(te),ne='',ye=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.bgColor="transparent",B.tipPosition={x:0,y:0},B.tipBase1Position={x:0,y:0},B.tipBase2Position={x:0,y:0},B.tipMoving=!1,B.color=K.defaultStrokeColor,B.bgColor=K.defaultFillColor,B.fontFamily=K.defaultFontFamily,B.defaultSize={x:100,y:30},B.setBgColor=B.setBgColor.bind(B),B.getTipPoints=B.getTipPoints.bind(B),B.positionTip=B.positionTip.bind(B),B.setTipPoints=B.setTipPoints.bind(B),B.colorPanel=new Xe("Text color",K.defaultColorSet,B.color,''),B.colorPanel.onColorChanged=B.setColor,B.bgColorPanel=new Xe("Fill color",K.defaultColorSet,B.bgColor,ne),B.bgColorPanel.onColorChanged=B.setBgColor,B.fontFamilyPanel=new Le("Font",K.defaultFontFamilies,K.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B.tipGrip=new ht,B.tipGrip.visual.transform.baseVal.appendItem(de.createTransform()),B.controlBox.appendChild(B.tipGrip.visual),B}return Se(s,W),s.prototype.ownsTarget=function(m){return W.prototype.ownsTarget.call(this,m)||this.tipGrip.ownsTarget(m)||this.tip===m},s.prototype.createTip=function(){de.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=de.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(m,U){this.state==="new"&&W.prototype.pointerDown.call(this,m,U),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(U)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,m,U)},s.prototype.pointerUp=function(m){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,m);else{var U=this.state==="creating";W.prototype.pointerUp.call(this,m),this.setTipPoints(U),this.positionTip()}},s.prototype.manipulate=function(m){if(this.tipMoving){var U=this.unrotatePoint(m);this.tipPosition={x:U.x-this.manipulationStartLeft,y:U.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,m)},s.prototype.setBgColor=function(m){this.bgRectangle&&this.tip&&(de.setAttributes(this.bgRectangle,[["fill",m]]),de.setAttributes(this.tip,[["fill",m]])),this.bgColor=m,this.fillColorChanged(m)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(m){m===void 0&&(m=!1);var U=Math.min(this.height/2,15),K=this.height/5;m&&(this.tipPosition={x:U+K/2,y:this.height+20});var B=Math.atan(this.height/2/(this.width/2));this.tipPosition.x=this.width/2&&this.tipPosition.y=this.width/2&&this.tipPosition.y>=this.height/2?B.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),U=this.tip1.transform.baseVal.getItem(0);U.setRotate(m,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(U,0);var K=this.tip2.transform.baseVal.getItem(0);K.setRotate(m+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(K,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='',s}(nt),ze=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.strokePanel.colors=K.defaultColorSet,B.fillColor="transparent",B}return Se(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='',s}(ge),ft=function(){function W(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),W.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))},W.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},W.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},W.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}},W.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},W}(),lt=function(W){function s(m,U,K){var B=W.call(this,m,U,K)||this;return B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.curveX=0,B.curveY=0,B.manipulationStartCurveX=0,B.manipulationStartCurveY=0,B.setStrokeColor=B.setStrokeColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.positionGrips=B.positionGrips.bind(B),B.addControlGrips=B.addControlGrips.bind(B),B.adjustVisual=B.adjustVisual.bind(B),B.setupControlBox=B.setupControlBox.bind(B),B.resize=B.resize.bind(B),B.strokeColor=K.defaultColor,B.strokeWidth=K.defaultStrokeWidth,B.strokeDasharray=K.defaultStrokeDasharray,B.strokePanel=new Xe("Line color",K.defaultColorSet,K.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new qe("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new Ve("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Se(s,W),s.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorCurve&&m!==this.visibleCurve&&!this.curveGrip.ownsTarget(m))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=de.createGroup(),this.selectorCurve=de.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=de.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,U){W.prototype.pointerDown.call(this,m,U),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=m.x,this.curveY=m.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(U)&&(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()),de.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),de.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),de.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=de.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=de.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,W.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var m=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-m/2,this.curveY-m/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},s.prototype.manipulate=function(m){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+m.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+m.y-this.manipulationStartY),W.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){this.activeGrip===this.curveGrip&&(this.curveX=m.x,this.curveY=m.y),W.prototype.resize.call(this,m),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual()},s.prototype.scale=function(m,U){this.curveX=this.curveX*m,this.curveY=this.curveY*U,W.prototype.scale.call(this,m,U)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var U=m;this.strokeColor=U.strokeColor,this.strokeWidth=U.strokeWidth,this.strokeDasharray=U.strokeDasharray,this.curveX=U.curveX,this.curveY=U.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='',s}(tt),At=function(){function W(s,m){m===void 0&&(m=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=m}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),Et=function(W){function s(m,U,K){var B=W.call(this,m,!1)||this;return B.dataUrl=U,B.state=K,B}return Se(s,W),s}(At),$e=function(W){function s(m,U,K){K===void 0&&(K=!1);var B=W.call(this,m,K)||this;return B.marker=U,B}return Se(s,W),s}(At),Rt=function(){function W(){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 W.prototype.addEventListener=function(s,m){this[s].push(m)},W.prototype.removeEventListener=function(s,m){var U=this[s].indexOf(m);U>-1&&this[s].splice(U,1)},W}(),yt=function(){function W(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 Ce,this._isOpen=!1,this.undoRedoManager=new ft,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new Rt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.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(W.prototype,"ALL_MARKER_TYPES",{get:function(){return[it,pe,ue,Ie,ze,ge,re,ye,_e,te,nt,lt]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[it,pe,ue,Ie,ge,re,ye]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[it,pe,ue,Ie,re]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var m=this;this._availableMarkerTypes.splice(0),s.forEach(function(U){if(typeof U=="string"){var K=m.ALL_MARKER_TYPES.find(function(B){return B.typeName===U});K!==void 0&&m._availableMarkerTypes.push(K)}else m._availableMarkerTypes.push(U)})},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.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(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),W.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),ke.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&Ge.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ge.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(m){return m(new At(s))})},W.prototype.render=function(){return we(this,void 0,void 0,function(){var s;return Te(this,function(m){switch(m.label){case 0:return this.setCurrentMarker(),(s=new Je).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return m.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,m.sent()]}})})},W.prototype.close=function(s){var m=this;if(s===void 0&&(s=!1),this.isOpen){var U=!1;s||this.eventListeners.beforeclose.forEach(function(K){var B=new At(m,!0);K(B),B.defaultPrevented&&(U=!0)}),U||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(K){return K(new At(m))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var s,m=[],U=0;Uthis.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,U=m',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()},W.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")},W.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"},W.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},W.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Me(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},W.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())},W.prototype.toolbarButtonClicked=function(s,m){if(s==="marker"&&m!==void 0)this.createNewMarker(m);else if(s==="action")switch(m){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},W.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var m=!1;if(this.eventListeners.markerbeforedelete.forEach(function(K){var B=new $e(s,s._currentMarker,!0);K(B),B.defaultPrevented&&(m=!0)}),!m){var U=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(K){return K(new $e(s,U))})}}},W.prototype.clear=function(){var s=this,m=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ce){var Oe=new $e(s,void 0,!0);ce(Oe),Oe.defaultPrevented&&(m=!0)}),!m)){this.setCurrentMarker();for(var U=function(ce){var Oe=K.markers[ce];K.setCurrentMarker(K.markers[ce]),K._currentMarker.dispose(),K.markerImage.removeChild(K._currentMarker.container),K.markers.splice(K.markers.indexOf(K._currentMarker),1),K.eventListeners.markerdelete.forEach(function(rt){return rt(new $e(s,Oe))})},K=this,B=this.markers.length-1;B>=0;B--)U(B);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.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))},W.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)},W.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},W.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var m=this.getState(),U=this.undoRedoManager.getLastUndoStep();if(!U||U.width===m.width&&U.height===m.height){var K=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(m),K1&&this.panTo({x:s.clientX,y:s.clientY}))},W.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()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(s,m){var U=this.markerImage.getBoundingClientRect();return{x:(s-U.left)/this.zoomLevel,y:(m-U.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.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()},W.prototype.addLicenseKey=function(s){ke.addKey(s)},W.prototype.addEventListener=function(s,m){this.eventListeners.addEventListener(s,m)},W.prototype.removeEventListener=function(s,m){this.eventListeners.removeEventListener(s,m)},W.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(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(m){return m(new At(s))}))},W.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(m){return m(new At(s))}))},W.instanceCounter=0,W}();/* ********************************** 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 Ot=function(W,s){return(Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,U){m.__proto__=U}||function(m,U){for(var K in U)Object.prototype.hasOwnProperty.call(U,K)&&(m[K]=U[K])})(W,s)};function Lt(W,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function m(){this.constructor=W}Ot(W,s),W.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Tt(W,s,m,U){return new(m||(m=Promise))(function(K,B){function ce(pt){try{rt(U.next(pt))}catch(Ue){B(Ue)}}function Oe(pt){try{rt(U.throw(pt))}catch(Ue){B(Ue)}}function rt(pt){var Ue;pt.done?K(pt.value):(Ue=pt.value,Ue instanceof m?Ue:new m(function(wt){wt(Ue)})).then(ce,Oe)}rt((U=U.apply(W,s||[])).next())})}function wr(W,s){var m,U,K,B,ce={label:0,sent:function(){if(1&K[0])throw K[1];return K[1]},trys:[],ops:[]};return B={next:Oe(0),throw:Oe(1),return:Oe(2)},typeof Symbol=="function"&&(B[Symbol.iterator]=function(){return this}),B;function Oe(rt){return function(pt){return function(Ue){if(m)throw new TypeError("Generator is already executing.");for(;ce;)try{if(m=1,U&&(K=2&Ue[0]?U.return:Ue[0]?U.throw||((K=U.return)&&K.call(U),0):U.next)&&!(K=K.call(U,Ue[1])).done)return K;switch(U=0,K&&(Ue=[2&Ue[0],K.value]),Ue[0]){case 0:case 1:K=Ue;break;case 4:return ce.label++,{value:Ue[1],done:!1};case 5:ce.label++,U=Ue[1],Ue=[0];continue;case 7:Ue=ce.ops.pop(),ce.trys.pop();continue;default:if(!(K=ce.trys,(K=K.length>0&&K[K.length-1])||Ue[0]!==6&&Ue[0]!==2)){ce=0;continue}if(Ue[0]===3&&(!K||Ue[1]>K[0]&&Ue[1]0&&m>0){var U=new Jt(s,m),K=U.ratio>=1?20:U.getHorizontalLength(20),B=U.ratio<1?20:U.getVerticalLength(20),ce=document.createElementNS("http://www.w3.org/2000/svg","svg");ce.setAttribute("xmlns","http://www.w3.org/2000/svg"),ce.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ce);var Oe=vt.createDefs();ce.appendChild(Oe);var rt=vt.createElement("clipPath",[["id","text-bg-clip"]]);Oe.appendChild(rt);var pt=vt.createPath(vt.getHollowRectanglePath((24-K)/2,(24-B)/2,K,B,(24-K)/2+2,(24-B)/2+2,K-4,B-4));ce.appendChild(pt);var Ue=vt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ue.appendChild(vt.createTSpan(s+":"+m)),ce.appendChild(Ue);var wt=Ue.getBBox();vt.setAttributes(Ue,[["x",((24-wt.width)/2).toString()],["y",((24-wt.height)/2-wt.y).toString()]]);var It=vt.createPath(vt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(wt.width))/2,(24-Math.ceil(wt.height))/2,Math.ceil(wt.width),Math.ceil(wt.height)));return rt.appendChild(It),vt.setAttributes(pt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ce),ce.outerHTML}return''},W}(),Ut=function(W){function s(m,U,K){var B=W.call(this,m,U)||this;return B.isDropdownOpen=!1,B.onClick=B.dropdownButtonClicked,B.dropdownButtons=K,B}return Lt(s,W),s.prototype.setupDropdown=function(){var m=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(U){U.className=m.className,U.colorsClassName=m.colorsClassName,m.dropdownBlock.appendChild(U.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(ct),kt=function(){function W(s,m){this.GRIP_SIZE=10,this.color=s,this.fillColor=m,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 W.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},W.prototype.setCenter=function(s,m){this.visual.childNodes.forEach(function(U){return vt.setAttributes(U,[["cx",s.toString()],["cy",m.toString()]])})},W}(),Gt=function(){function W(s,m,U,K){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=m,this.margin=U,this.container=K,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(W.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(W.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(W.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),W.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 m=0;mthis.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-m.height/2),vt.setAttributes(this.cropRectElement,[["x",m.x.toString()],["y",m.y.toString()],["width",m.width.toString()],["height",m.height.toString()]]);var U=m.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(B,ce){var Oe=m.y+U*(ce+1);vt.setAttributes(B,[["x1",""+m.x],["y1",""+Oe],["x2",""+(m.x+m.width)],["y2",""+Oe]])});var K=m.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(B,ce){var Oe=m.x+K*(ce+1);vt.setAttributes(B,[["x1",""+Oe],["y1",""+m.y],["x2",""+Oe],["y2",""+(m.y+m.height)]])}),vt.setAttributes(this.cropShadeElement,[["d",vt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,m.x,m.y,m.width,m.height)]]),this.topLeftGrip.setCenter(m.x,m.y),this.topRightGrip.setCenter(m.x+m.width,m.y),this.bottomLeftGrip.setCenter(m.x,m.y+m.height),this.bottomRightGrip.setCenter(m.x+m.width,m.y+m.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},W.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)},W.prototype.clientToLocalCoordinates=function(s,m){var U=this.container.getBoundingClientRect();return{x:s-U.left+this.margin,y:m-U.top+this.margin}},W.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)},W.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var m=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(m)}s.preventDefault()},W.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},W.prototype.move=function(s){var m=s.x-this.previousPoint.x,U=s.y-this.previousPoint.y;this.zoomFactor!==1&&(m=-m/this.zoomFactor,U=-U/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+m),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+U),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},W.prototype.resize=function(s){var m=Object.assign({},this.cropRect),U=s.x-this.previousPoint.x,K=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:m.x+Uthis.canvasWidth*this.zoomFactor&&(U=this.canvasWidth*this.zoomFactor-m.width),m.width+=U}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(m.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(U),m.height=this.aspectRatio.getVerticalLength(m.width)):(m.y+=K,m.height=this.cropRect.y+this.cropRect.height-m.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?m.height=this.aspectRatio.getVerticalLength(m.width):m.height+=K}m.width<10&&(m.x=this.cropRect.x,m.width=10),m.height<10&&(m.y=this.cropRect.y,m.height=10),this.previousPoint=s,m.x>=this.margin&&m.y>=this.margin&&m.x-this.margin+m.width<=this.canvasWidth&&m.y-this.margin+m.height<=this.canvasHeight&&(this.cropRect=m,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},W.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,m=this.cropRect.y+this.cropRect.height/2,U=this.aspectRatio.getHorizontalLength(this.cropRect.height),K=this.aspectRatio.getVerticalLength(this.cropRect.width);U/this.canvasWidththis.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=m-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},W.prototype.getRescaledRect=function(s,m,U,K,B,ce){var Oe=U/s,rt=K/m;return{x:(B.x-ce)*Oe+ce,y:(B.y-ce)*rt+ce,width:B.width*Oe,height:B.height*rt}},W.prototype.scaleCanvas=function(s,m){var U=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,m,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=m,this.onCropChange&&this.onCropChange(U),this.setCropRectangle(U)},W}(),Sr=function(){function W(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(W.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),W.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},W.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},W.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},W.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},W.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()]])}},W.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)}},W.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var m="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,U=1;U<=this.width/5+10;U++){var K=U%5==0?this.height/3:this.height/6;m+="h4v"+-K+"h1v"+K}m+="v1H0Z",this.scaleShape=vt.createPath(m);var B=vt.createTransform();this.scaleShape.transform.baseVal.appendItem(B),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 ce=vt.createTSpan("");return ce.innerHTML="°",this.angleLabelElement.appendChild(ce),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},W}(),ui=function(){function W(){this.naturalSize=!1,this.imageType="image/png"}return W.prototype.rasterize=function(s,m,U,K,B,ce,Oe){var rt=this;return new Promise(function(pt){var Ue=document.createElement("canvas");Ue.width=s.width.baseVal.value-2*K,Ue.height=s.height.baseVal.value-2*K;var wt=1,It=1;rt.naturalSize===!0?(wt=m.naturalWidth/(s.width.baseVal.value-2*K)/ce,It=m.naturalHeight/(s.height.baseVal.value-2*K)/Oe,Ue.width=m.naturalWidth/ce,Ue.height=m.naturalHeight/Oe):rt.width!==void 0&&rt.height!==void 0&&(wt=rt.width/U.width,It=rt.height/U.height,Ue.width*=wt,Ue.height*=It);var $t=Ue.getContext("2d");$t.translate(Ue.width/2,Ue.height/2),$t.rotate(B*Math.PI/180),$t.scale(ce,Oe),$t.translate(-Ue.width/2,-Ue.height/2),$t.drawImage(m,0,0,Ue.width,Ue.height);var Wr=document.createElement("canvas");Wr.width=U.width*wt,Wr.height=U.height*It,Wr.getContext("2d").putImageData($t.getImageData((U.x-K)*wt,(U.y-K)*It,U.width*wt,U.height*It),0,0),pt(Wr.toDataURL(rt.imageType,rt.imageQuality))})},W}(),He=function(){function W(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=W.instanceCounter++,this.styles=new rr(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(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(W.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(W.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(W.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(W.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.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}),W.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},W.prototype.show=function(){this.showUI(),this.open()},W.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(m){return m()}),this._isOpen=!1)},W.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},W.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},W.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},W.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},W.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))},W.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,m=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,U=m+2*this.CANVAS_MARGINs+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=m+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},W.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},W.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Nr,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var m=new Jr;m.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(m);var U=[];this.aspectRatios.forEach(function(It){var $t=new ct(jt.getIcon(It.horizontal,It.vertical),It.horizontal===0&&It.vertical===0?"FREE":It.horizontal+":"+It.vertical);$t.onClick=function(){return s.ratioButtonClicked(It)},U.push($t)}),this.aspectRatioButton=new Ut(jt.getIcon(0,0),"Aspect ratio",U),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,m.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var K=new ct('',"Toggle grid");K.isActive=this.isGridVisible,K.onClick=function(){s.isGridVisible=!s.isGridVisible,K.isActive=s.isGridVisible},m.addButton(K);var B=new ct('',"Zoom to selection");if(B.isActive=this.zoomToCropEnabled,B.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,B.isActive=s.zoomToCropEnabled},m.addButton(B),!fr.isLicensed){var ce=new st;this.topToolbar.addElementBlock(ce);var Oe=document.createElement("div");Oe.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var rt=document.createElement("a");rt.style.color="currentColor",rt.href="https://markerjs.com/products/cropro",rt.target="_blank",rt.innerHTML='',Oe.appendChild(rt),ce.addElement(Oe)}var pt=new Jr;pt.minWidth=3*this.toolbarHeight+"px",pt.contentAlign="end",this.topToolbar.addButtonBlock(pt);var Ue=new ct('',"OK");Ue.onClick=this.startRenderAndClose,pt.addButton(Ue),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ue.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var wt=new ct('',"Close");wt.onClick=this.close,pt.addButton(wt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(wt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},W.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Nr,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var m=new Jr;m.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(m);var U=new ct('',"Rotate left");U.onClick=this.rotateLeftButtonClicked,m.addButton(U);var K=new ct('',"Rotate right");K.onClick=this.rotateRightButtonClicked,m.addButton(K);var B=new st;B.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(B),this.straightener=new Sr("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(pt){s.rotateBy(pt),s.straightener.angle=s.rotationAngle},B.addElement(this.straightener.getUI());var ce=new Jr;ce.minWidth=2*this.toolbarHeight+"px",ce.contentAlign="end",this.bottomToolbar.addButtonBlock(ce);var Oe=new ct('',"Flip horizontal");Oe.onClick=this.flipHorizontallyButtonClicked,ce.addButton(Oe);var rt=new ct('',"Flip vertical");rt.onClick=this.flipVerticallyButtonClicked,ce.addButton(rt)},W.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},W.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=jt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},W.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Jt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},W.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},W.prototype.restoreState=function(s){if(s){var m=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(m),this.cropRectChanged(m),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},W.prototype.clientToLocalCoordinates=function(s,m){var U=this.cropImage.getBoundingClientRect();return{x:s-U.left,y:m-U.top}},W.prototype.onWindowResize=function(){this.positionUI()},W.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()},W.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)},W.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)},W.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},W.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},W.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var m=this.editingTargetRotationContainer.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(m,0);var U=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/U.width,this.imageHeight/U.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},W.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},W.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},W.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},W.prototype.startRenderAndClose=function(){return Tt(this,void 0,void 0,function(){var s,m;return wr(this,function(U){switch(U.label){case 0:return[4,this.render()];case 1:return s=U.sent(),m=this.getState(),this.renderEventListeners.forEach(function(K){return K(s,m)}),this.close(!0),[2]}})})},W.prototype.render=function(){return Tt(this,void 0,void 0,function(){var s;return wr(this,function(m){switch(m.label){case 0:return(s=new ui).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 m.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,m.sent()]}})})},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new or("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 or("toolbar_colors",` background-color: `+this.styles.settings.toolbarBackgroundColor+`; `)),this.toolbarBlockStyleClass=this.styles.addClass(new or("toolbar-block",` display: flex; align-items: center; box-sizing: content-box; `));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new or("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 or("toolbar_button_colors",` color: `+this.styles.settings.toolbarColor+`; fill: currentColor; `)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new or("toolbar_active_button",` color: `+this.styles.settings.toolbarColor+`; fill: currentColor; background-color: `+this.styles.settings.toolbarBackgroundActiveColor+` `)),this.styles.addRule(new ir("."+this.toolbarButtonStyleClass.name+" svg",` height: `+this.toolbarHeight/2+`px; `)),this.styles.addRule(new ir("."+this.toolbarButtonStyleColorsClass.name+":hover",` background-color: `+this.styles.settings.toolbarBackgroundHoverColor+` `)),this.toolbarDropdownStyleClass=this.styles.addClass(new or("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 or("toolbar_dropdown_colors",` background-color: `+this.styles.settings.toolbarBackgroundColor+`; `)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new or("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 or("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 or("toolbar_straightener_colors",` color: `+this.styles.settings.toolbarColor+`; fill: currentColor; `))},W.instanceCounter=0,W}(),_t=ie("8hTe"),di=ie.n(_t),Ai=/]*>/g;function hi(W){var s=document.createElement("div");return s.innerHTML=W,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var _i=dt.a=function(W){var s=W.value,m=s===void 0?"":s,U=W.edit,K=U===void 0?!1:U,B=W.className,ce=W.showTextOnly,Oe=W.showLines,rt=W.replaces,pt=W.zoomImg,Ue=W.hasMask,wt=W.style,It=wt===void 0?{}:wt,$t=W.stylesPrev,Wr=$t===void 0?{}:$t,Hr=String(m),hr=Object(O.useRef)(),Yr=Object(O.useRef)(),Hi=Object(O.useState)(""),_r=Object(H.a)(Hi,2),Gr=_r[0],Ur=_r[1],gi=Object(O.useState)("office"),Qr=Object(H.a)(gi,2),ci=Qr[0],ni=Qr[1],hn=function(){var Wt=new He(Yr.current);Wt.displayMode="popup",Wt.addRenderEventListener(function(){var br=Object(D.a)(M.a.mark(function Ft(sr){var Kt;return M.a.wrap(function(nr){for(;;)switch(nr.prev=nr.next){case 0:return hr.current.style.display="none",nr.next=3,Object(Re.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:sr}});case 3:Kt=nr.sent,Kt!=null&&Kt.id&&rt(Yr.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(Kt==null?void 0:Kt.id,"?type=").concat(Kt.content_type));case 5:case"end":return nr.stop()}},Ft)}));return function(Ft){return br.apply(this,arguments)}}()),Wt.show()},Gi=function(){var Wt=new yt(Yr.current);Wt.settings.displayMode="popup",Wt.addEventListener("render",function(){var br=Object(D.a)(M.a.mark(function Ft(sr){var Kt;return M.a.wrap(function(nr){for(;;)switch(nr.prev=nr.next){case 0:if(hr.current.style.display="none",!Yr.current){nr.next=6;break}return nr.next=4,Object(Re.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:sr.dataUrl}});case 4:Kt=nr.sent,Kt!=null&&Kt.id&&rt(Yr.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(Kt==null?void 0:Kt.id,"?type=").concat(Kt.content_type));case 6:case"end":return nr.stop()}},Ft)}));return function(Ft){return br.apply(this,arguments)}}()),Wt.show(),window.markerArea=Wt},qr=Object(O.useMemo)(function(){try{var er=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Wt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,br=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Hr=Hr.replace(er,"("+oe.a.API_SERVER+"/api/attachments/").replace(Wt,'"'+oe.a.API_SERVER+"/api/attachments/").replace(br,'"'+oe.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,` `),Hr=Hr.replace(new RegExp("(?[TOC]

    ",_()),L()),Ft=Ft.replace(/(__special_katext_id_\d+__)/g,function(ai,nr){var Dr=sr[nr],zi=Dr.type,Ki=Dr.expression;return Object(fe.renderToString)(hi(Ki)||"",{displayMode:zi==="block",throwOnError:!1,output:"html"})}),Ft=Ft.replace(/▁/g,"\u2581\u2581\u2581"),y(),ce){var Kt=document.createElement("div");return Kt.innerHTML=Ft,Kt.innerText}return setTimeout(function(){return Ri()},500),Ft},[Hr]),zr=Object(O.useRef)();f.WebkitLineClamp=Oe,Oe&&(It=Object(I.a)(Object(I.a)({},It),f));function Di(er){var Wt=er.target;if(Wt.tagName.toUpperCase()==="IMG"){if(pt){var br=Wt.getAttribute("src");Ur(br),ni("image")}}else if(Wt.tagName.toUpperCase()==="A"){var Ft=Wt.getAttribute("href");if(Ft.indexOf("office")>-1)er.preventDefault(),Ur(Ft),ni("office");else if(Ft.indexOf("application/pdf")>-1)er.preventDefault(),Ur(Ft),ni("pdf");else if(Ft.indexOf("type=text")>-1)er.preventDefault(),Ur(Ft),ni("html");else if(Ft.startsWith("#")){er.preventDefault();var sr=document.getElementById(Ft.replace("#",""));sr&&sr.scrollIntoView(!0)}}}var Ri=function(){var Wt,br=(Wt=zr.current)===null||Wt===void 0?void 0:Wt.querySelectorAll("video");br==null||br.forEach(function(Ft){if(Ft.oncontextmenu=function(){return!1},Ft.src.indexOf(".m3u8")>-1&&!Ft.canPlayType("application/vnd.apple.mpegurl")){if(ee.a.isSupported()){var sr=new ee.a;sr.loadSource(Ft.src),sr.attachMedia(Ft)}}})};Object(O.useEffect)(function(){if(zr.current&&qr&&(qr.match(Ai)&&window.PR.prettyPrint()),zr.current)return zr.current.addEventListener("click",Di),function(){zr.current.removeEventListener("click",Di),y(),L()}},[qr,zr.current,Di]);var cn=function(Wt){if(!K)return;Wt.target.nodeName==="IMG"?(hr.current.style.display="flex",hr.current.style.width=Wt.target.clientWidth+"px",hr.current.style.height=Wt.target.clientHeight+"px",hr.current.style.top=Wt.target.offsetTop+"px",hr.current.style.left=Wt.target.offsetLeft+"px",Yr.current.src=Wt.target.getAttribute("src")):hr.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:zr,style:Object(I.a)({},It),className:"".concat(B||""," markdown-body ").concat(di.a.mdBody),onMouseOver:cn,dangerouslySetInnerHTML:{__html:qr}}),v.a.createElement("div",{ref:hr,className:di.a.button},v.a.createElement(Z.a,null,v.a.createElement(X.a,{onClick:function(){return hn()}},"\u88C1\u526A"),v.a.createElement(X.a,{onClick:function(){return Gi()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Yr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.a.createElement(ve.a,{close:!0,data:Gr,hasMask:Ue,type:Gr!=null&&Gr.length?ci:"",style:Object(I.a)({},Wr),onClose:function(){return Ur("")}}))}},"9VGf":function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return R});var ae=ie("q1tI"),Z=ie.n(ae);function R(X,I){var D=Object(ae.useRef)();Object(ae.useEffect)(function(){D.current=X}),Object(ae.useEffect)(function(){function H(){D.current()}if(I!==null){var F=setInterval(H,I);return function(){return clearInterval(F)}}},[I])}},BU3w:function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return D});var ae=ie("MNnm"),Z="rc-util-key";function R(H){if(H.attachTo)return H.attachTo;var F=document.querySelector("head");return F||document.body}function X(H){var F,M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(ae.a)())return null;var O=document.createElement("style");if((F=M.csp)===null||F===void 0?void 0:F.nonce){var v;O.nonce=(v=M.csp)===null||v===void 0?void 0:v.nonce}O.innerHTML=H;var C=R(M),k=C.firstChild;return M.prepend&&C.prepend?C.prepend(O):M.prepend&&k?C.insertBefore(O,k):C.appendChild(O),O}var I=new Map;function D(H,F){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},O=R(M);if(!I.has(O)){var v=X("",M),C=v.parentNode;I.set(O,C),C.removeChild(v)}var k=Array.from(I.get(O).children).find(function(o){return o.tagName==="STYLE"&&o[Z]===F});if(k){var A,E;if(((A=M.csp)===null||A===void 0?void 0:A.nonce)&&k.nonce!==((E=M.csp)===null||E===void 0?void 0:E.nonce)){var w;k.nonce=(w=M.csp)===null||w===void 0?void 0:w.nonce}return k.innerHTML!==H&&(k.innerHTML=H),k}var d=X(H,M);return d[Z]=F,d}},Bd2K:function(Ct,dt,ie){(function(ae){ae(ie("VrN/"),ie("osHv"))})(function(ae){ae.defineOption("autoCloseTags",!1,function(M,O,v){if(v!=ae.Init&&v&&M.removeKeyMap("autoCloseTags"),!O)return;var C={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(C["'/'"]=function(k){return D(k)}),(typeof O!="object"||O.whenOpening!==!1)&&(C["'>'"]=function(k){return X(k)}),M.addKeyMap(C)});var Z=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],R=["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 X(M){if(M.getOption("disableInput"))return ae.Pass;for(var O=M.listSelections(),v=[],C=M.getOption("autoCloseTags"),k=0;kA.ch&&(l=l.slice(0,l.length-E.end+A.ch));var p=l.toLowerCase();if(!l||E.type=="string"&&(E.end!=A.ch||!/[\"\']/.test(E.string.charAt(E.string.length-1))||E.string.length==1)||E.type=="tag"&&o.close||E.string.indexOf("/")==A.ch-E.start-1||L&&H(L,p)>-1||F(M,w.mode.xmlCurrentContext&&w.mode.xmlCurrentContext(d)||[],l,A,!0))return ae.Pass;var _=typeof C=="object"&&C.emptyTags;if(_&&H(_,l)>-1){v[k]={text:"/>",newPos:ae.Pos(A.line,A.ch+2)};continue}var b=f&&H(f,p)>-1;v[k]={indent:b,text:">"+(b?` `:"")+"",newPos:b?ae.Pos(A.line+1,0):ae.Pos(A.line,A.ch+1)}}for(var g=typeof C=="object"&&C.dontIndentOnAutoClose,k=O.length-1;k>=0;k--){var c=v[k];M.replaceRange(c.text,O[k].head,O[k].anchor,"+insert");var u=M.listSelections().slice(0);u[k]={head:c.newPos,anchor:c.newPos},M.setSelections(u),!g&&c.indent&&(M.indentLine(c.newPos.line,null,!0),M.indentLine(c.newPos.line+1,null,!0))}}function I(M,O){for(var v=M.listSelections(),C=[],k=O?"/":""&&(L+=">"),C[w]=L}if(M.replaceSelections(C),v=M.listSelections(),!E)for(var w=0;w=0&&O[d]==v;d--)++w;C=E.to;for(var d=1;d0){for(var O=0;O1&&arguments[1]!==void 0?arguments[1]:"",O=[],v=0;vpe.length)&&(le=pe.length);for(var ue=0,te=new Array(le);ue=pe.length?{done:!0}:{done:!1,value:pe[te++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return ue=pe[Symbol.iterator](),ue.next.bind(ue)}function D(pe,le){return le={exports:{}},pe(le,le.exports),le.exports}var H=D(function(pe){function le(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function ue(te){pe.exports.defaults=te}pe.exports={defaults:le(),getDefaults:le,changeDefaults:ue}}),F=H.defaults,M=H.getDefaults,O=H.changeDefaults,v=/[&<>"']/,C=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,A=/[<>"']|&(?!#?\w+;)/g,E={"&":"&","<":"<",">":">",'"':""","'":"'"},w=function(le){return E[le]};function d(pe,le){if(le){if(v.test(pe))return pe.replace(C,w)}else if(k.test(pe))return pe.replace(A,w);return pe}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(pe){return pe.replace(o,function(le,ue){return ue=ue.toLowerCase(),ue==="colon"?":":ue.charAt(0)==="#"?ue.charAt(1)==="x"?String.fromCharCode(parseInt(ue.substring(2),16)):String.fromCharCode(+ue.substring(1)):""})}var h=/(^|[^\[])\^/g;function L(pe,le){pe=pe.source||pe,le=le||"";var ue={replace:function(q,re){return re=re.source||re,re=re.replace(h,"$1"),pe=pe.replace(q,re),ue},getRegex:function(){return new RegExp(pe,le)}};return ue}var f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function _(pe,le,ue){if(pe){var te;try{te=decodeURIComponent(l(ue)).replace(f,"").toLowerCase()}catch(q){return null}if(te.indexOf("javascript:")===0||te.indexOf("vbscript:")===0||te.indexOf("data:")===0)return null}le&&!p.test(ue)&&(ue=a(le,ue));try{ue=encodeURI(ue).replace(/%25/g,"%")}catch(q){return null}return ue}var b={},g=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(pe,le){b[" "+pe]||(g.test(pe)?b[" "+pe]=pe+"/":b[" "+pe]=P(pe,"/",!0)),pe=b[" "+pe];var ue=pe.indexOf(":")===-1;return le.substring(0,2)==="//"?ue?le:pe.replace(c,"$1")+le:le.charAt(0)==="/"?ue?le:pe.replace(u,"$1")+le:pe+le}var x={exec:function(){}};function y(pe){for(var le=1,ue,te;le=0&&ye[_e]==="\\";)ge=!ge;return ge?"|":" |"}),te=ue.split(/ \|/),q=0;if(te.length>le)te.splice(le);else for(;te.length=te.length?q.slice(te.length):q}).join(` `)}var Ee=function(){function pe(ue){this.options=ue||z}var le=pe.prototype;return le.space=function(te){var q=this.rules.block.newline.exec(te);if(q)return q[0].length>1?{type:"space",raw:q[0]}:{raw:` `}},le.code=function(te,q){var re=this.rules.block.code.exec(te);if(re){var ne=q[q.length-1];if(ne&&ne.type==="paragraph")return{raw:re[0],text:re[0].trimRight()};var ye=re[0].replace(/^ {4}/gm,"");return{type:"code",raw:re[0],codeBlockStyle:"indented",text:this.options.pedantic?ye:j(ye,` `)}}},le.fences=function(te){var q=this.rules.block.fences.exec(te);if(q){var re=q[0],ne=Re(re,q[3]||"");return{type:"code",raw:re,lang:q[2]?q[2].trim():q[2],text:ne}}},le.heading=function(te){var q=this.rules.block.heading.exec(te);if(q)return{type:"heading",raw:q[0],depth:q[1].length,text:q[2]}},le.nptable=function(te){var q=this.rules.block.nptable.exec(te);if(q){var re={type:"table",header:ee(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(` `):[],raw:q[0]};if(re.header.length===re.align.length){var ne=re.align.length,ye;for(ye=0;ye ?/gm,"");return{type:"blockquote",raw:q[0],text:re}}},le.list=function(te){var q=this.rules.block.list.exec(te);if(q){for(var re=q[0],ne=q[2],ye=ne.length>1,ge=ne[ne.length-1]===")",_e={type:"list",raw:re,ordered:ye,start:ye?+ne.slice(0,-1):"",loose:!1,items:[]},ze=q[0].match(this.rules.block.item),ft=!1,lt,At,Et,$e,Rt,yt,Ot,Lt=ze.length,Tt=0;Tt1||this.options.smartLists&&Et!==ne)&&($e=ze.slice(Tt+1).join(` `),_e.raw=_e.raw.substring(0,_e.raw.length-$e.length),Tt=Lt-1)),Rt=ft||/\n\n(?!\s*$)/.test(lt),Tt!==Lt-1&&(ft=lt.charAt(lt.length-1)===` `,Rt||(Rt=ft)),Rt&&(_e.loose=!0),yt=/^\[[ xX]\] /.test(lt),Ot=void 0,yt&&(Ot=lt[1]!==" ",lt=lt.replace(/^\[[ xX]\] +/,"")),_e.items.push({type:"list_item",raw:re,task:yt,checked:Ot,loose:Rt,text:lt});return _e}},le.html=function(te){var q=this.rules.block.html.exec(te);if(q)return{type:this.options.sanitize?"paragraph":"html",raw:q[0],pre:!this.options.sanitizer&&(q[1]==="pre"||q[1]==="script"||q[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):oe(q[0]):q[0]}},le.def=function(te){var q=this.rules.block.def.exec(te);if(q){q[3]&&(q[3]=q[3].substring(1,q[3].length-1));var re=q[1].toLowerCase().replace(/\s+/g," ");return{tag:re,raw:q[0],href:q[2],title:q[3]}}},le.table=function(te){var q=this.rules.block.table.exec(te);if(q){var re={type:"table",header:ee(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(` `):[]};if(re.header.length===re.align.length){re.raw=q[0];var ne=re.align.length,ye;for(ye=0;ye/i.test(ne[0])&&(q=!1),!re&&/^<(pre|code|kbd|script)(\s|>)/i.test(ne[0])?re=!0:re&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ne[0])&&(re=!1),{type:this.options.sanitize?"text":"html",raw:ne[0],inLink:q,inRawBlock:re,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):oe(ne[0]):ne[0]}},le.link=function(te){var q=this.rules.inline.link.exec(te);if(q){var re=fe(q[2],"()");if(re>-1){var ne=q[0].indexOf("!")===0?5:4,ye=ne+q[1].length+re;q[2]=q[2].substring(0,re),q[0]=q[0].substring(0,ye).trim(),q[3]=""}var ge=q[2],_e="";if(this.options.pedantic){var ze=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ge);ze?(ge=ze[1],_e=ze[3]):_e=""}else _e=q[3]?q[3].slice(1,-1):"";ge=ge.trim().replace(/^<([\s\S]*)>$/,"$1");var ft=ve(q,{href:ge&&ge.replace(this.rules.inline._escapes,"$1"),title:_e&&_e.replace(this.rules.inline._escapes,"$1")},q[0]);return ft}},le.reflink=function(te,q){var re;if((re=this.rules.inline.reflink.exec(te))||(re=this.rules.inline.nolink.exec(te))){var ne=(re[2]||re[1]).replace(/\s+/g," ");if(ne=q[ne.toLowerCase()],!ne||!ne.href){var ye=re[0].charAt(0);return{type:"text",raw:ye,text:ye}}var ge=ve(re,ne,re[0]);return ge}},le.strong=function(te,q,re){re===void 0&&(re="");var ne=this.rules.inline.strong.start.exec(te);if(ne&&(!ne[1]||ne[1]&&(re===""||this.rules.inline.punctuation.exec(re)))){q=q.slice(-1*te.length);var ye=ne[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ye.lastIndex=0;for(var ge;(ne=ye.exec(q))!=null;)if(ge=this.rules.inline.strong.middle.exec(q.slice(0,ne.index+3)),ge)return{type:"strong",raw:te.slice(0,ge[0].length),text:te.slice(2,ge[0].length-2)}}},le.em=function(te,q,re){re===void 0&&(re="");var ne=this.rules.inline.em.start.exec(te);if(ne&&(!ne[1]||ne[1]&&(re===""||this.rules.inline.punctuation.exec(re)))){q=q.slice(-1*te.length);var ye=ne[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ye.lastIndex=0;for(var ge;(ne=ye.exec(q))!=null;)if(ge=this.rules.inline.em.middle.exec(q.slice(0,ne.index+2)),ge)return{type:"em",raw:te.slice(0,ge[0].length),text:te.slice(1,ge[0].length-1)}}},le.codespan=function(te){var q=this.rules.inline.code.exec(te);if(q){var re=q[2].replace(/\n/g," "),ne=/[^ ]/.test(re),ye=re.startsWith(" ")&&re.endsWith(" ");return ne&&ye&&(re=re.substring(1,re.length-1)),re=oe(re,!0),{type:"codespan",raw:q[0],text:re}}},le.br=function(te){var q=this.rules.inline.br.exec(te);if(q)return{type:"br",raw:q[0]}},le.del=function(te){var q=this.rules.inline.del.exec(te);if(q)return{type:"del",raw:q[0],text:q[1]}},le.autolink=function(te,q){var re=this.rules.inline.autolink.exec(te);if(re){var ne,ye;return re[2]==="@"?(ne=oe(this.options.mangle?q(re[1]):re[1]),ye="mailto:"+ne):(ne=oe(re[1]),ye=ne),{type:"link",raw:re[0],text:ne,href:ye,tokens:[{type:"text",raw:ne,text:ne}]}}},le.url=function(te,q){var re;if(re=this.rules.inline.url.exec(te)){var ne,ye;if(re[2]==="@")ne=oe(this.options.mangle?q(re[0]):re[0]),ye="mailto:"+ne;else{var ge;do ge=re[0],re[0]=this.rules.inline._backpedal.exec(re[0])[0];while(ge!==re[0]);ne=oe(re[0]),re[1]==="www."?ye="http://"+ne:ye=ne}return{type:"link",raw:re[0],text:ne,href:ye,tokens:[{type:"text",raw:ne,text:ne}]}}},le.inlineText=function(te,q,re){var ne=this.rules.inline.text.exec(te);if(ne){var ye;return q?ye=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):oe(ne[0]):ne[0]:ye=oe(this.options.smartypants?re(ne[0]):ne[0]),{type:"text",raw:ne[0],text:ye}}},pe}(),Se=Q.noopTest,we=Q.edit,Te=Q.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]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|\\n*|\\n*|)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Se,table:Se,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=we(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=we(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=we(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=//,me.html=we(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=we(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",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.blockquote=we(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Te({},me),me.gfm=Te({},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=we(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",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.gfm.table=we(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",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.pedantic=Te({},me.normal,{html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\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:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Se,paragraph:we(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 de={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Se,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\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:Se,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~",de.punctuation=we(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",de._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",de.em.start=we(de.em.start).replace(/punctuation/g,de._punctuation).getRegex(),de.em.middle=we(de.em.middle).replace(/punctuation/g,de._punctuation).replace(/overlapSkip/g,de._overlapSkip).getRegex(),de.em.endAst=we(de.em.endAst,"g").replace(/punctuation/g,de._punctuation).getRegex(),de.em.endUnd=we(de.em.endUnd,"g").replace(/punctuation/g,de._punctuation).getRegex(),de.strong.start=we(de.strong.start).replace(/punctuation/g,de._punctuation).getRegex(),de.strong.middle=we(de.strong.middle).replace(/punctuation/g,de._punctuation).replace(/blockSkip/g,de._blockSkip).getRegex(),de.strong.endAst=we(de.strong.endAst,"g").replace(/punctuation/g,de._punctuation).getRegex(),de.strong.endUnd=we(de.strong.endUnd,"g").replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=we(de._blockSkip,"g").getRegex(),de.overlapSkip=we(de._overlapSkip,"g").getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._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])?)+(?![-_])/,de.autolink=we(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=we(de.tag).replace("comment",me._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=we(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=we(de.reflink).replace("label",de._label).getRegex(),de.reflinkSearch=we(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal=Te({},de),de.pedantic=Te({},de.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:we(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()}),de.gfm=Te({},de.normal,{escape:we(de.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]*?(?:(?=[\\.5&&(te="x"+te.toString(16)),le+="&#"+te+";";return le}var Me=function(){function pe(ue){this.tokens=[],this.tokens.links=Object.create(null),this.options=ue||Je,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var te={block:Ge.normal,inline:Qe.normal};this.options.pedantic?(te.block=Ge.pedantic,te.inline=Qe.pedantic):this.options.gfm&&(te.block=Ge.gfm,this.options.breaks?te.inline=Qe.breaks:te.inline=Qe.gfm),this.tokenizer.rules=te}pe.lex=function(te,q){var re=new pe(q);return re.lex(te)};var le=pe.prototype;return le.lex=function(te){return te=te.replace(/\r\n|\r/g,` `).replace(/\t/g," "),this.blockTokens(te,this.tokens,!0),this.inline(this.tokens),this.tokens},le.blockTokens=function(te,q,re){q===void 0&&(q=[]),re===void 0&&(re=!0),te=te.replace(/^ +$/gm,"");for(var ne,ye,ge,_e;te;){if(ne=this.tokenizer.space(te)){te=te.substring(ne.raw.length),ne.type&&q.push(ne);continue}if(ne=this.tokenizer.code(te,q)){te=te.substring(ne.raw.length),ne.type?q.push(ne):(_e=q[q.length-1],_e.raw+=` `+ne.raw,_e.text+=` `+ne.text);continue}if(ne=this.tokenizer.fences(te)){te=te.substring(ne.raw.length),q.push(ne);continue}if(ne=this.tokenizer.heading(te)){te=te.substring(ne.raw.length),q.push(ne);continue}if(ne=this.tokenizer.nptable(te)){te=te.substring(ne.raw.length),q.push(ne);continue}if(ne=this.tokenizer.hr(te)){te=te.substring(ne.raw.length),q.push(ne);continue}if(ne=this.tokenizer.blockquote(te)){te=te.substring(ne.raw.length),ne.tokens=this.blockTokens(ne.text,[],re),q.push(ne);continue}if(ne=this.tokenizer.list(te)){for(te=te.substring(ne.raw.length),ge=ne.items.length,ye=0;ye0)for(;(ze=this.tokenizer.rules.inline.reflinkSearch.exec(_e))!=null;)ft.includes(ze[0].slice(ze[0].lastIndexOf("[")+1,-1))&&(_e=_e.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(ze=this.tokenizer.rules.inline.blockSkip.exec(_e))!=null;)_e=_e.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;te;){if(ge=this.tokenizer.escape(te)){te=te.substring(ge.raw.length),q.push(ge);continue}if(ge=this.tokenizer.tag(te,re,ne)){te=te.substring(ge.raw.length),re=ge.inLink,ne=ge.inRawBlock,q.push(ge);continue}if(ge=this.tokenizer.link(te)){te=te.substring(ge.raw.length),ge.type==="link"&&(ge.tokens=this.inlineTokens(ge.text,[],!0,ne)),q.push(ge);continue}if(ge=this.tokenizer.reflink(te,this.tokens.links)){te=te.substring(ge.raw.length),ge.type==="link"&&(ge.tokens=this.inlineTokens(ge.text,[],!0,ne)),q.push(ge);continue}if(ge=this.tokenizer.strong(te,_e,ye)){te=te.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],re,ne),q.push(ge);continue}if(ge=this.tokenizer.em(te,_e,ye)){te=te.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],re,ne),q.push(ge);continue}if(ge=this.tokenizer.codespan(te)){te=te.substring(ge.raw.length),q.push(ge);continue}if(ge=this.tokenizer.br(te)){te=te.substring(ge.raw.length),q.push(ge);continue}if(ge=this.tokenizer.del(te)){te=te.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],re,ne),q.push(ge);continue}if(ge=this.tokenizer.autolink(te,Ae)){te=te.substring(ge.raw.length),q.push(ge);continue}if(!re&&(ge=this.tokenizer.url(te,Ae))){te=te.substring(ge.raw.length),q.push(ge);continue}if(ge=this.tokenizer.inlineText(te,ne,Ye)){te=te.substring(ge.raw.length),ye=ge.raw.slice(-1),q.push(ge);continue}if(te){var lt="Infinite loop on byte: "+te.charCodeAt(0);if(this.options.silent){console.error(lt);break}else throw new Error(lt)}}return q},Z(pe,null,[{key:"rules",get:function(){return{block:Ge,inline:Qe}}}]),pe}(),je=H.defaults,et=Q.cleanUrl,Xe=Q.escape,Ne=function(){function pe(ue){this.options=ue||je}var le=pe.prototype;return le.code=function(te,q,re){var ne=(q||"").match(/\S*/)[0];if(this.options.highlight){var ye=this.options.highlight(te,ne);ye!=null&&ye!==te&&(re=!0,te=ye)}return ne?'
    '+(re?te:Xe(te,!0))+`
    `:"
    "+(re?te:Xe(te,!0))+`
    `},le.blockquote=function(te){return`
    `+te+`
    `},le.html=function(te){return te},le.heading=function(te,q,re,ne){return this.options.headerIds?"'+te+" `:""+te+" `},le.hr=function(){return this.options.xhtml?`
    `:`
    `},le.list=function(te,q,re){var ne=q?"ol":"ul",ye=q&&re!==1?' start="'+re+'"':"";return"<"+ne+ye+`> `+te+" `},le.listitem=function(te){return"
  • "+te+`
  • `},le.checkbox=function(te){return" "},le.paragraph=function(te){return"

    "+te+`

    `},le.table=function(te,q){return q&&(q=""+q+""),` `+te+` `+q+`
    `},le.tablerow=function(te){return` `+te+` `},le.tablecell=function(te,q){var re=q.header?"th":"td",ne=q.align?"<"+re+' align="'+q.align+'">':"<"+re+">";return ne+te+" `},le.strong=function(te){return""+te+""},le.em=function(te){return""+te+""},le.codespan=function(te){return""+te+""},le.br=function(){return this.options.xhtml?"
    ":"
    "},le.del=function(te){return""+te+""},le.link=function(te,q,re){if(te=et(this.options.sanitize,this.options.baseUrl,te),te===null)return re;var ne='",ne},le.image=function(te,q,re){if(te=et(this.options.sanitize,this.options.baseUrl,te),te===null)return re;var ne=''+re+'":">",ne},le.text=function(te){return te},pe}(),Be=function(){function pe(){}var le=pe.prototype;return le.strong=function(te){return te},le.em=function(te){return te},le.codespan=function(te){return te},le.del=function(te){return te},le.html=function(te){return te},le.text=function(te){return te},le.link=function(te,q,re){return""+re},le.image=function(te,q,re){return""+re},le.br=function(){return""},pe}(),ht=function(){function pe(){this.seen={}}var le=pe.prototype;return le.slug=function(te){var q=te.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(q)){var re=q;do this.seen[re]++,q=re+"-"+this.seen[re];while(this.seen.hasOwnProperty(q))}return this.seen[q]=0,q},pe}(),We=H.defaults,Pe=Q.unescape,Ke=function(){function pe(ue){this.options=ue||We,this.options.renderer=this.options.renderer||new Ne,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Be,this.slugger=new ht}pe.parse=function(te,q){var re=new pe(q);return re.parse(te)};var le=pe.prototype;return le.parse=function(te,q){q===void 0&&(q=!0);var re="",ne,ye,ge,_e,ze,ft,lt,At,Et,$e,Rt,yt,Ot,Lt,Tt,wr,fr,vt,rr=te.length;for(ne=0;ne0&&Tt.tokens[0].type==="text"?(Tt.tokens[0].text=vt+" "+Tt.tokens[0].text,Tt.tokens[0].tokens&&Tt.tokens[0].tokens.length>0&&Tt.tokens[0].tokens[0].type==="text"&&(Tt.tokens[0].tokens[0].text=vt+" "+Tt.tokens[0].tokens[0].text)):Tt.tokens.unshift({type:"text",text:vt}):Lt+=vt),Lt+=this.parse(Tt.tokens,Ot),Et+=this.renderer.listitem(Lt,fr,wr);re+=this.renderer.list(Et,Rt,yt);continue}case"html":{re+=this.renderer.html($e.text);continue}case"paragraph":{re+=this.renderer.paragraph(this.parseInline($e.tokens));continue}case"text":{for(Et=$e.tokens?this.parseInline($e.tokens):$e.text;ne+1An error occurred:

    "+it(ge.message+"",!0)+"
    ";throw ge}}Le.options=Le.setOptions=function(pe){return qe(Le.defaults,pe),tt(Le.defaults),Le},Le.getDefaults=Ce,Le.defaults=nt,Le.use=function(pe){var le=qe({},pe);if(pe.renderer&&function(){var te=Le.defaults.renderer||new Ne,q=function(ye){var ge=te[ye];te[ye]=function(){for(var _e=arguments.length,ze=new Array(_e),ft=0;ft<_e;ft++)ze[ft]=arguments[ft];var lt=pe.renderer[ye].apply(te,ze);return lt===!1&&(lt=ge.apply(te,ze)),lt}};for(var re in pe.renderer)q(re);le.renderer=te}(),pe.tokenizer&&function(){var te=Le.defaults.tokenizer||new Ee,q=function(ye){var ge=te[ye];te[ye]=function(){for(var _e=arguments.length,ze=new Array(_e),ft=0;ft<_e;ft++)ze[ft]=arguments[ft];var lt=pe.tokenizer[ye].apply(te,ze);return lt===!1&&(lt=ge.apply(te,ze)),lt}};for(var re in pe.tokenizer)q(re);le.tokenizer=te}(),pe.walkTokens){var ue=Le.defaults.walkTokens;le.walkTokens=function(te){pe.walkTokens(te),ue&&ue(te)}}Le.setOptions(le)},Le.walkTokens=function(pe,le){for(var ue=I(pe),te;!(te=ue()).done;){var q=te.value;le(q);switch(q.type){case"table":{for(var re=I(q.tokens.header),ne;!(ne=re()).done;){var ye=ne.value;Le.walkTokens(ye,le)}for(var ge=I(q.tokens.cells),_e;!(_e=ge()).done;)for(var ze=_e.value,ft=I(ze),lt;!(lt=ft()).done;){var At=lt.value;Le.walkTokens(At,le)}break}case"list":{Le.walkTokens(q.items,le);break}default:q.tokens&&Le.walkTokens(q.tokens,le)}}},Le.Parser=Ke,Le.parser=Ke.parse,Le.Renderer=Ne,Le.TextRenderer=Be,Le.Lexer=Me,Le.lexer=Me.lex,Le.Tokenizer=Ee,Le.Slugger=ht,Le.parse=Le;var Ie=Le;return Ie})},ELLl:function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){var Z={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},R=ae.Pos;ae.defineOption("autoCloseBrackets",!1,function(E,w,d){d&&d!=ae.Init&&(E.removeKeyMap(I),E.state.closeBrackets=null),w&&(D(X(w,"pairs")),E.state.closeBrackets=w,E.addKeyMap(I))});function X(E,w){return w=="pairs"&&typeof E=="string"?E:typeof E=="object"&&E[w]!=null?E[w]:Z[w]}var I={Backspace:M,Enter:O};function D(E){for(var w=0;w=0;l--){var L=o[l].head;E.replaceRange("",R(L.line,L.ch-1),R(L.line,L.ch+1),"+delete")}}function O(E){var w=F(E),d=w&&X(w,"explode");if(!d||E.getOption("disableInput"))return ae.Pass;for(var o=E.listSelections(),l=0;l0;return{anchor:new R(E.anchor.line,E.anchor.ch+(w?-1:1)),head:new R(E.head.line,E.head.ch+(w?1:-1))}}function C(E,w){var d=F(E);if(!d||E.getOption("disableInput"))return ae.Pass;var o=X(d,"pairs"),l=o.indexOf(w);if(l==-1)return ae.Pass;for(var h=X(d,"closeBefore"),L=X(d,"triples"),f=o.charAt(l+1)==w,p=E.listSelections(),_=l%2==0,b,g=0;g=0&&E.getRange(u,R(u.line,u.ch+3))==w+w+w?a="skipThree":a="skip";else if(f&&u.ch>1&&L.indexOf(w)>=0&&E.getRange(R(u.line,u.ch-2),u)==w+w){if(u.ch>2&&/\bstring/.test(E.getTokenTypeAt(R(u.line,u.ch-2))))return ae.Pass;a="addFour"}else if(f){var y=u.ch==0?" ":E.getRange(R(u.line,u.ch-1),u);if(!ae.isWordChar(x)&&y!=w&&!ae.isWordChar(y))a="both";else return ae.Pass}else if(_&&(x.length===0||/\s/.test(x)||h.indexOf(x)>-1))a="both";else return ae.Pass;if(!b)b=a;else if(b!=a)return ae.Pass}var S=l%2?o.charAt(l-1):w,P=l%2?w:o.charAt(l+1);E.operation(function(){if(b=="skip")E.execCommand("goCharRight");else if(b=="skipThree")for(var G=0;G<3;G++)E.execCommand("goCharRight");else if(b=="surround"){for(var Y=E.getSelections(),G=0;G10)},[pe==null?void 0:pe.replies_count]);var Nr=function(){var ct=Object(ae.a)(X.a.mark(function st(){var Jt,jt,Ut;return X.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return Jt=wr+1,fr(Jt),Gt.next=4,Object(l.h)({id:ue.memoId,page:Jt});case 4:jt=Gt.sent,jt!=null&&jt.memo_replies&&(tt({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},Ve.forumsDetailData),{},{memo_replies:[].concat(Object(oe.a)(le),Object(oe.a)(jt.memo_replies))})}),Ot(((Ut=jt.memo_replies)===null||Ut===void 0?void 0:Ut.length)===10));case 6:case"end":return Gt.stop()}},st)}));return function(){return ct.apply(this,arguments)}}(),Xr=function(st){var Jt,jt,Ut,kt;return Object(E.a)(Object(E.a)({},st),{},{image_url:(Jt=qe.userInfo)===null||Jt===void 0?void 0:Jt.image_url,children:[],user_id:(jt=qe.userInfo)===null||jt===void 0?void 0:jt.user_id,user_login:(Ut=qe.userInfo)===null||Ut===void 0?void 0:Ut.login,username:(kt=qe.userInfo)===null||kt===void 0?void 0:kt.username,time:"".concat(Object(me.Z)((new Date().getTime()-new Date(st.created_at).getTime())/1e3),"\u524D")})},Jr=function(){or(!0)};return D.a.createElement("section",{className:Se.a.wrap},!!(le!=null&&le.length)&&D.a.createElement("aside",{className:Se.a.content},D.a.createElement("div",{style:{padding:"10px 15px 5px 15px",justifyContent:"space-between",display:"flex"}},D.a.createElement("span",null,"\u5168\u90E8\u56DE\u590D\uFF08",pe.replies_count,"\uFF09")),D.a.createElement("aside",{className:Se.a.replyList},le==null?void 0:le.map(function(ct,st){var Jt;return D.a.createElement(O.a,{gutter:[12,12],key:st},D.a.createElement(C.a,{flex:"40px"},D.a.createElement("a",{href:"/users/".concat(ct.user_login),target:"_blank"},D.a.createElement("img",{alt:"\u7528\u6237\u5934\u50CF",width:"50",height:"50",src:"".concat(w.a.IMG_SERVER,"/images/").concat(ct==null?void 0:ct.image_url)}))),D.a.createElement(C.a,{flex:"1"},D.a.createElement(O.a,{align:"middle"},D.a.createElement(C.a,{span:24},D.a.createElement("a",{href:"/users/".concat(ct.user_login),target:"_blank"},D.a.createElement("span",{className:"c-light-black"},ct==null?void 0:ct.username)),D.a.createElement("span",{className:"c-light-black ml10"},ct.time)),D.a.createElement(C.a,{span:24},D.a.createElement("div",{onClick:nt},D.a.createElement(ee.a,{value:ct.content}))),!!(ct!=null&&(Jt=ct.children)!==null&&Jt!==void 0&&Jt.length)&&D.a.createElement(Te,{user:qe,id:ct==null?void 0:ct.id,vlist:ct==null?void 0:ct.children,dispatch:tt,params:ue,memo_replies:le,forumsDetail:Ve}),D.a.createElement(C.a,{span:24,className:"mt5 c-light-black"},At===st?D.a.createElement("aside",null,D.a.createElement(ve.a,{onChange:function(Ut){ze(Ut)},height:150,isFocus:!0,placeholder:"\u6211\u8981\u56DE\u590D..."}),D.a.createElement(O.a,null,D.a.createElement(C.a,{span:24,className:"tr"},D.a.createElement(A.a,{type:"primary",size:"large",onClick:Object(ae.a)(X.a.mark(function jt(){var Ut;return X.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:if(!(_e==="")){Gt.next=4;break}Y.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),Gt.next=9;break;case 4:return Gt.next=6,Object(l.k)({parent_id:ct.id,content:_e});case 6:Ut=Gt.sent,ze(null),Ut&&(Et(-1),le.find(function(Sr){return Sr.id===Ut.parent_id}).children.push(Xr(Ut)),tt({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},Ve.forumsDetailData),{},{memo:Object(E.a)(Object(E.a)({},pe),{},{replies_count:pe.replies_count+1}),memo_replies:Object(oe.a)(le)})}));case 9:case"end":return Gt.stop()}},jt)}))},"\u53D1\u9001")))):D.a.createElement("div",{className:"tr"},D.a.createElement("span",{className:"iconfont icon-huifu1 mr15 ml30 current",onClick:function(){return Et(st)}}),D.a.createElement(b.a,{title:ct.user_praise?"\u53D6\u6D88\u70B9\u8D5E":"\u70B9\u8D5E"},D.a.createElement("span",{className:ct.user_praise?"c-orange":"c-gery-888"},D.a.createElement("i",{className:"iconfont icon-dianzan mr3 current",onClick:Object(ae.a)(X.a.mark(function jt(){var Ut;return X.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return Gt.next=2,Object(l.i)({id:ct.id,container_type:"Memo",type:ct.user_praise?0:1});case 2:Ut=Gt.sent,(Ut==null?void 0:Ut.praise_count)>=0&&(le.find(function(Sr){return Sr.id===ct.id}).user_praise=!ct.user_praise,le.find(function(Sr){return Sr.id===ct.id}).praise_count=Ut==null?void 0:Ut.praise_count,tt({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},Ve.forumsDetailData),{},{memo_replies:Object(oe.a)(le)})}));case 4:case"end":return Gt.stop()}},jt)}))}),ct.praise_count>0?ct.praise_count:"")))))))}))),yt&&D.a.createElement("aside",{className:"bg-white pb20",style:{display:"flex",justifyContent:"center"}},D.a.createElement(O.a,{justify:"space-between"},D.a.createElement(C.a,null),D.a.createElement(C.a,null,yt&&D.a.createElement("a",{className:"c-black",onClick:Nr},"\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA")))),D.a.createElement("aside",{className:Se.a.reply},D.a.createElement(ve.a,{onBlur:function(){return or(!1)},isFocus:ir,defaultValue:re,id:"writeForumsReviewId",onChange:function(st){ne(st)},placeholder:"\u6211\u8981\u56DE\u590D...",height:240}),D.a.createElement(O.a,null,D.a.createElement(C.a,{flex:"1"}),D.a.createElement(C.a,null,D.a.createElement(A.a,{type:"primary",size:"large",onClick:Object(ae.a)(X.a.mark(function ct(){var st;return X.a.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:if(!(re==="")){jt.next=4;break}Y.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),jt.next=9;break;case 4:return jt.next=6,Object(l.k)({parent_id:pe.id,content:re});case 6:st=jt.sent,ne(null),st&&tt({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},Ve.forumsDetailData),{},{memo:Object(E.a)(Object(E.a)({},pe),{},{replies_count:pe.replies_count+1}),memo_replies:[Xr(st)].concat(Object(oe.a)(le))})});case 9:case"end":return jt.stop()}},ct)}))},"\u53D1\u9001")))))},ke=Object(F.a)(function(We){var Pe=We.user,Ke=We.forumsDetail,qe=We.loading,Ve=We.globalSetting;return{user:Pe,forumsDetail:Ke,globalSetting:Ve,loading:qe.models.forumsDetail}},null,null,{forwardRef:!0})(Object(I.forwardRef)(de)),Je=ie("smFo"),Ge=ie.n(Je),Qe=ie("RCxd"),Ye=ie("kaH+"),Ae=ie("dhSg"),Me={5:"\u6280\u672F\u5206\u4EAB",3:"\u64CD\u4F5C\u6307\u5357",16:"\u901A\u77E5\u516C\u544A"},je=function(Pe){var Ke,qe,Ve,it,Ce,tt=Pe.user,nt=Pe.forumsDetail,Le=Pe.globalSetting,Ie=Pe.loading,pe=Pe.dispatch,le=Object(Z.a)(Pe,["user","forumsDetail","globalSetting","loading","dispatch"]),ue=nt.forumsDetailData||{},te=ue.author_info,q=ue.memo,re=ue.attachments_list,ne=Object(I.useRef)(),ye=Object(I.useRef)(),ge=function(){var $e=Object(ae.a)(X.a.mark(function Rt(){var yt,Ot;return X.a.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return yt={id:q.id,sticky:q.sticky?0:1},Tt.next=3,Object(l.m)(yt);case 3:Ot=Tt.sent,(Ot==null?void 0:Ot.status)===0&&pe({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},nt.forumsDetailData),{},{memo:Object(E.a)(Object(E.a)({},q),{},{sticky:!(q!=null&&q.sticky)})})});case 5:case"end":return Tt.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),_e=function(){var $e=Object(ae.a)(X.a.mark(function Rt(){var yt;return X.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Lt.next=2,Object(l.b)({id:q==null?void 0:q.id});case 2:yt=Lt.sent,(yt==null?void 0:yt.status)===0&&(Y.b.success("\u5220\u9664\u6210\u529F"),F.d.push("/forums")),(yt==null?void 0:yt.status)===-1&&F.d.push("/forums");case 5:case"end":return Lt.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),ze=function(){var $e=Object(ae.a)(X.a.mark(function Rt(){return X.a.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:P.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u5956\u52B1\u8BBE\u7F6E",content:D.a.createElement("div",{className:"font14 tc"},D.a.createElement(y.a,{defaultValue:ne.current,onChange:function(Tt){return ne.current=Tt.target.value}})),onOk:function(){var Lt=Object(ae.a)(X.a.mark(function wr(){var fr;return X.a.wrap(function(rr){for(;;)switch(rr.prev=rr.next){case 0:return rr.next=2,Object(l.l)({id:q==null?void 0:q.id,container_type:"Memo",score:ne.current?Number(ne.current):0,user_id:te==null?void 0:te.user_id});case 2:if(fr=rr.sent,ne.current=null,!((fr==null?void 0:fr.code)>0)){rr.next=8;break}return pe({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},nt.forumsDetailData),{},{memo:Object(E.a)(Object(E.a)({},q),{},{reward:fr==null?void 0:fr.code})})}),Y.b.success("\u5956\u52B1\u6210\u529F"),rr.abrupt("return");case 8:Y.b.success("\u5956\u52B1\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01");case 9:case"end":return rr.stop()}},wr)}));function Tt(){return Lt.apply(this,arguments)}return Tt}()});case 1:case"end":return Ot.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),ft=function(){ye.current.onMdFouch&&ye.current.onMdFouch()},lt=function(){var $e=Object(ae.a)(X.a.mark(function Rt(){var yt;return X.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Lt.next=2,Object(l.i)({id:q.id,container_type:"Memo",type:1});case 2:yt=Lt.sent,(yt==null?void 0:yt.praise_count)>=0&&pe({type:"forumsDetail/setForumsDetailData",payload:Object(E.a)(Object(E.a)({},nt.forumsDetailData),{},{memo:Object(E.a)(Object(E.a)({},q),{},{user_praise:!(q!=null&&q.user_praise),memo_praise_count:yt==null?void 0:yt.praise_count})})});case 4:case"end":return Lt.stop()}},Rt)}));return function(){return $e.apply(this,arguments)}}(),At=D.a.createElement(a.a,{className:Ge.a.menu},((Ke=tt.userInfo)===null||Ke===void 0?void 0:Ke.admin)&&(q==null?void 0:q.sticky)&&D.a.createElement(a.a.Item,null,D.a.createElement("a",{onClick:function(){return ge()}},"\u53D6\u6D88\u7F6E\u9876")),((qe=tt.userInfo)===null||qe===void 0?void 0:qe.admin)&&!(q!=null&&q.sticky)&&D.a.createElement(a.a.Item,null,D.a.createElement("a",{onClick:function(){return ge()}},"\u7F6E\xA0\xA0\u9876")),D.a.createElement(a.a.Item,null,D.a.createElement(Q.a,{to:"/forums/".concat(q==null?void 0:q.id,"/edit")},"\u7F16\xA0\xA0\u8F91")),D.a.createElement(a.a.Item,null,D.a.createElement("a",{onClick:function(){P.a.confirm({title:"\u63D0\u793A",icon:D.a.createElement(Qe.a,null),content:"\u5E16\u5B50\u5C06\u88AB\u5220\u9664\uFF0C\u65E0\u6CD5\u6062\u590D\u3002\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",okText:"\u786E\u8BA4",onOk:function(){_e()},cancelText:"\u53D6\u6D88"})}},"\u5220\xA0\xA0\u9664"))),Et=function(Rt){var yt=Rt.target,Ot=yt.nodeName,Lt=yt.src;Ot==="IMG"&&(Ae.a.publish("preview-image",Lt),console.log("src:",Lt))};return Object(I.useEffect)(function(){},[]),D.a.createElement("section",{className:Ge.a.wrap},D.a.createElement(c.a,{separator:"/",className:"mb5"},D.a.createElement(c.a.Item,null,D.a.createElement(Q.a,{to:"/forums/categories/".concat(q==null?void 0:q.forum_id)},Me[q==null?void 0:q.forum_id])),D.a.createElement(c.a.Item,null,"\u8BE6\u60C5")),D.a.createElement("header",{className:"bg-white pt40 pb40 pl30 pr30 ".concat(Ge.a.header)},D.a.createElement(O.a,{align:"middle"},D.a.createElement(C.a,{flex:1,className:"font24 mb5"},D.a.createElement("span",{className:Ge.a.title},q==null?void 0:q.subject),(q==null?void 0:q.sticky)&&D.a.createElement("span",{className:Ge.a.top},"\u7F6E\u9876"),!!(q!=null&&q.reward)&&D.a.createElement(b.a,{placement:"bottom",title:"\u83B7\u5F97\u5E73\u53F0\u5956\u52B1\u91D1\u5E01\uFF1A".concat(q==null?void 0:q.reward)},D.a.createElement("span",{className:"ml10 c-orange-ff7"},D.a.createElement("i",{className:"iconfont icon-gift font16 mr5"}),D.a.createElement("span",{className:"font14"},q==null?void 0:q.reward)))),D.a.createElement(C.a,null,(((Ve=tt.userInfo)===null||Ve===void 0?void 0:Ve.admin)||((it=tt.userInfo)===null||it===void 0?void 0:it.user_id)===(te==null?void 0:te.user_id))&&D.a.createElement(p.a,{overlay:At},D.a.createElement("i",{className:"fa fa-bars font-16 current c-grey-bcb"})))),D.a.createElement(O.a,{align:"middle",className:"font14"},D.a.createElement(C.a,{flex:1,className:"c-grey-999"},D.a.createElement("span",null,j()(q==null?void 0:q.time).fromNow()," \u53D1\u5E03")),D.a.createElement(C.a,{className:"c-grey-999"},((Ce=tt.userInfo)===null||Ce===void 0?void 0:Ce.admin)&&D.a.createElement(b.a,{placement:"bottom",title:"\u5E16\u5B50\u5956\u52B1"},D.a.createElement("span",{className:"current pr10 ".concat(Ge.a.line),onClick:ze},D.a.createElement("i",{className:"iconfont icon-jiangli font18 mr5"}))),D.a.createElement("span",{className:"pr10 pl10 ".concat(q!=null&&q.replies_count?Ge.a.line:"")},D.a.createElement("i",{className:"iconfont icon-liulanyan font18 mr5"}),q==null?void 0:q.viewed_count),!!(q!=null&&q.replies_count)&&D.a.createElement(b.a,{placement:"bottom",title:"\u5199\u8BC4\u8BBA"},D.a.createElement("span",{className:"current pl10",onClick:ft},D.a.createElement("i",{className:"iconfont icon-huifu1 font18 mr5"}),q==null?void 0:q.replies_count))))),D.a.createElement("main",{className:"bg-white pt40 pb40 pl40 pr40"},D.a.createElement("div",{onClick:Et},D.a.createElement(ee.a,{value:q==null?void 0:q.content})),D.a.createElement("div",{className:"bg-white pl40 pr40 mt40"},D.a.createElement("div",{className:"mt10 mb20 ".concat(Ge.a.flexCenter)},D.a.createElement("div",{className:"".concat(Ge.a.like," ").concat(q!=null&&q.user_praise?"":Ge.a.canLike),onClick:lt},D.a.createElement("i",{className:"iconfont icon-dianzan font18"}),D.a.createElement("br",null),D.a.createElement("span",null,q==null?void 0:q.memo_praise_count)))),!!(re!=null&&re.length)&&D.a.createElement("div",{className:"mt40"},re==null?void 0:re.map(function($e){return D.a.createElement("div",{className:"c-grey-888 ".concat(Ge.a.flexCenter)},D.a.createElement("i",{className:"iconfont icon-fujian mr10 font14 c-green-29b"}),D.a.createElement("a",{href:$e==null?void 0:$e.url,title:$e==null?void 0:$e.title,className:"".concat(Ge.a.attachmentName," mr10")},$e==null?void 0:$e.title),D.a.createElement("span",{className:"font12 c-grey-666 mt3"},$e==null?void 0:$e.filesize))}))),D.a.createElement(ke,{ref:ye,handleClick:Et}),D.a.createElement(Ye.a,null))},et=Object(F.a)(function(We){var Pe=We.user,Ke=We.forumsDetail,qe=We.loading,Ve=We.globalSetting;return{user:Pe,forumsDetail:Ke,globalSetting:Ve,loading:qe.effects}})(je),Xe=ie("G8my"),Ne=ie.n(Xe),Be=function(Pe){var Ke=Pe.forumsDetail,qe=Pe.globalSetting,Ve=Pe.loading,it=Pe.dispatch,Ce=Object(Z.a)(Pe,["forumsDetail","globalSetting","loading","dispatch"]),tt=Object(H.i)();Object(I.useEffect)(function(){nt()},[tt.memoId]);var nt=function(){var Le=Object(ae.a)(X.a.mark(function Ie(){return X.a.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:it({type:"forumsDetail/getForumsDetailData",payload:{id:tt.memoId}});case 1:case"end":return le.stop()}},Ie)}));return function(){return Le.apply(this,arguments)}}();return D.a.createElement("section",{className:"edu-container mb20 mt30 ".concat(Ne.a.flex)},D.a.createElement(et,null),D.a.createElement(L,null))},ht=dt.default=Object(F.a)(function(We){var Pe=We.forumsDetail,Ke=We.loading,qe=We.globalSetting;return{forumsDetail:Pe,globalSetting:qe,loading:Ke.models.forumsDetail}})(Be)},LO5M:function(Ct,dt,ie){Ct.exports={wrap:"wrap___1d4rP",head:"head___1_Uzf",recommendItem:"recommendItem___IStR9",buttonWrap:"buttonWrap___3dpFm",privateMessage:"privateMessage___24GfS",flex1:"flex1___3wIqQ",mWidth147:"mWidth147___3ODny"}},LdHM:function(Ct,dt,ie){"use strict";ie.d(dt,"b",function(){return h}),ie.d(dt,"a",function(){return f});var ae=ie("1OyB"),Z=ie("vuIU"),R=ie("Ji7U"),X=ie("LK+K"),I=ie("q1tI"),D=ie("rePB"),H=ie("Ff2n"),F=ie("ODXe"),M=ie("4IlW"),O=ie("bX4T"),v=ie("YrtM"),C=ie("TSYQ"),k=ie.n(C),A=ie("+nKL"),E=ie("8OUc"),w=function(ee,oe){var fe=ee.prefixCls,ve=ee.id,Re=ee.flattenOptions,Ee=ee.childrenAsData,Se=ee.values,we=ee.searchValue,Te=ee.multiple,me=ee.defaultActiveFirstOption,de=ee.height,ke=ee.itemHeight,Je=ee.notFoundContent,Ge=ee.open,Qe=ee.menuItemSelectedIcon,Ye=ee.virtual,Ae=ee.onSelect,Me=ee.onToggleOpen,je=ee.onActiveValue,et=ee.onScroll,Xe=ee.onMouseEnter,Ne="".concat(fe,"-item"),Be=Object(v.a)(function(){return Re},[Ge,Re],function(Ie,pe){return pe[0]&&Ie[1]!==pe[1]}),ht=I.useRef(null),We=function(pe){pe.preventDefault()},Pe=function(pe){ht.current&&ht.current.scrollTo({index:pe})},Ke=function(pe){for(var le=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ue=Be.length,te=0;te1&&arguments[1]!==void 0?arguments[1]:!1;return Object(_.a)(j).map(function(oe,fe){if(!I.isValidElement(oe)||!oe.type)return null;var ve=oe.type.isSelectOptGroup,Re=oe.key,Ee=oe.props,Se=Ee.children,we=Object(H.a)(Ee,["children"]);return ee||!ve?b(oe):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(Re===null?fe:Re,"__"),label:Re},we),{},{options:g(Se)})}).filter(function(oe){return oe})}var c=ie("2Qr1"),u=ie("qNPg"),a=ie("U8pU"),x=ie("Kwbf"),y=ie("WKfj");function S(j){var ee=j.mode,oe=j.options,fe=j.children,ve=j.backfill,Re=j.allowClear,Ee=j.placeholder,Se=j.getInputElement,we=j.showSearch,Te=j.onSearch,me=j.defaultOpen,de=j.autoFocus,ke=j.labelInValue,Je=j.value,Ge=j.inputValue,Qe=j.optionLabelProp,Ye=ee==="multiple"||ee==="tags",Ae=we!==void 0?we:Ye||ee==="combobox",Me=oe||g(fe);if(Object(x.a)(ee!=="tags"||Me.every(function(Ne){return!Ne.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ee==="tags"||ee==="combobox"){var je=Me.some(function(Ne){return Ne.options?Ne.options.some(function(Be){return typeof("value"in Be?Be.value:Be.key)=="number"}):typeof("value"in Ne?Ne.value:Ne.key)=="number"});Object(x.a)(!je,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(x.a)(ee!=="combobox"||!Qe,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(x.a)(ee==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(x.a)(ee==="combobox"||!Se,"`getInputElement` only work with `combobox` mode."),Object(x.b)(ee!=="combobox"||!Se||!Re||!Ee,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Te&&!Ae&&ee!=="combobox"&&ee!=="tags"&&Object(x.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(x.b)(!me||de,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Je!=null){var et=Object(y.d)(Je);Object(x.a)(!ke||et.every(function(Ne){return Object(a.a)(Ne)==="object"&&("key"in Ne||"value"in Ne)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(x.a)(!Ye||Array.isArray(Je),"`value` should be array when `mode` is `multiple` or `tags`")}if(fe){var Xe=null;Object(_.a)(fe).some(function(Ne){if(!I.isValidElement(Ne)||!Ne.type)return!1;var Be=Ne.type;if(Be.isSelectOption)return!1;if(Be.isSelectOptGroup){var ht=Object(_.a)(Ne.props.children).every(function(We){return!I.isValidElement(We)||!Ne.type||We.type.isSelectOption?!0:(Xe=We.type,!1)});return!ht}return Xe=Be,!0}),Xe&&Object(x.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Xe.displayName||Xe.name||Xe,"`.")),Object(x.a)(Ge===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=S,G=Object(u.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:g,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:P,fillOptionsWithMissingValue:c.a}),Y=function(j){Object(R.a)(oe,j);var ee=Object(X.a)(oe);function oe(){var fe;return Object(ae.a)(this,oe),fe=ee.apply(this,arguments),fe.selectRef=I.createRef(),fe.focus=function(){fe.selectRef.current.focus()},fe.blur=function(){fe.selectRef.current.blur()},fe}return Object(Z.a)(oe,[{key:"render",value:function(){return I.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),oe}(I.Component);Y.Option=h,Y.OptGroup=f;var Q=Y,z=dt.c=Q},M8RZ:function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return M});var ae=ie("fWQN"),Z=ie("mtLc"),R=ie("yKVA"),X=ie("879j"),I=ie("q1tI"),D=ie.n(I),H=ie("i8i4"),F=ie.n(H),M=function(O){Object(R.a)(C,O);var v=Object(X.a)(C);function C(k){var A;Object(ae.a)(this,C),A=v.call(this,k);var E=window.document;return A.node=E.createElement("div"),E.body.appendChild(A.node),A}return Object(Z.a)(C,[{key:"render",value:function(){var A=this.props.children;return Object(H.createPortal)(A,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),C}(D.a.Component)},Ot1p:function(Ct,dt,ie){"use strict";var ae=ie("2qtc"),Z=ie("kLXV"),R=ie("rAM+"),X=ie("miYZ"),I=ie("tsqr"),D=ie("9og8"),H=ie("tJVT"),F=ie("jrin"),M=ie("WmNS"),O=ie.n(M),v=ie("q1tI"),C=ie.n(v),k=ie("VrN/"),A=ie.n(k),E=ie("bdgK"),w=ie("p77/"),d=ie("Bd2K"),o=ie("ELLl"),l=ie("19Vz"),h=ie("lZu9"),L=ie("+NIl"),f=ie("kSUc"),p=ie("9Bee"),_=function(ge){var _e=ge.value,ze=_e===void 0?"":_e,ft=ge.className,lt=ge.showTextOnly,At=ge.showLines,Et=ge.style,$e=Et===void 0?{}:Et,Rt=Object(v.useMemo)(function(){return""},[ze]);return C.a.createElement(C.a.Fragment,null,C.a.createElement("div",{dangerouslySetInnerHTML:{__html:Rt}}))},b=ie("0Owb"),g=ie("dejd"),c=ie("C+DQ"),u=ie("1vsH"),a=ie("m3rI"),x=[{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(ge){var _e=ge.onActionCallback,ze=ge.title,ft=ge.icon,lt=ge.actionName,At=ge.className,Et=At===void 0?"":At,$e=ge.children;function Rt(){_e(lt)}return C.a.createElement("a",{title:ze,className:Et,onClick:Rt},C.a.createElement("i",{className:"md-iconfont ".concat(ft)}),$e)}var S=function(ge){var _e=ge.watch,ze=ge.showNullButton,ft=ge.onActionCallback,lt=ge.fullScreen,At=ge.insertTemp,Et=ge.hidetoolBar,$e=ge.uuid,Rt=ge.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(u.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(u.E)("_educoder_session"),"&key=").concat($e,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var yt=[].concat(x,[{title:"".concat(_e?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(_e?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return C.a.createElement("ul",{className:"markdown-toolbar-container"},!Et&&yt.map(function(Ot,Lt){return C.a.createElement("li",{key:Lt},Ot.actionName?C.a.createElement(y,Object(b.a)({},Ot,{onActionCallback:ft})):C.a.createElement("span",{className:"v-line"}))}),ze?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:ft},C.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,At&&C.a.createElement("li",null,C.a.createElement(y,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(At),onActionCallback:ft},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(lt?"icon-shrink":"icon-enlarge"),title:lt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:ft})))},P=ie("M8RZ"),G=ie("+L6B"),Y=ie("2/Rp"),Q=ie("y8nQ"),z=ie("Vl3Y"),j=ie("5NDa"),ee=ie("5rEg"),oe={labelCol:{span:4},wrapperCol:{span:20}},fe=function(ge){var _e=ge.callback,ze=ge.onCancel;function ft(lt){_e(lt)}return C.a.createElement(z.a,Object(b.a)({},oe,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:ft}),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(ee.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(ee.a,null)),C.a.createElement("div",{className:"flex-container flex-end"},C.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(Y.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))},ve=ie("7ahc"),Re=ie("k1fw"),Ee=ie("HmJG"),Se=ie("BjJ7"),we=z.a.useForm,Te={width:280,marginRight:10},me={labelCol:{span:5},wrapperCol:{span:19}},de=function(ge){var _e=ge.callback,ze=ge.onCancel,ft=we(),lt=Object(H.a)(ft,1),At=lt[0],Et=Object(v.useRef)();function $e(Ot){_e(Object(Re.a)(Object(Re.a)({},Ot),{},{name:Et.current}))}function Rt(Ot,Lt){At.setFieldsValue({src:"/api/attachments/".concat(Ot.id,"?type=").concat(Ot.content_type),type:Lt.type})}function yt(Ot){var Lt=Ot.target.files[0];Et.current=Lt.name,Je(Lt,Rt)}return C.a.createElement(z.a,Object(b.a)({form:At},me,{className:"upload-image-panel",onFinish:$e}),C.a.createElement(z.a.Item,{label:"\u6587\u4EF6\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\u6587\u4EF6\u5730\u5740"}]},C.a.createElement(ee.a,{style:Te})),C.a.createElement(ke,{onFileChange:yt}))),C.a.createElement(z.a.Item,{label:"\u6587\u4EF6\u63CF\u8FF0",name:"alt"},C.a.createElement(ee.a,{style:{width:264}})),C.a.createElement(z.a.Item,{style:{textAlign:"right"}},C.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(Y.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))};function ke(ge){var _e=ge.onFileChange;return C.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",C.a.createElement("input",{type:"file",onChange:_e}))}function Je(ge,_e){if(!ge)throw new String("\u6CA1\u6709\u6587\u4EF6");var ze=new FormData;ze.append("editormd-image-file",ge),ze.append("file_param_name","editormd-image-file"),ze.append("byxhr","true");var ft=new window.XMLHttpRequest;ft.withCredentials=!0,ft.addEventListener("load",function(lt){_e(JSON.parse(lt.target.responseText),ge)},!1),ft.addEventListener("error",function(lt){console.error(lt)},!1),ft.open("POST","".concat(Se.a,"/api/attachments.json")),ft.send(ze)}var Ge=ie("giR+"),Qe=ie("fyUT"),Ye=ie("7Kak"),Ae=ie("9yH6"),Me=Ae.a.Group,je={margin:"0 8px"},et=function(ge){var _e=ge.callback,ze=ge.onCancel;function ft(lt){_e(lt)}return C.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:ft},C.a.createElement("div",{className:"flex-container"},C.a.createElement("span",{style:je},"\u5355\u5143\u683C\u6570\uFF1A"),C.a.createElement("span",{style:je},"\u884C\u6570"),C.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},C.a.createElement(Qe.a,null)),C.a.createElement("span",{style:je},"\u5217\u6570"),C.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},C.a.createElement(Qe.a,null))),C.a.createElement("div",{className:"flex-container",style:{marginTop:12}},C.a.createElement("span",{style:je},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),C.a.createElement(z.a.Item,{name:"align"},C.a.createElement(Me,null,C.a.createElement(Ae.a,{value:"default"},C.a.createElement("i",{className:"fa fa-align-justify"})),C.a.createElement(Ae.a,{value:"left"},C.a.createElement("i",{className:"fa fa-align-left"})),C.a.createElement(Ae.a,{value:"center"},C.a.createElement("i",{className:"fa fa-align-center"})),C.a.createElement(Ae.a,{value:"right"},C.a.createElement("i",{className:"fa fa-align-right"}))))),C.a.createElement("div",{className:"flex-container flex-end"},C.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),C.a.createElement(Y.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))},Xe=ie("ErOA"),Ne=ie("7Cbv"),Be="link",ht="upload-image",We="code-block",Pe="add-table",Ke="------------",qe={default:Ke,left:":".concat(Ke),center:":".concat(Ke,":"),right:"".concat(Ke,":")},Ve=ie("9VGf"),it,Ce;function tt(){}var nt=0,Le=1e4,Ie="\u2581",pe=` **\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 le(ge){return/^\d+$/.test(ge)?"".concat(ge,"px"):ge}var ue=navigator.platform.toUpperCase().indexOf("MAC")>=0,te=ue?"Cmd":"Ctrl",q=["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"],re=(it={},Object(F.a)(it,te+"-B","bold"),Object(F.a)(it,te+"-I","italic"),it),ne=(Ce={},Object(F.a)(Ce,Be,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Ce,We,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Ce,ht,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Ce,Pe,"\u6DFB\u52A0\u8868\u683C"),Ce),ye=dt.a=function(ge){var _e=ge.defaultValue,ze=_e===void 0?"":_e,ft=ge.onChange,lt=ge.width,At=lt===void 0?"100%":lt,Et=ge.height,$e=Et===void 0?400:Et,Rt=ge.miniToolbar,yt=Rt===void 0?!1:Rt,Ot=ge.isFocus,Lt=Ot===void 0?!1:Ot,Tt=ge.watch,wr=ge.insertTemp,fr=ge.mode,vt=fr===void 0?"markdown":fr,rr=ge.id,ir=rr===void 0?"markdown-editor-id":rr,or=ge.showResizeBar,Nr=or===void 0?!1:or,Xr=ge.noStorage,Jr=Xr===void 0?!1:Xr,ct=ge.showNullButton,st=ct===void 0?!1:ct,Jt=ge.hidetoolBar,jt=Jt===void 0?!1:Jt,Ut=ge.fullScreen,kt=Ut===void 0?!1:Ut,Gt=ge.onBlur,Sr=ge.onCMBeforeChange,ui=ge.onFullScreen,He=ge.className,_t=He===void 0?"":He,di=ge.disablePaste,Ai=di===void 0?!1:di,hi=ge.placeholder,_i=hi===void 0?"":hi,W=ge.values,s=W===void 0?"":W,m=Object(v.useState)(null),U=Object(H.a)(m,2),K=U[0],B=U[1],ce=Object(v.useState)(ze),Oe=Object(H.a)(ce,2),rt=Oe[0],pt=Oe[1],Ue=Object(v.useState)(Tt),wt=Object(H.a)(Ue,2),It=wt[0],$t=wt[1],Wr=Object(v.useState)(kt),Hr=Object(H.a)(Wr,2),hr=Hr[0],Yr=Hr[1],Hi=Object(v.useState)(""),_r=Object(H.a)(Hi,2),Gr=_r[0],Ur=_r[1],gi=Object(v.useState)(0),Qr=Object(H.a)(gi,2),ci=Qr[0],ni=Qr[1],hn=Object(v.useState)($e),Gi=Object(H.a)(hn,2),qr=Gi[0],zr=Gi[1],Di=Object(v.useState)(!1),Ri=Object(H.a)(Di,2),cn=Ri[0],er=Ri[1],Wt=Object(v.useRef)(Object(Ne.a)()),br=Object(v.useRef)(!1),Ft=Object(v.useRef)(),sr=Object(v.useRef)(),Kt=Object(v.useRef)(),ai=Object(v.useRef)(),nr=Object(v.useRef)(),Dr=function(){var gt=Object(D.a)(O.a.mark(function Dt(){var xt,Pt;return O.a.wrap(function(Xt){for(;;)switch(Xt.prev=Xt.next){case 0:return Xt.next=2,Object(Xe.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Wt.current}});case 2:Pt=Xt.sent,Pt!=null&&(xt=Pt.attachments)!==null&&xt!==void 0&&xt.length&&(console.log("cm:",K,sr),Pt.attachments.map(function(Bt){Bt.content_type.indexOf("image")>-1?K.replaceSelection("![,](/api/attachments/".concat(Bt.id,"?type=").concat(Bt.content_type,")")):Bt.content_type.indexOf("video")>-1?K.replaceSelection('')):Bt.content_type.indexOf("pdf")>-1?K.replaceSelection('
    ').concat(Bt.name,"")):K.replaceSelection("[".concat(Bt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Bt.id,"?type=").concat(Bt.content_type,")"))}));case 4:case"end":return Xt.stop()}},Dt)}));return function(){return gt.apply(this,arguments)}}();Object(v.useEffect)(function(){pt(s),K==null||K.setValue(s)},[s]),Object(v.useEffect)(function(){ui==null||ui(hr)},[hr]),Object(v.useEffect)(function(){if(sr.current){var gt=A.a.fromTextArea(sr.current,{mode:vt,lineNumbers:!yt,lineWrapping:!0,value:ze,autoCloseTags:!0,autoCloseBrackets:!0});Lt&>.focus();function Dt(xt,Pt){if(Ai){Pt.preventDefault();return}var Ht=Pt.clipboardData;if(Ht){var Xt=Ht.types.toString(),Bt=Ht.items;if(Xt==="Files"||Ht.types.indexOf("Files")>-1){if(Pt.preventDefault(),vt=="stex")return;try{var lr,Rr=Bt[1];((lr=Bt[0])===null||lr===void 0?void 0:lr.kind)==="file"&&(Rr=Bt[0]);var Nt=Rr.getAsFile(),yi=Nt.name.split(".").pop();Je(Nt,function(zt){if(zt.id){var pr,$r,Zr;(Nt==null||((pr=Nt.type)===null||pr===void 0)?void 0:pr.indexOf("image"))>-1?gt.replaceSelection("![,](/api/attachments/".concat(zt.id,"?type=").concat(zt.content_type,")")):(Nt==null||(($r=Nt.type)===null||$r===void 0)?void 0:$r.indexOf("video"))>-1?gt.replaceSelection('')):(Nt==null||((Zr=Nt.type)===null||Zr===void 0)?void 0:Zr.indexOf("pdf"))>-1?gt.replaceSelection('').concat(Nt.name,"")):q.includes(yi)?gt.replaceSelection('').concat(Nt.name,"")):gt.replaceSelection("[".concat(Nt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(zt.id,"?type=").concat(zt.content_type,")"))}else(zt==null?void 0:zt.status)===401&&(document.location.href="/user/login")})}catch(zt){I.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return gt.on("paste",Dt),gt.on("dragleave",function(xt,Pt){Kt.current.classList.remove("mouse-hover-md")}),gt.on("dragover",function(xt,Pt){Kt.current.classList.add("mouse-hover-md")}),gt.on("drop",function(xt,Pt){Kt.current.classList.add("mouse-hover-md");var Ht;if(Ht=Pt.dataTransfer.files,Ht.length>0){Pt.preventDefault(),Pt.stopPropagation();for(var Xt=function(Rr){var Nt=Ht[Rr],yi=Nt.name.split(".").pop();Je(Nt,function(zt){if(zt.id){var pr,$r,Zr;(Nt==null||((pr=Nt.type)===null||pr===void 0)?void 0:pr.indexOf("image"))>-1?gt.replaceSelection("![,](/api/attachments/".concat(zt.id,"?type=").concat(zt.content_type,")")):(Nt==null||(($r=Nt.type)===null||$r===void 0)?void 0:$r.indexOf("video"))>-1?gt.replaceSelection('')):(Nt==null||((Zr=Nt.type)===null||Zr===void 0)?void 0:Zr.indexOf("pdf"))>-1?gt.replaceSelection('').concat(Nt.name,"")):q.includes(yi)?gt.replaceSelection('').concat(Nt.name,"")):gt.replaceSelection("[".concat(Nt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(zt.id,"?type=").concat(zt.content_type,")"))}else(zt==null?void 0:zt.status)===401&&(document.location.href="/user/login")})},Bt=0;Bt0||Bt.target.offsetWidth>0)&&(zi(),K.setSize("100%","100%"),K.refresh())}}catch(lr){Ht.e(lr)}finally{Ht.f()}});return xt.observe(sr.current.parentElement),xt}if(K){var Dt=gt();return function(){Dt.unobserve(sr.current.parentElement)}}},[K,zi]),Object(v.useEffect)(function(){if(K){for(var gt=[],Dt=function(){var Bt=Pt[xt];Ht=Object(H.a)(Bt,2);var lr=Ht[0],Rr=Ht[1],Nt=Object(F.a)({},lr,function(){Ki(Rr)});gt.push(Nt),K.addKeyMap(Nt)},xt=0,Pt=Object.entries(re);xt0){var gt=new Date().getTime(),Dt=window.sessionStorage.getItem(ir);gt>=ci+Le&&(!Dt||Dt!==rt)&&(window.sessionStorage.setItem(ir,rt),er(!0))}},Le),Object(v.useEffect)(function(){$t(Tt)},[K,Tt]),Object(v.useEffect)(function(){K&&(Lt&&K.focus())},[K,Lt]),Object(v.useEffect)(function(){if(It&&K){var gt=K.getScrollerElement();function Dt(xt){var Pt=xt.target;if(nr.current){var Ht=Pt.scrollTop/Pt.scrollHeight;nr.current.scrollTop=nr.current.scrollHeight*Ht}}return gt.addEventListener("scroll",Dt),function(){gt.removeEventListener("scroll",Dt)}}},[K,It]),Object(v.useEffect)(function(){if(K&&Sr){function gt(Dt,xt){Sr(Dt,xt)}return K.on("beforeChange",gt),function(){K.off("beforeChange",gt)}}},[K,Sr]),Object(v.useEffect)(function(){if(K&&Gt){function gt(){Gt(K.getValue())}return K.on("blur",gt),function(){K.off("blur",gt)}}},[K,Gt]),Object(v.useEffect)(function(){if(K){function gt(Dt){var xt=Dt.getValue();pt(xt),ni(new Date().getTime()),Dt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),ft&&ft(xt)}return K.on("change",gt),function(){K.off("change",gt)}}},[K,ft]),Object(v.useEffect)(function(){K&&(ze==null?(K.setValue(""),pt("")):ze!==K.getValue()&&(K.setValue(ze),pt(ze),K.setCursor(K.lineCount(),0)))},[K,ze]);var Ki=Object(v.useCallback)(function(gt){var Dt=K.getCursor(),xt=K.getSelection(),Pt=xt.split(` `);switch(gt){case"bold":return K.replaceSelection("**"+xt+"**"),xt===""&&K.setCursor(Dt.line,Dt.ch+2),K.focus();case"italic":return K.replaceSelection("*"+xt+"*"),xt===""&&K.setCursor(Dt.line,Dt.ch+1),K.focus();case"code":return K.replaceSelection("`"+xt+"`"),xt===""&&K.setCursor(Dt.line,Dt.ch+1),K.focus();case"inline-latex":return K.replaceSelection("`$$"+xt+"$$`"),xt===""&&K.setCursor(Dt.line,Dt.ch+3),K.focus();case"latex":return K.replaceSelection("```latex\n"+xt+"\n```"),K.setCursor(Dt.line+1,xt.length+1),K.focus();case"line-break":return K.replaceSelection(`
    `),K.focus();case"list-ul":return xt===""?K.replaceSelection("- "+xt):K.replaceSelection(Pt.map(function(Ht){return Ht===""?"":"- ".concat(Ht)}).join(` `)),K.focus();case"list-ol":return xt===""?K.replaceSelection("1. "+xt):K.replaceSelection(Pt.map(function(Ht,Xt){return Ht===""?"":"".concat(Xt+1,". ").concat(Ht)}).join(` `)),K.focus();case"add-null-ch":return xt===""&&K.setCursor(Dt.line,Dt.ch+1),K.replaceSelection(Ie),K.focus();case"inster-template-1":return xt===""&&K.setCursor(Dt.line,Dt.ch),K.replaceSelection(pe),K.focus();case"eraser":return K.setValue(""),K.focus();case"trigger-watch":return $t(!It),K.focus();case"trigger-full-screen":return Yr(!hr),K.focus();case Be:Ur(Be);return;case We:Ur(We);return;case ht:Ur(ht);return;case Pe:Ur(Pe);return;default:throw new Error}},[K,It,hr]),vi=Object(v.useCallback)(function(gt){Ur("");switch(Gr){case Be:var Dt=gt.title,xt=gt.link;return K.replaceSelection("[".concat(Dt,"](").concat(xt,")")),K.focus();case We:var Pt=gt.language,Ht=gt.content;return K.replaceSelection(["```"+Pt,Ht,"```"].join(` `)),K.focus();case ht:var Xt=gt.src,Bt=gt.alt,lr=gt.name;return Xt.indexOf("type=image")>-1?K.replaceSelection("![ ".concat(Bt||""," ]( ").concat(Xt,' "').concat(Bt||"",'" )')):Xt.indexOf("type=application/pdf")>-1?K.replaceSelection('').concat(lr,"")):K.replaceSelection('').concat(lr,"")),K.focus();case Pe:for(var Rr=gt.row,Nt=gt.col,yi=gt.align,zt=` `,pr=0;pr300&&(lr=300);var Rr=$e+lr+"px";zr(Rr)}}return gt.addEventListener("mousedown",Pt),document.addEventListener("mousemove",Xt),document.addEventListener("mouseup",Ht),function(){gt.removeEventListener("mousedown",Pt),document.removeEventListener("mousemove",Xt),document.removeEventListener("mouseup",Ht)}}},[K,ai]),Object(v.useEffect)(function(){zr($e)},[$e]);var fn=le(At),ei=le(qr),Vi={width:fn,height:ei},jn=Object(v.useMemo)(function(){if(ci){var gt=new Date(ci),Dt=gt.getHours(),xt=gt.getMinutes(),Pt=gt.getSeconds();return Dt=Dt<10?"0"+Dt:Dt,xt=xt<10?"0"+xt:xt,Pt=Pt<10?"0"+Pt:Pt,"".concat(Dt,":").concat(xt,":").concat(Pt)}return 0},[ci]);function ki(){window.sessionStorage.removeItem(ir),er(!1),ni(0)}function $a(){er(!1),ni(0),K.setValue(window.sessionStorage.getItem(ir))}function da(gt,Dt){var xt=K.getValue();xt=xt.replace(gt,Dt),pt(xt),K==null||K.setValue(xt)}return C.a.createElement(v.Fragment,null,C.a.createElement("div",{className:"markdown-editor-wrapper",ref:Kt},C.a.createElement("div",{className:"markdown-editor-container ".concat(_t," ").concat(It?"on-preview":""," ").concat(yt?"mini":""," ").concat(hr?"full-screen":""),style:Vi},C.a.createElement(S,{insertTemp:wr,watch:It,fullScreen:hr,showNullButton:st,onActionCallback:Ki,hidetoolBar:jt,uuid:Wt.current,setOpenPhones:function(){br.current=!0}}),C.a.createElement("div",{className:"markdown-editor-body"},C.a.createElement("div",{className:"codemirror-container"},C.a.createElement("textarea",{ref:sr,placeholder:_i})),It?C.a.createElement("div",{ref:nr,className:"preview-container"},vt==="stex"&&C.a.createElement(_,{value:rt}),vt!=="stex"&&C.a.createElement(p.a,{edit:!0,value:rt,replaces:da})):null))),Nr?C.a.createElement("a",{ref:ai,className:"editor-resize"}):null,C.a.createElement(P.a,null,ne[Gr]?C.a.createElement(Z.a,{centered:!0,title:ne[Gr],visible:!0,onCancel:Br,footer:null},Fn):null))}},SJMd:function(Ct,dt){/** * @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 ie,ae,Z,R=!1,X,I;window.PR_SHOULD_USE_CONTINUATION=!0;var D,H;(function(){var F=window,M=["break,continue,do,else,for,if,return,while"],O=[M,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],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"],A=[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"],E="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",w=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],d="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",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"],L=[C,A,k,w,d,o,l,h],f=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,p="str",_="kwd",b="com",g="typ",c="lit",u="pun",a="pln",x="tag",y="dec",S="src",P="atn",G="atv",Y="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(Ae){for(var Me=0,je=!1,et=!1,Xe=0,Ne=Ae.length;Xe122||(te<65||ue>90||tt.push([Math.max(65,ue)|32,Math.min(te,90)|32]),te<97||ue>122||tt.push([Math.max(97,ue)&~32,Math.min(te,122)&~32]))}}tt.sort(function(ye,ge){return ye[0]-ge[0]||ge[1]-ye[1]});for(var q=[],re=[],Ie=0;Iene[0]&&(ne[1]+1>ne[0]&&Le.push("-"),Le.push(Pe(ne[1])))}return Le.push("]"),Le.join("")}function qe(it){for(var Ce=it.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")),tt=Ce.length,nt=[],Le=0,Ie=0;Le=2&&ue==="["?Ce[Le]=Ke(pe):ue!=="\\"&&(Ce[Le]=pe.replace(/[a-zA-Z]/g,function(re){var ne=re.charCodeAt(0);return"["+String.fromCharCode(ne&~32,ne|32)+"]"}))}return Ce.join("")}for(var Ve=[],Xe=0,Ne=Ae.length;Xe=0;)je[Ve.charAt(it)]=qe;var Ce=qe[1],tt=""+Ce;We.hasOwnProperty(tt)||(ht.push(Ce),We[tt]=null)}ht.push(/[\0-\uffff]/),et=z(ht)})();var Xe=Me.length,Ne=function(Be){for(var ht=Be.sourceCode,We=Be.basePos,Pe=Be.sourceNode,Ke=[We,a],qe=0,Ve=ht.match(et)||[],it={},Ce=0,tt=Ve.length;Ce=5&&Le.substring(0,5)==="lang-",pe&&!(Ie&&typeof Ie[1]=="string")&&(pe=!1,Le=S),pe||(it[nt]=Le)}var te=qe;if(qe+=nt.length,!pe)Ke.push(We+te,Le);else{var q=Ie[1],re=nt.indexOf(q),ne=re+q.length;Ie[2]&&(ne=nt.length-Ie[2].length,re=ne-q.length);var ye=Le.substring(5);ee(Pe,We+te,nt.substring(0,re),Ne,Ke),ee(Pe,We+te+re,q,de(ye,q),Ke),ee(Pe,We+te+ne,nt.substring(ne),Ne,Ke)}}Be.decorations=Ke};return Ne}function Re(Ae){var Me=[],je=[];Ae.tripleQuotedStrings?Me.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Ae.multiLineStrings?Me.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Me.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Ae.verbatimStrings&&je.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var et=Ae.hashComments;et&&(Ae.cStyleComments?(et>1?Me.push([b,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([b,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),je.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([b,/^#[^\r\n]*/,null,"#"])),Ae.cStyleComments&&(je.push([b,/^\/\/[^\r\n]*/,null]),je.push([b,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Xe=Ae.regexLiterals;if(Xe){var Ne=Xe>1?"":` \r`,Be=Ne?".":"[\\S\\s]",ht="/(?=[^/*"+Ne+"])(?:[^/\\x5B\\x5C"+Ne+"]|\\x5C"+Be+"|\\x5B(?:[^\\x5C\\x5D"+Ne+"]|\\x5C"+Be+")*(?:\\x5D|$))+/";je.push(["lang-regex",RegExp("^"+Q+"("+ht+")")])}var We=Ae.types;We&&je.push([g,We]);var Pe=(""+Ae.keywords).replace(/^ | $/g,"");Pe.length&&je.push([_,new RegExp("^(?:"+Pe.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([a,/^\s+/,null,` \r \xA0`]);var Ke="^.[^\\s\\w.$@'\"`/\\\\]*";return Ae.regexLiterals&&(Ke+="(?!s*/)"),je.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[g,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[u,new RegExp(Ke),null]),ve(Me,je)}var Ee=Re({keywords:L,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Se(Ae,Me,je){for(var et=/(?:^|\s)nocode(?:\s|$)/,Xe=/\r\n?|\n/,Ne=Ae.ownerDocument,Be=Ne.createElement("li");Ae.firstChild;)Be.appendChild(Ae.firstChild);var ht=[Be];function We(Ce){var tt=Ce.nodeType;if(tt==1&&!et.test(Ce.className))if(Ce.nodeName==="br")Pe(Ce),Ce.parentNode&&Ce.parentNode.removeChild(Ce);else for(var nt=Ce.firstChild;nt;nt=nt.nextSibling)We(nt);else if((tt==3||tt==4)&&je){var Le=Ce.nodeValue,Ie=Le.match(Xe);if(Ie){var pe=Le.substring(0,Ie.index);Ce.nodeValue=pe;var le=Le.substring(Ie.index+Ie[0].length);if(le){var ue=Ce.parentNode;ue.insertBefore(Ne.createTextNode(le),Ce.nextSibling)}Pe(Ce),pe||Ce.parentNode.removeChild(Ce)}}}function Pe(Ce){for(;!Ce.nextSibling;)if(Ce=Ce.parentNode,!Ce)return;function tt(Ie,pe){var le=pe?Ie.cloneNode(!1):Ie,ue=Ie.parentNode;if(ue){var te=tt(ue,1),q=Ie.nextSibling;te.appendChild(le);for(var re=q;re;re=q)q=re.nextSibling,te.appendChild(re)}return le}for(var nt=tt(Ce.nextSibling,0),Le;(Le=nt.parentNode)&&Le.nodeType===1;)nt=Le;ht.push(nt)}for(var Ke=0;Ke=ue&&(We+=2),Ne>=te&&(qe+=2)}}finally{Le&&(Le.style.display=Ie)}}var Te={};function me(Ae,Me){for(var je=Me.length;--je>=0;){var et=Me[je];Te.hasOwnProperty(et)?F.console&&console.warn("cannot override language handler %s",et):Te[et]=Ae}}function de(Ae,Me){return Ae&&Te.hasOwnProperty(Ae)||(Ae=/^\s*]*(?:>|$)/],[b,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[u,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\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,`"'`]],[[x,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[u,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),me(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),me(Re({keywords:C,hashComments:!0,cStyleComments:!0,types:f}),["c","cc","cpp","cxx","cyc","m"]),me(Re({keywords:"null,true,false"}),["json"]),me(Re({keywords:A,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:f}),["cs"]),me(Re({keywords:k,cStyleComments:!0}),["java"]),me(Re({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(Re({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(Re({keywords:d,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(Re({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(Re({keywords:w,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(Re({keywords:E,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[p,/^[\s\S]+/]]),["regex"]);function ke(Ae){var Me=Ae.langExtension;try{var je=j(Ae.sourceNode,Ae.pre),et=je.sourceCode;Ae.sourceCode=et,Ae.spans=je.spans,Ae.basePos=0,de(Me,et)(Ae),we(Ae)}catch(Xe){F.console&&console.log(Xe&&Xe.stack||Xe)}}function Je(Ae,Me,je){var et=je||!1,Xe=Me||null,Ne=document.createElement("div");Ne.innerHTML="
    "+Ae+"
    ",Ne=Ne.firstChild,et&&Se(Ne,et,!0);var Be={langExtension:Xe,numberLines:et,sourceNode:Ne,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return ke(Be),Ne.innerHTML}function Ge(Ae,Me){var je=Me||document.body,et=je.ownerDocument||document;function Xe(le){return je.getElementsByTagName(le)}for(var Ne=[Xe("pre"),Xe("code"),Xe("xmp")],Be=[],ht=0;ht=15&&(C=!1,M=!0);var p=l&&(O||C&&(f==null||f<12.11)),_=R||H&&F>=9;function b(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var g=function(e,t){var i=e.className,r=b(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function c(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function u(e,t){return c(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var T=0;T=t)return N+(t-T);N+=V-T,N+=i-N%i,T=V+1}}var oe=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};oe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},oe.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i=t)return r+Math.min(N,t-n);if(n+=T-r,n+=i-n%i,r=T+1,n>=t)return r}}var me=[""];function de(e){for(;me.length<=e;)me.push(ke(me)+" ");return me[e]}function ke(e){return e[e.length-1]}function Je(e,t){for(var i=[],r=0;r"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ae.test(e))}function je(e,t){return t?t.source.indexOf("\\w")>-1&&Me(e)?!0:t.test(e):Me(e)}function et(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Xe=/[\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 Ne(e){return e.charCodeAt(0)>=768&&Xe.test(e)}function Be(e,t,i){for(;(i<0?t>0:ti?-1:1;;){if(t==i)return t;var n=(t+i)/2,T=r<0?Math.ceil(n):Math.floor(n);if(T==t)return e(T)?t:i;e(T)?i=T:t=T+r}}function We(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,T=0;Tt||t==i&&N.to==t)&&(r(Math.max(N.from,t),Math.min(N.to,i),N.level==1?"rtl":"ltr",T),n=!0)}n||r(t,i,"ltr")}var Pe=null;function Ke(e,t,i){var r;Pe=null;for(var n=0;nt)return n;T.to==t&&(T.from!=T.to&&i=="before"?r=n:Pe=n),T.from==t&&(T.from!=T.to&&i!="before"?r=n:Pe=n)}return r!=null?r:Pe}var qe=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(J){return J<=247?e.charAt(J):1424<=J&&J<=1524?"R":1536<=J&&J<=1785?t.charAt(J-1536):1774<=J&&J<=2220?"r":8192<=J&&J<=8203?"w":J==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,T=/[LRr]/,N=/[Lb1n]/,V=/[1n]/;function $(J,se,he){this.level=J,this.from=se,this.to=he}return function(J,se){var he=se=="ltr"?"L":"R";if(J.length==0||se=="ltr"&&!r.test(J))return!1;for(var xe=J.length,be=[],De=0;De-1&&(r[t]=n.slice(0,T).concat(n.slice(T+1)))}}}function Le(e,t){var i=tt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n0}function ue(e){e.prototype.on=function(t,i){Ce(this,t,i)},e.prototype.off=function(t,i){nt(this,t,i)}}function te(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function q(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function re(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ne(e){te(e),q(e)}function ye(e){return e.target||e.srcElement}function ge(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 _e=function(){if(H&&F<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),ze;function ft(e){if(ze==null){var t=a("span","\u200B");u(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(ze=t.offsetWidth<=1&&t.offsetHeight>2&&!(H&&F<8))}var i=ze?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var lt;function At(e){if(lt!=null)return lt;var t=u(e,document.createTextNode("A\u062EA")),i=y(t,0,1).getBoundingClientRect(),r=y(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:lt=r.right-i.right<3}var Et=` 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 T=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=T.indexOf("\r");N!=-1?(i.push(T.slice(0,N)),t+=N+1):(i.push(T),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},$e=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Rt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),yt=null;function Ot(e){if(yt!=null)return yt;var t=u(e,a("span","x")),i=t.getBoundingClientRect(),r=y(t,0,1).getBoundingClientRect();return yt=Math.abs(i.left-r.left)>1}var Lt={},Tt={};function wr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Lt[e]=t}function fr(e,t){Tt[e]=t}function vt(e){if(typeof e=="string"&&Tt.hasOwnProperty(e))e=Tt[e];else if(e&&typeof e.name=="string"&&Tt.hasOwnProperty(e.name)){var t=Tt[e.name];typeof t=="string"&&(t={name:t}),e=Ye(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return 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 rr(e,t){t=vt(t);var i=Lt[t.name];if(!i)return rr(e,"text/plain");var r=i(e,t);if(ir.hasOwnProperty(t.name)){var n=ir[t.name];for(var T in n){if(!n.hasOwnProperty(T))continue;r.hasOwnProperty(T)&&(r["_"+T]=r[T]),r[T]=n[T]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var N in t.modeProps)r[N]=t.modeProps[N];return r}var ir={};function or(e,t){var i=ir.hasOwnProperty(e)?ir[e]:ir[e]={};j(t,i)}function Nr(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 Xr(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 Jr(e,t,i){return e.startState?e.startState(t,i):!0}var ct=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};ct.prototype.eol=function(){return this.pos>=this.string.length},ct.prototype.sol=function(){return this.pos==this.lineStart},ct.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ct.prototype.next=function(){if(this.post},ct.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},ct.prototype.skipToEnd=function(){this.pos=this.string.length},ct.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},ct.prototype.backUp=function(e){this.pos-=e},ct.prototype.column=function(){return this.lastColumnPos0?null:(T&&t!==!1&&(this.pos+=T[0].length),T)}},ct.prototype.current=function(){return this.string.slice(this.start,this.pos)},ct.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},ct.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},ct.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function st(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],T=n.chunkSize();if(t=e.first&&ti?He(i,st(e,i).text.length):m(t,st(e,t.line).text.length)}function m(e,t){var i=e.ch;return i==null||i>t?He(e.line,t):i<0?He(e.line,0):e}function U(e,t){for(var i=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},B.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}},B.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},B.fromSaved=function(e,t,i){return t instanceof K?new B(e,Nr(e.mode,t.state),i,t.lookAhead):new B(e,Nr(e.mode,t),i)},B.prototype.save=function(e){var t=e!==!1?Nr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new K(t,this.maxLookAhead):t};function ce(e,t,i,r){var n=[e.state.modeGen],T={};Hr(e,t.text,e.doc.mode,i,function(J,se){return n.push(J,se)},T,r);for(var N=i.state,V=function(J){i.baseTokens=n;var se=e.state.overlays[J],he=1,xe=0;i.state=!0,Hr(e,t.text,se.mode,i,function(be,De){for(var Fe=he;xebe&&n.splice(he,1,be,n[he+1],Ze),he+=2,xe=Math.min(be,Ze)}if(!De)return;if(se.opaque)n.splice(Fe,he-Fe,be,"overlay "+De),he=Fe+2;else for(;Fee.options.maxHighlightLength&&Nr(e.doc.mode,r.state),T=ce(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=T.styles,T.classes?t.styleClasses=T.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 rt(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new B(r,!0,t);var T=hr(e,t,i),N=T>r.first&&st(r,T-1).stateAfter,V=N?B.fromSaved(r,N,T):new B(r,Jr(r.mode),T);return r.iter(T,t,function($){pt(e,$.text,V);var J=V.line;$.stateAfter=J==t-1||J%5==0||J>=n.viewFrom&&Jt.start)return T}throw new Error("Mode "+e.name+" failed to advance stream.")}var It=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function $t(e,t,i,r){var n=e.doc,T=n.mode,N;t=s(n,t);var V=st(n,t.line),$=rt(e,t.line,i),J=new ct(V.text,e.options.tabSize,$),se;for(r&&(se=[]);(r||J.pose.options.maxHighlightLength?(V=!1,N&&pt(e,t,r,se.pos),se.pos=t.length,he=null):he=Wr(wt(i,se,r.state,xe),T),xe){var be=xe[0].name;be&&(he="m-"+(he?be+" "+he:be))}if(!V||J!=he){for(;$N;--V){if(V<=T.first)return T.first;var $=st(T,V-1),J=$.stateAfter;if(J&&(!i||V+(J instanceof K?J.lookAhead:0)<=T.modeFrontier))return V;var se=ee($.text,null,e.options.tabSize);(n==null||r>se)&&(n=V-1,r=se)}return n}function Yr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontieri;r--){var n=st(e,r).stateAfter;if(n&&(!(n instanceof K)||r+n.lookAhead=t:T.to>t);(r||(r=[])).push(new gi(N,T.from,$?null:T.to))}}return r}function Gi(e,t,i){var r;if(e)for(var n=0;n=t:T.to>t);if(V||T.from==t&&N.type=="bookmark"&&(!i||T.marker.insertLeft)){var $=T.from==null||(N.inclusiveLeft?T.from<=t:T.from0&&V)for(var mt=0;mt0)continue;var se=[$,1],he=_t(J.from,V.from),xe=_t(J.to,V.to);(he<0||!N.inclusiveLeft&&!he)&&se.push({from:J.from,to:V.from}),(xe>0||!N.inclusiveRight&&!xe)&&se.push({from:V.to,to:J.to}),n.splice.apply(n,se),$+=se.length-3}return n}function Ri(e){var t=e.markedSpans;if(!t)return;for(var i=0;it)&&(!r||br(r,T.marker)<0)&&(r=T.marker)}return r}function nr(e,t,i,r,n){var T=st(e,t),N=_r&&T.markedSpans;if(N)for(var V=0;V=0&&he<=0||se<=0&&he>=0)continue;if(se<=0&&($.marker.inclusiveRight&&n.inclusiveLeft?_t(J.to,i)>=0:_t(J.to,i)>0)||se>=0&&($.marker.inclusiveRight&&n.inclusiveLeft?_t(J.from,r)<=0:_t(J.from,r)<0))return!0}}function Dr(e){for(var t;t=sr(e);)e=t.find(-1,!0).line;return e}function zi(e){for(var t;t=Kt(e);)e=t.find(1,!0).line;return e}function Ki(e){for(var t,i;t=Kt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function vi(e,t){var i=st(e,t),r=Dr(i);return i==r?t:kt(r)}function Fn(e,t){if(t>e.lastLine())return t;var i=st(e,t),r;if(!Br(e,i))return t;for(;r=Kt(i);)i=r.find(1,!0).line;return kt(i)+1}function Br(e,t){var i=_r&&t.markedSpans;if(i)for(var r=void 0,n=0;nt.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var ki=function(e,t,i){this.text=e,cn(this,t),this.height=i?i(this):1};ki.prototype.lineNo=function(){return kt(this)},ue(ki);function $a(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Ri(e),cn(e,i);var n=r?r(e):1;n!=e.height&&Ut(e,n)}function da(e){e.parent=null,Ri(e)}var gt={},Dt={};function xt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Dt:gt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Pt(e,t){var i=x("span",null,null,M?"padding-right: .1px":null),r={pre:x("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 T=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=Xt,At(e.display.measure)&&(N=Ve(T,e.doc.direction))&&(r.addToken=lr(r.addToken,N)),r.map=[];var V=t!=e.display.externalMeasured&&kt(T);Nt(T,r,Oe(e,T,V)),T.styleClasses&&(T.styleClasses.bgClass&&(r.bgClass=Y(T.styleClasses.bgClass,r.bgClass||"")),T.styleClasses.textClass&&(r.textClass=Y(T.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(ft(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(M){var $=r.content.lastChild;(/\bcm-tab\b/.test($.className)||$.querySelector&&$.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Le(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=Y(r.pre.className,r.textClass||"")),r}function Ht(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 Xt(e,t,i,r,n,T,N){if(!t)return;var V=e.splitSpaces?Bt(t,e.trailingSpace):t,$=e.cm.state.specialChars,J=!1,se;if(!$.test(t))e.col+=t.length,se=document.createTextNode(V),e.map.push(e.pos,e.pos+t.length,se),H&&F<9&&(J=!0),e.pos+=t.length;else{se=document.createDocumentFragment();for(var he=0;;){$.lastIndex=he;var xe=$.exec(t),be=xe?xe.index-he:t.length-he;if(be){var De=document.createTextNode(V.slice(he,he+be));H&&F<9?se.appendChild(a("span",[De])):se.appendChild(De),e.map.push(e.pos,e.pos+be,De),e.col+=be,e.pos+=be}if(!xe)break;he+=be+1;var Fe=void 0;if(xe[0]==" "){var Ze=e.cm.options.tabSize,at=Ze-e.col%Ze;Fe=se.appendChild(a("span",de(at),"cm-tab")),Fe.setAttribute("role","presentation"),Fe.setAttribute("cm-text"," "),e.col+=at}else xe[0]=="\r"||xe[0]==` `?(Fe=se.appendChild(a("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Fe.setAttribute("cm-text",xe[0]),e.col+=1):(Fe=e.cm.options.specialCharPlaceholder(xe[0]),Fe.setAttribute("cm-text",xe[0]),H&&F<9?se.appendChild(a("span",[Fe])):se.appendChild(Fe),e.col+=1);e.map.push(e.pos,e.pos+1,Fe),e.pos++}}if(e.trailingSpace=V.charCodeAt(t.length-1)==32,i||r||n||J||T||N){var ut=i||"";r&&(ut+=r),n&&(ut+=n);var ot=a("span",[se],ut,T);if(N)for(var mt in N)N.hasOwnProperty(mt)&&mt!="style"&&mt!="class"&&ot.setAttribute(mt,N[mt]);return e.content.appendChild(ot)}e.content.appendChild(se)}function Bt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;nJ&&he.from<=J);xe++);if(he.to>=se)return e(i,r,n,T,N,V,$);e(i,r.slice(0,he.to-J),n,T,null,V,$),T=null,r=r.slice(he.to-J),J=he.to}}}function Rr(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 Nt(e,t,i){var r=e.markedSpans,n=e.text,T=0;if(!r){for(var N=1;N$||Mt.collapsed&&bt.to==$&&bt.from==$)){if(bt.to!=null&&bt.to!=$&&be>bt.to&&(be=bt.to,Fe=""),Mt.className&&(De+=" "+Mt.className),Mt.css&&(xe=(xe?xe+";":"")+Mt.css),Mt.startStyle&&bt.from==$&&(Ze+=" "+Mt.startStyle),Mt.endStyle&&bt.to==be&&(mt||(mt=[])).push(Mt.endStyle,bt.to),Mt.title&&((ut||(ut={})).title=Mt.title),Mt.attributes)for(var Zt in Mt.attributes)(ut||(ut={}))[Zt]=Mt.attributes[Zt];Mt.collapsed&&(!at||br(at.marker,Mt)<0)&&(at=bt)}else bt.from>$&&be>bt.from&&(be=bt.from)}if(mt)for(var vr=0;vr=V)break;for(var jr=Math.min(V,be);;){if(se){var Mr=$+se.length;if(!at){var ur=Mr>jr?se.slice(0,jr-$):se;t.addToken(t,ur,he?he+De:De,Ze,$+ur.length==be?Fe:"",xe,ut)}if(Mr>=jr){se=se.slice(jr-$),$=jr;break}$=Mr,Ze=""}se=n.slice(T,T=i[J++]),he=xt(i[J++],t.cm.options)}}}function yi(e,t,i){this.line=t,this.rest=Ki(t),this.size=this.rest?kt(ke(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Br(e,t)}function zt(e,t,i){for(var r=[],n,T=t;T2&&T.push(($.bottom+J.top)/2-i.top)}}T.push(i.bottom-i.top)}}function ro(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;ri)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=Dr(t);var i=kt(t),r=e.display.externalMeasured=new yi(e.doc,t,i);r.lineN=i;var n=r.built=Pt(e,r);return r.text=n.pre,u(e.display.lineMeasure,n.pre),r}function io(e,t,i,r){return si(e,Xi(e,t),i,r)}function pa(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(T=$-V,n=T-1,t>=$&&(N="right")),n!=null){if(r=e[J+2],V==$&&i==(r.insertLeft?"left":"right")&&(N=i),i=="left"&&n==0)for(;J&&e[J-2]==e[J-3]&&e[J-1].insertLeft;)r=e[(J-=3)+2],N="left";if(i=="right"&&n==$-V)for(;J=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=ao(t.map,i,r),T=n.node,N=n.start,V=n.end,$=n.collapse,J;if(T.nodeType==3){for(var se=0;se<4;se++){for(;N&&Ne(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+V0&&($=r="right");var he;e.options.lineWrapping&&(he=T.getClientRects()).length>1?J=he[r=="right"?he.length-1:0]:J=T.getBoundingClientRect()}if(H&&F<9&&!N&&(!J||!J.left&&!J.right)){var xe=T.parentNode.getClientRects()[0];xe?J={left:xe.left,right:xe.left+$i(e.display),top:xe.top,bottom:xe.bottom}:J=no}for(var be=J.top-t.rect.top,De=J.bottom-t.rect.top,Fe=(be+De)/2,Ze=t.view.measure.heights,at=0;at=r.text.length?($=r.text.length,J="before"):$<=0&&($=0,J="after"),!V)return N(J=="before"?$-1:$,J=="before");function se(De,Fe,Ze){var at=V[Fe],ut=at.level==1;return N(Ze?De-1:De,ut!=Ze)}var he=Ke(V,$,J),xe=Pe,be=se($,he,J=="before");return xe!=null&&(be.other=se($,xe,J!="before")),be}function co(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=st(e.doc,t.line),n=ei(r)+Hn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function va(e,t,i,r,n){var T=He(e,t,i);return T.xRel=n,r&&(T.outside=r),T}function ya(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return va(r.first,0,null,-1,-1);var n=Gt(r,i),T=r.first+r.size-1;if(n>T)return va(r.first+r.size-1,st(r,T).text.length,null,1,1);t<0&&(t=0);for(var N=st(r,n);;){var V=Gs(e,N,n,t,i),$=ai(N,V.ch+(V.xRel>0||V.outside>0?1:0));if(!$)return V;var J=$.find(1);if(J.line==n)return J;N=st(r,n=J.line)}}function fo(e,t,i,r){r-=ma(t);var n=t.text.length,T=ht(function(N){return si(e,i,N-1).bottom<=r},n,0);return n=ht(function(N){return si(e,i,N).top>r},T,n),{begin:T,end:n}}function po(e,t,i,r){i||(i=Xi(e,t));var n=Gn(e,t,si(e,i,r),"line").top;return fo(e,t,i,n)}function ba(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-=ei(t);var T=Xi(e,t),N=ma(t),V=0,$=t.text.length,J=!0,se=Ve(t,e.doc.direction);if(se){var he=(e.options.lineWrapping?Ks:zs)(e,t,i,T,se,r,n);J=he.level!=1,V=J?he.from:he.to-1,$=J?he.to:he.from-1}var xe=null,be=null,De=ht(function(St){var bt=si(e,T,St);return bt.top+=N,bt.bottom+=N,ba(bt,r,n,!1)?(bt.top<=n&&bt.left<=r&&(xe=St,be=bt),!0):!1},V,$),Fe,Ze,at=!1;if(be){var ut=r-be.left=mt.bottom?1:0}return De=Be(t.text,De,1),va(i,De,Ze,at,r-Fe)}function zs(e,t,i,r,n,T,N){var V=ht(function(he){var xe=n[he],be=xe.level!=1;return ba(ti(e,He(i,be?xe.to:xe.from,be?"before":"after"),"line",t,r),T,N,!0)},0,n.length-1),$=n[V];if(V>0){var J=$.level!=1,se=ti(e,He(i,J?$.from:$.to,J?"after":"before"),"line",t,r);ba(se,T,N,!0)&&se.top>N&&($=n[V-1])}return $}function Ks(e,t,i,r,n,T,N){var V=fo(e,t,r,N),$=V.begin,J=V.end;/\s/.test(t.text.charAt(J-1))&&J--;for(var se=null,he=null,xe=0;xe=J||be.to<=$)continue;var De=be.level!=1,Fe=si(e,r,De?Math.min(J,be.to)-1:Math.max($,be.from)).right,Ze=FeZe)&&(se=be,he=Ze)}return se||(se=n[n.length-1]),se.from<$&&(se={from:$,to:se.to,level:se.level}),se.to>J&&(se={from:se.from,to:J,level:se.level}),se}var Mi;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Mi==null){Mi=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Mi.appendChild(document.createTextNode("x")),Mi.appendChild(a("br"));Mi.appendChild(document.createTextNode("x"))}u(e.measure,Mi);var i=Mi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");u(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function xa(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,T=t.gutters.firstChild,N=0;T;T=T.nextSibling,++N){var V=e.display.gutterSpecs[N].className;i[V]=T.offsetLeft+T.clientLeft+n,r[V]=T.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function mo(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(Br(e.doc,n))return 0;var T=0;if(n.widgets)for(var N=0;N0&&(J=st(e.doc,$.line).text).length==$.ch){var se=ee(J,J.length,e.options.tabSize)-J.length;$=He($.line,Math.max(0,Math.round((T-to(e.display).left)/$i(e.display))-se))}return $}function Ii(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;rt)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)_r&&vi(e.doc,t)n.viewFrom?xi(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)xi(e);else if(t<=n.viewFrom){var T=zn(e,i,i+r,1);T?(n.view=n.view.slice(T.index),n.viewFrom=T.lineN,n.viewTo+=r):xi(e)}else if(i>=n.viewTo){var N=zn(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):xi(e)}else{var V=zn(e,t,t,-1),$=zn(e,i,i+r,1);V&&$?(n.view=n.view.slice(0,V.index).concat(zt(e,V.lineN,$.lineN)).concat(n.view.slice($.index)),n.viewTo+=r):xi(e)}var J=n.externalMeasured;J&&(i=n.lineN&&t=r.viewTo)return;var T=r.view[Ii(e,t)];if(T.node==null)return;var N=T.changes||(T.changes=[]);fe(N,i)==-1&&N.push(i)}function xi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,i,r){var n=Ii(e,t),T,N=e.display.view;if(!_r||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var V=e.display.viewFrom,$=0;$0){if(n==N.length-1)return null;T=V+N[n].size-t,n++}else T=V-t;t+=T,i+=T}for(;vi(e.doc,i)!=i;){if(n==(r<0?0:N.length-1))return null;i+=r*N[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=zt(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=zt(e,t,r.viewFrom).concat(r.view):r.viewFromi&&(r.view=r.view.slice(0,Ii(e,i)))),r.viewTo=i}function go(e){for(var t=e.display.view,i=0,r=0;r=e.display.viewTo||V.to().line0?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 bo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function xo(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||(Le(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()),Ca(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Le(e,"blur",e,t),e.state.focused=!1,g(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Vn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r.005||se<-.005)&&(Ut(n.line,N),Eo(n.line),n.rest))for(var he=0;hee.display.sizerWidth){var xe=Math.ceil(V/$i(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function Eo(e){if(e.widgets)for(var t=0;t=N&&(T=Gt(t,ei(st(t,$))-e.wrapper.clientHeight),N=$)}return{from:T,to:Math.max(N,T+1)}}function Ys(e,t){if(Ie(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&&!E){var T=a("div","\u200B",null,`position: absolute; top: `+(t.top-i.viewOffset-Hn(e.display))+`px; height: `+(t.bottom-t.top+oi(e)+i.barHeight)+`px; left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(T),T.scrollIntoView(n),e.display.lineSpace.removeChild(T)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?He(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?He(t.line,t.ch+1,"before"):t);for(var T=0;T<5;T++){var N=!1,V=ti(e,t),$=!i||i==t?V:ti(e,i);n={left:Math.min(V.left,$.left),top:Math.min(V.top,$.top)-r,right:Math.max(V.left,$.left),bottom:Math.max(V.bottom,$.bottom)+r};var J=wa(e,n),se=e.doc.scrollTop,he=e.doc.scrollLeft;if(J.scrollTop!=null&&(xn(e,J.scrollTop),Math.abs(e.doc.scrollTop-se)>1&&(N=!0)),J.scrollLeft!=null&&(Ni(e,J.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(N=!0)),!N)break}return n}function Zs(e,t){var i=wa(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Ni(e,i.scrollLeft)}function wa(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,T=fa(e),N={};t.bottom-t.top>T&&(t.bottom=t.top+T);var V=e.doc.height+ca(i),$=t.topV-r;if(t.topn+T){var se=Math.min(t.top,(J?V:t.bottom)-T);se!=n&&(N.scrollTop=se)}var he=e.options.fixedGutter?0:i.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-he,be=Oi(e)-i.gutters.offsetWidth,De=t.right-t.left>be;return De&&(t.right=t.left+be),t.left<10?N.scrollLeft=0:t.leftbe+xe-3&&(N.scrollLeft=t.right+(De?0:10)-be),N}function La(e,t){if(t==null)return;Yn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Yn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function bn(e,t,i){(t!=null||i!=null)&&Yn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Yn(e),e.curOp.scrollToPos=t}function Yn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=co(e,t.from),r=co(e,t.to);So(e,i,r,t.margin)}}function So(e,t,i,r){var n=wa(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});bn(e,n.scrollLeft,n.scrollTop)}function xn(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;R||_a(e,{top:t}),Co(e,t,!0),R&&_a(e),Cn(e,100)}function Co(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 Ni(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,_o(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function En(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(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+oi(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Ce(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ce(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,H&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var T=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+T)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.prototype.zeroWidthHack=function(){var e=l&&!A?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new oe,this.disableVert=new oe},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),T=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);T!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Sn=function(){};Sn.prototype.update=function(){return{bottom:0,right:0}},Sn.prototype.setScrollLeft=function(){},Sn.prototype.setScrollTop=function(){},Sn.prototype.clear=function(){};function Qi(e,t){t||(t=En(e));var i=e.display.barWidth,r=e.display.barHeight;To(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Vn(e),To(e,En(e)),i=e.display.barWidth,r=e.display.barHeight}function To(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 wo={native:Ui,null:Sn};function Lo(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&g(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new wo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ce(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"?Ni(e,t):xn(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function Bi(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},$r(e.curOp)}function Fi(e){var t=e.curOp;t&&Wn(t,function(i){for(var r=0;r=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new $n(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&&Vn(t),e.barMeasure=En(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=io(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+oi(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Oi(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=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=rt(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(T){if(r.line>=e.display.viewFrom){var N=T.styles,V=T.text.length>e.options.maxHighlightLength?Nr(t.mode,r.state):null,$=ce(e,T,r,!0);V&&(r.state=V),T.styles=$.styles;var J=T.styleClasses,se=$.classes;se?T.styleClasses=se:J&&(T.styleClasses=null);for(var he=!N||N.length!=T.styles.length||J!=se&&(!J||!se||J.bgClass!=se.bgClass||J.textClass!=se.textClass),xe=0;!he&&xei)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Fr(e,function(){for(var T=0;T=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&go(e)==0)return!1;Do(e)&&(xi(e),t.dims=xa(e));var n=r.first+r.size,T=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFromN&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),_r&&(T=vi(e.doc,T),N=Fn(e.doc,N));var V=T!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,T,N),i.viewOffset=ei(st(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var $=go(e);if(!V&&$==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var J=sl(e);return $>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),$>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(J),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,V&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function Ao(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Oi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ca(e.display)-fa(e),i.top)}),t.visible=Xn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xn(e.display,e.doc,i));if(!Aa(e,t))break;Vn(e);var n=En(e);yn(e),Qi(e,n),Ra(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 _a(e,t){var i=new $n(e,t);if(Aa(e,i)){Vn(e),Ao(e,i);var r=En(e);yn(e),Qi(e,r),Ra(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,T=r.lineDiv,N=T.firstChild;function V(De){var Fe=De.nextSibling;return M&&l&&e.display.currentWheelTarget==De?De.style.display="none":De.parentNode.removeChild(De),Fe}for(var $=r.view,J=r.viewFrom,se=0;se<$.length;se++){var he=$[se];if(!he.hidden)if(!he.node||he.node.parentNode!=T){var xe=Ns(e,he,J,i);T.insertBefore(xe,N)}else{for(;N!=he.node;)N=V(N);var be=n&&t!=null&&t<=J&&he.lineNumber;he.changes&&(fe(he.changes,"gutter")>-1&&(be=!1),Za(e,he,J,i)),be&&(c(he.lineNumber),he.lineNumber.appendChild(document.createTextNode(ui(e.options,J)))),N=he.node.nextSibling}J+=he.size}for(;N;)N=V(N)}function Da(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Ra(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+oi(e)+"px"}function _o(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,T=r+"px",N=0;NN.clientWidth,$=N.scrollHeight>N.clientHeight;if(!(r&&V||n&&$))return;if(n&&l&&M){e:for(var J=t.target,se=T.view;J!=N;J=J.parentNode)for(var he=0;he=0&&_t(e,r.to())<=0)return i}return-1};var Vt=function(e,t){this.anchor=e,this.head=t};Vt.prototype.from=function(){return _i(this.anchor,this.head)},Vt.prototype.to=function(){return hi(this.anchor,this.head)},Vt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function ri(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(xe,be){return _t(xe.from(),be.from())}),i=fe(t,n);for(var T=1;T0:$>=0){var J=_i(V.from(),N.from()),se=hi(V.to(),N.to()),he=V.empty()?N.from()==N.head:V.from()==V.head;T<=i&&--i,t.splice(--T,2,new Vt(he?se:J,he?J:se))}}return new Vr(t,i)}function Ei(e,t){return new Vr([new Vt(e,t||e)],0)}function Si(e){return e.text?He(e.from.line+e.text.length-1,ke(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Mo(e,t){if(_t(e,t.from)<0)return e;if(_t(e,t.to)<=0)return Si(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+=Si(t).ch-t.to.ch),He(i,r)}function Oa(e,t){for(var i=[],r=0;r1&&e.remove(V.line+1,De-1),e.insert(V.line+1,at)}xr(e,"change",e,t)}function Ci(e,t,i){function r(n,T,N){if(n.linked)for(var V=0;V1&&!e.done[e.done.length-2].ranges)return e.done.pop(),ke(e.done)}function Fo(e,t,i,r){var n=e.history;n.undone.length=0;var T=+new Date,N,V;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>T-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))V=ke(N.changes),_t(t.from,t.to)==0&&_t(t.from,V.to)==0?V.to=Si(t):N.changes.push(Ia(e,t));else{var $=ke(n.done);for((!$||!$.ranges)&&Qn(e.sel,n.done),N={changes:[Ia(e,t)],generation:n.generation},n.done.push(N);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=T,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,V||Le(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,T=r&&r.origin;i==n.lastSelOp||T&&n.lastSelOrigin==T&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==T||ml(e,T,ke(n.done),t))?n.done[n.done.length-1]=t:Qn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=T,n.lastSelOp=i,r&&r.clearRedo!==!1&&Bo(n.undone)}function Qn(e,t){var i=ke(t);i&&i.ranges&&i.equals(e)||t.push(e)}function jo(e,t,i,r){var n=t["spans_"+e.id],T=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(N){N.markedSpans&&((n||(n=t["spans_"+e.id]={}))[T]=N.markedSpans),++T})}function vl(e){if(!e)return null;for(var t,i=0;i-1&&(ke(V)[he]=J[he],delete J[he]))}}return r}function Na(e,t,i,r){if(r){var n=e.anchor;if(i){var T=_t(t,n)<0;T!=_t(i,n)<0?(n=t,t=i):T!=_t(t,i)<0&&(t=i)}return new Vt(n,t)}else return new Vt(i||t,t)}function qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Cr(e,new Vr([Na(e.sel.primary(),t,i,n)],0),r)}function Ho(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),T=0;T=t.ch:V.to>t.ch))){if(n&&(Le($,"beforeCursorEnter"),$.explicitlyCleared))if(T.markedSpans){--N;continue}else break;if(!$.atomic)continue;if(i){var he=$.find(r<0?1:-1),xe=void 0;if((r<0?se:J)&&(he=Yo(e,he,-r,he&&he.line==t.line?T:null)),he&&he.line==t.line&&(xe=_t(he,i))&&(r<0?xe<0:xe>0))return en(e,he,t,r,n)}var be=$.find(r<0?-1:1);return(r<0?J:se)&&(be=Yo(e,be,r,be.line==t.line?T:null)),be?en(e,be,t,r,n):null}}return t}function ta(e,t,i,r,n){var T=r||1,N=en(e,t,i,T,n)||!n&&en(e,t,i,T,!0)||en(e,t,i,-T,n)||!n&&en(e,t,i,-T,!0);return N||(e.cantEdit=!0,He(e.first,0))}function Yo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,He(t.line-1)):null:i>0&&t.ch==(r||st(e,t.line)).text.length?t.line=0;--n)Jo(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Jo(e,t)}function Jo(e,t){if(t.text.length==1&&t.text[0]==""&&_t(t.from,t.to)==0)return;var i=Oa(e,t);Fo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,qr(e,t));var r=[];Ci(e,function(n,T){!T&&fe(r,n.history)==-1&&(ts(n.history,t),r.push(n.history)),Ln(n,t,null,qr(n,t))})}function ra(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,T,N=e.sel,V=t=="undo"?n.done:n.undone,$=t=="undo"?n.undone:n.done,J=0;J=0;--be){var De=xe(be);if(De)return De.v}}function Qo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Vr(Je(e.sel.ranges,function(n){return new Vt(He(n.anchor.line+t,n.anchor.ch),He(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){kr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;re.lastLine())return;if(t.from.lineT&&(t={from:t.from,to:He(T,st(e,T).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Jt(e,t.from,t.to),i||(i=Oa(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),ea(e,i,Ee),e.cantEdit&&ta(e,He(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,T=t.from,N=t.to,V=!1,$=T.line;e.options.lineWrapping||($=kt(Dr(st(r,T.line))),r.iter($,N.line+1,function(be){if(be==n.maxLine)return V=!0,!0})),r.sel.contains(t.from,t.to)>-1&&pe(e),Pa(r,t,i,mo(e)),e.options.lineWrapping||(r.iter($,T.line+t.text.length,function(be){var De=Vi(be);De>n.maxLineLength&&(n.maxLine=be,n.maxLineLength=De,n.maxLineChanged=!0,V=!1)}),V&&(e.curOp.updateMaxLine=!0)),Yr(r,T.line),Cn(e,400);var J=t.text.length-(N.line-T.line)-1;t.full?kr(e):T.line==N.line&&t.text.length==1&&!Io(e.doc,t)?bi(e,T.line,"text"):kr(e,T.line,N.line+1,J);var se=le(e,"changes"),he=le(e,"change");if(he||se){var xe={from:T,to:N,text:t.text,removed:t.removed,origin:t.origin};he&&xr(e,"change",e,xe),se&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var T;r||(r=i),_t(r,i)<0&&(T=[r,i],i=T[0],r=T[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function qo(e,t,i,r){i1||!(this.children[0]instanceof _n))){var V=[];this.collapse(V),this.children=[new _n(V)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var N=n.lines.length%25+25,V=N;V10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=J,e.display.maxLineLength=se,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&kr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Vo(e.doc)),e&&xr(e,"markerCleared",e,this,r,n),t&&Fi(e),this.parent&&this.parent.clear()},Ti.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n0||N==0&&T.clearWhenEmpty!==!1)return T;if(T.replacedWith&&(T.collapsed=!0,T.widgetNode=x("span",[T.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||T.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(T.widgetNode.insertLeft=!0)),T.collapsed){if(nr(e,t.line,t,i,T)||t.line!=i.line&&nr(e,i.line,t,i,T))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ur()}T.addToHistory&&Fo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var V=t.line,$=e.cm,J;if(e.iter(V,i.line+1,function(he){$&&T.collapsed&&!$.options.lineWrapping&&Dr(he)==$.display.maxLine&&(J=!0),T.collapsed&&V!=t.line&&Ut(he,0),ni(he,new gi(T,V==t.line?t.ch:null,V==i.line?i.ch:null)),++V}),T.collapsed&&e.iter(t.line,i.line+1,function(he){Br(e,he)&&Ut(he,0)}),T.clearOnEnter&&Ce(T,"beforeCursorEnter",function(){return T.clear()}),T.readOnly&&(Gr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),T.collapsed&&(T.id=++is,T.atomic=!0),$){if(J&&($.curOp.updateMaxLine=!0),T.collapsed)kr($,t.line,i.line+1);else if(T.className||T.startStyle||T.endStyle||T.css||T.attributes||T.title)for(var se=t.line;se<=i.line;se++)bi($,se,"text");T.atomic&&Vo($.doc),xr($,"markerAdded",$,T)}return T}var kn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i=0;$--)tn(this,r[$]);V?zo(this,V):this.cm&&Ji(this.cm)}),undo:gr(function(){ra(this,"undo")}),redo:gr(function(){ra(this,"redo")}),undoSelection:gr(function(){ra(this,"undo",!0)}),redoSelection:gr(function(){ra(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.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(T){var N=T.markedSpans;if(N)for(var V=0;V=$.to||$.from==null&&n!=e.line||$.from!=null&&n==t.line&&$.from>=t.ch)&&(!i||i($.marker))&&r.push($.marker.parent||$.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;re)return t=e,!0;e-=T,++i}),s(this,He(i,t))},indexFromPos:function(e){e=s(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var se=e.dataTransfer.getData("Text");if(se){var he;if(t.state.draggingText&&!t.state.draggingText.copy&&(he=t.listSelections()),ea(t.doc,Ei(i,i)),he)for(var xe=0;xe=0;V--)rn(e.doc,"",r[V].from,r[V].to,"+delete");Ji(e)})}function Ba(e,t,i){var r=Be(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new He(t.line,r,i<0?"after":"before")}function ja(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var T=Ve(i,t.doc.direction);if(T){var N=n<0?ke(T):T[0],V=n<0==(N.level==1),$=V?"after":"before",J;if(N.level>0||t.doc.direction=="rtl"){var se=Xi(t,i);J=n<0?i.text.length-1:0;var he=si(t,se,J).top;J=ht(function(xe){return si(t,se,xe).top==he},n<0==(N.level==1)?N.from:N.to-1,J),$=="before"&&(J=Ba(i,J,1))}else J=n<0?N.to:N.from;return new He(r,J,$)}}return new He(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=Ve(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var T=Ke(n,i.ch,i.sticky),N=n[T];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from=N.from&&xe>=se.begin)){var be=he?"before":"after";return new He(i.line,xe,be)}}var De=function(at,ut,ot){for(var mt=function(Zt,vr){return vr?new He(i.line,V(Zt,1),"before"):new He(i.line,Zt,"after")};at>=0&&at0==(St.level!=1),Mt=bt?ot.begin:V(ot.end,-1);if(St.from<=Mt&&Mt0?se.end:V(se.begin,-1);return Ze!=null&&!(r>0&&Ze==t.text.length)&&(Fe=De(r>0?0:n.length-1,r,J(Ze)),Fe)?Fe:null}var Pn={selectAll:$o,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ee)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=st(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line0)n=new He(n.line,n.ch+1),e.replaceRange(T.charAt(n.ch-1)+T.charAt(n.ch-2),He(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=st(e.doc,n.line-1).text;N&&(n=new He(n.line,1),e.replaceRange(T.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),He(n.line-1,N.length-1),n,"+transpose"))}}i.push(new Vt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Fr(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;re&&_t(t,this.pos)==0&&i==this.button};var Nn,Un;function Wl(e,t){var i=+new Date;return Un&&Un.compare(i,e,t)?(Nn=Un=null,"triple"):Nn&&Nn.compare(i,e,t)?(Un=new Ha(i,e,t),Nn=null,"double"):(Nn=new Ha(i,e,t),Un=null,"single")}function bs(e){var t=this,i=t.display;if(Ie(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,fi(i,e)){M||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ga(t,e))return;var r=Pi(t,e),n=ge(e),T=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,T,e))return;n==1?r?zl(t,r,T,e):ye(e)==i.scroller&&te(e):n==2?(r&&qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(_?t.display.input.onContextMenu(e):xo(t))}function Hl(e,t,i,r,n){var T="Click";return r=="double"?T="Double"+T:r=="triple"&&(T="Triple"+T),T=(t==1?"Left":t==2?"Middle":"Right")+T,In(e,ds(T,n),n,function(N){if(typeof N=="string"&&(N=Pn[N]),!N)return!1;var V=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),V=N(e,i)!=Re}finally{e.state.suppressEdits=!1}return V})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var T=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=T?"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(bo,e),0):e.curOp.focus=P();var n=Gl(e,i,r),T=e.doc.sel,N;e.options.dragDrop&&_e&&!e.isReadOnly()&&i=="single"&&(N=T.contains(t))>-1&&(_t((N=T.ranges[N]).from(),t)<0||t.xRel>0)&&(_t(N.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,T=!1,N=mr(e,function(J){M&&(n.scroller.draggable=!1),e.state.draggingText=!1,nt(n.wrapper.ownerDocument,"mouseup",N),nt(n.wrapper.ownerDocument,"mousemove",V),nt(n.scroller,"dragstart",$),nt(n.scroller,"drop",N),T||(te(J),r.addNew||qn(e.doc,i,null,null,r.extend),M&&!k||H&&F==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),V=function(J){T=T||Math.abs(t.clientX-J.clientX)+Math.abs(t.clientY-J.clientY)>=10},$=function(){return T=!0};M&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Ce(n.wrapper.ownerDocument,"mouseup",N),Ce(n.wrapper.ownerDocument,"mousemove",V),Ce(n.scroller,"dragstart",$),Ce(n.scroller,"drop",N),xo(e),setTimeout(function(){return n.input.focus()},20)}function xs(e,t,i){if(i=="char")return new Vt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Vt(He(t.line,0),s(e.doc,He(t.line+1,0)));var r=i(e,t);return new Vt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,T=e.doc;te(t);var N,V,$=T.sel,J=$.ranges;if(r.addNew&&!r.extend?(V=T.sel.contains(i),V>-1?N=J[V]:N=new Vt(i,i)):(N=T.sel.primary(),V=T.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new Vt(i,i)),i=Pi(e,t,!0,!0),V=-1;else{var se=xs(e,i,r.unit);r.extend?N=Na(N,se.anchor,se.head,r.extend):N=se}r.addNew?V==-1?(V=J.length,Cr(T,ri(e,J.concat([N]),V),{scroll:!1,origin:"*mouse"})):J.length>1&&J[V].empty()&&r.unit=="char"&&!r.extend?(Cr(T,ri(e,J.slice(0,V).concat(J.slice(V+1)),0),{scroll:!1,origin:"*mouse"}),$=T.sel):Ua(T,V,N,Se):(V=0,Cr(T,new Vr([N],0),Se),$=T.sel);var he=i;function xe(ot){if(_t(he,ot)==0)return;if(he=ot,r.unit=="rectangle"){for(var mt=[],St=e.options.tabSize,bt=ee(st(T,i.line).text,i.ch,St),Mt=ee(st(T,ot.line).text,ot.ch,St),Zt=Math.min(bt,Mt),vr=Math.max(bt,Mt),qt=Math.min(i.line,ot.line),jr=Math.min(e.lastLine(),Math.max(i.line,ot.line));qt<=jr;qt++){var Mr=st(T,qt).text,ur=Te(Mr,Zt,St);Zt==vr?mt.push(new Vt(He(qt,ur),He(qt,ur))):Mr.length>ur&&mt.push(new Vt(He(qt,ur),He(qt,Te(Mr,vr,St))))}mt.length||mt.push(new Vt(i,i)),Cr(T,ri(e,$.ranges.slice(0,V).concat(mt),V),{origin:"*mouse",scroll:!1}),e.scrollIntoView(ot)}else{var Pr=N,Er=xs(e,ot,r.unit),cr=Pr.anchor,dr;_t(Er.anchor,cr)>0?(dr=Er.head,cr=_i(Pr.from(),Er.anchor)):(dr=Er.anchor,cr=hi(Pr.to(),Er.head));var tr=$.ranges.slice(0);tr[V]=Xl(e,new Vt(s(T,cr),dr)),Cr(T,ri(e,tr,V),Se)}}var be=n.wrapper.getBoundingClientRect(),De=0;function Fe(ot){var mt=++De,St=Pi(e,ot,!0,r.unit=="rectangle");if(!St)return;if(_t(St,he)!=0){e.curOp.focus=P(),xe(St);var bt=Xn(n,T);(St.line>=bt.to||St.linebe.bottom?20:0;Mt&&setTimeout(mr(e,function(){if(De!=mt)return;n.scroller.scrollTop+=Mt,Fe(ot)}),50)}}function Ze(ot){e.state.selectingText=!1,De=Infinity,ot&&(te(ot),n.input.focus()),nt(n.wrapper.ownerDocument,"mousemove",at),nt(n.wrapper.ownerDocument,"mouseup",ut),T.history.lastSelOrigin=null}var at=mr(e,function(ot){ot.buttons===0||!ge(ot)?Ze(ot):Fe(ot)}),ut=mr(e,Ze);e.state.selectingText=ut,Ce(n.wrapper.ownerDocument,"mousemove",at),Ce(n.wrapper.ownerDocument,"mouseup",ut)}function Xl(e,t){var i=t.anchor,r=t.head,n=st(e.doc,i.line);if(_t(i,r)==0&&i.sticky==r.sticky)return t;var T=Ve(n);if(!T)return t;var N=Ke(T,i.ch,i.sticky),V=T[N];if(V.from!=i.ch&&V.to!=i.ch)return t;var $=N+(V.from==i.ch==(V.level!=1)?0:1);if($==0||$==T.length)return t;var J;if(r.line!=i.line)J=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var se=Ke(T,r.ch,r.sticky),he=se-N||(r.ch-i.ch)*(V.level==1?-1:1);se==$-1||se==$?J=he<0:J=he>0}var xe=T[$+(J?-1:0)],be=J==(xe.level==1),De=be?xe.from:xe.to,Fe=be?"after":"before";return i.ch==De&&i.sticky==Fe?t:new Vt(new He(i.line,De,Fe),r)}function Es(e,t,i,r){var n,T;if(t.touches)n=t.touches[0].clientX,T=t.touches[0].clientY;else try{n=t.clientX,T=t.clientY}catch(xe){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&te(t);var N=e.display,V=N.lineDiv.getBoundingClientRect();if(T>V.bottom||!le(e,i))return re(t);T-=V.top-N.viewOffset;for(var $=0;$=n){var se=Gt(e.doc,T),he=e.display.gutterSpecs[$];return Le(e,i,e,se,he.className,t),re(t)}}}function Ga(e,t){return Es(e,t,"gutterClick",!0)}function Ss(e,t){if(fi(e.display,t)||Yl(e,t))return;if(Ie(e,t,"contextmenu"))return;_||e.display.input.onContextMenu(t)}function Yl(e,t){return le(e,"gutterContextMenu")?Es(e,t,"gutterContextMenu",!1):!1}function Cs(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),vn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ts={},oa={};function $l(e){var t=e.optionHandlers;function i(r,n,T,N){e.defaults[r]=n,T&&(t[r]=N?function(V,$,J){J!=sn&&T(V,$,J)}:T)}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,Ma(r)},!0),i("indentUnit",2,Ma,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){wn(r),vn(r),kr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var T=[],N=r.doc.first;r.doc.iter(function($){for(var J=0;;){var se=$.text.indexOf(n,J);if(se==-1)break;J=se+n.length,T.push(He(N,se))}N++});for(var V=T.length-1;V>=0;V--)rn(r.doc,n,T[V],He(T[V].line,T[V].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,T){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),T!=sn&&r.refresh()}),i("specialCharPlaceholder",Ht,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",!L),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Cs(r),Tn(r)},!0),i("keyMap","default",function(r,n,T){var N=na(n),V=T!=sn&&na(T);V&&V.detach&&V.detach(r,N),N.attach&&N.attach(r,V||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=ka(n,r.options.lineNumbers),Tn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Ea(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Qi(r)},!0),i("scrollbarStyle","native",function(r){Lo(r),Qi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=ka(r.options.gutters,n),Tn(r)},!0),i("firstLineNumber",1,Tn,!0),i("lineNumberFormatter",function(r){return r},Tn,!0),i("showCursorWhenSelecting",!1,yn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,yn,!0),i("singleCursorHeightPerLine",!0,yn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,wn,!0),i("addModeClass",!1,wn,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,wn,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,T=t?Ce:nt;T(e.display.scroller,"dragstart",n.start),T(e.display.scroller,"dragenter",n.enter),T(e.display.scroller,"dragover",n.over),T(e.display.scroller,"dragleave",n.leave),T(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(g(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Sa(e),kr(e),vn(e),setTimeout(function(){return Qi(e)},100)}function Qt(e,t){var i=this;if(!(this instanceof Qt))return new Qt(e,t);this.options=t=t?j(t):{},j(Ts,t,!1);var r=t.value;typeof r=="string"?r=new Or(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Qt.inputStyles[t.inputStyle](this),T=this.display=new dl(e,r,n,t);T.wrapper.CodeMirror=this,Cs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Lo(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new oe,keySeq:null,specialChars:null},t.autofocus&&!o&&T.input.focus(),H&&F<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),Bi(this),this.curOp.forceUpdate=!0,No(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var N in oa)oa.hasOwnProperty(N)&&oa[N](this,t[N],sn);Do(this),t.finishInit&&t.finishInit(this);for(var V=0;V20*20}Ce(t.scroller,"touchstart",function($){if(!Ie(e,$)&&!T($)&&!Ga(e,$)){t.input.ensurePolled(),clearTimeout(i);var J=+new Date;t.activeTouch={start:J,moved:!1,prev:J-r.end<=300?r:null},$.touches.length==1&&(t.activeTouch.left=$.touches[0].pageX,t.activeTouch.top=$.touches[0].pageY)}}),Ce(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ce(t.scroller,"touchend",function($){var J=t.activeTouch;if(J&&!fi(t,$)&&J.left!=null&&!J.moved&&new Date-J.start<300){var se=e.coordsChar(t.activeTouch,"page"),he;!J.prev||N(J,J.prev)?he=new Vt(se,se):!J.prev.prev||N(J,J.prev.prev)?he=e.findWordAt(se):he=new Vt(He(se.line,0),s(e.doc,He(se.line+1,0))),e.setSelection(he.anchor,he.head),e.focus(),te($)}n()}),Ce(t.scroller,"touchcancel",n),Ce(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Ni(e,t.scroller.scrollLeft,!0),Le(e,"scroll",e))}),Ce(t.scroller,"mousewheel",function($){return Oo(e,$)}),Ce(t.scroller,"DOMMouseScroll",function($){return Oo(e,$)}),Ce(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function($){Ie(e,$)||ne($)},over:function($){Ie(e,$)||(_l(e,$),ne($))},start:function($){return Al(e,$)},drop:mr(e,Ll),leave:function($){Ie(e,$)||os(e)}};var V=t.input.getField();Ce(V,"keyup",function($){return vs.call(e,$)}),Ce(V,"keydown",mr(e,gs)),Ce(V,"keypress",mr(e,ys)),Ce(V,"focus",function($){return Ta(e,$)}),Ce(V,"blur",function($){return Zi(e,$)})}var za=[];Qt.defineInitHook=function(e){return za.push(e)};function Bn(e,t,i,r){var n=e.doc,T;i==null&&(i="add"),i=="smart"&&(n.mode.indent?T=rt(e,t).state:i="prev");var N=e.options.tabSize,V=st(n,t),$=ee(V.text,null,N);V.stateAfter&&(V.stateAfter=null);var J=V.text.match(/^\s*/)[0],se;if(!r&&!/\S/.test(V.text))se=0,i="not";else if(i=="smart"&&(se=n.mode.indent(T,V.text.slice(J.length),V.text),se==Re||se>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?se=ee(st(n,t-1).text,null,N):se=0:i=="add"?se=$+e.options.indentUnit:i=="subtract"?se=$-e.options.indentUnit:typeof i=="number"&&(se=$+i),se=Math.max(0,se);var he="",xe=0;if(e.options.indentWithTabs)for(var be=Math.floor(se/N);be;--be)xe+=N,he+=" ";if(xeN,$=Et(t),J=null;if(V&&r.ranges.length>1)if(ii&&ii.text.join(` `)==t){if(r.ranges.length%ii.text.length==0){J=[];for(var se=0;se=0;xe--){var be=r.ranges[xe],De=be.from(),Fe=be.to();be.empty()&&(i&&i>0?De=He(De.line,De.ch-i):e.state.overwrite&&!V?Fe=He(Fe.line,Math.min(st(T,Fe.line).text.length,Fe.ch+ke($).length)):V&&ii&&ii.lineWise&&ii.text.join(` `)==$.join(` `)&&(De=Fe=He(De.line,0)));var Ze={from:De,to:Fe,text:J?J[xe%J.length]:$,origin:n||(V?"paste":e.state.cutIncoming>N?"cut":"+input")};tn(e.doc,Ze),xr(e,"inputRead",e,Ze)}t&&!V&&Ls(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=he),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function ws(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Fr(t,function(){return Ka(t,i,0,null,"paste")}),!0}function Ls(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 T=e.getModeAt(n.head),N=!1;if(T.electricChars){for(var V=0;V-1){N=Bn(e,n.head.line,"smart");break}}else T.electricInput&&(T.electricInput.test(st(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=Bn(e,n.head.line,"smart")));N&&xr(e,"electricInput",e,n.head.line)}}function As(e){for(var t=[],i=[],r=0;rT&&(Bn(this,V.head.line,r,!0),T=V.head.line,N==this.doc.sel.primIndex&&Ji(this));else{var $=V.from(),J=V.to(),se=Math.max(T,$.line);T=Math.min(this.lastLine(),J.line-(J.ch?0:1))+1;for(var he=se;he0&&Ua(this.doc,N,new Vt($,xe[N].to()),Ee)}}}),getTokenAt:function(r,n){return $t(this,r,n)},getLineTokens:function(r,n){return $t(this,He(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Oe(this,st(this.doc,r.line)),T=0,N=(n.length-1)/2,V=r.ch,$;if(V==0)$=n[2];else for(;;){var J=T+N>>1;if((J?n[J*2-1]:0)>=V)N=J;else if(n[J*2+1]$&&(r=$,N=!0),V=st(this.doc,r)}else V=r;return Gn(this,V,{top:0,left:0},n||"page",T||N).top+(N?this.doc.height-ei(V):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,T,N,V){var $=this.display;r=ti(this,s(this.doc,r));var J=r.bottom,se=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),$.sizer.appendChild(n),N=="over")J=r.top;else if(N=="above"||N=="near"){var he=Math.max($.wrapper.clientHeight,this.doc.height),xe=Math.max($.sizer.clientWidth,$.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>he)&&r.top>n.offsetHeight?J=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=he&&(J=r.bottom),se+n.offsetWidth>xe&&(se=xe-n.offsetWidth)}n.style.top=J+"px",n.style.left=n.style.right="",V=="right"?(se=$.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(V=="left"?se=0:V=="middle"&&(se=($.sizer.clientWidth-n.offsetWidth)/2),n.style.left=se+"px"),T&&Zs(this,{left:se,top:J,right:se+n.offsetWidth,bottom:J+n.offsetHeight})},triggerOnKeyDown:Lr(gs),triggerOnKeyPress:Lr(ys),triggerOnKeyUp:vs,triggerOnMouseDown:Lr(bs),execCommand:function(r){if(Pn.hasOwnProperty(r))return Pn[r].call(null,this)},triggerElectric:Lr(function(r){Ls(this,r)}),findPosH:function(r,n,T,N){var V=1;n<0&&(V=-1,n=-n);for(var $=s(this.doc,r),J=0;J0&&se(T.charAt(N-1));)--N;for(;V.5||this.options.lineWrapping)&&Sa(this),Le(this,"refresh",this)}),swapDoc:Lr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),No(this,r),vn(this),this.display.input.reset(),bn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,xr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},ue(e),e.registerHelper=function(r,n,T){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=T},e.registerGlobalHelper=function(r,n,T,N){e.registerHelper(r,n,N),i[r]._global.push({pred:T,val:N})}}function Va(e,t,i,r,n){var T=t,N=i,V=st(e,t.line),$=n&&e.direction=="rtl"?-i:i;function J(){var ut=t.line+$;return ut=e.first+e.size?!1:(t=new He(ut,t.ch,t.sticky),V=st(e,ut))}function se(ut){var ot;if(r=="codepoint"){var mt=V.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(mt)?ot=null:ot=new He(t.line,Math.max(0,Math.min(V.text.length,t.ch+i*(mt>=55296&&mt<56320?2:1))),-i)}else n?ot=Pl(e.cm,V,t,i):ot=Fa(V,t,i);if(ot==null)if(!ut&&J())t=ja(n,e.cm,V,t.line,$);else return!1;else t=ot;return!0}if(r=="char"||r=="codepoint")se();else if(r=="column")se(!0);else if(r=="word"||r=="group")for(var he=null,xe=r=="group",be=e.cm&&e.cm.getHelper(t,"wordChars"),De=!0;!(i<0&&!se(!De));De=!1){var Fe=V.text.charAt(t.ch)||` `,Ze=je(Fe,be)?"w":xe&&Fe==` `?"n":!xe||/\s/.test(Fe)?null:"p";if(xe&&!De&&!Ze&&(Ze="s"),he&&he!=Ze){i<0&&(i=1,se(),t.sticky="after");break}if(Ze&&(he=Ze),i>0&&!se(!De))break}var at=ta(e,t,T,N,!0);return di(T,at)&&(at.hitSide=!0),at}function Rs(e,t,i,r){var n=e.doc,T=t.left,N;if(r=="page"){var V=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),$=Math.max(V-.5*Yi(e.display),3);N=(i>0?t.bottom:t.top)+i*$}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var J;!(J=ya(e,T,N),!J.outside);){if(i<0?N<=0:N>=n.height){J.hitSide=!0;break}N+=i*5}return J}var Yt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new oe,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Yt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;_s(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function T(V){for(var $=V.target;$;$=$.parentNode){if($==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test($.className))break}return!1}Ce(n,"paste",function(V){if(!T(V)||Ie(r,V)||ws(V,r))return;F<=11&&setTimeout(mr(r,function(){return t.updateFromDOM()}),20)}),Ce(n,"compositionstart",function(V){t.composing={data:V.data,done:!1}}),Ce(n,"compositionupdate",function(V){t.composing||(t.composing={data:V.data,done:!1})}),Ce(n,"compositionend",function(V){t.composing&&(V.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ce(n,"touchstart",function(){return i.forceCompositionEnd()}),Ce(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(V){if(!T(V)||Ie(r,V))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()}),V.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var $=As(r);sa({lineWise:!0,text:$.text}),V.type=="cut"&&r.operation(function(){r.setSelections($.ranges,0,Ee),r.replaceSelection("",null,"cut")})}else return;if(V.clipboardData){V.clipboardData.clearData();var J=ii.text.join(` `);if(V.clipboardData.setData("Text",J),V.clipboardData.getData("Text")==J){V.preventDefault();return}}var se=Ds(),he=se.firstChild;r.display.lineSpace.insertBefore(se,r.display.lineSpace.firstChild),he.value=ii.text.join(` `);var xe=document.activeElement;Q(he),setTimeout(function(){r.display.lineSpace.removeChild(se),xe.focus(),xe==n&&i.showPrimarySelection()},50)}Ce(n,"copy",N),Ce(n,"cut",N)},Yt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Yt.prototype.prepareSelection=function(){var e=vo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Yt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Yt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Yt.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&&ks(t,r)||{node:V[0].measure.map[2],offset:0},J=n.linee.firstLine()&&(r=He(r.line-1,st(e.doc,r.line-1).length)),n.ch==st(e.doc,n.line).text.length&&n.linet.viewTo-1)return!1;var T,N,V;r.line==t.viewFrom||(T=Ii(e,r.line))==0?(N=kt(t.view[0].line),V=t.view[0].node):(N=kt(t.view[T].line),V=t.view[T-1].node.nextSibling);var $=Ii(e,n.line),J,se;if($==t.view.length-1?(J=t.viewTo-1,se=t.lineDiv.lastChild):(J=kt(t.view[$+1].line)-1,se=t.view[$+1].node.previousSibling),!V)return!1;for(var he=e.doc.splitLines(tu(e,V,se,N,J)),xe=Jt(e.doc,He(N,0),He(J,st(e.doc,J).text.length));he.length>1&&xe.length>1;)if(ke(he)==ke(xe))he.pop(),xe.pop(),J--;else if(he[0]==xe[0])he.shift(),xe.shift(),N++;else break;for(var be=0,De=0,Fe=he[0],Ze=xe[0],at=Math.min(Fe.length,Ze.length);ber.ch&&ut.charCodeAt(ut.length-De-1)==ot.charCodeAt(ot.length-De-1);)be--,De++;he[he.length-1]=ut.slice(0,ut.length-De).replace(/^\u200b+/,""),he[0]=he[0].slice(be).replace(/\u200b+$/,"");var St=He(N,be),bt=He(J,xe.length?ke(xe).length-De:0);if(he.length>1||he[0]||_t(St,bt))return rn(e.doc,he,St,bt,"+input"),!0},Yt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Yt.prototype.reset=function(){this.forceCompositionEnd()},Yt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Yt.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)},Yt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Fr(this.cm,function(){return kr(e.cm)})},Yt.prototype.setUneditable=function(e){e.contentEditable="false"},Yt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||mr(this.cm,Ka)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Yt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Yt.prototype.onContextMenu=function(){},Yt.prototype.resetPosition=function(){},Yt.prototype.needsContentAttribute=!0;function ks(e,t){var i=pa(e,t.line);if(!i||i.hidden)return null;var r=st(e.doc,t.line),n=ro(i,r,t.line),T=Ve(r,e.doc.direction),N="left";if(T){var V=Ke(T,t.ch);N=V%2?"right":"left"}var $=ao(n.map,t.ch,N);return $.offset=$.collapse=="right"?$.end:$.start,$}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var T="",N=!1,V=e.doc.lineSeparator(),$=!1;function J(be){return function(De){return De.id==be}}function se(){N&&(T+=V,$&&(T+=V),N=$=!1)}function he(be){be&&(se(),T+=be)}function xe(be){if(be.nodeType==1){var De=be.getAttribute("cm-text");if(De){he(De);return}var Fe=be.getAttribute("cm-marker"),Ze;if(Fe){var at=e.findMarks(He(r,0),He(n+1,0),J(+Fe));at.length&&(Ze=at[0].find(0))&&he(Jt(e.doc,Ze.from,Ze.to).join(V));return}if(be.getAttribute("contenteditable")=="false")return;var ut=/^(pre|div|p|li|table|br)$/i.test(be.nodeName);if(!/^br$/i.test(be.nodeName)&&be.textContent.length==0)return;ut&&se();for(var ot=0;ot=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Ce(n,"paste",function(N){if(Ie(r,N)||ws(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function T(N){if(Ie(r,N))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var V=As(r);sa({lineWise:!0,text:V.text}),N.type=="cut"?r.setSelections(V.ranges,null,Ee):(i.prevInput="",n.value=V.text.join(` `),Q(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Ce(n,"cut",T),Ce(n,"copy",T),Ce(e.scroller,"paste",function(N){if(fi(e,N)||Ie(r,N))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var V=new Event("paste");V.clipboardData=N.clipboardData,n.dispatchEvent(V)}),Ce(e.lineSpace,"selectstart",function(N){fi(e,N)||te(N)}),Ce(n,"compositionstart",function(){var N=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:N,range:r.markText(N,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ce(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},ar.prototype.createField=function(e){this.wrapper=Ds(),this.textarea=this.wrapper.firstChild},ar.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},ar.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=vo(e);if(e.options.moveInputWithCursor){var n=ti(e,i.sel.primary().head,"div"),T=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-T.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-T.left))}return r},ar.prototype.showSelection=function(e){var t=this.cm,i=t.display;u(i.cursorDiv,e.cursors),u(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},ar.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&&Q(this.textarea),H&&F>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",H&&F>=9&&(this.hasSelection=null))},ar.prototype.getField=function(){return this.textarea},ar.prototype.supportsTouch=function(){return!1},ar.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},ar.prototype.blur=function(){this.textarea.blur()},ar.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ar.prototype.receivedFocus=function(){this.slowPoll()},ar.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()})},ar.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)},ar.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||$e(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(H&&F>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var T=n.charCodeAt(0);if(T==8203&&!r&&(r="\u200B"),T==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,V=Math.min(r.length,n.length);N1e3||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},ar.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ar.prototype.onKeyPress=function(){H&&F>=9&&(this.hasSelection=null),this.fastPoll()},ar.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var T=Pi(i,e),N=r.scroller.scrollTop;if(!T||C)return;var V=i.options.resetSelectionOnContextMenu;V&&i.doc.sel.contains(T)==-1&&mr(i,Cr)(i.doc,Ei(T),Ee);var $=n.style.cssText,J=t.wrapper.style.cssText,se=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px; top: `+(e.clientY-se.top-5)+"px; left: "+(e.clientX-se.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 he;M&&(he=window.scrollY),r.input.focus(),M&&window.scrollTo(null,he),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=be,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(n.selectionStart!=null){var Fe=i.somethingSelected(),Ze="\u200B"+(Fe?n.value:"");n.value="\u21DA",n.value=Ze,t.prevInput=Fe?"":"\u200B",n.selectionStart=1,n.selectionEnd=Ze.length,r.selForContextMenu=i.doc.sel}}function be(){if(t.contextMenuPending!=be)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=J,n.style.cssText=$,H&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!H||H&&F<9)&&xe();var Fe=0,Ze=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?mr(i,$o)(i):Fe++<10?r.detectingSelectAll=setTimeout(Ze,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ze,200)}}if(H&&F>=9&&xe(),_){ne(e);var De=function(){nt(window,"mouseup",De),setTimeout(be,20)};Ce(window,"mouseup",De)}else setTimeout(be,50)},ar.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},ar.prototype.setUneditable=function(){},ar.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=P();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=V.getValue()}var n;if(e.form&&(Ce(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var T=e.form;n=T.submit;try{var N=T.submit=function(){r(),T.submit=n,T.submit(),T.submit=N}}catch($){}}t.finishInit=function($){$.save=r,$.getTextArea=function(){return e},$.toTextArea=function(){$.toTextArea=isNaN,r(),e.parentNode.removeChild($.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 V=Qt(function($){return e.parentNode.insertBefore($,e.nextSibling)},t);return V}function nu(e){e.off=nt,e.on=Ce,e.wheelEventPixels=hl,e.Doc=Or,e.splitLines=Et,e.countColumn=ee,e.findColumn=Te,e.isWordChar=Me,e.Pass=Re,e.signal=Le,e.Line=ki,e.changeEnd=Si,e.scrollbarModel=wo,e.Pos=He,e.cmpPos=_t,e.modes=Lt,e.mimeModes=Tt,e.resolveMode=vt,e.getMode=rr,e.modeExtensions=ir,e.extendMode=or,e.copyState=Nr,e.startState=Jr,e.innerMode=Xr,e.commands=Pn,e.keyMap=pi,e.keyName=hs,e.isModifierKey=us,e.lookupKey=an,e.normalizeKeyMap=Ml,e.StringStream=ct,e.SharedTextMarker=kn,e.TextMarker=Ti,e.LineWidget=Rn,e.e_preventDefault=te,e.e_stopPropagation=q,e.e_stop=ne,e.addClass=G,e.contains=S,e.rmClass=g,e.keyNames=wi}$l(Qt),ql(Qt);var au="iter insert remove copy getEditor constructor".split(" ");for(var ua in Or.prototype)Or.prototype.hasOwnProperty(ua)&&fe(au,ua)<0&&(Qt.prototype[ua]=function(e){return function(){return e.apply(this.doc,arguments)}}(Or.prototype[ua]));return ue(Or),Qt.inputStyles={textarea:ar,contenteditable:Yt},Qt.defineMode=function(e){!Qt.defaults.mode&&e!="null"&&(Qt.defaults.mode=e),wr.apply(this,arguments)},Qt.defineMIME=fr,Qt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Qt.defineMIME("text/plain","null"),Qt.defineExtension=function(e,t){Qt.prototype[e]=t},Qt.defineDocExtension=function(e,t){Or.prototype[e]=t},Qt.fromTextArea=iu,nu(Qt),Qt.version="5.58.2",Qt})},Y1PL:function(Ct,dt,ie){"use strict";ie.r(dt),ie.d(dt,"ResizableTextArea",function(){return fe});var ae=ie("wx14"),Z=ie("1OyB"),R=ie("vuIU"),X=ie("Ji7U"),I=ie("LK+K"),D=ie("q1tI"),H=ie("VTBJ"),F=ie("rePB"),M=ie("Zm9Q"),O=ie("Kwbf"),v=ie("c+Xe"),C=ie("m+aA"),k=ie("bdgK"),A=new Map;function E(Ee){Ee.forEach(function(Se){var we,Te=Se.target;(we=A.get(Te))===null||we===void 0||we.forEach(function(me){return me(Te)})})}var w=new k.default(E),d=null,o=null;function l(Ee,Se){A.has(Ee)||(A.set(Ee,new Set),w.observe(Ee)),A.get(Ee).add(Se)}function h(Ee,Se){A.has(Ee)&&(A.get(Ee).delete(Se),A.get(Ee).size||(w.unobserve(Ee),A.delete(Ee)))}var L=function(Ee){Object(X.a)(we,Ee);var Se=Object(I.a)(we);function we(){return Object(Z.a)(this,we),Se.apply(this,arguments)}return Object(R.a)(we,[{key:"render",value:function(){return this.props.children}}]),we}(D.Component),f=D.createContext(null);function p(Ee){var Se=Ee.children,we=Ee.onBatchResize,Te=D.useRef(0),me=D.useRef([]),de=D.useContext(f),ke=D.useCallback(function(Je,Ge,Qe){Te.current+=1;var Ye=Te.current;me.current.push({size:Je,element:Ge,data:Qe}),Promise.resolve().then(function(){Ye===Te.current&&(we==null||we(me.current),me.current=[])}),de==null||de(Je,Ge,Qe)},[we,de]);return D.createElement(f.Provider,{value:ke},Se)}function _(Ee){var Se=Ee.children,we=Ee.disabled,Te=D.useRef(null),me=D.useRef(null),de=D.useContext(f),ke=D.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Je=D.isValidElement(Se)&&Object(v.c)(Se),Ge=Je?Se.ref:null,Qe=D.useMemo(function(){return Object(v.a)(Ge,Te)},[Ge,Te]),Ye=D.useRef(Ee);Ye.current=Ee;var Ae=D.useCallback(function(Me){var je=Ye.current,et=je.onResize,Xe=je.data,Ne=Me.getBoundingClientRect(),Be=Ne.width,ht=Ne.height,We=Me.offsetWidth,Pe=Me.offsetHeight,Ke=Math.floor(Be),qe=Math.floor(ht);if(ke.current.width!==Ke||ke.current.height!==qe||ke.current.offsetWidth!==We||ke.current.offsetHeight!==Pe){var Ve={width:Ke,height:qe,offsetWidth:We,offsetHeight:Pe};ke.current=Ve;var it=We===Math.round(Be)?Be:We,Ce=Pe===Math.round(ht)?ht:Pe,tt=Object(H.a)(Object(H.a)({},Ve),{},{offsetWidth:it,offsetHeight:Ce});de==null||de(tt,Me,Xe),et&&Promise.resolve().then(function(){et(tt,Me)})}},[]);return D.useEffect(function(){var Me=Object(C.a)(Te.current)||Object(C.a)(me.current);return Me&&!we&&l(Me,Ae),function(){return h(Me,Ae)}},[Te.current,we]),D.createElement(L,{ref:me},Je?D.cloneElement(Se,{ref:Qe}):Se)}var b="rc-observer-key";function g(Ee){var Se=Ee.children,we=Object(M.a)(Se);return we.map(function(Te,me){var de=(Te==null?void 0:Te.key)||"".concat(b,"-").concat(me);return D.createElement(_,Object(ae.a)({},Ee,{key:de}),Te)})}g.Collection=p;var c=g,u=ie("bT9E"),a=ie("TSYQ"),x=ie.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 `,S=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],P={},G;function Y(Ee){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=Ee.getAttribute("id")||Ee.getAttribute("data-reactid")||Ee.getAttribute("name");if(Se&&P[we])return P[we];var Te=window.getComputedStyle(Ee),me=Te.getPropertyValue("box-sizing")||Te.getPropertyValue("-moz-box-sizing")||Te.getPropertyValue("-webkit-box-sizing"),de=parseFloat(Te.getPropertyValue("padding-bottom"))+parseFloat(Te.getPropertyValue("padding-top")),ke=parseFloat(Te.getPropertyValue("border-bottom-width"))+parseFloat(Te.getPropertyValue("border-top-width")),Je=S.map(function(Qe){return"".concat(Qe,":").concat(Te.getPropertyValue(Qe))}).join(";"),Ge={sizingStyle:Je,paddingSize:de,borderSize:ke,boxSizing:me};return Se&&we&&(P[we]=Ge),Ge}function Q(Ee){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Te=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)),Ee.getAttribute("wrap")?G.setAttribute("wrap",Ee.getAttribute("wrap")):G.removeAttribute("wrap");var me=Y(Ee,Se),de=me.paddingSize,ke=me.borderSize,Je=me.boxSizing,Ge=me.sizingStyle;G.setAttribute("style","".concat(Ge,";").concat(y)),G.value=Ee.value||Ee.placeholder||"";var Qe=Number.MIN_SAFE_INTEGER,Ye=Number.MAX_SAFE_INTEGER,Ae=G.scrollHeight,Me;if(Je==="border-box"?Ae+=ke:Je==="content-box"&&(Ae-=de),we!==null||Te!==null){G.value=" ";var je=G.scrollHeight-de;we!==null&&(Qe=je*we,Je==="border-box"&&(Qe=Qe+de+ke),Ae=Math.max(Qe,Ae)),Te!==null&&(Ye=je*Te,Je==="border-box"&&(Ye=Ye+de+ke),Me=Ae>Ye?"":"hidden",Ae=Math.min(Ye,Ae))}return{height:Ae,minHeight:Qe,maxHeight:Ye,overflowY:Me,resize:"none"}}var z=ie("Gytx"),j=ie.n(z),ee;(function(Ee){Ee[Ee.NONE=0]="NONE",Ee[Ee.RESIZING=1]="RESIZING",Ee[Ee.RESIZED=2]="RESIZED"})(ee||(ee={}));var oe=function(Ee){Object(X.a)(we,Ee);var Se=Object(I.a)(we);function we(Te){var me;return Object(Z.a)(this,we),me=Se.call(this,Te),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(de){me.textArea=de},me.handleResize=function(de){var ke=me.state.resizeStatus,Je=me.props,Ge=Je.autoSize,Qe=Je.onResize;if(ke!==ee.NONE)return;typeof Qe=="function"&&Qe(de),Ge&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var de=me.props.autoSize;if(!de||!me.textArea)return;var ke=de.minRows,Je=de.maxRows,Ge=Q(me.textArea,!1,ke,Je);me.setState({textareaStyles:Ge,resizeStatus:ee.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:ee.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:ee.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var de=me.props,ke=de.prefixCls,Je=ke===void 0?"rc-textarea":ke,Ge=de.autoSize,Qe=de.onResize,Ye=de.className,Ae=de.disabled,Me=me.state,je=Me.textareaStyles,et=Me.resizeStatus,Xe=Object(u.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ne=x()(Je,Ye,Object(F.a)({},"".concat(Je,"-disabled"),Ae));"value"in Xe&&(Xe.value=Xe.value||"");var Be=Object(H.a)(Object(H.a)(Object(H.a)({},me.props.style),je),et===ee.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return D.createElement(c,{onResize:me.handleResize,disabled:!(Ge||Qe)},D.createElement("textarea",Object(ae.a)({},Xe,{className:Ne,style:Be,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:ee.NONE},me}return Object(R.a)(we,[{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,de=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,de)}}catch(ke){}}},{key:"render",value:function(){return this.renderTextArea()}}]),we}(D.Component),fe=oe,ve=function(Ee){Object(X.a)(we,Ee);var Se=Object(I.a)(we);function we(Te){var me;Object(Z.a)(this,we),me=Se.call(this,Te),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(ke){me.resizableTextArea=ke},me.handleChange=function(ke){var Je=me.props.onChange;me.setValue(ke.target.value,function(){me.resizableTextArea.resizeTextarea()}),Je&&Je(ke)},me.handleKeyDown=function(ke){var Je=me.props,Ge=Je.onPressEnter,Qe=Je.onKeyDown;ke.keyCode===13&&Ge&&Ge(ke),Qe&&Qe(ke)};var de=typeof Te.value=="undefined"||Te.value===null?Te.defaultValue:Te.value;return me.state={value:de},me}return Object(R.a)(we,[{key:"setValue",value:function(me,de){"value"in this.props||this.setState({value:me},de)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return D.createElement(fe,Object(ae.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}}]),we}(D.Component),Re=dt.default=ve},ZW9T:function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return L});var ae=ie("k1fw"),Z=ie("miYZ"),R=ie("tsqr"),X=ie("rAM+"),I=ie("tJVT"),D=ie("PpiC"),H=ie("q1tI"),F=ie.n(H),M=ie("bdgK");function O(f,p,_,b,g){var c=p.getWordUntilPosition(_),u={startLineNumber:_.lineNumber,endLineNumber:_.lineNumber,startColumn:c.startColumn,endColumn:c.endColumn},a=b.map(function(x){return{label:x,kind:f.languages.CompletionItemKind.Keyword,insertText:x,insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:u}});return g.map(function(x){a.push(Object(ae.a)(Object(ae.a)({},x),{},{range:u}))}),a}var v=function(f){var p={label:"ifelse",kind:f.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(` `),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},_=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];f.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(u,a){var x=O(f,u,a,_,[p]);return{suggestions:x}}});var b=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];f.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(u,a){var x=[{label:"print",kind:f.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(` `),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],y=O(f,u,a,b,x);return{suggestions:y}}});var g=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];f.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(u,a){var x=[p,{label:"main",kind:f.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(` `),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:f.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(` `),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],y=O(f,u,a,g,x);return{suggestions:y}}})},C="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",k=ie("LvDl");function A(f){return/^\d+$/.test(f)?"".concat(f,"px"):f}function E(){}var w=!1,d={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function o(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=f;if(Array.isArray(f)){for(var _=0;_0||_e.target.offsetWidth>0)&&Ye.current.instance.layout()}}catch(ze){ye.e(ze)}finally{ye.f()}}),re.observe(Qe.current)),re}function We(){R.b.warn(decodeURIComponent(C))}var Pe=function(){var ne=Ye.current.instance;if(c!=null&&ne&&Ne){var ye=ne.getModel();ye&&c!==ye.getValue()&&(w=!0,ye.setValue(c),ne.layout(),w=!1)}};Object(H.useEffect)(function(){Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(function(){Pe()},500)},[c,Ne,Ye.current]);function Ke(){var re=Ye.current.instance;if(re){var ne=re.getSelection(),ye=Ye.current.pastePos||{},ge=new l.Range(ye.startLineNumber||ne.endLineNumber,ye.startColumn||ne.endColumn,ye.endLineNumber||ne.endLineNumber,ye.endColumn||ne.endColumn);setTimeout(function(){re.executeEdits("",[{range:ge,text:""}])},300)}}function qe(re){(window.navigator.platform.match("Mac")?re.metaKey:re.ctrlKey)&&re.keyCode==83&&(re.preventDefault(),ee())}var Ve=function(){if(fe&&Ye.current.instance){var ne=Ye.current.instance.getContentHeight();te(ne0||we.target.offsetWidth>0)&&fe.layout()}}catch(Te){Ee.e(Te)}finally{Ee.f()}}),ve.observe(S.current)),ve}Object(H.useEffect)(function(){S.current&&ie.e(27).then(ie.t.bind(null,"M/lh",7)).then(function(fe){l=fe;var ve=l.editor.createDiffEditor(S.current,Object(ae.a)(Object(ae.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},y),{},{wordWrap:!0}));Q(ve);var Re=z(ve);return function(){ve.dispose();var Ee=ve.getModel();Ee&&Ee.dispose(),Re.unobserve(S.current)}})},[]),Object(H.useEffect)(function(){Y&&Y.setModel({original:l.editor.createModel(c,a),modified:l.editor.createModel(u,a)})},[c,u,a,Y]);var j=A(_),ee=A(g),oe={width:j,height:ee};return F.a.createElement("div",{className:"my-diff-editor",ref:S,style:oe})}},ZpRC:function(Ct,dt,ie){"use strict";function ae(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function Z(v,C){return(!C||v!=="hidden")&&v!=="visible"&&v!=="clip"}function R(v,C){if(v.clientHeightC||w>v&&d=C&&o>=k?w-v-A:d>C&&ok?d-C+E:0}var I=function(v,C){var k=window,A=C.scrollMode,E=C.block,w=C.inline,d=C.boundary,o=C.skipOverflowHiddenElements,l=typeof d=="function"?d:function(je){return je!==d};if(!ae(v))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,L=[],f=v;ae(f)&&l(f);){if((f=f.parentElement)===h){L.push(f);break}f!=null&&f===document.body&&R(f)&&!R(document.documentElement)||f!=null&&R(f,o)&&L.push(f)}for(var p=k.visualViewport?k.visualViewport.width:innerWidth,_=k.visualViewport?k.visualViewport.height:innerHeight,b=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,c=v.getBoundingClientRect(),u=c.height,a=c.width,x=c.top,y=c.right,S=c.bottom,P=c.left,G=E==="start"||E==="nearest"?x:E==="end"?S:x+u/2,Y=w==="center"?P+a/2:w==="end"?y:P,Q=[],z=0;z=0&&P>=0&&S<=_&&y<=p&&x>=ve&&S<=Ee&&P>=Se&&y<=Re)return Q;var we=getComputedStyle(j),Te=parseInt(we.borderLeftWidth,10),me=parseInt(we.borderTopWidth,10),de=parseInt(we.borderRightWidth,10),ke=parseInt(we.borderBottomWidth,10),Je=0,Ge=0,Qe="offsetWidth"in j?j.offsetWidth-j.clientWidth-Te-de:0,Ye="offsetHeight"in j?j.offsetHeight-j.clientHeight-me-ke:0;if(h===j)Je=E==="start"?G:E==="end"?G-_:E==="nearest"?X(g,g+_,_,me,ke,g+G,g+G+u,u):G-_/2,Ge=w==="start"?Y:w==="center"?Y-p/2:w==="end"?Y-p:X(b,b+p,p,Te,de,b+Y,b+Y+a,a),Je=Math.max(0,Je+g),Ge=Math.max(0,Ge+b);else{Je=E==="start"?G-ve-me:E==="end"?G-Ee+ke+Ye:E==="nearest"?X(ve,Ee,oe,me,ke+Ye,G,G+u,u):G-(ve+oe/2)+Ye/2,Ge=w==="start"?Y-Se-Te:w==="center"?Y-(Se+fe/2)+Qe/2:w==="end"?Y-Re+de+Qe:X(Se,Re,fe,Te,de+Qe,Y,Y+a,a);var Ae=j.scrollLeft,Me=j.scrollTop;G+=Me-(Je=Math.max(0,Math.min(Me+Je,j.scrollHeight-oe+Ye))),Y+=Ae-(Ge=Math.max(0,Math.min(Ae+Ge,j.scrollWidth-fe+Qe)))}Q.push({el:j,top:Je,left:Ge})}return Q};function D(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(A){var E=A.el,w=A.top,d=A.left;E.scroll&&k?E.scroll({top:w,left:d,behavior:C}):(E.scrollTop=w,E.scrollLeft=d)})}function F(v){return v===!1?{block:"end",inline:"nearest"}:D(v)?v:{block:"start",inline:"nearest"}}function M(v,C){var k=!v.ownerDocument.documentElement.contains(v);if(D(C)&&typeof C.behavior=="function")return C.behavior(k?[]:I(v,C));if(k)return;var A=F(C);return H(I(v,A),A.behavior)}var O=dt.a=M},bT9E:function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return Z});var ae=ie("VTBJ");function Z(R,X){var I=Object(ae.a)({},R);return Array.isArray(X)&&X.forEach(function(D){delete I[D]}),I}},c5Ni:function(Ct,dt,ie){},dejd:function(Ct,dt,ie){},dmUQ:function(Ct,dt,ie){"use strict";var ae=ie("Ff2n"),Z=ie("rePB"),R=ie("1OyB"),X=ie("vuIU"),I=ie("Ji7U"),D=ie("md7G"),H=ie("foSv"),F=ie("q1tI"),M=ie.n(F),O=ie("TSYQ"),v=ie.n(O),C=ie("4IlW");function k(u,a){var x=Object.keys(u);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(u);a&&(y=y.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),x.push.apply(x,y)}return x}function A(u){for(var a=1;a1?fe-1:0),Re=1;Re1?z-1:0),ee=1;ee=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var z=0;return Q.indexOf(".")>=0&&(z=Q.length-Q.indexOf(".")-1),z},S.getInputDisplayValue=function(Y){var Q=Y||S.state,z=Q.focused,j=Q.inputValue,ee=Q.value,oe;z?oe=j:oe=S.toPrecisionAsStep(ee),oe==null&&(oe="");var fe=S.formatWrapper(oe);return p(S.props.decimalSeparator)&&(fe=fe.toString().replace(".",S.props.decimalSeparator)),fe},S.recordCursorPosition=function(){try{S.cursorStart=S.input.selectionStart,S.cursorEnd=S.input.selectionEnd,S.currentValue=S.input.value,S.cursorBefore=S.input.value.substring(0,S.cursorStart),S.cursorAfter=S.input.value.substring(S.cursorEnd)}catch(Y){}},S.restoreByAfter=function(Y){if(Y===void 0)return!1;var Q=S.input.value,z=Q.lastIndexOf(Y);if(z===-1)return!1;var j=S.cursorBefore.length;return S.lastKeyCode===C.a.DELETE&&S.cursorBefore.charAt(j-1)===Y[0]?(S.fixCaret(j,j),!0):z+Y.length===Q.length?(S.fixCaret(z,z),!0):!1},S.partRestoreByAfter=function(Y){return Y===void 0?!1:Array.prototype.some.call(Y,function(Q,z){var j=Y.substring(z);return S.restoreByAfter(j)})},S.isNotCompleteNumber=function(Y){return isNaN(Y)||Y===""||Y===null||Y&&Y.toString().indexOf(".")===Y.toString().length-1},S.stop=function(){S.autoStepTimer&&clearTimeout(S.autoStepTimer)},S.down=function(Y,Q,z){S.pressingUpOrDown=!0,S.step("down",Y,Q,z)},S.up=function(Y,Q,z){S.pressingUpOrDown=!0,S.step("up",Y,Q,z)},S.saveInput=function(Y){S.input=Y};var P=y.value;P===void 0&&(P=y.defaultValue),S.state={focused:y.autoFocus};var G=S.getValidValue(S.toNumber(P));return S.state=A(A({},S.state),{},{inputValue:S.toPrecisionAsStep(G),value:G}),S}return Object(X.a)(x,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(S){var P=this.props,G=P.value,Y=P.onChange,Q=P.max,z=P.min,j=this.state.focused;if(S){if(!_(S.value,G)||!_(S.max,Q)||!_(S.min,z)){var ee=j?G:this.getValidValue(G),oe;this.pressingUpOrDown?oe=ee:this.inputting?oe=this.rawInput:oe=this.toPrecisionAsStep(ee),this.setState({value:ee,inputValue:oe})}var fe="value"in this.props?G:this.state.value;"max"in this.props&&S.max!==Q&&typeof fe=="number"&&fe>Q&&Y&&Y(Q),"min"in this.props&&S.min!==z&&typeof fe=="number"&&fe1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,Y=parseFloat(S);return isNaN(Y)?S:(YG&&(Y=G),Y)}},{key:"setValue",value:function(S,P){var G=this.props.precision,Y=this.isNotCompleteNumber(parseFloat(S))?null:parseFloat(S),Q=this.state.value,z=Q===void 0?null:Q,j=this.state.inputValue,ee=j===void 0?null:j,oe=typeof Y=="number"?Y.toFixed(G):"".concat(Y),fe=Y!==z||oe!=="".concat(ee);return"value"in this.props?(ee=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ee},P)):this.setState({value:Y,inputValue:this.toPrecisionAsStep(S)},P),fe&&this.props.onChange(Y),Y}},{key:"getMaxPrecision",value:function(S){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,Y=G.precision,Q=G.step;if(p(Y))return Y;var z=this.getPrecision(P),j=this.getPrecision(Q),ee=this.getPrecision(S);return S?Math.max(ee,z+j):z+j}},{key:"getPrecisionFactor",value:function(S){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(S,P);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(S){return this.props.formatter?this.props.formatter(S):S}},{key:"toPrecisionAsStep",value:function(S){if(this.isNotCompleteNumber(S)||S==="")return S;var P=Math.abs(this.getMaxPrecision(S));return isNaN(P)?S.toString():Number(S).toFixed(P)}},{key:"toNumber",value:function(S){var P=this.props.precision,G=this.state.focused,Y=S&&S.length>16&&G;return this.isNotCompleteNumber(S)||Y?S:p(P)?Math.round(S*Math.pow(10,P))/Math.pow(10,P):Number(S)}},{key:"upStep",value:function(S,P){var G=this.props.step,Y=this.getPrecisionFactor(S,P),Q=Math.abs(this.getMaxPrecision(S,P)),z=((Y*S+Y*G*P)/Y).toFixed(Q);return this.toNumber(z)}},{key:"downStep",value:function(S,P){var G=this.props.step,Y=this.getPrecisionFactor(S,P),Q=Math.abs(this.getMaxPrecision(S,P)),z=((Y*S-Y*G*P)/Y).toFixed(Q);return this.toNumber(z)}},{key:"step",value:function(S,P){var G=this,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var z=this.props;if(z.disabled)return;var j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var ee=this["".concat(S,"Step")](j,Y),oe=ee>z.max||eez.max?ee=z.max:ee=ve),Ie=(qe||qe===0)&&(isNaN(qe)||Number(qe)<=Re),pe=Le||Y||Q,le=Ie||Y||Q,ue=v()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(Z.a)({},"".concat(G,"-handler-up-disabled"),pe)),te=v()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(Z.a)({},"".concat(G,"-handler-down-disabled"),le)),q=z?{onTouchStart:pe?d:this.up,onTouchEnd:this.stop}:{onMouseDown:pe?d:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},re=z?{onTouchStart:le?d:this.down,onTouchEnd:this.stop}:{onMouseDown:le?d:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:it,style:Ee,title:Se,onMouseEnter:we,onMouseLeave:Te,onMouseOver:me,onMouseOut:de,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"},q,{role:"button","aria-label":"Increase Value","aria-disabled":pe,className:ue}),ee||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),M.a.createElement("span",Object.assign({unselectable:"on"},re,{role:"button","aria-label":"Decrease Value","aria-disabled":le,className:te}),oe||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":Re,"aria-valuemax":ve,"aria-valuenow":qe,required:ke,type:Qe,placeholder:Ye,onPaste:ht,onClick:Je,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:Ge,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:tt?this.onKeyDown:d,onKeyUp:tt?this.onKeyUp:d,autoFocus:Ne,maxLength:Xe,readOnly:Q,disabled:Y,max:ve,min:Re,step:et,name:Be,title:Se,id:Ae,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(nt),pattern:je,inputMode:Me,onInput:We},Ce))))}}]),x}(M.a.Component);b.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:f,min:-f,step:1,style:{},onChange:d,onKeyDown:d,onPressEnter:d,onFocus:d,onBlur:d,parser:l,required:!1,autoComplete:"off"};var g=b,c=dt.a=g},kSUc:function(Ct,dt,ie){},"kaH+":function(Ct,dt,ie){"use strict";var ae=ie("+L6B"),Z=ie("2/Rp"),R=ie("tJVT"),X=ie("q1tI"),I=ie.n(X),D=ie("UZu5"),H=ie.n(D),F=ie("dhSg"),M=ie("rLCj"),O=ie("dF/Y"),v=ie("4i/N");dt.a=function(){var C=Object(X.useState)(""),k=Object(R.a)(C,2),A=k[0],E=k[1],w=Object(X.useState)(0),d=Object(R.a)(w,2),o=d[0],l=d[1],h=Object(X.useRef)("");Object(X.useEffect)(function(){var _=F.a.subscribe("preview-image",function(b){E(b),document.body.style.overflow="hidden"});return _},[]),Object(X.useEffect)(function(){return document.addEventListener("keydown",L),function(){document.removeEventListener("keydown",L)}},[]),Object(X.useEffect)(function(){h.current=A},[A]);function L(_){_.keyCode==27&&h.current&&f()}function f(){document.body.style.overflow="auto",E("")}function p(){l(o+90)}return I.a.createElement(X.Fragment,null,A?I.a.createElement("div",{className:"image-preview-container"},I.a.createElement("div",{className:"button-group"},I.a.createElement(Z.a,{onClick:p},"\u65CB\u8F6C",I.a.createElement(M.a,null)),I.a.createElement(Z.a,{href:A},"\u4E0B\u8F7D",I.a.createElement(O.a,null)),I.a.createElement(Z.a,{onClick:f},"\u5173\u95ED",I.a.createElement(v.a,null))),I.a.createElement("div",{className:"preview-wrp-group"},I.a.createElement("img",{className:"image-preview",src:A,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(o,"deg)")}}))):null)}},lZu9:function(Ct,dt,ie){(function(ae){ae(ie("VrN/"),ie("1eCo"),ie("8EBN"))})(function(ae){"use strict";ae.defineMode("markdown",function(Z,R){var X=ae.getMode(Z,"text/html"),I=X.name=="null";function D(z){if(ae.findModeByName){var j=ae.findModeByName(z);j&&(z=j.mime||j.mimes[0])}var ee=ae.getMode(Z,z);return ee.name=="null"?null:ee}R.highlightFormatting===void 0&&(R.highlightFormatting=!1),R.maxBlockquoteDepth===void 0&&(R.maxBlockquoteDepth=0),R.taskLists===void 0&&(R.taskLists=!1),R.strikethrough===void 0&&(R.strikethrough=!1),R.emoji===void 0&&(R.emoji=!1),R.fencedCodeBlockHighlighting===void 0&&(R.fencedCodeBlockHighlighting=!0),R.fencedCodeBlockDefaultMode===void 0&&(R.fencedCodeBlockDefaultMode="text/plain"),R.xml===void 0&&(R.xml=!0),R.tokenTypeOverrides===void 0&&(R.tokenTypeOverrides={});var H={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var F in H)H.hasOwnProperty(F)&&R.tokenTypeOverrides[F]&&(H[F]=R.tokenTypeOverrides[F]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,C=R.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,A=/^[^#!\[\]*_\\<>` "'(~:]+/,E=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,w=/^\s*\[[^\]]+?\]:.*$/,d=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(z,j,ee){return j.f=j.inline=ee,ee(z,j)}function h(z,j,ee){return j.f=j.block=ee,ee(z,j)}function L(z){return!z||!/\S/.test(z.string)}function f(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==_){var j=I;if(!j){var ee=ae.innerMode(X,z.htmlState);j=ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText}j&&(z.f=u,z.block=p,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function p(z,j){var ee=z.column()===j.indentation,oe=L(j.prevLine.stream),fe=j.indentedCode,ve=j.prevLine.hr,Re=j.list!==!1,Ee=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Se=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,Re)){for(j.list=null;Se=4&&(fe||j.prevLine.fencedCodeEnd||j.prevLine.header||oe))return z.skipToEnd(),j.indentedCode=!0,H.code;if(z.eatSpace())return null;if(ee&&j.indentation<=Ee&&(me=z.match(C))&&me[1].length<=6)return j.quote=0,j.header=me[1].length,j.thisLine.header=!0,R.highlightFormatting&&(j.formatting="header"),j.f=j.inline,g(j);if(j.indentation<=Ee&&z.eat(">"))return j.quote=ee?1:j.quote+1,R.highlightFormatting&&(j.formatting="quote"),z.eatSpace(),g(j);if(!Te&&!j.setext&&ee&&j.indentation<=Ee&&(me=z.match(O))){var de=me[1]?"ol":"ul";return j.indentation=Se+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,R.taskLists&&z.match(v,!1)&&(j.taskList=!0),j.f=j.inline,R.highlightFormatting&&(j.formatting=["list","list-"+de]),g(j)}else{if(ee&&j.indentation<=Ee&&(me=z.match(E,!0)))return j.quote=0,j.fencedEndRE=new RegExp(me[1]+"+ *$"),j.localMode=R.fencedCodeBlockHighlighting&&D(me[2]||R.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=ae.startState(j.localMode)),j.f=j.block=b,R.highlightFormatting&&(j.formatting="code-block"),j.code=-1,g(j);if(j.setext||(!we||!Re)&&!j.quote&&j.list===!1&&!j.code&&!Te&&!w.test(z.string)&&(me=z.lookAhead(1))&&(me=me.match(k)))return j.setext?(j.header=j.setext,j.setext=0,z.skipToEnd(),R.highlightFormatting&&(j.formatting="header")):(j.header=me[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,g(j);if(Te)return z.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,H.hr;if(z.peek()==="[")return l(z,j,P)}return l(z,j,j.inline)}function _(z,j){var ee=X.token(z,j.htmlState);if(!I){var oe=ae.innerMode(X,j.htmlState);(oe.mode.name=="xml"&&oe.state.tagStart===null&&!oe.state.context&&oe.state.tokenize.isInText||j.md_inside&&z.current().indexOf(">")>-1)&&(j.f=u,j.block=p,j.htmlState=null)}return ee}function b(z,j){var ee=j.listStack[j.listStack.length-1]||0,oe=j.indentation=z.quote?j.push(H.formatting+"-"+z.formatting[ee]+"-"+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),!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=z.quote?j.push(H.quote+"-"+z.quote):j.push(H.quote+"-"+R.maxBlockquoteDepth)),z.list!==!1){var oe=(z.listStack.length-1)%3;oe?oe===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 c(z,j){return z.match(A,!0)?g(j):void 0}function u(z,j){var ee=j.text(z,j);if(typeof ee!="undefined")return ee;if(j.list)return j.list=null,g(j);if(j.taskList){var oe=z.match(v,!0)[1]===" ";return oe?j.taskOpen=!0:j.taskClosed=!0,R.highlightFormatting&&(j.formatting="task"),j.taskList=!1,g(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&z.match(/^#+$/,!0))return R.highlightFormatting&&(j.formatting="header"),g(j);var fe=z.next();if(j.linkTitle){j.linkTitle=!1;var ve=fe;fe==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Re="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(Re),!0))return H.linkHref}if(fe==="`"){var Ee=j.formatting;R.highlightFormatting&&(j.formatting="code"),z.eatWhile("`");var Se=z.current().length;if(j.code==0&&(!j.quote||Se==1))return j.code=Se,g(j);if(Se==j.code){var we=g(j);return j.code=0,we}else return j.formatting=Ee,g(j)}else if(j.code)return g(j);if(fe==="\\"&&(z.next(),R.highlightFormatting)){var Te=g(j),me=H.formatting+"-escape";return Te?Te+" "+me:me}if(fe==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,R.highlightFormatting&&(j.formatting="image"),g(j);if(fe==="["&&j.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,R.highlightFormatting&&(j.formatting="image"),g(j);if(fe==="]"&&j.imageAltText){R.highlightFormatting&&(j.formatting="image");var Te=g(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=x,Te}if(fe==="["&&!j.image)return j.linkText&&z.match(/^.*?\]/)||(j.linkText=!0,R.highlightFormatting&&(j.formatting="link")),g(j);if(fe==="]"&&j.linkText){R.highlightFormatting&&(j.formatting="link");var Te=g(j);return j.linkText=!1,j.inline=j.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?x:u,Te}if(fe==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,R.highlightFormatting&&(j.formatting="link");var Te=g(j);return Te?Te+=" ":Te="",Te+H.linkInline}if(fe==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,R.highlightFormatting&&(j.formatting="link");var Te=g(j);return Te?Te+=" ":Te="",Te+H.linkEmail}if(R.xml&&fe==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var de=z.string.indexOf(">",z.pos);if(de!=-1){var ke=z.string.substring(z.start,de);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(ke)&&(j.md_inside=!0)}return z.backUp(1),j.htmlState=ae.startState(X),h(z,j,_)}if(R.xml&&fe==="<"&&z.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(fe==="*"||fe==="_"){for(var Je=1,Ge=z.pos==1?" ":z.string.charAt(z.pos-2);Je<3&&z.eat(fe);)Je++;var Qe=z.peek()||" ",Ye=!/\s/.test(Qe)&&(!d.test(Qe)||/\s/.test(Ge)||d.test(Ge)),Ae=!/\s/.test(Ge)&&(!d.test(Ge)||/\s/.test(Qe)||d.test(Qe)),Me=null,je=null;if(Je%2&&(!j.em&&Ye&&(fe==="*"||!Ae||d.test(Ge))?Me=!0:j.em==fe&&Ae&&(fe==="*"||!Ye||d.test(Qe))&&(Me=!1)),Je>1&&(!j.strong&&Ye&&(fe==="*"||!Ae||d.test(Ge))?je=!0:j.strong==fe&&Ae&&(fe==="*"||!Ye||d.test(Qe))&&(je=!1)),je!=null||Me!=null){R.highlightFormatting&&(j.formatting=Me==null?"strong":je==null?"em":"strong em"),Me===!0&&(j.em=fe),je===!0&&(j.strong=fe);var we=g(j);return Me===!1&&(j.em=!1),je===!1&&(j.strong=!1),we}}else if(fe===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return g(j);z.backUp(1)}if(R.strikethrough){if(fe==="~"&&z.eatWhile(fe)){if(j.strikethrough){R.highlightFormatting&&(j.formatting="strikethrough");var we=g(j);return j.strikethrough=!1,we}else if(z.match(/^[^\s]/,!1))return j.strikethrough=!0,R.highlightFormatting&&(j.formatting="strikethrough"),g(j)}else if(fe===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return g(j);z.backUp(2)}}if(R.emoji&&fe===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,R.highlightFormatting&&(j.formatting="emoji");var et=g(j);return j.emoji=!1,et}return fe===" "&&(z.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),g(j)}function a(z,j){var ee=z.next();if(ee===">"){j.f=j.inline=u,R.highlightFormatting&&(j.formatting="link");var oe=g(j);return oe?oe+=" ":oe="",oe+H.linkInline}return z.match(/^[^>]+/,!0),H.linkInline}function x(z,j){if(z.eatSpace())return null;var ee=z.next();return ee==="("||ee==="["?(j.f=j.inline=S(ee==="("?")":"]"),R.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,g(j)):"error"}var y={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function S(z){return function(j,ee){var oe=j.next();if(oe===z){ee.f=ee.inline=u,R.highlightFormatting&&(ee.formatting="link-string");var fe=g(ee);return ee.linkHref=!1,fe}return j.match(y[z]),ee.linkHref=!0,g(ee)}}function P(z,j){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=G,z.next(),R.highlightFormatting&&(j.formatting="link"),j.linkText=!0,g(j)):l(z,j,u)}function G(z,j){if(z.match(/^\]:/,!0)){j.f=j.inline=Y,R.highlightFormatting&&(j.formatting="link");var ee=g(j);return j.linkText=!1,ee}return z.match(/^([^\]\\]|\\.)+/,!0),H.linkText}function Y(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=u,H.linkHref+" url")}var Q={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:u,text:c,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&ae.copyState(X,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?ae.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 f(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!=_)){var ee=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(j.indentation=ee,j.indentationDiff=null,ee>0)return null}}return j.f(z,j)},innerMode:function(z){return z.block==_?{state:z.htmlState,mode:X}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:Q}},indent:function(z,j,ee){return z.block==_&&X.indent?X.indent(z.htmlState,j,ee):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,j,ee):ae.Pass},blankLine:f,getType:g,blockCommentStart:"",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),ae.defineMIME("text/markdown","markdown"),ae.defineMIME("text/x-markdown","markdown")})},osHv:function(Ct,dt,ie){(function(ae){ae(ie("VrN/"))})(function(ae){"use strict";var Z=ae.Pos;function R(d,o){return d.line-o.line||d.ch-o.ch}var X="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",I=X+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",D=new RegExp("<(/?)(["+X+"]["+I+"]*)","g");function H(d,o,l,h){this.line=o,this.ch=l,this.cm=d,this.text=d.getLine(o),this.min=h?Math.max(h.from,d.firstLine()):d.firstLine(),this.max=h?Math.min(h.to-1,d.lastLine()):d.lastLine()}function F(d,o){var l=d.cm.getTokenTypeAt(Z(d.line,o));return l&&/\btag\b/.test(l)}function M(d){return d.line>=d.max?void 0:(d.ch=0,d.text=d.cm.getLine(++d.line),!0)}function O(d){return d.line<=d.min?void 0:(d.text=d.cm.getLine(--d.line),d.ch=d.text.length,!0)}function v(d){for(;;){var o=d.text.indexOf(">",d.ch);if(o==-1){if(M(d))continue;return}if(!F(d,o+1)){d.ch=o+1;continue}var l=d.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(d.text.slice(l+1,o));return d.ch=o+1,h?"selfClose":"regular"}}function C(d){for(;;){var o=d.ch?d.text.lastIndexOf("<",d.ch-1):-1;if(o==-1){if(O(d))continue;return}if(!F(d,o+1)){d.ch=o;continue}D.lastIndex=o,d.ch=o;var l=D.exec(d.text);if(l&&l.index==o)return l}}function k(d){for(;;){D.lastIndex=d.ch;var o=D.exec(d.text);if(!o){if(M(d))continue;return}if(!F(d,o.index+1)){d.ch=o.index+1;continue}return d.ch=o.index+o[0].length,o}}function A(d){for(;;){var o=d.ch?d.text.lastIndexOf(">",d.ch-1):-1;if(o==-1){if(O(d))continue;return}if(!F(d,o+1)){d.ch=o;continue}var l=d.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(d.text.slice(l+1,o));return d.ch=o+1,h?"selfClose":"regular"}}function E(d,o){for(var l=[];;){var h=k(d),L,f=d.line,p=d.ch-(h?h[0].length:0);if(!h||!(L=v(d)))return;if(L=="selfClose")continue;if(h[1]){for(var _=l.length-1;_>=0;--_)if(l[_]==h[2]){l.length=_;break}if(_<0&&(!o||o==h[2]))return{tag:h[2],from:Z(f,p),to:Z(d.line,d.ch)}}else l.push(h[2])}}function w(d,o){for(var l=[];;){var h=A(d);if(!h)return;if(h=="selfClose"){C(d);continue}var L=d.line,f=d.ch,p=C(d);if(!p)return;if(p[1])l.push(p[2]);else{for(var _=l.length-1;_>=0;--_)if(l[_]==p[2]){l.length=_;break}if(_<0&&(!o||o==p[2]))return{tag:p[2],from:Z(d.line,d.ch),to:Z(L,f)}}}}ae.registerHelper("fold","xml",function(d,o){for(var l=new H(d,o.line,0);;){var h=k(l);if(!h||l.line!=o.line)return;var L=v(l);if(!L)return;if(!h[1]&&L!="selfClose"){var f=Z(l.line,l.ch),p=E(l,h[2]);return p&&R(p.from,f)>0?{from:f,to:p.from}:null}}}),ae.findMatchingTag=function(d,o,l){var h=new H(d,o.line,o.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var L=v(h),f=L&&Z(h.line,h.ch),p=L&&C(h);if(!L||!p||R(h,o)>0)return;var _={from:Z(h.line,h.ch),to:f,tag:p[2]};return L=="selfClose"?{open:_,close:null,at:"open"}:p[1]?{open:w(h,p[2]),close:_,at:"close"}:(h=new H(d,f.line,f.ch,l),{open:_,close:E(h,p[2]),at:"open"})},ae.findEnclosingTag=function(d,o,l,h){for(var L=new H(d,o.line,o.ch,l);;){var f=w(L,h);if(!f)break;var p=new H(d,o.line,o.ch,l),_=E(p,f.tag);if(_)return{open:f,close:_}}},ae.scanForClosingTag=function(d,o,l,h){var L=new H(d,o.line,o.ch,h?{from:0,to:h}:null);return E(L,l)}})},p5ED:function(Ct,dt,ie){"use strict";var ae=ie("+L6B"),Z=ie("2/Rp"),R=ie("5Dmo"),X=ie("3S7+"),I=ie("k1fw"),D=ie("9og8"),H=ie("tJVT"),F=ie("WmNS"),M=ie.n(F),O=ie("q1tI"),v=ie.n(O),C=ie("vHTk"),k=ie.n(C),A=ie("yEEn"),E=ie("ZW9T"),w=ie("1vsH"),d=ie("V0Rq"),o=ie("m3rI"),l=function(L){var f=L.name,p=L.data,_=L.theme,b=L.type,g=L.filename,c=L.monacoEditor,u=L.className,a=L.style,x=L.close,y=L.onClose,S=L.hasMask,P=L.otherData,G=P===void 0?{}:P,Y=Object(O.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),Q=Object(H.a)(Y,2),z=Q[0],j=Q[1],ee=Object(O.useState)(""),oe=Object(H.a)(ee,2),fe=oe[0],ve=oe[1],Re=Object(O.useState)(),Ee=Object(H.a)(Re,2),Se=Ee[0],we=Ee[1],Te=window.ENV==="build"?"/react/build/office.html":"/office.html",me,de=1024*1024,ke=10*de,Je=Object(O.useRef)();b==="office"&&(me=Object(w.R)(p).filesize,me>ke&&(b="other")),g&&(c.filename=g),Object(O.useEffect)(function(){var Ae,Me,je=(Ae=document.cookie)===null||Ae===void 0||((Me=Ae.replace(/\s/g,""))===null||Me===void 0)?void 0:Me.split(";");je==null||je.map(function(et){var Xe=et.split("=");Xe[0]==="_educoder_session"&&ve(Xe[1])})},[]),Object(O.useEffect)(function(){b==="office"&&Ge()},[b]);var Ge=function(){var Ae=Object(D.a)(M.a.mark(function Me(){var je,et,Xe;return M.a.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:return console.log("data:",p),je=p,p.startsWith("http")||(je=location.origin+je),et=new URL(je).pathname.split("/").pop(),Be.next=6,Object(d.U)({attachment_id:et});case 6:Xe=Be.sent,we(Xe);case 8:case"end":return Be.stop()}},Me)}));return function(){return Ae.apply(this,arguments)}}(),Qe=function(){if(p.startsWith("http")||p.startsWith("/api")||p.startsWith("blob:")){Ye();return}Object(w.x)(g||"educoder",p,g||"educoder")},Ye=function(){Object(w.v)(g||"educoder",decodeURIComponent(p))};return v.a.createElement("div",{style:Object(I.a)({},a||{}),className:"".concat(S&&k.a.bgBlack," ").concat(b?k.a.wrp:"hide")},x&&v.a.createElement("div",{className:k.a.close,ref:Je},v.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Je.current}},v.a.createElement("span",{onClick:Ye},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Je.current}},v.a.createElement("span",{className:"",onClick:function(){y(),we(null)}},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(k.a[u]," ").concat(u," ").concat(k.a.monaco," ").concat(b==="txt"?"show":"hide")},b==="txt"&&v.a.createElement(E.b,c)),b==="audio"&&v.a.createElement("audio",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(p),autoPlay:!0}),b==="video"&&v.a.createElement(v.a.Fragment,null,(p==null?void 0:p.indexOf("/api"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(p),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(p),autoPlay:!0})),b==="office"&&Se&&v.a.createElement("iframe",{src:"".concat(Te,"?key=").concat(Se.key,"&url=").concat(o.a.API_SERVER+Se.url,"&callbackUrl=").concat(o.a.API_SERVER+Se.callbackUrl,"&fileType=").concat(Se.fileType,"&title=").concat(Se.title,"&model=view")}),(b==="xlsx"||b==="doc"||b==="pptx"||b==="docx")&&v.a.createElement("iframe",{src:"".concat(Te,"?key=").concat(G.key,"&url=").concat(o.a.API_SERVER+G.url,"&callbackUrl=").concat(o.a.API_SERVER+G.callbackUrl,"&fileType=").concat(G.fileType,"&title=").concat(G.title,"&model=").concat(G.model)}),b==="html"&&v.a.createElement("iframe",{src:p+"&disposition=inline"}),b==="pdf"&&v.a.createElement("embed",{className:k.a.embed,src:p,type:"application/pdf"}),b==="image"&&v.a.createElement("img",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(p)}),b==="other"&&v.a.createElement("div",null,v.a.createElement(Z.a,{type:"primary",size:"large",onClick:Qe},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),b==="download"&&v.a.createElement(Z.a,{type:"primary",size:"large",onClick:Qe},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))};dt.a=l},"p77/":function(Ct,dt,ie){},"rAM+":function(Ct,dt,ie){"use strict";ie.d(dt,"a",function(){return Z});var ae=ie("Qw5x");function Z(R,X){var I;if(typeof Symbol=="undefined"||R[Symbol.iterator]==null){if(Array.isArray(R)||(I=Object(ae.a)(R))||X&&R&&typeof R.length=="number"){I&&(R=I);var D=0,H=function(){};return{s:H,n:function(){return D>=R.length?{done:!0}:{done:!1,value:R[D++]}},e:function(C){throw C},f:H}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var F=!0,M=!1,O;return{s:function(){I=R[Symbol.iterator]()},n:function(){var C=I.next();return F=C.done,C},e:function(C){M=!0,O=C},f:function(){try{!F&&I.return!=null&&I.return()}finally{if(M)throw O}}}}},rUJ1:function(Ct,dt){const ie=/[&<>"']/,ae=/[&<>"']/g,Z=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},I=b=>X[b];function D(b,g){if(g){if(ie.test(b))return b.replace(ae,I)}else if(Z.test(b))return b.replace(R,I);return b}const H=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(b){return b.replace(H,(g,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const M=/(^|[^\[])\^/g;function O(b,g){b=b.source||b,g=g||"";const c={replace:(u,a)=>(a=a.source||a,a=a.replace(M,"$1"),b=b.replace(u,a),c),getRegex:()=>new RegExp(b,g)};return c}const v=/[^\w:]/g,C=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(b,g,c){if(b){let u;try{u=decodeURIComponent(F(c)).replace(v,"").toLowerCase()}catch(a){return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}g&&!C.test(c)&&(c=o(g,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(u){return null}return c}const A={},E=/^[^:]+:\/*[^/]*$/,w=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(b,g){A[" "+b]||(E.test(b)?A[" "+b]=b+"/":A[" "+b]=f(b,"/",!0)),b=A[" "+b];const c=b.indexOf(":")===-1;return g.substring(0,2)==="//"?c?g:b.replace(w,"$1")+g:g.charAt(0)==="/"?c?g:b.replace(d,"$1")+g:b+g}const l={exec:function(){}};function h(b){let g=1,c,u;for(;g{let P=!1,G=y;for(;--G>=0&&S[G]==="\\";)P=!P;return P?"|":" |"}),u=c.split(/ \|/);let a=0;if(u.length>g)u.splice(g);else for(;u.length0},!1)}function v(C,k){for(var A={main:[k]},E={main:[]},w={main:{}};O(A);)for(var d=Object.keys(A),o=0;o=2*_/g||S<=G)return;var Y=Number.POSITIVE_INFINITY,Q;for(Q=d.level-1;Q>u;Q--){var z=c[Q].maxBitrate;if(Y=_*z/(8*.8*y),Y=S)return;var j=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+d.sn+(o?" part "+o.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Q+` Current BW estimate: `+(Object(X.isFiniteNumber)(j)?(j/1024).toFixed(3):"Unknown")+` Kb/s Estimated load time for current fragment: `+S.toFixed(3)+` s Estimated load time for the next fragment: `+Y.toFixed(3)+` s Time to underbuffer: `+G.toFixed(3)+" s"),l.nextLoadLevel=Q,this.bwEstimator.sample(b,p.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),l.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:o,stats:p})},E.onFragLoaded=function(d,o){var l=o.frag,h=o.part;if(l.type===M.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(l.sn)){var L=h?h.stats:l.stats,f=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[l.level],_=(p.loaded?p.loaded.bytes:0)+L.loaded,b=(p.loaded?p.loaded.duration:0)+f;p.loaded={bytes:_,duration:b},p.realBitrate=Math.round(8*_/b)}if(l.bitrateTest){var g={stats:L,frag:l,part:h,id:l.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,g),l.bitrateTest=!1}}},E.onFragBuffered=function(d,o){var l=o.frag,h=o.part,L=h?h.stats:l.stats;if(L.aborted)return;if(l.type!==M.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var f=L.parsing.end-L.loading.start;this.bwEstimator.sample(f,L.loaded),L.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=f/1e3:this.bitrateTestDelay=0},E.onError=function(d,o){switch(o.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},E.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},E.getNextABRAutoLevel=function(){var d=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.maxAutoLevel,L=l.config,f=l.minAutoLevel,p=l.media,_=o?o.duration:d?d.duration:0,b=p?p.currentTime:0,g=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():L.abrEwmaDefaultEstimate,u=(H.BufferHelper.bufferInfo(p,b,L.maxBufferHole).end-b)/g,a=this.findBestLevel(c,f,h,u,L.abrBandWidthFactor,L.abrBandWidthUpFactor);if(a>=0)return a;O.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=_?Math.min(_,L.maxStarvationDelay):L.maxStarvationDelay,y=L.abrBandWidthFactor,S=L.abrBandWidthUpFactor;if(!u){var P=this.bitrateTestDelay;if(P){var G=_?Math.min(_,L.maxLoadingDelay):L.maxLoadingDelay;x=G-P,O.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),y=S=1}}return a=this.findBestLevel(c,f,h,u+x,y,S),Math.max(a,0)},E.findBestLevel=function(d,o,l,h,L,f){for(var p,_=this.fragCurrent,b=this.partCurrent,g=this.lastLoadedFragLevel,c=this.hls.levels,u=c[g],a=!!(u!=null&&(p=u.details)!==null&&p!==void 0&&p.live),x=u==null?void 0:u.codecSet,y=b?b.duration:_?_.duration:0,S=l;S>=o;S--){var P=c[S];if(!P||x&&P.codecSet!==x)continue;var G=P.details,Y=(b?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||y,Q=void 0;S<=g?Q=L*d:Q=f*d;var z=c[S].maxBitrate,j=z*Y/Q;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(Q)+"/"+z+"/"+Y+"/"+h+"/"+j),Q>z&&(!j||a&&!this.bitrateTestDelay||j0&&u===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()},g.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var u,a=this.levels,x=this.trackId,y=a==null||((u=a[x])===null||u===void 0)?void 0:u.details;if(y){if(this.waitForCdnTuneIn(y))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var S,P=performance.now(),G=this.retryDate;(!G||P>=G||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var Y=this.waitingData;if(Y){var Q=Y.frag,z=Y.part,j=Y.cache,ee=Y.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var oe=j.flush(),fe={frag:Q,part:z,payload:oe,networkDetails:null};this._handleFragmentLoadProgress(fe),ee&&_.prototype._handleFragmentLoadComplete.call(this,fe)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),Re=H.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),Ee=Object(E.fragmentWithinToleranceTest)(Re.end,this.config.maxFragLookUpTolerance,Q);Ee<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+Re.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},g.clearWaitingFragment=function(){var u=this.waitingData;u&&(this.fragmentTracker.removeFragment(u.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},g.onTickEnd=function(){var u=this.media;if(!u||!u.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:u,x=a.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=u.currentTime},g.doTickIdle=function(){var u,a,x=this.hls,y=this.levels,S=this.media,P=this.trackId,G=x.config;if(!y||!y[P])return;if(!S&&(this.startFragRequested||!G.startFragPrefetch))return;var Y=y[P],Q=Y.details;if(!Q||Q.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(Q)){this.state=I.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,ee=this.getMaxBufferLength(),oe=this.audioSwitch;if(j>=ee&&!oe)return;if(!oe&&this._streamEnded(z,Q)){x.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var fe=Q.fragments,ve=fe[0].start,Re=z.end;if(oe){var Ee=this.getLoadPosition();Re=Ee,Q.PTSKnown&&Eeve||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),S.currentTime=ve+.05))}var Se=this.getNextFragment(Re,Q);if(!Se){this.bufferFlushed=!0;return}((u=Se.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((a=Se.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Se,Q):this.loadFragment(Se,Q,Re)},g.getMaxBufferLength=function(){var u=_.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return a===null?u:Math.max(u,a.len)},g.onMediaDetaching=function(){this.videoBuffer=null,_.prototype.onMediaDetaching.call(this)},g.onAudioTracksUpdated=function(u,a){var x=a.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(y){return new M.Level(y)})},g.onAudioTrackSwitching=function(u,a){var x=!!a.url;this.trackId=a.id;var y=this.fragCurrent;y!=null&&y.loader&&y.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(f):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},g.onLevelLoaded=function(u,a){this.mainDetails=a.details},g.onAudioTrackLoaded=function(u,a){var x,y=this.levels,S=a.details,P=a.id;if(!y){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+S.startSN+","+S.endSN+"],duration:"+S.totalduration);var G=y[P],Y=0;if(S.live||(x=G.details)!==null&&x!==void 0&&x.live){var Q=this.mainDetails;if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed||!Q)return;!G.details&&S.hasProgramDateTime&&Q.hasProgramDateTime?(Object(w.alignMediaPlaylistByPDT)(S,Q),Y=S.fragments[0].start):Y=this.alignPlaylists(S,G.details)}G.details=S,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!S.live)&&this.setStartPosition(G.details,Y),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(S)&&(this.state=I.State.IDLE),this.tick()},g._handleFragmentLoadProgress=function(u){var a,x=u.frag,y=u.part,S=u.payload,P=this.config,G=this.trackId,Y=this.levels;if(!Y){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var Q=Y[G];console.assert(Q,"Audio track is defined on fragment load progress");var z=Q.details;console.assert(z,"Audio track details are defined on fragment load progress");var j=P.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",ee=this.transmuxer;ee||(ee=this.transmuxer=new k.default(this.hls,O.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var oe=this.initPTS[x.cc],fe=(a=x.initSegment)===null||a===void 0?void 0:a.data;if(oe!==void 0){var ve=!1,Re=y?y.index:-1,Ee=Re!==-1,Se=new A.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,S.byteLength,Re,Ee);ee.push(S,fe,j,"",x,y,z.totalduration,ve,Se,oe)}else{o.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var we=this.waitingData=this.waitingData||{frag:x,part:y,cache:new C.default,complete:!1},Te=we.cache;Te.push(new Uint8Array(S)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},g._handleFragmentLoadComplete=function(u){if(this.waitingData){this.waitingData.complete=!0;return}_.prototype._handleFragmentLoadComplete.call(this,u)},g.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},g.onBufferCreated=function(u,a){var x=a.tracks.audio;x&&(this.mediaBuffer=x.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},g.onFragBuffered=function(u,a){var x=a.frag,y=a.part;if(x.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(y?" p: "+y.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,y)},g.onError=function(u,a){switch(a.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,a);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=a.fatal?I.State.ERROR:I.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var x=!0,y=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);y&&y.len>.5&&(x=!this.reduceMaxBufferLength(y.len)),x&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,_.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},g.onBufferFlushed=function(u,a){var x=a.type;x===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},g._handleTransmuxComplete=function(u){var a,x="audio",y=this.hls,S=u.remuxResult,P=u.chunkMeta,G=this.getCurrentContext(P);if(!G){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var Y=G.frag,Q=G.part,z=S.audio,j=S.text,ee=S.id3,oe=S.initSegment;if(this.fragContextChanged(Y))return;if(this.state=I.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),oe!=null&&oe.tracks&&(this._bufferInitSegment(oe.tracks,Y,P),y.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:Y,id:x,tracks:oe.tracks})),z){var fe=z.startPTS,ve=z.endPTS,Re=z.startDTS,Ee=z.endDTS;Q&&(Q.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:fe,endPTS:ve,startDTS:Re,endDTS:Ee}),Y.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,fe,ve,Re,Ee),this.bufferFragmentData(z,Y,Q,P)}if(ee!=null&&(a=ee.samples)!==null&&a!==void 0&&a.length){var Se=l({frag:Y,id:x},ee);y.trigger(D.Events.FRAG_PARSING_METADATA,Se)}if(j){var we=l({frag:Y,id:x},j);y.trigger(D.Events.FRAG_PARSING_USERDATA,we)}},g._bufferInitSegment=function(u,a,x){if(this.state!==I.State.PARSING)return;u.video&&delete u.video;var y=u.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(D.Events.BUFFER_CODECS,u);var S=y.initSegment;if(S!=null&&S.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:x,parent:a.type,data:S};this.hls.trigger(D.Events.BUFFER_APPENDING,P)}this.tick()},g.loadFragment=function(u,a,x){var y=this.fragmentTracker.getState(u);this.fragCurrent=u,(this.audioSwitch||y===F.FragmentState.NOT_LOADED||y===F.FragmentState.PARTIAL)&&(u.sn==="initSegment"?this._loadInitSegment(u):a.live&&!Object(X.isFiniteNumber)(this.initPTS[u.cc])?(this.log("Waiting for video PTS in continuity counter "+u.cc+" of live stream before loading audio fragment "+u.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,_.prototype.loadFragment.call(this,u,a,x)))},g.completeAudioSwitch=function(){var u=this.hls,a=this.media,x=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),_.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,u.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:x})},b}(I.default);Z.default=p},"./src/controller/audio-track-controller.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/events.ts"),I=R("./src/errors.ts"),D=R("./src/controller/base-playlist-controller.ts"),H=R("./src/types/loader.ts");function F(k,A){for(var E=0;E=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 "+d);var h=o[d],L=h.id,f=h.groupId,p=f===void 0?"":f,_=h.name,b=h.type,g=h.url;if(this.trackId=d,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:L,groupId:p,name:_,type:b,url:g}),h.details&&!h.details.live)return;var c=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(c)},E.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.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(X.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},E.findTrackId=function(d){for(var o=this.tracksInGroup,l=0;lA.partTarget&&(h+=1)}if(Object(X.isFiniteNumber)(l))return new I.HlsUrlParameters(l,Object(X.isFiniteNumber)(h)?h:void 0,I.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,E){var w=this,d=A.details,o=A.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(d.advancedDateTime=Date.now()-l,d.live||E!=null&&E.live){if(d.reloaded(E),E&&this.log("live playlist "+k+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),E&&d.fragments.length>0&&Object(D.mergeDetails)(E,d),!this.canLoad||!d.live)return;var h,L=void 0,f=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var p=this.hls.config.lowLatencyMode,_=d.lastPartSn,b=d.endSN,g=d.lastPartIndex,c=g!==-1,u=_===b,a=p?0:g;c?(L=u?b+1:_,f=u?a:g+1):L=b+1;var x=d.age,y=x+d.ageHeader,S=Math.min(y-d.partTarget,d.targetduration*1.5);if(S>0){if(E&&S>E.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+E.tuneInGoal+" to: "+S+" with playlist age: "+d.age),S=0;else{var P=Math.floor(S/d.targetduration);if(L+=P,f!==void 0){var G=Math.round(S%d.targetduration/d.partTarget);f+=G}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+S+" skip sn "+P+" to part "+f)}d.tuneInGoal=S}if(h=this.getDeliveryDirectives(d,A.deliveryDirectives,L,f),p||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(d,A.deliveryDirectives,L,f);var Y=Object(D.computeReloadInterval)(d,o);L!==void 0&&d.canBlockReload&&(Y-=d.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(Y)+" ms"),this.timer=self.setTimeout(function(){return w.loadPlaylist(h)},Y)}else this.clearTimer()},v.getDeliveryDirectives=function(k,A,E,w){var d=Object(I.getSkipValue)(k,E);return A!=null&&A.skip&&k.deltaUpdateFailed&&(E=A.msn,w=A.part,d=I.HlsSkip.No),new I.HlsUrlParameters(E,w,d)},v.retryLoadingOrFail=function(k){var A=this,E=this.hls.config,w=this.retryCount-1&&(d=k.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*E.levelLoadingRetryDelay,E.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return A.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 w},O}()},"./src/controller/base-stream-controller.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"State",function(){return b}),R.d(Z,"default",function(){return g});var X=R("./src/polyfills/number.ts"),I=R("./src/task-loop.ts"),D=R("./src/controller/fragment-tracker.ts"),H=R("./src/utils/buffer-helper.ts"),F=R("./src/utils/logger.ts"),M=R("./src/events.ts"),O=R("./src/errors.ts"),v=R("./src/types/transmuxer.ts"),C=R("./src/utils/mp4-tools.ts"),k=R("./src/utils/discontinuities.ts"),A=R("./src/controller/fragment-finders.ts"),E=R("./src/controller/level-helper.ts"),w=R("./src/loader/fragment-loader.ts"),d=R("./src/crypt/decrypter.ts"),o=R("./src/utils/time-ranges.ts"),l=R("./src/types/loader.ts");function h(c,u){for(var a=0;aoe;(Q0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var z=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(Y),Q.key.buffer,Q.iv.buffer).then(function(j){var ee=self.performance.now();return G.trigger(M.Events.FRAG_DECRYPTED,{frag:y,payload:j,stats:{tstart:z,tdecrypt:ee}}),P.payload=j,P})}return P}).then(function(P){var G=S.fragCurrent,Y=S.hls,Q=S.levels;if(!Q)throw new Error("init load aborted, missing levels");var z=Q[y.level].details;console.assert(z,"Level details are defined when init segment is loaded");var j=y.stats;S.state=b.IDLE,S.fragLoadError=0,y.data=new Uint8Array(P.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),P.frag===G&&Y.trigger(M.Events.FRAG_BUFFERED,{stats:j,frag:G,part:null,id:y.type}),S.tick()}).catch(function(P){S.warn(P),S.resetFragmentLoading(y)})},a.fragContextChanged=function(y){var S=this.fragCurrent;return!y||!S||y.level!==S.level||y.sn!==S.sn||y.urlId!==S.urlId},a.fragBufferedComplete=function(y,S){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+o.default.toString(H.BufferHelper.getBuffered(P))),this.state=b.IDLE,this.tick()},a._handleFragmentLoadComplete=function(y){var S=this.transmuxer;if(!S)return;var P=y.frag,G=y.part,Y=y.partsLoaded,Q=!Y||Y.length===0||Y.some(function(j){return!j}),z=new v.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,G?G.index:-1,!Q);S.flush(z)},a._handleFragmentLoadProgress=function(y){},a._doFragLoad=function(y,S,P,G){var Y=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(y.start,P||0),this.config.lowLatencyMode&&S){var Q=S.partList;if(Q&&G){P>y.end&&S.fragmentHint&&(y=S.fragmentHint);var z=this.getNextPart(Q,y,P);if(z>-1){var j=Q[z];return this.log("Loading part sn: "+y.sn+" p: "+j.index+" cc: "+y.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+z+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=b.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:y,part:Q[z],targetBufferTime:P}),this.doFragPartsLoad(y,Q,z,G).catch(function(ee){return Y.handleFragLoadError(ee)})}else if(!y.url||this.loadedEndOfParts(Q,P))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(P.toFixed(3))),Object(X.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=b.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:y,targetBufferTime:P}),this.fragmentLoader.load(y,G).catch(function(ee){return Y.handleFragLoadError(ee)})},a.doFragPartsLoad=function(y,S,P,G){var Y=this;return new Promise(function(Q,z){var j=[],ee=function oe(fe){var ve=S[fe];Y.fragmentLoader.loadPart(y,ve,G).then(function(Re){j[ve.index]=Re;var Ee=Re.part;Y.hls.trigger(M.Events.FRAG_LOADED,Re);var Se=S[fe+1];if(Se&&Se.fragment===y)oe(fe+1);else return Q({frag:y,part:Ee,partsLoaded:j})}).catch(z)};ee(P)})},a.handleFragLoadError=function(y){var S=y.data;return S&&S.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(M.Events.ERROR,S),null},a._handleTransmuxerFlush=function(y){var S=this.getCurrentContext(y);if(!S||this.state!==b.PARSING){this.fragCurrent||(this.state=b.IDLE);return}var P=S.frag,G=S.part,Y=S.level,Q=self.performance.now();P.stats.parsing.end=Q,G&&(G.stats.parsing.end=Q),this.updateLevelTiming(P,G,Y,y.partial)},a.getCurrentContext=function(y){var S=this.levels,P=y.level,G=y.sn,Y=y.part;if(!S||!S[P])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+P+". The current chunk will not be buffered."),null;var Q=S[P],z=Y>-1?Object(E.getPartWith)(Q,G,Y):null,j=z?z.fragment:Object(E.getFragmentWithSN)(Q,G,this.fragCurrent);return j?{frag:j,part:z,level:Q}:null},a.bufferFragmentData=function(y,S,P,G){if(!y||this.state!==b.PARSING)return;var Y=y.data1,Q=y.data2,z=Y;if(Y&&Q&&(z=Object(C.appendUint8Array)(Y,Q)),!z||!z.length)return;var j={type:y.type,frag:S,part:P,chunkMeta:G,parent:S.type,data:z};this.hls.trigger(M.Events.BUFFER_APPENDING,j),y.dropped&&y.independent&&!P&&this.flushBufferGap(S)},a.flushBufferGap=function(y){var S=this.media;if(!S)return;if(!H.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,y.start);return}var P=S.currentTime,G=H.BufferHelper.bufferInfo(S,P,0),Y=y.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,Y*.25),z=Math.max(Math.min(y.start-Q,G.end-Q),P+Q);y.start-z>Q&&this.flushMainBuffer(z,y.start)},a.getFwdBufferInfo=function(y,S){var P=this.config,G=this.getLoadPosition();if(!Object(X.isFiniteNumber)(G))return null;var Y=H.BufferHelper.bufferInfo(y,G,P.maxBufferHole);if(Y.len===0&&Y.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(G,S);if(Q&&Y.nextStart=P?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(y,S){var P,G,Y=S.fragments,Q=Y.length;if(!Q)return null;var z=this.config,j=Y[0].start,ee;if(S.live){var oe=z.initialLiveManifestSize;if(Q-1&&PP.start&&P.loaded},a.getInitialLiveFragment=function(y,S){var P=this.fragPrevious,G=null;if(P){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),G=Object(A.findFragmentByPDT)(S,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var Y=P.sn+1;if(Y>=y.startSN&&Y<=y.endSN){var Q=S[Y-y.startSN];P.cc===Q.cc&&(G=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(A.findFragWithCC)(S,P.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,S,P){var G=this.config,Y=this.fragPrevious,Q=P.fragments,z=P.endSN,j=P.fragmentHint,ee=G.maxFragLookUpTolerance,oe=!!(G.lowLatencyMode&&P.partList&&j);oe&&j&&!this.bitrateTest&&(Q=Q.concat(j),z=j.sn);var fe;if(yS-ee?0:ee;fe=Object(A.findFragmentByPTS)(Y,Q,y,ve)}else fe=Q[Q.length-1];if(fe){var Re=fe.sn-P.startSN,Ee=Y&&fe.level===Y.level,Se=Q[Re+1],we=this.fragmentTracker.getState(fe);if(we===D.FragmentState.BACKTRACKED){fe=null;for(var Te=Re;Q[Te]&&this.fragmentTracker.getState(Q[Te])===D.FragmentState.BACKTRACKED;)Y?fe=Q[Te--]:fe=Q[--Te];fe||(fe=Se)}else Y&&fe.sn===Y.sn&&!oe&&(Ee&&(fe.sn=Q-S.maxFragLookUpTolerance&&Y<=z;if(G!==null&&P.duration>G&&(Y"+y.startSN+" prev-sn: "+(Y?Y.sn:"na")+" fragments: "+z),fe}return j},a.waitForCdnTuneIn=function(y){var S=3;return y.live&&y.canBlockReload&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*S)},a.setStartPosition=function(y,S){var P=this.startPosition;if(P"+y))}}]),u}(I.default)},"./src/controller/buffer-controller.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return A});var X=R("./src/polyfills/number.ts"),I=R("./src/events.ts"),D=R("./src/utils/logger.ts"),H=R("./src/errors.ts"),F=R("./src/utils/buffer-helper.ts"),M=R("./src/utils/mediasource-helper.ts"),O=R("./src/loader/fragment.ts"),v=R("./src/controller/buffer-operation-queue.ts"),C=Object(M.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,A=function(){function E(d){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,L=o.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),l.trigger(I.Events.MEDIA_ATTACHED,{media:h})),L&&L.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){D.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var w=E.prototype;return w.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},w.destroy=function(){this.unregisterListeners(),this.details=null},w.registerListeners=function(){var o=this.hls;o.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(I.Events.BUFFER_RESET,this.onBufferReset,this),o.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(I.Events.BUFFER_EOS,this.onBufferEos,this),o.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(I.Events.FRAG_PARSED,this.onFragParsed,this),o.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},w.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(I.Events.BUFFER_RESET,this.onBufferReset,this),o.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(I.Events.BUFFER_EOS,this.onBufferEos,this),o.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(I.Events.FRAG_PARSED,this.onFragParsed,this),o.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},w._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},w.onManifestParsed=function(o,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},w.onMediaAttaching=function(o,l){var h=this.media=l.media;if(h&&C){var L=this.mediaSource=new C;L.addEventListener("sourceopen",this._onMediaSourceOpen),L.addEventListener("sourceended",this._onMediaSourceEnded),L.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(L),this._objectUrl=h.src}},w.onMediaDetaching=function(){var o=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(D.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(L){D.logger.warn("[buffer-controller]: onMediaDetaching: "+L.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()):D.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(I.Events.MEDIA_DETACHED,void 0)},w.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(L){D.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",L)}}),this._initSourceBuffer()},w.onBufferCodecs=function(o,l){var h=this,L=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(f){if(L){var p=h.tracks[f];if(p&&typeof p.buffer.changeType=="function"){var _=l[f],b=_.codec,g=_.levelCodec,c=_.container,u=(p.levelCodec||p.codec).replace(k,"$1"),a=(g||b).replace(k,"$1");if(u!==a){var x=c+";codecs="+(g||b);h.appendChangeType(f,x)}}}else h.pendingTracks[f]=l[f]}),L)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},w.appendChangeType=function(o,l){var h=this,L=this.operationQueue,f={execute:function(){var _=h.sourceBuffer[o];_&&(D.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),_.changeType(l)),L.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(_){D.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",_)}};L.append(f,o)},w.onBufferAppending=function(o,l){var h=this,L=this.hls,f=this.operationQueue,p=this.tracks,_=l.data,b=l.type,g=l.frag,c=l.part,u=l.chunkMeta,a=u.buffering[b],x=self.performance.now();a.start=x;var y=g.stats.buffering,S=c?c.stats.buffering:null;y.start===0&&(y.start=x),S&&S.start===0&&(S.start=x);var P=p.audio,G=b==="audio"&&u.id===1&&(P==null?void 0:P.container)==="audio/mpeg",Y={execute:function(){if(a.executeStart=self.performance.now(),G){var z=h.sourceBuffer[b];if(z){var j=g.start-z.timestampOffset;Math.abs(j)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+j+") sn: "+g.sn+")"),z.timestampOffset=g.start)}}h.appendExecutor(_,b)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,y.first===0&&(y.first=z),S&&S.first===0&&(S.first=z);var j=h.sourceBuffer,ee={};for(var oe in j)ee[oe]=F.BufferHelper.getBuffered(j[oe]);h.appendError=0,h.hls.trigger(I.Events.BUFFER_APPENDED,{type:b,frag:g,part:c,chunkMeta:u,parent:g.type,timeRanges:ee})},onError:function(z){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+b+" SourceBuffer",z);var j={type:H.ErrorTypes.MEDIA_ERROR,parent:g.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>L.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+L.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),j.fatal=!0)),L.trigger(I.Events.ERROR,j)}};f.append(Y,b)},w.onBufferFlushing=function(o,l){var h=this,L=this.operationQueue,f=function(_){return{execute:h.removeExecutor.bind(h,_,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(I.Events.BUFFER_FLUSHED,{type:_})},onError:function(g){D.logger.warn("[buffer-controller]: Failed to remove from "+_+" SourceBuffer",g)}}};l.type?L.append(f(l.type),l.type):this.getSourceBufferTypes().forEach(function(p){L.append(f(p),p)})},w.onFragParsed=function(o,l){var h=this,L=l.frag,f=l.part,p=[],_=f?f.elementaryStreams:L.elementaryStreams;_[O.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(_[O.ElementaryStreamTypes.AUDIO]&&p.push("audio"),_[O.ElementaryStreamTypes.VIDEO]&&p.push("video"));var b=function(){var c=self.performance.now();L.stats.buffering.end=c,f&&(f.stats.buffering.end=c);var u=f?f.stats:L.stats;h.hls.trigger(I.Events.FRAG_BUFFERED,{frag:L,part:f,stats:u,id:L.type})};p.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+L.type+" level: "+L.level+" sn: "+L.sn),this.blockBuffers(b,p)},w.onFragChanged=function(o,l){this.flushBackBuffer()},w.onBufferEos=function(o,l){var h=this,L=this.getSourceBufferTypes().reduce(function(f,p){var _=h.sourceBuffer[p];return(!l.type||l.type===p)&&(_&&!_.ended&&(_.ended=!0,D.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),f&&!!(!_||_.ended)},!0);L&&this.blockBuffers(function(){var f=h.mediaSource;if(!f||f.readyState!=="open")return;f.endOfStream()})},w.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()},w.flushBackBuffer=function(){var o=this.hls,l=this.details,h=this.media,L=this.sourceBuffer;if(!h||l===null)return;var f=this.getSourceBufferTypes();if(!f.length)return;var p=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(p)||p<0)return;var _=h.currentTime,b=l.levelTargetDuration,g=Math.max(p,b),c=Math.floor(_/b)*b-g;f.forEach(function(u){var a=L[u];if(a){var x=F.BufferHelper.getBuffered(a);x.length>0&&c>x.start(0)&&(o.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),l.live&&o.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u}))}})},w.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,h=this.media,L=this.mediaSource,f=o.fragments[0].start+o.totalduration,p=h.duration,_=Object(X.isFiniteNumber)(L.duration)?L.duration:0;o.live&&l.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),L.duration=Infinity,this.updateSeekableRange(o)):(f>_&&f>p||!Object(X.isFiniteNumber)(p))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+f.toFixed(3)),L.duration=f)},w.updateSeekableRange=function(o){var l=this.mediaSource,h=o.fragments,L=h.length;if(L&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var f=Math.max(0,h[0].start),p=Math.max(f,f+o.totalduration);l.setLiveSeekableRange(f,p)}},w.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,L=Object.keys(h).length;if(L&&!o||L===2){this.createSourceBuffers(h),this.pendingTracks={};var f=this.getSourceBufferTypes();if(f.length===0){this.hls.trigger(I.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}f.forEach(function(p){l.executeNext(p)})}},w.createSourceBuffers=function(o){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var L=0;for(var f in o)if(!l[f]){var p=o[f];if(!p)throw Error("source buffer exists for track "+f+", however track does not");var _=p.levelCodec||p.codec,b=p.container+";codecs="+_;D.logger.log("[buffer-controller]: creating sourceBuffer("+b+")");try{var g=l[f]=h.addSourceBuffer(b),c=f;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[f]={buffer:g,codec:_,container:p.container,levelCodec:p.levelCodec,id:p.id},L++}catch(u){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(I.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:b})}}L&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},w._onSBUpdateStart=function(o){var l=this.operationQueue,h=l.current(o);h.onStart()},w._onSBUpdateEnd=function(o){var l=this.operationQueue,h=l.current(o);h.onComplete(),l.shiftAndExecuteNext(o)},w._onSBUpdateError=function(o,l){D.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(I.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)},w.removeExecutor=function(o,l,h){var L=this.media,f=this.mediaSource,p=this.operationQueue,_=this.sourceBuffer,b=_[o];if(!L||!f||!b){D.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var g=Object(X.isFiniteNumber)(L.duration)?L.duration:Infinity,c=Object(X.isFiniteNumber)(f.duration)?f.duration:Infinity,u=Math.max(0,l),a=Math.min(h,g,c);a>u?(D.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+o+" SourceBuffer"),console.assert(!b.updating,o+" sourceBuffer must not be updating"),b.remove(u,a)):p.shiftAndExecuteNext(o)},w.appendExecutor=function(o,l){var h=this.operationQueue,L=this.sourceBuffer,f=L[l];if(!f){D.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}f.ended=!1,console.assert(!f.updating,l+" sourceBuffer must not be updating"),f.appendBuffer(o)},w.blockBuffers=function(o,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var L=this.operationQueue,f=l.map(function(p){return L.appendBlocker(p)});Promise.all(f).then(function(){o(),l.forEach(function(p){var _=h.sourceBuffer[p];(!_||!_.updating)&&L.shiftAndExecuteNext(p)})})},w.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},w.addBufferListener=function(o,l,h){var L=this.sourceBuffer[o];if(!L)return;var f=h.bind(this,o);this.listeners[o].push({event:l,listener:f}),L.addEventListener(l,f)},w.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(h){l.removeEventListener(h.event,h.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return I});var X=R("./src/utils/logger.ts"),I=function(){function D(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var H=D.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 A=k[0];try{A.execute()}catch(E){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),A.onError(E),(!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]},D}()},"./src/controller/cap-level-controller.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/events.ts");function I(F,M){for(var O=0;O0&&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 A=k.filter(function(E,w){return F.isLevelAllowed(w,C.restrictedLevels)&&w<=v});return this.clientRect=null,F.getMaxLevelByMediaSize(A,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},F.isLevelAllowed=function(v,C){return C===void 0&&(C=[]),C.indexOf(v)===-1},F.getMaxLevelByMediaSize=function(v,C,k){if(!v||!v.length)return-1;for(var A=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},E=v.length-1,w=0;w=C||d.height>=k)&&A(d,v[w+1])){E=w;break}}return E},D(F,[{key:"mediaWidth",get:function(){return this.getDimensions().width*F.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*F.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(C){}return v}}]),F}();Z.default=H},"./src/controller/cmcd-controller.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return A});var X=R("./src/events.ts"),I=R("./src/types/cmcd.ts"),D=R("./src/utils/buffer-helper.ts"),H=R("./src/utils/logger.ts");function F(E,w){for(var d=0;d=E.length?{done:!0}:{done:!1,value:E[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(E,w){if(!E)return;if(typeof E=="string")return C(E,w);var d=Object.prototype.toString.call(E).slice(8,-1);if(d==="Object"&&E.constructor&&(d=E.constructor.name),d==="Map"||d==="Set")return Array.from(E);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return C(E,w)}function C(E,w){(w==null||w>E.length)&&(w=E.length);for(var d=0,o=new Array(w);dl&&(l=p.bitrate)}return l>0?l:NaN},w.getBufferLength=function(o){var l=this.hls.media,h=o===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var L=D.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return L.len*1e3},w.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,h=o||this.config.loader;return function(){function L(p){this.loader=void 0,this.loader=new h(p)}var f=L.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(_,b,g){l(_),this.loader.load(_,b,g)},M(L,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),L}()},w.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,h=o||this.config.loader;return function(){function L(p){this.loader=void 0,this.loader=new h(p)}var f=L.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(_,b,g){l(_),this.loader.load(_,b,g)},M(L,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),L}()},E.uuid=function(){var o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},E.serialize=function(o){for(var l=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},L=function(G){return Math.round(G)},f=function(G){return L(G/100)*100},p=function(G){return encodeURIComponent(G)},_={br:L,d:L,bl:f,dl:f,mtp:f,nor:p,rtp:f,tb:L},b=Object.keys(o||{}).sort(),g=O(b),c;!(c=g()).done;){var u=c.value,a=o[u];if(!h(a))continue;if(u==="v"&&a===1)continue;if(u=="pr"&&a===1)continue;var x=_[u];x&&(a=x(a));var y=typeof a,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+a:y==="boolean"?S=u:y==="number"?S=u+"="+a:S=u+"="+JSON.stringify(a),l.push(S)}return l.join(",")},E.toHeaders=function(o){for(var l=Object.keys(o),h={},L=["Object","Request","Session","Status"],f=[{},{},{},{}],p={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},_=0,b=l;_O){this.hls.trigger(X.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var p=O-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(l,h)}break}},E._generateLicenseRequestChallenge=function(d,o){switch(d.mediaKeySystemDomain){case H.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},E._requestLicense=function(d,o){D.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),L=this._createLicenseXhr(h,d,o);D.logger.log("Sending license request to URL: "+h);var f=this._generateLicenseRequestChallenge(l,d);L.send(f)}catch(p){D.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(X.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},E.onMediaAttached=function(d,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},E.onMediaDetached=function(){var d=this._media,o=this._mediaKeysList;if(!d)return;d.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 d.setMediaKeys(null)}).catch(function(){})},E.onManifestParsed=function(d,o){if(!this._emeEnabled)return;var l=o.levels.map(function(L){return L.audioCodec}).filter(function(L){return!!L}),h=o.levels.map(function(L){return L.videoCodec}).filter(function(L){return!!L});this._attemptKeySystemAccess(H.KeySystems.WIDEVINE,l,h)},M(A,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),A}();Z.default=k},"./src/controller/fps-controller.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/events.ts"),I=R("./src/utils/logger.ts"),D=function(){function H(M){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=M,this.registerListeners()}var F=H.prototype;return F.setStreamController=function(O){this.streamController=O},F.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(O,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)}},F.checkFPS=function(O,v,C){var k=performance.now();if(v){if(this.lastTime){var A=k-this.lastTime,E=C-this.lastDroppedFrames,w=v-this.lastDecodedFrames,d=1e3*E/A,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:E,currentDecoded:w,totalDroppedFrames:C}),d>0&&E>o.config.fpsDroppedMonitoringThreshold*w){var l=o.currentLevel;I.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(X.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}},F.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}();Z.default=D},"./src/controller/fragment-finders.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"findFragmentByPDT",function(){return D}),R.d(Z,"findFragmentByPTS",function(){return H}),R.d(Z,"fragmentWithinToleranceTest",function(){return F}),R.d(Z,"pdtWithinToleranceTest",function(){return M}),R.d(Z,"findFragWithCC",function(){return O});var X=R("./src/polyfills/number.ts"),I=R("./src/utils/binary-search.ts");function D(v,C,k){if(C===null||!Array.isArray(v)||!v.length||!Object(X.isFiniteNumber)(C))return null;var A=v[0].programDateTime;if(C<(A||0))return null;var E=v[v.length-1].endProgramDateTime;if(C>=(E||0))return null;k=k||0;for(var w=0;wv&&k.start?-1:0}function M(v,C,k){var A=Math.min(C,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,E=k.endProgramDateTime||0;return E-A>v}function O(v,C){return I.default.search(v,function(k){return k.ccC?-1:0})}},"./src/controller/fragment-tracker.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"FragmentState",function(){return D}),R.d(Z,"FragmentTracker",function(){return H});var X=R("./src/events.ts"),I=R("./src/types/loader.ts"),D;(function(O){O.NOT_LOADED="NOT_LOADED",O.BACKTRACKED="BACKTRACKED",O.APPENDING="APPENDING",O.PARTIAL="PARTIAL",O.OK="OK"})(D||(D={}));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(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var k=this.hls;k.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(k,A){if(A===I.PlaylistLevelType.MAIN){var E=this.activeFragment,w=this.activeParts;if(!E)return null;if(w)for(var d=w.length;d--;){var o=w[d],l=o?o.end:E.appendedPTS;if(o.start<=k&&l!==void 0&&k<=l)return d>9&&(this.activeParts=w.slice(d-9)),o}else if(E.start<=k&&E.appendedPTS!==void 0&&k<=E.appendedPTS)return E}return this.getBufferedFrag(k,A)},v.getBufferedFrag=function(k,A){for(var E=this.fragments,w=Object.keys(E),d=w.length;d--;){var o=E[w[d]];if((o==null?void 0:o.body.type)===A&&o.buffered){var l=o.body;if(l.start<=k&&k<=l.end)return l}}return null},v.detectEvictedFragments=function(k,A,E){var w=this;Object.keys(this.fragments).forEach(function(d){var o=w.fragments[d];if(!o)return;if(!o.buffered){o.body.type===E&&w.removeFragment(o.body);return}var l=o.range[k];if(!l)return;l.time.some(function(h){var L=!w.isTimeBuffered(h.startPTS,h.endPTS,A);return L&&w.removeFragment(o.body),L})})},v.detectPartialFragments=function(k){var A=this,E=this.timeRanges,w=k.frag,d=k.part;if(!E||w.sn==="initSegment")return;var o=M(w),l=this.fragments[o];if(!l)return;Object.keys(E).forEach(function(h){var L=w.elementaryStreams[h];if(!L)return;var f=E[h],p=d!==null||L.partial===!0;l.range[h]=A.getBufferedTimes(w,d,p,f)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},v.fragBuffered=function(k){var A=M(k),E=this.fragments[A];E&&(E.backtrack=E.loaded=null,E.buffered=!0)},v.getBufferedTimes=function(k,A,E,w){for(var d={time:[],partial:E},o=A?A.start:k.start,l=A?A.end:k.end,h=k.minEndPTS||l,L=k.maxStartPTS||o,f=0;f=p&&h<=_){d.time.push({startPTS:Math.max(o,w.start(f)),endPTS:Math.min(l,w.end(f))});break}else if(o<_&&l>p)d.partial=!0,d.time.push({startPTS:Math.max(o,w.start(f)),endPTS:Math.min(l,w.end(f))});else if(l<=p)break}return d},v.getPartialFragment=function(k){var A=null,E,w,d,o=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(L){var f=h[L];if(!f)return;F(f)&&(w=f.body.start-l,d=f.body.end+l,k>=w&&k<=d&&(E=Math.min(k-w,d-k),o<=E&&(A=f.body,o=E)))}),A},v.getState=function(k){var A=M(k),E=this.fragments[A];return E?E.buffered?F(E)?D.PARTIAL:D.OK:E.backtrack?D.BACKTRACKED:D.APPENDING:D.NOT_LOADED},v.backtrack=function(k,A){var E=M(k),w=this.fragments[E];if(!w||w.backtrack)return null;var d=w.backtrack=A||w.loaded;return w.loaded=null,d},v.getBacktrackData=function(k){var A=M(k),E=this.fragments[A];if(E){var w,d=E.backtrack;if(d!=null&&(w=d.payload)!==null&&w!==void 0&&w.byteLength)return d;this.removeFragment(k)}return null},v.isTimeBuffered=function(k,A,E){for(var w,d,o=0;o=w&&A<=d)return!0;if(A<=w)return!1}return!1},v.onFragLoaded=function(k,A){var E=A.frag,w=A.part;if(E.sn==="initSegment"||E.bitrateTest||w)return;var d=M(E);this.fragments[d]={body:E,loaded:A,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(k,A){var E=this,w=A.frag,d=A.part,o=A.timeRanges;if(w.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=w,d){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(d)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var L=o[h];if(E.detectEvictedFragments(h,L),!d)for(var f=0;fk&&w.removeFragment(l)}})},v.removeFragment=function(k){var A=M(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[A]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function F(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(ae,Z,R){"use strict";R.r(Z),R.d(Z,"STALL_MINIMUM_DURATION_MS",function(){return F}),R.d(Z,"MAX_START_GAP_JUMP",function(){return M}),R.d(Z,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),R.d(Z,"SKIP_BUFFER_RANGE_START",function(){return v}),R.d(Z,"default",function(){return C});var X=R("./src/utils/buffer-helper.ts"),I=R("./src/errors.ts"),D=R("./src/events.ts"),H=R("./src/utils/logger.ts"),F=250,M=2,O=.1,v=.05,C=function(){function k(E,w,d,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=E,this.media=w,this.fragmentTracker=d,this.hls=o}var A=k.prototype;return A.destroy=function(){this.hls=this.fragmentTracker=this.media=null},A.poll=function(w){var d=this.config,o=this.media,l=this.stalled,h=o.currentTime,L=o.seeking,f=this.seeking&&!L,p=!this.seeking&&L;if(this.seeking=L,h!==w){if(this.moved=!0,l!==null){if(this.stallReported){var _=self.performance.now()-l;H.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(_)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||f)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!X.BufferHelper.getBuffered(o).length)return;var b=X.BufferHelper.bufferInfo(o,h,0),g=b.len>0,c=b.nextStart||0;if(!g&&!c)return;if(L){var u=b.len>M,a=!c||c-h>M&&!this.fragmentTracker.getPartialFragment(h);if(u||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,y=Math.max(c,b.start||0)-h,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=S==null||((x=S.details)===null||x===void 0)?void 0:x.live,G=P?S.details.targetduration*2:M;if(y>0&&y<=G){this._trySkipBufferHole(null);return}}var Y=self.performance.now();if(l===null){this.stalled=Y;return}var Q=Y-l;!L&&Q>=F&&this._reportStall(b.len);var z=X.BufferHelper.bufferInfo(o,h,d.maxBufferHole);this._tryFixBufferStall(z,Q)},A._tryFixBufferStall=function(w,d){var o=this.config,l=this.fragmentTracker,h=this.media,L=h.currentTime,f=l.getPartialFragment(L);if(f){var p=this._trySkipBufferHole(f);if(p)return}w.len>o.maxBufferHole&&d>o.highBufferWatchdogPeriod*1e3&&(H.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},A._reportStall=function(w){var d=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="+w+")"),d.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:w}))},A._trySkipBufferHole=function(w){for(var d=this.config,o=this.hls,l=this.media,h=l.currentTime,L=0,f=X.BufferHelper.getBuffered(l),p=0;p=L&&h<_){var b=Math.max(_+v,l.currentTime+O);return H.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+b),this.moved=!0,this.stalled=null,l.currentTime=b,w&&o.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+b,frag:w}),b}L=f.end(p)}return 0},A._tryNudgeBuffer=function(){var w=this.config,d=this.hls,o=this.media,l=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),_=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;k.playbackRate=Math.min(p,Math.max(1,_))}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},F(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var k=this.config,A=this.levelDetails;return k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:A?k.liveMaxLatencyDurationCount*A.targetduration:0}},{key:"targetLatency",get:function(){var k=this.levelDetails;if(k===null)return null;var A=k.holdBack,E=k.partHoldBack,w=k.targetduration,d=this.config,o=d.liveSyncDuration,l=d.liveSyncDurationCount,h=d.lowLatencyMode,L=this.hls.userConfig,f=h&&E||A;(L.liveSyncDuration||L.liveSyncDurationCount||f===0)&&(f=o!==void 0?o:l*w);var p=w,_=1;return f+Math.min(this.stallCount*_,p)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),A=this.targetLatency,E=this.levelDetails;if(k===null||A===null||E===null)return null;var w=E.edge,d=k-A-this.edgeStalled,o=w-E.totalduration,l=w-(this.config.lowLatencyMode&&E.partTarget||E.targetduration);return Math.min(Math.max(o,d),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 A=(this.config.lowLatencyMode&&k.partTarget||k.targetduration)*3;return Math.max(k.age-A,0)}},{key:"forwardBufferLength",get:function(){var k=this.media,A=this.levelDetails;if(!k||!A)return 0;var E=k.buffered.length;return E?k.buffered.end(E-1):A.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return d});var X=R("./src/types/level.ts"),I=R("./src/events.ts"),D=R("./src/errors.ts"),H=R("./src/utils/codecs.ts"),F=R("./src/controller/level-helper.ts"),M=R("./src/controller/base-playlist-controller.ts"),O=R("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var l=1;l0){c=_[0].bitrate,_.sort(function(Q,z){return Q.bitrate-z.bitrate}),this._levels=_;for(var P=0;P<_.length;P++)if(_[P].bitrate===c){this._firstLevel=P,this.log("manifest loaded, "+_.length+" level(s) found, first bitrate: "+c);break}var G=S&&!y,Y={levels:_,audioTracks:b,subtitleTracks:g,firstLevel:this._firstLevel,stats:p.stats,audio:S,video:y,altAudio:!G&&b.some(function(Q){return!!Q.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,Y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(f,p){if(o.prototype.onError.call(this,f,p),p.fatal)return;var _=p.context,b=this._levels[this.currentLevelIndex];if(_&&(_.type===O.PlaylistContextType.AUDIO_TRACK&&b.audioGroupIds&&_.groupId===b.audioGroupIds[b.urlId]||_.type===O.PlaylistContextType.SUBTITLE_TRACK&&b.textGroupIds&&_.groupId===b.textGroupIds[b.urlId])){this.redundantFailover(this.currentLevelIndex);return}var g=!1,c=!0,u;switch(p.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(u=p.frag.level)):u=p.frag.level}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:_&&(_.deliveryDirectives&&(c=!1),u=_.level),g=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:u=p.level,g=!0;break}u!==void 0&&this.recoverLevel(p,u,g,c)},h.recoverLevel=function(f,p,_,b){var g=f.details,c=this._levels[p];if(c.loadError++,_){var u=this.retryLoadingOrFail(f);if(u)f.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(b){var a=c.url.length;if(a>1&&c.loadError1){var b=(p.urlId+1)%_;this.warn("Switching to redundant URL-id "+b),this._levels.forEach(function(g){g.urlId=b}),this.level=f}},h.onFragLoaded=function(f,p){var _=p.frag;if(_!==void 0&&_.type===O.PlaylistLevelType.MAIN){var b=this._levels[_.level];b!==void 0&&(b.fragmentError=0,b.loadError=0)}},h.onLevelLoaded=function(f,p){var _,b=p.level,g=p.details,c=this._levels[b];if(!c){var u;this.warn("Invalid level index "+b),(u=p.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(g.deltaUpdateFailed=!0);return}b===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(b,p,c.details)):(_=p.deliveryDirectives)!==null&&_!==void 0&&_.skip&&(g.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(f,p){var _=this.hls.levels[this.currentLevelIndex];if(!_)return;if(_.audioGroupIds){for(var b=-1,g=this.hls.audioTracks[p.id].groupId,c=0;c<_.audioGroupIds.length;c++)if(_.audioGroupIds[c]===g){b=c;break}b!==_.urlId&&(_.urlId=b,this.startLoad())}},h.loadPlaylist=function(f){var p=this.currentLevelIndex,_=this._levels[p];if(this.canLoad&&_&&_.url.length>0){var b=_.urlId,g=_.url[b];if(f)try{g=f.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+p+(f?" at sn "+f.msn+" part "+f.part:"")+" with URL-id "+b+" "+g),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:g,level:p,id:b,deliveryDirectives:f||null})}},h.removeLevel=function(f,p){var _=function(c,u){return u!==p},b=this._levels.filter(function(g,c){return c!==f?!0:g.url.length>1&&p!==void 0?(g.url=g.url.filter(_),g.audioGroupIds&&(g.audioGroupIds=g.audioGroupIds.filter(_)),g.textGroupIds&&(g.textGroupIds=g.textGroupIds.filter(_)),g.urlId=0,!0):!1}).map(function(g,c){var u=g.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=c}),g});this._levels=b,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:b})},k(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(f){var p,_=this._levels;if(_.length===0)return;if(this.currentLevelIndex===f&&(p=_[f])!==null&&p!==void 0&&p.details)return;if(f<0||f>=_.length){var b=f<0;if(this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:f,fatal:b,reason:"invalid level idx"}),b)return;f=Math.min(f,_.length-1)}this.clearTimer();var g=this.currentLevelIndex,c=_[g],u=_[f];this.log("switching to level "+f+" from "+g),this.currentLevelIndex=f;var a=v({},u,{level:f,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,a);var x=u.details;if(!x||x.live){var y=this.switchParams(u.uri,c==null?void 0:c.details);this.loadPlaylist(y)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(f){this.manualLevelIndex=f,this._startLevel===void 0&&(this._startLevel=f),f!==-1&&(this.level=f)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(f){this._firstLevel=f}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var f=this.hls.config.startLevel;return f!==void 0?f:this._firstLevel}else return this._startLevel},set:function(f){this._startLevel=f}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(f){this.level=f,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=f)}}]),l}(M.default)},"./src/controller/level-helper.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"addGroupId",function(){return D}),R.d(Z,"assignTrackIdsByGroup",function(){return H}),R.d(Z,"updatePTS",function(){return F}),R.d(Z,"updateFragPTSDTS",function(){return O}),R.d(Z,"mergeDetails",function(){return v}),R.d(Z,"mapPartIntersection",function(){return C}),R.d(Z,"mapFragmentIntersection",function(){return k}),R.d(Z,"adjustSliding",function(){return A}),R.d(Z,"addSliding",function(){return E}),R.d(Z,"computeReloadInterval",function(){return w}),R.d(Z,"getFragmentWithSN",function(){return d}),R.d(Z,"getPartWith",function(){return o});var X=R("./src/polyfills/number.ts"),I=R("./src/utils/logger.ts");function D(l,h,L){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(L);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(L);break}}function H(l){var h={};l.forEach(function(L){var f=L.groupId||"";L.id=h[f]=h[f]||0,h[f]++})}function F(l,h,L){var f=l[h],p=l[L];M(f,p)}function M(l,h){var L=h.startPTS;if(Object(X.isFiniteNumber)(L)){var f=0,p;h.sn>l.sn?(f=L-l.start,p=l):(f=l.start-L,p=h),p.duration!==f&&(p.duration=f)}else if(h.sn>l.sn){var _=l.cc===h.cc;_&&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,L,f,p,_){var b=f-L;b<=0&&(I.logger.warn("Fragment should have a positive duration",h),f=L+h.duration,_=p+h.duration);var g=L,c=f,u=h.startPTS,a=h.endPTS;if(Object(X.isFiniteNumber)(u)){var x=Math.abs(u-L);Object(X.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(x,h.deltaPTS):h.deltaPTS=x,g=Math.max(L,u),L=Math.min(L,u),p=Math.min(p,h.startDTS),c=Math.min(f,a),f=Math.max(f,a),_=Math.max(_,h.endDTS)}h.duration=f-L;var y=L-h.start;h.appendedPTS=f,h.start=h.startPTS=L,h.maxStartPTS=g,h.startDTS=p,h.endPTS=f,h.minEndPTS=c,h.endDTS=_;var S=h.sn;if(!l||Sl.endSN)return 0;var P,G=S-l.startSN,Y=l.fragments;for(Y[G]=h,P=G;P>0;P--)M(Y[P],Y[P-1]);for(P=G;P=0;p--){var _=f[p].initSegment;if(_){L=_;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var b=0,g;if(k(l,h,function(P,G){P.relurl&&(b=P.cc-G.cc),Object(X.isFiniteNumber)(P.startPTS)&&Object(X.isFiniteNumber)(P.endPTS)&&(G.start=G.startPTS=P.startPTS,G.startDTS=P.startDTS,G.appendedPTS=P.appendedPTS,G.maxStartPTS=P.maxStartPTS,G.endPTS=P.endPTS,G.endDTS=P.endDTS,G.minEndPTS=P.minEndPTS,G.duration=P.endPTS-P.startPTS,G.duration&&(g=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=P.elementaryStreams,G.loader=P.loader,G.stats=P.stats,G.urlId=P.urlId,P.initSegment&&(G.initSegment=P.initSegment,L=P.initSegment)}),L){var c=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;c.forEach(function(P){var G;(!P.initSegment||P.initSegment.relurl===((G=L)===null||G===void 0?void 0:G.relurl))&&(P.initSegment=L)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(P){return!P}),h.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=h.skippedSegments;u--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var a=h.fragments;if(b){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x=f.length)return;E(h,f[L].start)}function E(l,h){if(h){for(var L=l.fragments,f=l.skippedSegments;f0&&p0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),c=u),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},b.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},b.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var c,u=this.levels,a=this.level,x=u==null||((c=u[a])===null||c===void 0)?void 0:c.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var y,S=self.performance.now(),P=this.retryDate;(!P||S>=P||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},b.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},b.doTickIdle=function(){var c,u,a=this.hls,x=this.levelLastLoaded,y=this.levels,S=this.media,P=a.config,G=a.nextLoadLevel;if(x===null||!S&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!y||!y[G])return;var Y=y[G];this.level=a.nextLoadLevel=G;var Q=Y.details;if(!Q||this.state===I.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==G){this.state=I.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:S,O.PlaylistLevelType.MAIN);if(z===null)return;var j=z.len,ee=this.getMaxBufferLength(Y.maxBitrate);if(j>=ee)return;if(this._streamEnded(z,Q)){var oe={};this.altAudio&&(oe.type="video"),this.hls.trigger(H.Events.BUFFER_EOS,oe),this.state=I.State.ENDED;return}var fe=z.end,ve=this.getNextFragment(fe,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var Re=ve.sn-Q.startSN;Re>1&&(ve=Q.fragments[Re-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===M.FragmentState.OK&&this.nextLoadPosition>fe){var Ee=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(S,Ee,O.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((c=ve.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((u=ve.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,fe)},b.loadFragment=function(c,u,a){var x,y=this.fragmentTracker.getState(c);if(this.fragCurrent=c,y===M.FragmentState.BACKTRACKED){var S=this.fragmentTracker.getBacktrackData(c);if(S){this._handleFragmentLoadProgress(S),this._handleFragmentLoadComplete(S);return}else y=M.FragmentState.NOT_LOADED}y===M.FragmentState.NOT_LOADED||y===M.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,c,u,a)):y===M.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},b.getAppendedFrag=function(c){var u=this.fragmentTracker.getAppendedFrag(c,O.PlaylistLevelType.MAIN);return u&&"fragment"in u?u.fragment:u},b.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,O.PlaylistLevelType.MAIN)},b.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},b.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},b.nextLevelSwitch=function(){var c=this.levels,u=this.media;if(u!=null&&u.readyState){var a,x=this.getAppendedFrag(u.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!u.paused&&c){var y=this.hls.nextLoadLevel,S=c[y],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*S.maxBitrate/(1e3*P)+1:a=0}else a=0;var G=this.getBufferedFrag(u.currentTime+a);if(G){var Y=this.followingBufferedFrag(G);if(Y){this.abortCurrentFrag();var Q=Y.maxStartPTS?Y.maxStartPTS:Y.start,z=Y.duration,j=Math.max(G.end,Q+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(j,Number.POSITIVE_INFINITY)}}}},b.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===I.State.KEY_LOADING&&(this.state=I.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},b.flushMainBuffer=function(c,u){p.prototype.flushMainBuffer.call(this,c,u,this.altAudio?"video":null)},b.onMediaAttached=function(c,u){p.prototype.onMediaAttached.call(this,c,u);var a=u.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new A.default(this.config,a,this.fragmentTracker,this.hls)},b.onMediaDetaching=function(){var c=this.media;c&&(c.removeEventListener("playing",this.onvplaying),c.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),p.prototype.onMediaDetaching.call(this)},b.onMediaPlaying=function(){this.tick()},b.onMediaSeeked=function(){var c=this.media,u=c?c.currentTime:null;Object(X.isFiniteNumber)(u)&&this.log("Media seeked to "+u.toFixed(3)),this.tick()},b.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},b.onManifestParsed=function(c,u){var a=!1,x=!1,y;u.levels.forEach(function(S){y=S.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(a=!0),y.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=a&&x&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=u.levels,this.startFragRequested=!1},b.onLevelLoading=function(c,u){var a=this.levels;if(!a||this.state!==I.State.IDLE)return;var x=a[u.level];(!x.details||x.details.live&&this.levelLastLoaded!==u.level||this.waitForCdnTuneIn(x.details))&&(this.state=I.State.WAITING_LEVEL)},b.onLevelLoaded=function(c,u){var a,x=this.levels,y=u.level,S=u.details,P=S.totalduration;if(!x){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+S.startSN+","+S.endSN+"], cc ["+S.startCC+", "+S.endCC+"] duration:"+P);var G=this.fragCurrent;G&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==u.level&&G.loader&&(this.state=I.State.IDLE,G.loader.abort()));var Y=x[y],Q=0;if(S.live||(a=Y.details)!==null&&a!==void 0&&a.live){if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed)return;Q=this.alignPlaylists(S,Y.details)}if(Y.details=S,this.levelLastLoaded=y,this.hls.trigger(H.Events.LEVEL_UPDATED,{details:S,level:y}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(S))return;this.state=I.State.IDLE}this.startFragRequested?S.live&&this.synchronizeToLiveEdge(S):this.setStartPosition(S,Q),this.tick()},b._handleFragmentLoadProgress=function(c){var u,a=c.frag,x=c.part,y=c.payload,S=this.levels;if(!S){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var P=S[a.level],G=P.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var Y=P.videoCodec,Q=G.PTSKnown||!G.live,z=(u=a.initSegment)===null||u===void 0?void 0:u.data,j=this._getAudioCodec(P),ee=this.transmuxer=this.transmuxer||new C.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=x?x.index:-1,fe=oe!==-1,ve=new k.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,y.byteLength,oe,fe),Re=this.initPTS[a.cc];ee.push(y,z,j,Y,a,x,G.totalduration,Q,ve,Re)},b.onAudioTrackSwitching=function(c,u){var a=this.altAudio,x=!!u.url,y=u.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var S=this.fragCurrent;S!=null&&S.loader&&(this.log("Switching to main audio track, cancel main fragment load"),S.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;a&&P.trigger(H.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(H.Events.AUDIO_TRACK_SWITCHED,{id:y})}},b.onAudioTrackSwitched=function(c,u){var a=u.id,x=!!this.hls.audioTracks[a].url;if(x){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=x,this.tick()},b.onBufferCreated=function(c,u){var a=u.tracks,x,y,S=!1;for(var P in a){var G=a[P];if(G.id==="main"){if(y=P,x=G,P==="video"){var Y=a[P];Y&&(this.videoBuffer=Y.buffer)}}else S=!0}S&&x?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},b.onFragBuffered=function(c,u){var a=u.frag,x=u.part;if(a&&a.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(x?" p: "+x.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var y=x?x.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,x)},b.onError=function(c,u){switch(u.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.MAIN,u);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(u.fatal?(this.warn(""+u.details),this.state=I.State.ERROR):!u.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case E.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var a=!0,x=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);x&&x.len>.5&&(a=!this.reduceMaxBufferLength(x.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},b.checkBuffer=function(){var c=this.media,u=this.gapController;if(!c||!u||!c.readyState)return;var a=F.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):u.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},b.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},b.onBufferFlushed=function(c,u){var a=u.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,a,O.PlaylistLevelType.MAIN)}},b.onLevelsUpdated=function(c,u){this.levels=u.levels},b.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},b.seekToStartPos=function(){var c=this.media,u=c.currentTime,a=this.startPosition;if(a>=0&&u0&&(S1&&c.seeking===!1){var a=c.currentTime;if(F.BufferHelper.isBuffered(c,a)?u=this.getAppendedFrag(a):F.BufferHelper.isBuffered(c,a+.1)&&(u=this.getAppendedFrag(a+.1)),u){var x=this.fragPlaying,y=u.level;(!x||u.sn!==x.sn||x.level!==y||u.urlId!==x.urlId)&&(this.hls.trigger(H.Events.FRAG_CHANGED,{frag:u}),(!x||x.level!==y)&&this.hls.trigger(H.Events.LEVEL_SWITCHED,{level:y}),this.fragPlaying=u)}}},o(_,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);if(u)return u.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(u)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),_}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"SubtitleStreamController",function(){return l});var X=R("./src/events.ts"),I=R("./src/utils/logger.ts"),D=R("./src/utils/buffer-helper.ts"),H=R("./src/controller/fragment-finders.ts"),F=R("./src/utils/discontinuities.ts"),M=R("./src/controller/level-helper.ts"),O=R("./src/controller/fragment-tracker.ts"),v=R("./src/controller/base-stream-controller.ts"),C=R("./src/types/loader.ts"),k=R("./src/types/level.ts");function A(h,L){for(var f=0;f=u[y].start&&x<=u[y].end){a=u[y];break}var S=g.start+g.duration;a?a.end=S:(a={start:x,end:S},u.push(a)),this.fragmentTracker.fragBuffered(g)},f.onBufferFlushing=function(_,b){var g=b.startOffset,c=b.endOffset;if(g===0&&c!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var x=a[u].details,y=x.targetduration,S=c-y;if(S<=0)return;b.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(P){for(var G=0;G=x.length||u!==a||!y)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(g=y.details)!==null&&g!==void 0&&g.live){var S=this.mainDetails;if(c.deltaUpdateFailed||!S)return;var P=S.fragments[0];if(!y.details)c.hasProgramDateTime&&S.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(c,S):P&&Object(M.addSliding)(c,P.start);else{var G=this.alignPlaylists(c,y.details);G===0&&P&&Object(M.addSliding)(c,P.start)}}if(y.details=c,this.levelLastLoaded=u,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var Y=Object(H.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);Y||(this.warn("Subtitle playlist not aligned with playback"),y.details=void 0)}},f._handleFragmentLoadComplete=function(_){var b=_.frag,g=_.payload,c=b.decryptdata,u=this.hls;if(this.fragContextChanged(b))return;if(g&&g.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),c.key.buffer,c.iv.buffer).then(function(x){var y=performance.now();u.trigger(X.Events.FRAG_DECRYPTED,{frag:b,payload:x,stats:{tstart:a,tdecrypt:y}})})}},f.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var _,b=this.currentTrackId,g=this.levels;if(!g.length||!g[b]||!g[b].details)return;var c=g[b].details,u=c.targetduration,a=this.config,x=this.media,y=D.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,x.currentTime-u,a.maxBufferHole),S=y.end,P=y.len,G=this.getMaxBufferLength()+u;if(P>G)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var Y=c.fragments,Q=Y.length,z=c.edge,j,ee=this.fragPrevious;if(S-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)},w.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},w.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(I.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},w.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},w.onSubtitleTrackLoaded=function(o,l){var h=l.id,L=l.details,f=this.trackId,p=this.tracksInGroup[f];if(!p){this.warn("Invalid subtitle track id "+h);return}var _=p.details;p.details=l.details,this.log("subtitle track "+h+" loaded ["+L.startSN+"-"+L.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,_))},w.onLevelLoading=function(o,l){this.switchLevel(l.level)},w.onLevelSwitching=function(o,l){this.switchLevel(l.level)},w.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 L=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,f=this.tracks.filter(function(b){return!h||b.groupId===h});this.tracksInGroup=f;var p=this.findTrackId(L==null?void 0:L.name)||this.findTrackId();this.groupId=h;var _={subtitleTracks:f};this.log("Updating subtitle tracks, "+f.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,_),p!==-1&&this.setSubtitleTrack(p,L)}},w.findTrackId=function(o){for(var l=this.tracksInGroup,h=0;h=L.length)return;this.clearTimer();var f=L[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,f){var p=f.id,_=f.groupId,b=_===void 0?"":_,g=f.name,c=f.type,u=f.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:b,name:g,type:c,url:u});var a=this.switchParams(f.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},w.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=0&&(c[0]=Math.min(c[0],L),c[1]=Math.max(c[1],f),b=!0,u/(f-L)>.5))return}if(b||_.push([L,f]),this.config.renderTextTracksNatively){var a=this.captionsTracks[h];this.Cues.newCue(a,L,f,p)}else{var x=this.Cues.newCue(null,L,f,p);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:x,track:h})}},o.onInitPtsFound=function(h,L){var f=this,p=L.frag,_=L.id,b=L.initPTS,g=L.timescale,c=this.unparsedVttFrags;_==="main"&&(this.initPTS[p.cc]=b,this.timescale[p.cc]=g),c.length&&(this.unparsedVttFrags=[],c.forEach(function(u){f.onFragLoaded(I.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(h){var L=this.media;if(L)for(var f=0;f>>8^g&255^99,O[p]=g,v[g]=p;var c=f[p],u=f[c],a=f[u],x=f[g]*257^g*16843008;k[p]=x<<24|x>>>8,A[p]=x<<16|x>>>16,E[p]=x<<8|x>>>24,w[p]=x,x=a*16843009^u*65537^c*257^p*16843008,o[g]=x<<24|x>>>8,l[g]=x<<16|x>>>16,h[g]=x<<8|x>>>24,L[g]=x,p?(p=c^f[f[f[a^c]]],_^=f[f[_]]):p=_=1}},F.expandKey=function(O){for(var v=this.uint8ArrayToUint32Array_(O),C=!0,k=0;k>>6)+1;var x=(h[L+2]&60)>>>2;if(x>a.length-1){l.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return b=(h[L+2]&1)<<2,b|=(h[L+3]&192)>>>6,X.logger.log("manifest codec:"+f+", ADTS type:"+p+", samplingIndex:"+x),/firefox/i.test(c)?x>=6?(p=5,g=new Array(4),_=x-3):(p=2,g=new Array(2),_=x):c.indexOf("android")!==-1?(p=2,g=new Array(2),_=x):(p=5,g=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&x>=6?_=x-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(x>=6&&b===1||/vivaldi/i.test(c))||!f&&b===1)&&(p=2,g=new Array(2)),_=x)),g[0]=p<<3,g[0]|=(x&14)>>1,g[1]|=(x&1)<<7,g[1]|=b<<3,p===5&&(g[1]|=(_&14)>>1,g[2]=(_&1)<<7,g[2]|=2<<2,g[3]=0),{config:g,samplerate:a[x],channelCount:b,codec:"mp4a.40."+p,manifestCodec:u}}function F(l,h){return l[h]===255&&(l[h+1]&246)===240}function M(l,h){return l[h+1]&1?7:9}function O(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function v(l,h){return h+5=l.length)return!1;var f=O(l,h);if(f<=L)return!1;var p=h+f;return p===l.length||C(l,p)}return!1}function E(l,h,L,f,p){if(!l.samplerate){var _=H(h,L,f,p);if(!_)return;l.config=_.config,l.samplerate=_.samplerate,l.channelCount=_.channelCount,l.codec=_.codec,l.manifestCodec=_.manifestCodec,X.logger.log("parsed codec:"+l.codec+", rate:"+_.samplerate+", channels:"+_.channelCount)}}function w(l){return 1024*9e4/l}function d(l,h,L,f,p){var _=M(l,h),b=O(l,h);if(b-=_,b>0){var g=L+f*p;return{headerLength:_,frameLength:b,stamp:g}}}function o(l,h,L,f,p){var _=w(l.samplerate),b=d(h,L,f,p,_);if(b){var g=b.frameLength,c=b.headerLength,u=b.stamp,a=c+g,x=Math.max(0,L+a-h.length),y;x?(y=new Uint8Array(a-c),y.set(h.subarray(L+c,h.length),0)):y=h.subarray(L+c,L+a);var S={unit:y,pts:u};return x||l.samples.push(S),{sample:S,length:a,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"initPTSFn",function(){return O});var X=R("./src/polyfills/number.ts"),I=R("./src/demux/id3.ts"),D=R("./src/demux/dummy-demuxed-track.ts"),H=R("./src/utils/mp4-tools.ts"),F=R("./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,w){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,E){return!1},C.appendFrame=function(A,E,w){},C.demux=function(A,E){this.cachedData&&(A=Object(H.appendUint8Array)(this.cachedData,A),this.cachedData=null);var w=I.getID3Data(A,0),d=w?w.length:0,o,l,h=this._audioTrack,L=this._id3Track,f=w?I.getTimeStamp(w):void 0,p=A.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(f,E)),w&&w.length>0&&L.samples.push({pts:this.initPTS,dts:this.initPTS,data:w}),l=this.initPTS;dM?(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&&X.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<>>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;k0?p.subarray(b,b+g):void 0},H=function(p,_){var b=0;return b=(p[_]&127)<<21,b|=(p[_+1]&127)<<14,b|=(p[_+2]&127)<<7,b|=p[_+3]&127,b},F=function(p,_){return X(p,_)&&H(p,_+6)+10<=p.length-_},M=function(p){for(var _=C(p),b=0;b<_.length;b++){var g=_[b];if(O(g))return d(g)}return},O=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},v=function(p){var _=String.fromCharCode(p[0],p[1],p[2],p[3]),b=H(p,4),g=10;return{type:_,size:b,data:p.subarray(g,g+b)}},C=function(p){for(var _=0,b=[];X(p,_);){var g=H(p,_+6);_+=10;for(var c=_+g;_+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:x=p[P++],S+=String.fromCharCode((a&31)<<6|x&63);break;case 14:x=p[P++],y=p[P++],S+=String.fromCharCode((a&15)<<12|(x&63)<<6|(y&63)<<0);break;default:}}return S},l={decodeTextFrame:E},h;function L(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/demux/base-audio-demuxer.ts"),I=R("./src/demux/id3.ts"),D=R("./src/utils/logger.ts"),H=R("./src/demux/mpegaudio.ts");function F(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,E){return A.__proto__=E,A},M(v,C)}var O=function(v){F(C,v);function C(){return v.apply(this,arguments)||this}var k=C.prototype;return k.resetInitSegment=function(E,w,d){v.prototype.resetInitSegment.call(this,E,w,d),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:E,duration:d,inputTimeScale:9e4,dropped:0}},C.probe=function(E){if(!E)return!1;for(var w=I.getID3Data(E,0)||[],d=w.length,o=E.length;d0},F.demux=function(O){var v=O,C=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(X.appendUint8Array)(this.remainderData,O));var k=Object(X.segmentValidRange)(v);this.remainderData=k.remainder,C.samples=k.valid||new Uint8Array}else C.samples=v;return{audioTrack:Object(I.dummyTrack)(),avcTrack:C,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},F.flush=function(){var O=Object(I.dummyTrack)();return O.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(I.dummyTrack)(),avcTrack:O,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},F.demuxSampleAes=function(O,v,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},H}();D.minProbeByteLength=1024,Z.default=D},"./src/demux/mpegaudio.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"appendFrame",function(){return M}),R.d(Z,"parseHeader",function(){return O}),R.d(Z,"isHeaderPattern",function(){return v}),R.d(Z,"isHeader",function(){return C}),R.d(Z,"canParse",function(){return k}),R.d(Z,"probe",function(){return A});var X=null,I=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],D=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],H=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function M(E,w,d,o,l){if(d+24>w.length)return;var h=O(w,d);if(h&&d+h.frameLength<=w.length){var L=h.samplesPerFrame*9e4/h.sampleRate,f=o+l*L,p={unit:w.subarray(d,d+h.frameLength),pts:f,dts:f};return E.config=[],E.channelCount=h.channelCount,E.samplerate=h.sampleRate,E.samples.push(p),{sample:p,length:h.frameLength,missing:0}}}function O(E,w){var d=E[w+1]>>3&3,o=E[w+1]>>1&3,l=E[w+2]>>4&15,h=E[w+2]>>2&3;if(d!==1&&l!==0&&l!==15&&h!==3){var L=E[w+2]>>1&1,f=E[w+3]>>6,p=d===3?3-o:o===3?3:4,_=I[p*14+l-1]*1e3,b=d===3?0:d===2?1:2,g=D[b*3+h],c=f===3?1:2,u=H[d][o],a=F[o],x=u*8*a,y=Math.floor(u*_/g+L)*a;if(X===null){var S=navigator.userAgent||"",P=S.match(/Chrome\/(\d+)/i);X=P?parseInt(P[1]):0}var G=!!X&&X<=87;return G&&o===2&&_>=224e3&&f===0&&(E[w+3]=E[w+3]|128),{sampleRate:g,channelCount:c,frameLength:y,samplesPerFrame:x}}}function v(E,w){return E[w]===255&&(E[w+1]&224)===224&&(E[w+1]&6)!==0}function C(E,w){return w+1=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}},F.getAvcEncryptedData=function(O){for(var v=Math.floor((O.length-48)/160)*16+16,C=new Int8Array(v),k=0,A=32;A<=O.length-16;A+=160,k+=16)C.set(O.subarray(A,A+16),k);return C},F.getAvcDecryptedUnit=function(O,v){for(var C=new Uint8Array(v),k=0,A=32;A<=O.length-16;A+=160,k+=16)O.set(C.subarray(k,k+16),A);return O},F.decryptAvcSample=function(O,v,C,k,A,E){var w=Object(I.discardEPB)(A.data),d=this.getAvcEncryptedData(w),o=this;this.decryptBuffer(d.buffer,function(l){A.data=o.getAvcDecryptedUnit(w,l),E||o.decryptAvcSamples(O,v,C+1,k)})},F.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 A=O[v].units;!(C>=A.length);C++){var E=A[C];if(E.data.length<=48||E.type!==1&&E.type!==5)continue;var w=this.decrypter.isSync();if(this.decryptAvcSample(O,v,C,k,E,w),!w)return}}},H}();Z.default=D},"./src/demux/transmuxer-interface.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return A});var X=R("./node_modules/webworkify-webpack/index.js"),I=R.n(X),D=R("./src/events.ts"),H=R("./src/demux/transmuxer.ts"),F=R("./src/utils/logger.ts"),M=R("./src/errors.ts"),O=R("./src/utils/mediasource-helper.ts"),v=R("./node_modules/eventemitter3/index.js"),C=R.n(v),k=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},A=function(){function E(d,o,l,h){var L=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=d,this.id=o,this.onTransmuxComplete=l,this.onFlush=h;var f=d.config,p=function(u,a){a=a||{},a.frag=L.frag,a.id=L.id,d.trigger(u,a)};this.observer=new v.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,p),this.observer.on(D.Events.ERROR,p);var _={mp4:k.isTypeSupported("video/mp4"),mpeg:k.isTypeSupported("audio/mpeg"),mp3:k.isTypeSupported('audio/mp4; codecs="mp3"')},b=navigator.vendor;if(f.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var g;try{g=this.worker=X("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){d.trigger(D.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:_,vendor:b,id:o,config:JSON.stringify(f)})}catch(c){F.logger.warn("Error in worker:",c),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new H.default(this.observer,_,f,b,o),this.worker=null}}else this.transmuxer=new H.default(this.observer,_,f,b,o)}var w=E.prototype;return w.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},w.push=function(o,l,h,L,f,p,_,b,g,c){var u=this;g.transmuxing.start=self.performance.now();var a=this.transmuxer,x=this.worker,y=p?p.start:f.start,S=f.decryptdata,P=this.frag,G=!(P&&f.cc===P.cc),Y=!(P&&g.level===P.level),Q=P?g.sn-P.sn:-1,z=this.part?g.part-this.part.index:1,j=!Y&&(Q===1||Q===0&&z===1),ee=self.performance.now();(Y||Q||f.stats.parsing.start===0)&&(f.stats.parsing.start=ee),p&&(z||!j)&&(p.stats.parsing.start=ee);var oe=new H.TransmuxState(G,j,b,Y,y);if(!j||G){F.logger.log("[transmuxer-interface, "+f.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+` discontinuity: `+G+` trackSwitch: `+Y+` contiguous: `+j+` accurateTimeOffset: `+b+` timeOffset: `+y);var fe=new H.TransmuxConfig(h,L,l,_,c);this.configureTransmuxer(fe)}if(this.frag=f,this.part=p,x)x.postMessage({cmd:"demux",data:o,decryptdata:S,chunkMeta:g,state:oe},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,S,g,oe);Object(H.isPromise)(ve)?ve.then(function(Re){u.handleTransmuxComplete(Re)}):this.handleTransmuxComplete(ve)}},w.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,L=this.worker;if(L)L.postMessage({cmd:"flush",chunkMeta:o});else if(h){var f=h.flush(o);Object(H.isPromise)(f)?f.then(function(p){l.handleFlushResult(p,o)}):this.handleFlushResult(f,o)}},w.handleFlushResult=function(o,l){var h=this;o.forEach(function(L){h.handleTransmuxComplete(L)}),this.onFlush(l)},w.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}}},w.configureTransmuxer=function(o){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},w.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},E}()},"./src/demux/transmuxer-worker.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return M});var X=R("./src/demux/transmuxer.ts"),I=R("./src/events.ts"),D=R("./src/utils/logger.ts"),H=R("./node_modules/eventemitter3/index.js"),F=R.n(H);function M(A){var E=new H.EventEmitter,w=function(o,l){A.postMessage({event:o,data:l})};E.on(I.Events.FRAG_DECRYPTED,w),E.on(I.Events.ERROR,w),A.addEventListener("message",function(d){var o=d.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);A.transmuxer=new X.default(E,o.typeSupported,l,o.vendor,o.id),Object(D.enableLogs)(l.debug),w("init",null);break}case"configure":{A.transmuxer.configure(o.config);break}case"demux":{var h=A.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(h)?h.then(function(p){O(A,p)}):O(A,h);break}case"flush":{var L=o.chunkMeta,f=A.transmuxer.flush(L);Object(X.isPromise)(f)?f.then(function(p){C(A,p,L)}):C(A,f,L);break}default:break}})}function O(A,E){if(k(E.remuxResult))return;var w=[],d=E.remuxResult,o=d.audio,l=d.video;o&&v(w,o),l&&v(w,l),A.postMessage({event:"transmuxComplete",data:E},w)}function v(A,E){E.data1&&A.push(E.data1.buffer),E.data2&&A.push(E.data2.buffer)}function C(A,E,w){E.forEach(function(d){O(A,d)}),A.postMessage({event:"flush",data:w})}function k(A){return!A.audio&&!A.video&&!A.text&&!A.id3&&!A.initSegment}},"./src/demux/transmuxer.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return l}),R.d(Z,"isPromise",function(){return f}),R.d(Z,"TransmuxConfig",function(){return p}),R.d(Z,"TransmuxState",function(){return _});var X=R("./src/events.ts"),I=R("./src/errors.ts"),D=R("./src/crypt/decrypter.ts"),H=R("./src/demux/aacdemuxer.ts"),F=R("./src/demux/mp4demuxer.ts"),M=R("./src/demux/tsdemuxer.ts"),O=R("./src/demux/mp3demuxer.ts"),v=R("./src/remux/mp4-remuxer.ts"),C=R("./src/remux/passthrough-remuxer.ts"),k=R("./src/demux/chunk-cache.ts"),A=R("./src/utils/mp4-tools.ts"),E=R("./src/utils/logger.ts"),w;try{w=self.performance.now.bind(self.performance)}catch(b){E.logger.debug("Unable to use Performance API on this environment"),w=self.Date.now}var d=[{demux:M.default,remux:v.default},{demux:F.default,remux:C.default},{demux:H.default,remux:v.default},{demux:O.default,remux:v.default}],o=1024;d.forEach(function(b){var g=b.demux;o=Math.max(o,g.minProbeByteLength)});var l=function(){function b(c,u,a,x,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=c,this.typeSupported=u,this.config=a,this.vendor=x,this.id=y}var g=b.prototype;return g.configure=function(u){this.transmuxConfig=u,this.decrypter&&this.decrypter.reset()},g.push=function(u,a,x,y){var S=this,P=x.transmuxing;P.executeStart=w();var G=new Uint8Array(u),Y=this.cache,Q=this.config,z=this.currentTransmuxState,j=this.transmuxConfig;y&&(this.currentTransmuxState=y);var ee=h(G,a);if(ee&&ee.method==="AES-128"){var oe=this.getDecrypter();if(Q.enableSoftwareAES){var fe=oe.softwareDecrypt(G,ee.key.buffer,ee.iv.buffer);if(!fe)return P.executeEnd=w(),L(x);G=new Uint8Array(fe)}else return this.decryptionPromise=oe.webCryptoDecrypt(G,ee.key.buffer,ee.iv.buffer).then(function(Me){var je=S.push(Me,null,x);return S.decryptionPromise=null,je}),this.decryptionPromise}var ve=y||z,Re=ve.contiguous,Ee=ve.discontinuity,Se=ve.trackSwitch,we=ve.accurateTimeOffset,Te=ve.timeOffset,me=j.audioCodec,de=j.videoCodec,ke=j.defaultInitPts,Je=j.duration,Ge=j.initSegmentData;if((Ee||Se)&&this.resetInitSegment(Ge,me,de,Je),Ee&&this.resetInitialTimestamp(ke),Re||this.resetContiguity(),this.needsProbing(G,Ee,Se)){if(Y.dataLength){var Qe=Y.flush();G=Object(A.appendUint8Array)(Qe,G)}this.configureTransmuxer(G,j)}var Ye=this.transmux(G,ee,Te,we,x),Ae=this.currentTransmuxState;return Ae.contiguous=!0,Ae.discontinuity=!1,Ae.trackSwitch=!1,P.executeEnd=w(),Ye},g.flush=function(u){var a=this,x=u.transmuxing;x.executeStart=w();var y=this.decrypter,S=this.cache,P=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(u)});var Y=[],Q=P.timeOffset;if(y){var z=y.flush();z&&Y.push(this.push(z,null,u))}var j=S.dataLength;S.reset();var ee=this.demuxer,oe=this.remuxer;if(!ee||!oe)return j>=o&&this.observer.emit(X.Events.ERROR,X.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=w(),[L(u)];var fe=ee.flush(Q);return f(fe)?fe.then(function(ve){return a.flushRemux(Y,ve,u),Y}):(this.flushRemux(Y,fe,u),Y)},g.flushRemux=function(u,a,x){var y=a.audioTrack,S=a.avcTrack,P=a.id3Track,G=a.textTrack,Y=this.currentTransmuxState,Q=Y.accurateTimeOffset,z=Y.timeOffset;E.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var j=this.remuxer.remux(y,S,P,G,z,Q,!0,this.id);u.push({remuxResult:j,chunkMeta:x}),x.transmuxing.executeEnd=w()},g.resetInitialTimestamp=function(u){var a=this.demuxer,x=this.remuxer;if(!a||!x)return;a.resetTimeStamp(u),x.resetTimeStamp(u)},g.resetContiguity=function(){var u=this.demuxer,a=this.remuxer;if(!u||!a)return;u.resetContiguity(),a.resetNextTimestamp()},g.resetInitSegment=function(u,a,x,y){var S=this.demuxer,P=this.remuxer;if(!S||!P)return;S.resetInitSegment(a,x,y),P.resetInitSegment(u,a,x)},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(u,a,x,y,S){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(u,a,x,y,S):P=this.transmuxUnencrypted(u,x,y,S),P},g.transmuxUnencrypted=function(u,a,x,y){var S=this.demuxer.demux(u,a,!1,!this.config.progressive),P=S.audioTrack,G=S.avcTrack,Y=S.id3Track,Q=S.textTrack,z=this.remuxer.remux(P,G,Y,Q,a,x,!1,this.id);return{remuxResult:z,chunkMeta:y}},g.transmuxSampleAes=function(u,a,x,y,S){var P=this;return this.demuxer.demuxSampleAes(u,a,x).then(function(G){var Y=P.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,x,y,!1,P.id);return{remuxResult:Y,chunkMeta:S}})},g.configureTransmuxer=function(u,a){for(var x=this.config,y=this.observer,S=this.typeSupported,P=this.vendor,G=a.audioCodec,Y=a.defaultInitPts,Q=a.duration,z=a.initSegmentData,j=a.videoCodec,ee,oe=0,fe=d.length;oe0&&g!=null&&g.key!=null&&g.iv!==null&&g.method!=null&&(c=g),c}var L=function(g){return{remuxResult:{},chunkMeta:g}};function f(b){return"then"in b&&b.then instanceof Function}var p=function(g,c,u,a,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=g,this.videoCodec=c,this.initSegmentData=u,this.duration=a,this.defaultInitPts=x},_=function(g,c,u,a,x){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=g,this.contiguous=c,this.accurateTimeOffset=u,this.trackSwitch=a,this.timeOffset=x}},"./src/demux/tsdemuxer.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"discardEPB",function(){return L});var X=R("./src/demux/adts.ts"),I=R("./src/demux/mpegaudio.ts"),D=R("./src/demux/exp-golomb.ts"),H=R("./src/demux/id3.ts"),F=R("./src/demux/sample-aes.ts"),M=R("./src/events.ts"),O=R("./src/utils/mp4-tools.ts"),v=R("./src/utils/logger.ts"),C=R("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},A=function(){function f(_,b,g){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=_,this.config=b,this.typeSupported=g}f.probe=function(b){var g=f.syncOffset(b);return g<0?!1:(g&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),!0)},f.syncOffset=function(b){for(var g=Math.min(1e3,b.length-3*188),c=0;c>4,me=void 0;if(Te>1){if(me=Ee+5+b[Ee+4],me===Ee+188)continue}else me=Ee+4;switch(we){case P:Se&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(b.subarray(me,Ee+188)),G.size+=Ee+188-me);break;case Y:Se&&(z&&(a=o(z))&&(y.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(b.subarray(me,Ee+188)),z.size+=Ee+188-me);break;case Q:Se&&(j&&(a=o(j))&&this.parseID3PES(a),j={data:[],size:0}),j&&(j.data.push(b.subarray(me,Ee+188)),j.size+=Ee+188-me);break;case 0:Se&&(me+=b[me]+1),fe=this._pmtId=w(b,me);break;case fe:{Se&&(me+=b[me]+1);var de=d(b,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);P=de.avc,P>0&&(x.pid=P),Y=de.audio,Y>0&&(y.pid=Y,y.isAAC=de.isAAC),Q=de.id3,Q>0&&(S.pid=Q),ee&&!oe&&(v.logger.log("reparse from beginning"),ee=!1,Ee=Re-188),oe=this.pmtParsed=!0;break}case 17:case 8191:break;default:ee=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});x.pesData=G,y.pesData=z,S.pesData=j;var ke={audioTrack:y,avcTrack:x,id3Track:S,textTrack:this._txtTrack};return u&&this.extractRemainingSamples(ke),ke},p.flush=function(){var b=this.remainderData;this.remainderData=null;var g;return b?g=this.demux(b,-1,!1,!0):g={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},p.extractRemainingSamples=function(b){var g=b.audioTrack,c=b.avcTrack,u=b.id3Track,a=c.pesData,x=g.pesData,y=u.pesData,S;a&&(S=o(a))?(this.parseAVCPES(S,!0),c.pesData=null):c.pesData=a,x&&(S=o(x))?(g.isAAC?this.parseAACPES(S):this.parseMPEGPES(S),g.pesData=null):(x!=null&&x.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),g.pesData=x),y&&(S=o(y))?(this.parseID3PES(S),u.pesData=null):u.pesData=y},p.demuxSampleAes=function(b,g,c){var u=this.demux(b,c,!0,!this.config.progressive),a=this.sampleAes=new F.default(this.observer,this.config,g);return this.decrypt(u,a)},p.decrypt=function(b,g){return new Promise(function(c){var u=b.audioTrack,a=b.avcTrack;u.samples&&u.isAAC?g.decryptAacSamples(u.samples,0,function(){a.samples?g.decryptAvcSamples(a.samples,0,0,function(){c(b)}):c(b)}):a.samples&&g.decryptAvcSamples(a.samples,0,0,function(){c(b)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(b,g){var c=this,u=this._avcTrack,a=this.parseAVCNALu(b.data),x=!1,y=this.avcSample,S,P=!1;b.data=null,y&&a.length&&!u.audFound&&(l(y,u),y=this.avcSample=E(!1,b.pts,b.dts,"")),a.forEach(function(G){switch(G.type){case 1:{S=!0,y||(y=c.avcSample=E(!0,b.pts,b.dts,"")),x&&(y.debug+="NDR "),y.frame=!0;var Y=G.data;if(P&&Y.length>4){var Q=new D.default(Y).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(y.key=!0)}break}case 5:S=!0,y||(y=c.avcSample=E(!0,b.pts,b.dts,"")),x&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{S=!0,x&&y&&(y.debug+="SEI ");var z=new D.default(L(G.data));z.readUByte();for(var j=0,ee=0,oe=!1,fe=0;!oe&&z.bytesAvailable>1;){j=0;do fe=z.readUByte(),j+=fe;while(fe===255);ee=0;do fe=z.readUByte(),ee+=fe;while(fe===255);if(j===4&&z.bytesAvailable!==0){oe=!0;var ve=z.readUByte();if(ve===181){var Re=z.readUShort();if(Re===49){var Ee=z.readUInt();if(Ee===1195456820){var Se=z.readUByte();if(Se===3){for(var we=z.readUByte(),Te=z.readUByte(),me=31&we,de=[we,Te],ke=0;ke16){for(var Je=[],Ge=0;Ge<16;Ge++)Je.push(z.readUByte().toString(16)),(Ge===3||Ge===5||Ge===7||Ge===9)&&Je.push("-");for(var Qe=ee-16,Ye=new Uint8Array(Qe),Ae=0;Ae=0){var z={data:b.subarray(Y,y-u-1),type:Q};x.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))),P=y-u-1,P>0)){var ee=new Uint8Array(j.data.byteLength+P);ee.set(j.data,0),ee.set(b.subarray(0,P),j.data.byteLength),j.data=ee,j.state=0}}y=0&&u>=0){var oe={data:b.subarray(Y,g),type:Q,state:u};x.push(oe)}if(x.length===0){var fe=this.getLastNalUnit();if(fe){var ve=new Uint8Array(fe.data.byteLength+b.byteLength);ve.set(fe.data,0),ve.set(b,fe.data.byteLength),fe.data=ve}}return c.naluState=u,x},p.parseAACPES=function(b){var g=0,c=this._audioTrack,u=this.aacOverFlow,a=b.data;if(u){this.aacOverFlow=null;var x=u.sample.unit.byteLength,y=Math.min(u.missing,x),S=x-y;u.sample.unit.set(a.subarray(0,y),S),c.samples.push(u.sample),g=u.missing}var P,G;for(P=g,G=a.length;P1;){var x=new Uint8Array(a[0].length+a[1].length);x.set(a[0]),x.set(a[1],a[0].length),a[0]=x,a.splice(1,1)}_=a[0];var y=(_[0]<<16)+(_[1]<<8)+_[2];if(y===1){if(b=(_[4]<<8)+_[5],b&&b>f.size-6)return null;var S=_[7];S&192&&(c=(_[9]&14)*536870912+(_[10]&255)*4194304+(_[11]&254)*16384+(_[12]&255)*128+(_[13]&254)/2,S&64?(u=(_[14]&14)*536870912+(_[15]&255)*4194304+(_[16]&254)*16384+(_[17]&255)*128+(_[18]&254)/2,c-u>60*9e4&&(v.logger.warn(Math.round((c-u)/9e4)+"s delta between PTS and DTS, align them"),c=u)):u=c),g=_[8];var P=g+9;if(f.size<=P)return null;f.size-=P;for(var G=new Uint8Array(f.size),Y=0,Q=a.length;Yz){P-=z;continue}else _=_.subarray(P),z-=P,P=0;G.set(_,p),p+=z}return b&&(b-=g+3),{data:G,pts:c,dts:u,len:b}}return null}function l(f,p){if(f.units.length&&f.frame){if(f.pts===void 0){var _=p.samples,b=_.length;if(b){var g=_[b-1];f.pts=g.pts,f.dts=g.dts}else{p.dropped++;return}}p.samples.push(f)}f.debug.length&&v.logger.log(f.pts+"/"+f.dts+":"+f.debug)}function h(f,p){var _=f.length;if(_>0){if(p.pts>=f[_-1].pts)f.push(p);else for(var b=_-1;b>=0;b--)if(p.ptsc)return a;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,c=this.autoLevelCapping,u;return c===-1&&g&&g.length?u=g.length-1:u=c,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var c=this.audioTrackController;c&&(c.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return g?g.subtitleDisplay:!1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:E.hlsDefaultConfig},set:function(g){p.defaultConfig=g}}]),p}();f.defaultConfig=void 0},"./src/is-supported.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"isSupported",function(){return D}),R.d(Z,"changeTypeSupported",function(){return H});var X=R("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var F=Object(X.getMediaSource)();if(!F)return!1;var M=I(),O=F&&typeof F.isTypeSupported=="function"&&F.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 F,M=I();return typeof(M==null||((F=M.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return A}),R.d(Z,"LoadError",function(){return w});var X=R("./src/polyfills/number.ts"),I=R("./src/errors.ts");function D(d,o){d.prototype=Object.create(o.prototype),d.prototype.constructor=d,v(d,o)}function H(d){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,L)}function L(){return F(h,arguments,C(this).constructor)}return L.prototype=Object.create(h.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),v(L,h)},H(d)}function F(d,o,l){return M()?F=Reflect.construct:F=function(L,f,p){var _=[null];_.push.apply(_,f);var b=Function.bind.apply(L,_),g=new b;return p&&v(g,p.prototype),g},F.apply(null,arguments)}function M(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function O(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function v(d,o){return v=Object.setPrototypeOf||function(h,L){return h.__proto__=L,h},v(d,o)}function C(d){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},C(d)}var k=Math.pow(2,17),A=function(){function d(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var o=d.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,L){var f=this,p=h.url;if(!p)return Promise.reject(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var _=this.config,b=_.fLoader,g=_.loader;return new Promise(function(c,u){f.loader&&f.loader.destroy();var a=f.loader=h.loader=b?new b(_):new g(_),x=E(h),y={timeout:_.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:_.fragLoadingMaxRetryTimeout,highWaterMark:k};h.stats=a.stats,a.load(x,y,{onSuccess:function(P,G,Y,Q){f.resetLoader(h,a),c({frag:h,part:null,payload:P.data,networkDetails:Q})},onError:function(P,G,Y){f.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:P,networkDetails:Y}))},onAbort:function(P,G,Y){f.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:Y}))},onTimeout:function(P,G,Y){f.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:Y}))},onProgress:function(P,G,Y,Q){L&&L({frag:h,part:null,payload:Y,networkDetails:Q})}})})},o.loadPart=function(h,L,f){var p=this;this.abort();var _=this.config,b=_.fLoader,g=_.loader;return new Promise(function(c,u){p.loader&&p.loader.destroy();var a=p.loader=h.loader=b?new b(_):new g(_),x=E(h,L),y={timeout:_.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:_.fragLoadingMaxRetryTimeout,highWaterMark:k};L.stats=a.stats,a.load(x,y,{onSuccess:function(P,G,Y,Q){p.resetLoader(h,a),p.updateStatsFromPart(h,L);var z={frag:h,part:L,payload:P.data,networkDetails:Q};f(z),c(z)},onError:function(P,G,Y){p.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:L,response:P,networkDetails:Y}))},onAbort:function(P,G,Y){h.stats.aborted=L.stats.aborted,p.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:L,networkDetails:Y}))},onTimeout:function(P,G,Y){p.resetLoader(h,a),u(new w({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:L,networkDetails:Y}))}})})},o.updateStatsFromPart=function(h,L){var f=h.stats,p=L.stats,_=p.total;if(f.loaded+=p.loaded,_){var b=Math.round(h.duration/L.duration),g=Math.min(Math.round(f.loaded/_),b),c=b-g,u=c*Math.round(f.loaded/g);f.total=f.loaded+u}else f.total=Math.max(f.loaded,f.total);var a=f.loading,x=p.loading;a.start?a.first+=x.first-x.start:(a.start=x.start,a.first=x.first),a.end=x.end},o.resetLoader=function(h,L){h.loader=null,this.loader===L&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),L.destroy()},d}();function E(d,o){o===void 0&&(o=null);var l=o||d,h={frag:d,part:o,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},L=l.byteRangeStartOffset,f=l.byteRangeEndOffset;return Object(X.isFiniteNumber)(L)&&Object(X.isFiniteNumber)(f)&&(h.rangeStart=L,h.rangeEnd=f),h}var w=function(d){D(o,d);function o(l){for(var h,L=arguments.length,f=new Array(L>1?L-1:0),p=1;p>8*(15-_)&255;return p},h.setDecryptDataFromLevelKey=function(f,p){var _=f;return(f==null?void 0:f.method)==="AES-128"&&f.uri&&!f.iv&&(_=F.LevelKey.fromURI(f.uri),_.method=f.method,_.iv=this.createInitializationVector(p),_.keyFormat="identity"),_},h.setElementaryStreamInfo=function(f,p,_,b,g,c){c===void 0&&(c=!1);var u=this.elementaryStreams,a=u[f];if(!a){u[f]={startPTS:p,endPTS:_,startDTS:b,endDTS:g,partial:c};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,_),a.startDTS=Math.min(a.startDTS,b),a.endDTS=Math.max(a.endDTS,g)},h.clearElementaryStreamInfo=function(){var f=this.elementaryStreams;f[A.AUDIO]=null,f[A.VIDEO]=null,f[A.AUDIOVIDEO]=null},k(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var f=this.sn;typeof f!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&H.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),f=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,f)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(X.isFiniteNumber)(this.programDateTime))return null;var f=Object(X.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+f*1e3}},{key:"encrypted",get:function(){var f;return!!((f=this.decryptdata)!==null&&f!==void 0&&f.keyFormat&&this.decryptdata.uri)}}]),l}(E),d=function(o){O(l,o);function l(h,L,f,p,_){var b;b=o.call(this,f)||this,b.fragOffset=0,b.duration=0,b.gap=!1,b.independent=!1,b.relurl=void 0,b.fragment=void 0,b.index=void 0,b.stats=new M.LoadStats,b.duration=h.decimalFloatingPoint("DURATION"),b.gap=h.bool("GAP"),b.independent=h.bool("INDEPENDENT"),b.relurl=h.enumeratedString("URI"),b.fragment=L,b.index=p;var g=h.enumeratedString("BYTERANGE");return g&&b.setByteRange(g,_),_&&(b.fragOffset=_.fragOffset+_.duration),b}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 L=this.elementaryStreams;return!!(L.audio||L.video||L.audiovideo)}}]),l}(E)},"./src/loader/key-loader.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return H});var X=R("./src/events.ts"),I=R("./src/errors.ts"),D=R("./src/utils/logger.ts"),H=function(){function F(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var M=F.prototype;return M._registerListeners=function(){this.hls.on(X.Events.KEY_LOADING,this.onKeyLoading,this)},M._unregisterListeners=function(){this.hls.off(X.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,A=k.type,E=this.loaders[A];if(!k.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var w=k.decryptdata.uri;if(w!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(E&&(D.logger.warn("abort previous key loader for type:"+A),E.abort()),!w){D.logger.warn("key uri is falsy");return}var o=d.loader,l=k.loader=this.loaders[A]=new o(d);this.decrypturl=w,this.decryptkey=null;var h={url:w,frag:k,responseType:"arraybuffer"},L={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,L,f)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:k}))},M.loadsuccess=function(v,C,k){var A=k.frag;if(!A.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=A.decryptdata.key=new Uint8Array(v.data),A.loader=null,delete this.loaders[A.type],this.hls.trigger(X.Events.KEY_LOADED,{frag:A})},M.loaderror=function(v,C){var k=C.frag,A=k.loader;A&&A.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:v})},M.loadtimeout=function(v,C){var k=C.frag,A=k.loader;A&&A.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},F}()},"./src/loader/level-details.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"LevelDetails",function(){return F});var X=R("./src/polyfills/number.ts");function I(M,O){for(var v=0;vC.endSN||k>0||k===0&&A>0,this.updated||this.advanced?this.misses=Math.floor(C.misses*.6):this.misses=C.misses+1,this.availabilityDelay=C.availabilityDelay},D(M,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(X.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(ae,Z,R){"use strict";R.r(Z),R.d(Z,"LevelKey",function(){return F});var X=R("./node_modules/url-toolkit/src/url-toolkit.js"),I=R.n(X);function D(M,O){for(var v=0;v2){var u=c.shift()+".";return u+=parseInt(c.shift()).toString(16),u+=("000"+parseInt(c.shift()).toString(16)).substr(-4),u}return g},_.resolve=function(g,c){return I.buildAbsoluteURL(c,g,{alwaysNormalize:!0})},_.parseMasterPlaylist=function(g,c){var u=[],a={},x=!1;k.lastIndex=0;for(var y;(y=k.exec(g))!=null;)if(y[1]){var S=new O.AttrList(y[1]),P={attrs:S,bitrate:S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),name:S.NAME,url:_.resolve(y[2],c)},G=S.decimalResolution("RESOLUTION");G&&(P.width=G.width,P.height=G.height),h((S.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=_.convertAVC1ToAVCOTI(P.videoCodec)),u.push(P)}else if(y[3]){var Y=new O.AttrList(y[3]);Y["DATA-ID"]&&(x=!0,a[Y["DATA-ID"]]=Y)}return{levels:u,sessionData:x?a:null}},_.parseMasterPlaylistMedia=function(g,c,u,a){a===void 0&&(a=[]);var x,y=[],S=0;for(A.lastIndex=0;(x=A.exec(g))!==null;){var P=new O.AttrList(x[1]);if(P.TYPE===u){var G={attrs:P,bitrate:0,id:S++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:u,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?_.resolve(P.URI,c):""};if(a.length){var Y=_.findGroup(a,G.groupId)||a[0];L(G,Y,"audioCodec"),L(G,Y,"textCodec")}y.push(G)}}return y},_.parseLevelPlaylist=function(g,c,u,a,x){var y=new F.LevelDetails(c),S=y.fragments,P=null,G=0,Y=0,Q=0,z=0,j=null,ee=new H.Fragment(a,c),oe,fe,ve,Re=-1,Ee=!1;for(E.lastIndex=0,y.m3u8=g;(oe=E.exec(g))!==null;){Ee&&(Ee=!1,ee=new H.Fragment(a,c),ee.start=Q,ee.sn=G,ee.cc=z,ee.level=u,P&&(ee.initSegment=P,ee.rawProgramDateTime=P.rawProgramDateTime));var Se=oe[1];if(Se){ee.duration=parseFloat(Se);var we=(" "+oe[2]).slice(1);ee.title=we||null,ee.tagList.push(we?["INF",Se,we]:["INF",Se])}else if(oe[3])Object(X.isFiniteNumber)(ee.duration)&&(ee.start=Q,ve&&(ee.levelkey=ve),ee.sn=G,ee.level=u,ee.cc=z,ee.urlId=x,S.push(ee),ee.relurl=(" "+oe[3]).slice(1),p(ee,j),j=ee,Q+=ee.duration,G++,Y=0,Ee=!0);else if(oe[4]){var Te=(" "+oe[4]).slice(1);j?ee.setByteRange(Te,j):ee.setByteRange(Te)}else if(oe[5])ee.rawProgramDateTime=(" "+oe[5]).slice(1),ee.tagList.push(["PROGRAM-DATE-TIME",ee.rawProgramDateTime]),Re===-1&&(Re=S.length);else{if(oe=oe[0].match(w),!oe){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(fe=1;fe-1){v.logger.warn("Keyformat "+ht+" is not supported from the manifest");continue}else if(ht!=="identity")continue;je&&(ve=M.LevelKey.fromURL(c,et),et&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(je)>=0&&(ve.method=je,ve.keyFormat=ht,Be&&(ve.keyID=Be),Ne&&(ve.keyFormatVersions=Ne),ve.iv=Xe));break}case"START":{var Pe=new O.AttrList(de),Ke=Pe.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(Ke)&&(y.startTimeOffset=Ke);break}case"MAP":{var qe=new O.AttrList(de);ee.relurl=qe.URI,qe.BYTERANGE&&ee.setByteRange(qe.BYTERANGE),ee.level=u,ee.sn="initSegment",ve&&(ee.levelkey=ve),ee.initSegment=null,P=ee,Ee=!0;break}case"SERVER-CONTROL":{var Ve=new O.AttrList(de);y.canBlockReload=Ve.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=Ve.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&Ve.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=Ve.optionalFloat("PART-HOLD-BACK",0),y.holdBack=Ve.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var it=new O.AttrList(de);y.partTarget=it.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ce=y.partList;Ce||(Ce=y.partList=[]);var tt=Y>0?Ce[Ce.length-1]:void 0,nt=Y++,Le=new H.Part(new O.AttrList(de),ee,c,nt,tt);Ce.push(Le),ee.duration+=Le.duration;break}case"PRELOAD-HINT":{var Ie=new O.AttrList(de);y.preloadHint=Ie;break}case"RENDITION-REPORT":{var pe=new O.AttrList(de);y.renditionReports=y.renditionReports||[],y.renditionReports.push(pe);break}default:v.logger.warn("line parsed but not handled: "+oe);break}}}j&&!j.relurl?(S.pop(),Q-=j.duration,y.partList&&(y.fragmentHint=j)):y.partList&&(p(ee,j),ee.cc=z,y.fragmentHint=ee);var le=S.length,ue=S[0],te=S[le-1];if(Q+=y.skippedSegments*y.targetduration,Q>0&&le&&te){y.averagetargetduration=Q/le;var q=te.sn;y.endSN=q!=="initSegment"?q:0,ue&&(y.startCC=ue.cc,ue.initSegment||y.fragments.every(function(re){return re.relurl&&o(re.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ee=new H.Fragment(a,c),ee.relurl=te.relurl,ee.level=u,ee.sn="initSegment",ue.initSegment=ee,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(Q+=y.fragmentHint.duration),y.totalduration=Q,y.endCC=z,Re>0&&f(S,Re),y},_}();function h(_,b){["video","audio","text"].forEach(function(g){var c=_.filter(function(a){return Object(C.isCodecType)(a,g)});if(c.length){var u=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});b[g+"Codec"]=u.length>0?u[0]:c[0],_=_.filter(function(a){return c.indexOf(a)===-1})}}),b.unknownCodecs=_}function L(_,b,g){var c=b[g];c&&(_[g]=c)}function f(_,b){for(var g=_[b],c=b;c--;){var u=_[c];if(!u)return;u.programDateTime=g.programDateTime-u.duration*1e3,g=u}}function p(_,b){_.rawProgramDateTime?_.programDateTime=Date.parse(_.rawProgramDateTime):b!=null&&b.programDateTime&&(_.programDateTime=b.endProgramDateTime),Object(X.isFiniteNumber)(_.programDateTime)||(_.programDateTime=null,_.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/polyfills/number.ts"),I=R("./src/events.ts"),D=R("./src/errors.ts"),H=R("./src/utils/logger.ts"),F=R("./src/utils/mp4-tools.ts"),M=R("./src/loader/m3u8-parser.ts"),O=R("./src/types/loader.ts"),v=R("./src/utils/attr-list.ts");function C(E){var w=E.type;switch(w){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(E,w){var d=E.url;return(d===void 0||d.indexOf("data:")===0)&&(d=w.url),d}var A=function(){function E(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var w=E.prototype;return w.registerListeners=function(){var o=this.hls;o.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},w.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},w.createInternalLoader=function(o){var l=this.hls.config,h=l.pLoader,L=l.loader,f=h||L,p=new f(l);return o.loader=p,this.loaders[o.type]=p,p},w.getInternalLoader=function(o){return this.loaders[o.type]},w.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},w.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},w.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},w.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})},w.onLevelLoading=function(o,l){var h=l.id,L=l.level,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:null,level:L,responseType:"text",type:O.PlaylistContextType.LEVEL,url:f,deliveryDirectives:p})},w.onAudioTrackLoading=function(o,l){var h=l.id,L=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:L,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:f,deliveryDirectives:p})},w.onSubtitleTrackLoading=function(o,l){var h=l.id,L=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:L,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:f,deliveryDirectives:p})},w.load=function(o){var l,h=this.hls.config,L=this.getInternalLoader(o);if(L){var f=L.context;if(f&&f.url===o.url){H.logger.trace("[playlist-loader]: playlist request ongoing");return}H.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),L.abort()}var p,_,b,g;switch(o.type){case O.PlaylistContextType.MANIFEST:p=h.manifestLoadingMaxRetry,_=h.manifestLoadingTimeOut,b=h.manifestLoadingRetryDelay,g=h.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:p=0,_=h.levelLoadingTimeOut;break;default:p=h.levelLoadingMaxRetry,_=h.levelLoadingTimeOut,b=h.levelLoadingRetryDelay,g=h.levelLoadingMaxRetryTimeout;break}if(L=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var c;if(o.type===O.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===O.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===O.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var u=c.partTarget,a=c.targetduration;u&&a&&(_=Math.min(Math.max(u*3,a*.8)*1e3,_))}}var x={timeout:_,maxRetry:p,retryDelay:b,maxRetryDelay:g,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};L.load(o,x,y)},w.loadsuccess=function(o,l,h,L){if(L===void 0&&(L=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,l,h,L);return}this.resetInternalLoader(h.type);var f=o.data;if(f.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",L);return}l.parsing.start=performance.now(),f.indexOf("#EXTINF:")>0||f.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,h,L):this.handleMasterPlaylist(o,l,h,L)},w.loaderror=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,o)},w.loadtimeout=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},w.handleMasterPlaylist=function(o,l,h,L){var f=this.hls,p=o.data,_=k(o,h),b=M.default.parseMasterPlaylist(p,_),g=b.levels,c=b.sessionData;if(!g.length){this.handleManifestParsingError(o,h,"no level found in manifest",L);return}var u=g.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=g.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),x=M.default.parseMasterPlaylistMedia(p,_,"AUDIO",u),y=M.default.parseMasterPlaylistMedia(p,_,"SUBTITLES",a),S=M.default.parseMasterPlaylistMedia(p,_,"CLOSED-CAPTIONS");if(x.length){var P=x.some(function(G){return!G.url});!P&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(H.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}f.trigger(I.Events.MANIFEST_LOADED,{levels:g,audioTracks:x,subtitles:y,captions:S,url:_,stats:l,networkDetails:L,sessionData:c})},w.handleTrackOrLevelPlaylist=function(o,l,h,L){var f=this.hls,p=h.id,_=h.level,b=h.type,g=k(o,h),c=Object(X.isFiniteNumber)(p)?p:0,u=Object(X.isFiniteNumber)(_)?_:c,a=C(h),x=M.default.parseLevelPlaylist(o.data,g,u,a,c);if(!x.fragments.length){f.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(b===O.PlaylistContextType.MANIFEST){var y={attrs:new v.AttrList({}),bitrate:0,details:x,name:"",url:g};f.trigger(I.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:g,stats:l,networkDetails:L,sessionData:null})}if(l.parsing.end=performance.now(),x.needSidxRanges){var S,P=(S=x.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:P,isSidxRequest:!0,type:b,level:_,levelDetails:x,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=x,this.handlePlaylistLoaded(o,l,h,L)},w.handleSidxRequest=function(o,l){var h=Object(F.parseSegmentIndex)(new Uint8Array(o.data));if(!h)return;var L=h.references,f=l.levelDetails;L.forEach(function(p,_){var b=p.info,g=f.fragments[_];g.byteRange.length===0&&g.setByteRange(String(1+b.end-b.start)+"@"+String(b.start)),g.initSegment&&g.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},w.handleManifestParsingError=function(o,l,h,L){this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===O.PlaylistContextType.MANIFEST,url:o.url,reason:h,response:o,context:l,networkDetails:L})},w.handleNetworkError=function(o,l,h,L){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 f=D.ErrorDetails.UNKNOWN,p=!1,_=this.getInternalLoader(o);switch(o.type){case O.PlaylistContextType.MANIFEST:f=h?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case O.PlaylistContextType.LEVEL:f=h?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case O.PlaylistContextType.AUDIO_TRACK:f=h?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:f=h?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}_&&this.resetInternalLoader(o.type);var b={type:D.ErrorTypes.NETWORK_ERROR,details:f,fatal:p,url:o.url,loader:_,context:o,networkDetails:l};L&&(b.response=L),this.hls.trigger(I.Events.ERROR,b)},w.handlePlaylistLoaded=function(o,l,h,L){var f=h.type,p=h.level,_=h.id,b=h.groupId,g=h.loader,c=h.levelDetails,u=h.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,h,"invalid target duration",L);return}if(!g)return;c.live&&(g.getCacheAge&&(c.ageHeader=g.getCacheAge()||0),(!g.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(f){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:c,level:p||0,id:_||0,stats:l,networkDetails:L,deliveryDirectives:u});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:c,id:_||0,groupId:b||"",stats:l,networkDetails:L,deliveryDirectives:u});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:c,id:_||0,groupId:b||"",stats:l,networkDetails:L,deliveryDirectives:u});break}},E}();Z.default=A},"./src/polyfills/number.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"isFiniteNumber",function(){return X}),R.d(Z,"MAX_SAFE_INTEGER",function(){return I});var X=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ae,Z,R){"use strict";R.r(Z);var X=function(){function I(){}return I.getSilentFrame=function(H,F){switch(H){case"mp4a.40.2":if(F===1)return new Uint8Array([0,200,0,128,35,128]);if(F===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(F===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(F===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(F===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(F===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(F===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},I}();Z.default=X},"./src/remux/mp4-generator.ts":function(ae,Z,R){"use strict";R.r(Z);var X=Math.pow(2,32)-1,I=function(){function D(){}return D.init=function(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var F;for(F in D.types)D.types.hasOwnProperty(F)&&(D.types[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.charCodeAt(3)]);var M=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),O=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);D.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]);D.STTS=D.STSC=D.STCO=C,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var k=new Uint8Array([105,115,111,109]),A=new Uint8Array([97,118,99,49]),E=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,k,E,k,A),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,v))},D.box=function(F){for(var M=8,O=arguments.length,v=new Array(O>1?O-1:0),C=1;C>24&255,E[1]=M>>16&255,E[2]=M>>8&255,E[3]=M&255,E.set(F,4),k=0,M=8;k>24&255,F>>16&255,F>>8&255,F&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]))},D.mdia=function(F){return D.box(D.types.mdia,D.mdhd(F.timescale,F.duration),D.hdlr(F.type),D.minf(F))},D.mfhd=function(F){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,F>>24,F>>16&255,F>>8&255,F&255]))},D.minf=function(F){return F.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(F)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(F))},D.moof=function(F,M,O){return D.box(D.types.moof,D.mfhd(F),D.traf(O,M))},D.moov=function(F){for(var M=F.length,O=[];M--;)O[M]=D.trak(F[M]);return D.box.apply(null,[D.types.moov,D.mvhd(F[0].timescale,F[0].duration)].concat(O).concat(D.mvex(F)))},D.mvex=function(F){for(var M=F.length,O=[];M--;)O[M]=D.trex(F[M]);return D.box.apply(null,[D.types.mvex].concat(O))},D.mvhd=function(F,M){M*=F;var O=Math.floor(M/(X+1)),v=Math.floor(M%(X+1)),C=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,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 D.box(D.types.mvhd,C)},D.sdtp=function(F){var M=F.samples||[],O=new Uint8Array(4+M.length),v,C;for(v=0;v>>8&255),M.push(k&255),M=M.concat(Array.prototype.slice.call(C));for(v=0;v>>8&255),O.push(k&255),O=O.concat(Array.prototype.slice.call(C));var A=D.box(D.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|F.sps.length].concat(M).concat([F.pps.length]).concat(O))),E=F.width,w=F.height,d=F.pixelRatio[0],o=F.pixelRatio[1];return D.box(D.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,E>>8&255,E&255,w>>8&255,w&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]),A,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,o>>24,o>>16&255,o>>8&255,o&255])))},D.esds=function(F){var M=F.config.length;return new Uint8Array([0,0,0,0,3,23+M,0,1,0,4,15+M,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([M]).concat(F.config).concat([6,1,2]))},D.mp4a=function(F){var M=F.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),D.box(D.types.esds,D.esds(F)))},D.mp3=function(F){var M=F.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},D.stsd=function(F){return F.type==="audio"?!F.isAAC&&F.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(F)):D.box(D.types.stsd,D.STSD,D.mp4a(F)):D.box(D.types.stsd,D.STSD,D.avc1(F))},D.tkhd=function(F){var M=F.id,O=F.duration*F.timescale,v=F.width,C=F.height,k=Math.floor(O/(X+1)),A=Math.floor(O%(X+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,0,0,0,0,k>>24,k>>16&255,k>>8&255,k&255,A>>24,A>>16&255,A>>8&255,A&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]))},D.traf=function(F,M){var O=D.sdtp(F),v=F.id,C=Math.floor(M/(X+1)),k=Math.floor(M%(X+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),D.box(D.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])),D.trun(F,O.length+16+20+8+16+8+8),O)},D.trak=function(F){return F.duration=F.duration||4294967295,D.box(D.types.trak,D.tkhd(F),D.mdia(F))},D.trex=function(F){var M=F.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(F,M){var O=F.samples||[],v=O.length,C=12+16*v,k=new Uint8Array(C),A,E,w,d,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),A=0;A>>24&255,w>>>16&255,w>>>8&255,w&255,d>>>24&255,d>>>16&255,d>>>8&255,d&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*A);return D.box(D.types.trun,k)},D.initSegment=function(F){D.types||D.init();var M=D.moov(F),O=new Uint8Array(D.FTYP.byteLength+M.byteLength);return O.set(D.FTYP),O.set(M,D.FTYP.byteLength),O},D}();I.types=void 0,I.HDLR_TYPES=void 0,I.STTS=void 0,I.STSC=void 0,I.STCO=void 0,I.STSZ=void 0,I.VMHD=void 0,I.SMHD=void 0,I.STSD=void 0,I.FTYP=void 0,I.DINF=void 0,Z.default=I},"./src/remux/mp4-remuxer.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return l}),R.d(Z,"normalizePts",function(){return h});var X=R("./src/polyfills/number.ts"),I=R("./src/remux/aac-helper.ts"),D=R("./src/remux/mp4-generator.ts"),H=R("./src/events.ts"),F=R("./src/errors.ts"),M=R("./src/utils/logger.ts"),O=R("./src/types/loader.ts"),v=R("./src/utils/timescale-conversion.ts");function C(){return C=Object.assign||function(_){for(var b=1;b0?x:y.pts},c[0].pts);return u&&M.logger.debug("PTS rollover detected"),a},b.remux=function(c,u,a,x,y,S,P,G){var Y,Q,z,j,ee,oe,fe=y,ve=y,Re=c.pid>-1,Ee=u.pid>-1,Se=u.samples.length,we=c.samples.length>0,Te=Se>1,me=(!Re||we)&&(!Ee||Te)||this.ISGenerated||P;if(me){this.ISGenerated||(z=this.generateIS(c,u,y));var de=this.isVideoContiguous,ke=-1;if(Te&&(ke=L(u.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,ke>0){M.logger.warn("[mp4-remuxer]: Dropped "+ke+" out of "+Se+" video samples due to a missing keyframe");var Je=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(ke),u.dropped+=ke,ve+=(u.samples[0].pts-Je)/(u.timescale||9e4)}else ke===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+Se+" video samples"),oe=!1);if(this.ISGenerated){if(we&&Te){var Ge=this.getVideoStartPts(u.samples),Qe=h(c.samples[0].pts,Ge)-Ge,Ye=Qe/u.inputTimeScale;fe+=Math.max(0,Ye),ve+=Math.max(0,-Ye)}if(we){if(c.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(c,u,y)),Q=this.remuxAudio(c,fe,this.isAudioContiguous,S,Ee||Te||G===O.PlaylistLevelType.AUDIO?ve:void 0),Te){var Ae=Q?Q.endPTS-Q.startPTS:0;u.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(c,u,y)),Y=this.remuxVideo(u,ve,de,Ae)}}else Te&&(Y=this.remuxVideo(u,ve,de,0));Y&&(Y.firstKeyFrame=ke,Y.independent=ke!==-1)}}return this.ISGenerated&&(a.samples.length&&(ee=this.remuxID3(a,y)),x.samples.length&&(j=this.remuxText(x,y))),{audio:Q,video:Y,initSegment:z,independent:oe,text:j,id3:ee}},b.generateIS=function(c,u,a){var x=c.samples,y=u.samples,S=this.typeSupported,P={},G=!Object(X.isFiniteNumber)(this._initPTS),Y="audio/mp4",Q,z,j;if(G&&(Q=z=Infinity),c.config&&x.length&&(c.timescale=c.samplerate,c.isAAC||(S.mpeg?(Y="audio/mpeg",c.codec=""):S.mp3&&(c.codec="mp3")),P.audio={id:"audio",container:Y,codec:c.codec,initSegment:!c.isAAC&&S.mpeg?new Uint8Array(0):D.default.initSegment([c]),metadata:{channelCount:c.channelCount}},G&&(j=c.inputTimeScale,Q=z=x[0].pts-Math.round(j*a))),u.sps&&u.pps&&y.length&&(u.timescale=u.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:D.default.initSegment([u]),metadata:{width:u.width,height:u.height}},G)){j=u.inputTimeScale;var ee=this.getVideoStartPts(y),oe=Math.round(j*a);z=Math.min(z,h(y[0].dts,ee)-oe),Q=Math.min(Q,ee-oe)}if(Object.keys(P).length)return this.ISGenerated=!0,G&&(this._initPTS=Q,this._initDTS=z),{tracks:P,initPTS:Q,timescale:j}},b.remuxVideo=function(c,u,a,x){var y=c.inputTimeScale,S=c.samples,P=[],G=S.length,Y=this._initPTS,Q=this.nextAvcDts,z=8,j,ee,oe,fe=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,Re=0,Ee=!1;if(!a||Q===null){var Se=u*y,we=S[0].pts-h(S[0].dts,S[0].pts);Q=Se-we}for(var Te=0;Teme.pts){var de=9e4*.2;Re=Math.max(Math.min(Re,me.pts-me.dts),-1*de)}me.dts0?Te-1:Te].dts&&(Ee=!0)}Ee&&S.sort(function(At,Et){var $e=At.dts-Et.dts,Rt=At.pts-Et.pts;return $e||Rt}),ee=S[0].dts,oe=S[S.length-1].dts;var ke=Math.round((oe-ee)/(G-1));if(Re<0){if(Reke,Me=Ye<-1;if(Ae||Me){Ae?M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(Ye,!0)+" ms ("+Ye+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-Ye,!0)+" ms ("+Ye+"dts) overlapping between fragments detected"),ee=Q;var je=S[0].pts-Ye;S[0].dts=ee,S[0].pts=je,M.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(je,!0)+"/"+Object(v.toMsFromMpegTsClock)(ee,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(Ye,!0)+" ms")}}o&&(ee=Math.max(0,ee));for(var et=0,Xe=0,Ne=0;Ne0?Ce-1:Ce].dts;if(q.stretchShortVideoTrack&&this.nextAudioPts!==null){var ne=Math.floor(q.maxBufferHole*y),ye=(x?fe+x*y:this.nextAudioPts)-tt.pts;ye>ne?(j=ye-re,j<0&&(j=re),M.logger.log("[mp4-remuxer]: It is approximately "+ye/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=re}else j=re}var ge=Math.round(tt.pts-tt.dts);P.push(new f(tt.key,j,Le,ge))}if(P.length&&w&&w<70){var _e=P[0].flags;_e.dependsOn=2,_e.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=oe+j,this.isVideoContiguous=!0;var ze=D.default.moof(c.sequenceNumber++,ee,C({},c,{samples:P})),ft="video",lt={data1:ze,data2:Ve,startPTS:fe/y,endPTS:(ve+j)/y,startDTS:ee/y,endDTS:Q/y,type:ft,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(Ve.length,"MDAT length must not be zero"),lt},b.remuxAudio=function(c,u,a,x,y){var S=c.inputTimeScale,P=c.samplerate?c.samplerate:S,G=S/P,Y=c.isAAC?A:E,Q=Y*G,z=this._initPTS,j=!c.isAAC&&this.typeSupported.mpeg,ee=[],oe=c.samples,fe=j?0:8,ve=this.nextAudioPts||-1,Re=u*S;if(this.isAudioContiguous=a=a||oe.length&&ve>0&&(x&&Math.abs(Re-ve)<9e3||Math.abs(h(oe[0].pts-z,Re)-ve)<20*Q),oe.forEach(function(ue){ue.pts=h(ue.pts-z,Re)}),!a||ve<0){if(oe=oe.filter(function(ue){return ue.pts>=0}),!oe.length)return;y===0?ve=0:x?ve=Math.max(0,Re):ve=oe[0].pts}if(c.isAAC)for(var Ee=y!==void 0,Se=this.config.maxAudioFramesDrift,we=0,Te=ve;we=Se*Q&&Je0){Xe+=fe;try{et=new Uint8Array(Xe)}catch(ue){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Xe,reason:"fail allocating audio mdat "+Xe});return}if(!j){var Ve=new DataView(et.buffer);Ve.setUint32(0,Xe),et.set(D.default.types.mdat,4)}}else return;et.set(Pe,fe);var it=Pe.byteLength;fe+=it,ee.push(new f(!0,Y,it,0)),je=Ke}var Ce=ee.length;if(!Ce)return;var tt=ee[ee.length-1];this.nextAudioPts=ve=je+G*tt.duration;var nt=j?new Uint8Array(0):D.default.moof(c.sequenceNumber++,Me/G,C({},c,{samples:ee}));c.samples=[];var Le=Me/S,Ie=ve/S,pe="audio",le={data1:nt,data2:et,startPTS:Le,endPTS:Ie,startDTS:Le,endDTS:Ie,type:pe,hasAudio:!0,hasVideo:!1,nb:Ce};return this.isAudioContiguous=!0,console.assert(et.length,"MDAT length must not be zero"),le},b.remuxEmptyAudio=function(c,u,a,x){var y=c.inputTimeScale,S=c.samplerate?c.samplerate:y,P=y/S,G=this.nextAudioPts,Y=(G!==null?G:x.startDTS*y)+this._initDTS,Q=x.endDTS*y+this._initDTS,z=P*A,j=Math.ceil((Q-Y)/z),ee=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!ee){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var oe=[],fe=0;fe4294967296;)_+=g;return _}function L(_){for(var b=0;b<_.length;b++)if(_[b].key)return b;return-1}var f=function(b,g,c,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=g,this.size=c,this.cts=u,this.flags=new p(b)},p=function(b){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=b?2:1,this.isNonSync=b?0:1}},"./src/remux/passthrough-remuxer.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/polyfills/number.ts"),I=R("./src/utils/mp4-tools.ts"),D=R("./src/loader/fragment.ts"),H=R("./src/utils/logger.ts"),F=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(A){this.initPTS=A,this.lastEndDTS=null},C.resetNextTimestamp=function(){this.lastEndDTS=null},C.resetInitSegment=function(A,E,w){this.audioCodec=E,this.videoCodec=w,this.generateInitSegment(A),this.emitInitSegment=!0},C.generateInitSegment=function(A){var E=this.audioCodec,w=this.videoCodec;if(!A||!A.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(I.parseInitSegment)(A);E||(E=O(d.audio,D.ElementaryStreamTypes.AUDIO)),w||(w=O(d.video,D.ElementaryStreamTypes.VIDEO));var o={};d.audio&&d.video?o.audiovideo={container:"video/mp4",codec:E+","+w,initSegment:A,id:"main"}:d.audio?o.audio={container:"audio/mp4",codec:E,initSegment:A,id:"audio"}:d.video?o.video={container:"video/mp4",codec:w,initSegment:A,id:"main"}:H.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},C.remux=function(A,E,w,d,o){var l=this.initPTS,h=this.lastEndDTS,L={audio:void 0,video:void 0,text:d,id3:w,initSegment:void 0};Object(X.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var f=E.samples;if(!f||!f.length)return L;var p={initPTS:void 0,timescale:1},_=this.initData;if((!_||!_.length)&&(this.generateInitSegment(f),_=this.initData),!_||!_.length)return H.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),L;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(X.isFiniteNumber)(l)||(this.initPTS=p.initPTS=l=M(_,f,h));var b=Object(I.getDuration)(f,_),g=h,c=b+g;Object(I.offsetStartDTS)(_,f,l),b>0?this.lastEndDTS=c:(H.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!_.audio,a=!!_.video,x="";u&&(x+="audio"),a&&(x+="video");var y={data1:f,startPTS:g,startDTS:g,endPTS:c,endDTS:c,type:x,hasAudio:u,hasVideo:a,nb:1,dropped:0};return L.audio=y.type==="audio"?y:void 0,L.video=y.type!=="audio"?y:void 0,L.text=d,L.id3=w,L.initSegment=p,L},v}(),M=function(C,k,A){return Object(I.getStartDTS)(C,k)-A};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===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Z.default=F},"./src/task-loop.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"default",function(){return X});var X=function(){function I(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=I.prototype;return D.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},D.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},D.onHandlerDestroyed=function(){},D.hasInterval=function(){return!!this._tickInterval},D.hasNextTick=function(){return!!this._tickTimer},D.setInterval=function(F){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,F),!0)},D.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},D.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},D.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},D.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},D.doTick=function(){},I}()},"./src/types/cmcd.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"CMCDVersion",function(){return X}),R.d(Z,"CMCDObjectType",function(){return I}),R.d(Z,"CMCDStreamingFormat",function(){return D}),R.d(Z,"CMCDStreamType",function(){return H});var X=1,I;(function(F){F.MANIFEST="m",F.AUDIO="a",F.VIDEO="v",F.MUXED="av",F.INIT="i",F.CAPTION="c",F.TIMED_TEXT="tt",F.KEY="k",F.OTHER="o"})(I||(I={}));var D;(function(F){F.DASH="d",F.HLS="h",F.SMOOTH="s",F.OTHER="o"})(D||(D={}));var H;(function(F){F.VOD="v",F.LIVE="l"})(H||(H={}))},"./src/types/level.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"HlsSkip",function(){return D}),R.d(Z,"getSkipValue",function(){return H}),R.d(Z,"HlsUrlParameters",function(){return F}),R.d(Z,"Level",function(){return M});function X(O,v){for(var C=0;CNumber.MAX_SAFE_INTEGER?Infinity:v},F.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;kNumber.MAX_SAFE_INTEGER?Infinity:v},F.decimalFloatingPoint=function(O){return parseFloat(this[O])},F.optionalFloat=function(O,v){var C=this[O];return C?parseFloat(C):v},F.enumeratedString=function(O){return this[O]},F.bool=function(O){return this[O]==="YES"},F.decimalResolution=function(O){var v=X.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(I.lastIndex=0;(v=I.exec(O))!==null;){var A=v[2];A.indexOf(k)===0&&A.lastIndexOf(k)===A.length-1&&(A=A.slice(1,-1)),C[v[1]]=A}return C},H}()},"./src/utils/binary-search.ts":function(ae,Z,R){"use strict";R.r(Z);var X={search:function(D,H){for(var F=0,M=D.length-1,O=null,v=null;F<=M;){O=(F+M)/2|0,v=D[O];var C=H(v);if(C>0)F=O+1;else if(C<0)M=O-1;else return v}return null}};Z.default=X},"./src/utils/buffer-helper.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"BufferHelper",function(){return D});var X=R("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function H(){}return H.isBuffered=function(M,O){try{if(M){for(var v=H.getBuffered(M),C=0;C=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=[],A;for(A=0;AE&&(C[A-1].end=M[k].end):C.push(M[k])}else C.push(M[k])}else C=M;for(var w=0,d,o=O,l=O,h=0;h=L&&O=a&&X.logger.log(this.time+" ["+a+"] "+x)},g}(),w=function(c){for(var u=[],a=0;aF&&(this.logger.log(A.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},c.moveCursor=function(a){var x=this.pos+a;if(a>1)for(var y=this.pos+1;y=144&&this.backSpace();var x=D(a);if(this.pos>=F){this.logger.log(A.ERROR,"Cannot insert "+a.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var x;for(x=a;x0&&(a?y="["+x.join(" | ")+"]":y=x.join(` `)),y},c.getTextAndFormat=function(){return this.rows},g}(),L=function(){function g(u,a,x){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(x),this.nonDisplayedMemory=new h(x),this.lastOutputScreen=new h(x),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var c=g.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(A.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},c.insertChars=function(a){for(var x=0;x=46,x.italics)x.foreground="white";else{var y=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=S[y]}this.logger.log(A.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var x=this.logger.time;if(x===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},g}(),f=function(){function g(u,a,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new E;this.channels=[null,new L(u,a,y),new L(u+1,x,y)],this.cmdHistory=b(),this.logger=y}var c=g.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,x){this.channels[a].setHandler(x)},c.addData=function(a,x){var y,S,P,G=!1;this.logger.time=a;for(var Y=0;Y ("+w([S,P])+")"),y=this.parseCmd(S,P),y||(y=this.parseMidrow(S,P)),y||(y=this.parsePAC(S,P)),y||(y=this.parseBackgroundAttributes(S,P)),!y&&(G=this.parseChars(S,P),G)){var Q=this.currentChannel;if(Q&&Q>0){var z=this.channels[Q];z.insertChars(G)}else this.logger.log(A.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!G&&this.logger.log(A.WARNING,"Couldn't parse cleaned data "+w([S,P])+" orig: "+w([x[Y],x[Y+1]]))}},c.parseCmd=function(a,x){var y=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&x>=32&&x<=47,P=(a===23||a===31)&&x>=33&&x<=35;if(!(S||P))return!1;if(_(a,x,y))return p(null,null,y),this.logger.log(A.DEBUG,"Repeated command ("+w([a,x])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,Y=this.channels[G];return a===20||a===21||a===28||a===29?x===32?Y.ccRCL():x===33?Y.ccBS():x===34?Y.ccAOF():x===35?Y.ccAON():x===36?Y.ccDER():x===37?Y.ccRU(2):x===38?Y.ccRU(3):x===39?Y.ccRU(4):x===40?Y.ccFON():x===41?Y.ccRDC():x===42?Y.ccTR():x===43?Y.ccRTD():x===44?Y.ccEDM():x===45?Y.ccCR():x===46?Y.ccENM():x===47&&Y.ccEOC():Y.ccTO(x-32),p(a,x,y),this.currentChannel=G,!0},c.parseMidrow=function(a,x){var y=0;if((a===17||a===25)&&x>=32&&x<=47){if(a===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(A.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[y];return S?(S.ccMIDROW(x),this.logger.log(A.DEBUG,"MIDROW ("+w([a,x])+")"),!0):!1}return!1},c.parsePAC=function(a,x){var y,S=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&x>=64&&x<=127,G=(a===16||a===24)&&x>=64&&x<=95;if(!(P||G))return!1;if(_(a,x,S))return p(null,null,S),!0;var Y=a<=23?1:2;x>=64&&x<=95?y=Y===1?M[a]:v[a]:y=Y===1?O[a]:C[a];var Q=this.channels[Y];return Q?(Q.setPAC(this.interpretPAC(y,x)),p(a,x,S),this.currentChannel=Y,!0):!1},c.interpretPAC=function(a,x){var y,S={color:null,italics:!1,indent:null,underline:!1,row:a};return x>95?y=x-96:y=x-64,S.underline=(y&1)===1,y<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((y-16)/2)*4,S},c.parseChars=function(a,x){var y,S=null,P=null;if(a>=25?(y=2,P=a-8):(y=1,P=a),P>=17&&P<=19){var G;P===17?G=x+80:P===18?G=x+112:G=x+144,this.logger.log(A.INFO,"Special char '"+D(G)+"' in channel "+y),S=[G]}else a>=32&&a<=127&&(S=x===0?[a]:[a,x]);if(S){var Y=w(S);this.logger.log(A.DEBUG,"Char codes = "+Y.join(",")),p(a,x,this.cmdHistory)}return S},c.parseBackgroundAttributes=function(a,x){var y=(a===16||a===24)&&x>=32&&x<=47,S=(a===23||a===31)&&x>=45&&x<=47;if(!(y||S))return!1;var P,G={};a===16||a===24?(P=Math.floor((x-32)/2),G.background=k[P],x%2===1&&(G.background=G.background+"_semi")):x===45?G.background="transparent":(G.foreground="black",x===47&&(G.underline=!0));var Y=a<=23?1:2,Q=this.channels[Y];return Q.setBkgData(G),p(a,x,this.cmdHistory),!0},c.reset=function(){for(var a=0;a=16?o--:o++;var p=Object(X.fixLineBreaks)(l.trim()),_=Object(I.generateCueId)(v,C,p);(!O||!O.cues||!O.cues.getCueById(_))&&(w=new h(v,C,p),w.id=_,w.line=L+1,w.align="left",w.position=10+Math.min(80,Math.floor(o*8/32)*10),A.push(w))}return O&&A.length&&(A.sort(function(b,g){return b.line==="auto"||g.line==="auto"?0:b.line>8&&g.line>8?g.line-b.line:b.line-g.line}),A.forEach(function(b){return Object(D.addCueToTrack)(O,b)})),A}};Z.default=F},"./src/utils/discontinuities.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"findFirstFragWithCC",function(){return H}),R.d(Z,"shouldAlignOnDiscontinuities",function(){return F}),R.d(Z,"findDiscontinuousReferenceFrag",function(){return M}),R.d(Z,"adjustSlidingStart",function(){return v}),R.d(Z,"alignStream",function(){return C}),R.d(Z,"alignPDT",function(){return A}),R.d(Z,"alignFragmentByPDTDelta",function(){return E}),R.d(Z,"alignMediaPlaylistByPDT",function(){return w});var X=R("./src/polyfills/number.ts"),I=R("./src/utils/logger.ts"),D=R("./src/controller/level-helper.ts");function H(d,o){for(var l=null,h=0,L=d.length;hl.startCC||d&&d.cc=this.minWeight_},H.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},H.destroy=function(){},D}();Z.default=I},"./src/utils/ewma.ts":function(ae,Z,R){"use strict";R.r(Z);var X=function(){function I(H,F,M){F===void 0&&(F=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=H,this.alpha_=H?Math.exp(Math.log(.5)/H):0,this.estimate_=F,this.totalWeight_=M}var D=I.prototype;return D.sample=function(F,M){var O=Math.pow(this.alpha_,F);this.estimate_=M*(1-O)+O*this.estimate_,this.totalWeight_+=F},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var F=1-Math.pow(this.alpha_,this.totalWeight_);if(F)return this.estimate_/F}return this.estimate_},I}();Z.default=X},"./src/utils/fetch-loader.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"fetchSupported",function(){return E});var X=R("./src/polyfills/number.ts"),I=R("./src/loader/load-stats.ts"),D=R("./src/demux/chunk-cache.ts");function H(h,L){h.prototype=Object.create(L.prototype),h.prototype.constructor=h,C(h,L)}function F(h){var L=typeof Map=="function"?new Map:void 0;return F=function(p){if(p===null||!v(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof L!="undefined"){if(L.has(p))return L.get(p);L.set(p,_)}function _(){return M(p,arguments,k(this).constructor)}return _.prototype=Object.create(p.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),C(_,p)},F(h)}function M(h,L,f){return O()?M=Reflect.construct:M=function(_,b,g){var c=[null];c.push.apply(c,b);var u=Function.bind.apply(_,c),a=new u;return g&&C(a,g.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,L){return C=Object.setPrototypeOf||function(p,_){return p.__proto__=_,p},C(h,L)}function k(h){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(f){return f.__proto__||Object.getPrototypeOf(f)},k(h)}function A(){return A=Object.assign||function(h){for(var L=1;L=g&&c(_,b,u.flush(),p)):c(_,b,P,p),y()}).catch(function(){return Promise.reject()})};return x()},h}();function d(h,L){var f={method:"GET",mode:"cors",credentials:"same-origin",signal:L,headers:new self.Headers(A({},h.headers))};return h.rangeEnd&&f.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),f}function o(h,L){return new self.Request(h.url,L)}var l=function(h){H(L,h);function L(f,p,_){var b;return b=h.call(this,f)||this,b.code=void 0,b.details=void 0,b.code=p,b.details=_,b}return L}(F(Error));Z.default=w},"./src/utils/imsc1-ttml-parser.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"IMSC1_CODEC",function(){return v}),R.d(Z,"parseIMSC1",function(){return E});var X=R("./src/utils/mp4-tools.ts"),I=R("./src/utils/vttparser.ts"),D=R("./src/utils/vttcue.ts"),H=R("./src/demux/id3.ts"),F=R("./src/utils/timescale-conversion.ts"),M=R("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(g){for(var c=1;c"):X}function F(v){for(var C=arguments.length,k=new Array(C>1?C-1:0),A=1;A>24,L[f+1]=p>>16&255,L[f+2]=p>>8&255,L[f+3]=p&255}function C(L,f){var p=[];if(!f.length)return p;var _,b,g;"data"in L?(_=L.data,b=L.start,g=L.end):(_=L,b=0,g=_.byteLength);for(var c=b;c1?c+u:g;if(a===f[0])if(f.length===1)p.push({data:_,start:c+8,end:x});else{var y=C({data:_,start:c+8,end:x},f.slice(1));y.length&&H.apply(p,y)}c=x}return p}function k(L){var f=C(L,["moov"]),p=f[0],_=p?p.end:null,b=C(L,["sidx"]);if(!b||!b[0])return null;var g=[],c=b[0],u=c.data[0],a=u===0?8:16,x=O(c,a);a+=4;var y=0,S=0;u===0?a+=8:a+=16,a+=2;var P=c.end+S,G=M(c,a);a+=2;for(var Y=0;Y>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var oe=O(c,Q);Q+=4,g.push({referenceSize:j,subsegmentDuration:oe,info:{duration:oe/x,start:P,end:P+j-1}}),P+=j,Q+=4,a=Q}return{earliestPresentationTime:y,timescale:x,version:u,referencesCount:G,references:g,moovEndOffset:_}}function A(L){for(var f=[],p=C(L,["moov","trak"]),_=0;_F)&&(this.startTime=F),this.endTime=M,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"sendAddTrackEvent",function(){return I}),R.d(Z,"addCueToTrack",function(){return D}),R.d(Z,"clearCurrentCues",function(){return H}),R.d(Z,"removeCuesInRange",function(){return F}),R.d(Z,"getCuesInRange",function(){return O});var X=R("./src/utils/logger.ts");function I(v,C){var k;try{k=new Event("addtrack")}catch(A){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=v,C.dispatchEvent(k)}function D(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(E){X.logger.debug("[texttrack-utils]: "+E);var A=new self.TextTrackCue(C.startTime,C.endTime,C.text);A.id=C.id,v.addCue(A)}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 F(v,C,k){var A=v.mode;if(A==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var E=O(v.cues,C,k),w=0;wv[k].endTime)return-1;for(var A=0,E=k;A<=E;){var w=Math.floor((E+A)/2);if(Cv[w].startTime&&A-1)for(var w=E,d=v.length;w=C&&o.endTime<=k)A.push(o);else if(o.startTime>k)return A}return A}},"./src/utils/time-ranges.ts":function(ae,Z,R){"use strict";R.r(Z);var X={toString:function(D){for(var H="",F=D.length,M=0;M1?C-1:0),A=1;A100)throw new Error("Position must be between 0 and 100.");g=y,this.hasBeenReset=!0}})),Object.defineProperty(A,"positionAlign",M({},E,{get:function(){return c},set:function(y){var S=F(y);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(A,"size",M({},E,{get:function(){return u},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");u=y,this.hasBeenReset=!0}})),Object.defineProperty(A,"align",M({},E,{get:function(){return a},set:function(y){var S=F(y);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),A.displayState=void 0}return O.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"parseTimeStamp",function(){return D}),R.d(Z,"fixLineBreaks",function(){return C}),R.d(Z,"VTTParser",function(){return k});var X=R("./src/utils/vttcue.ts"),I=function(){function A(){}var E=A.prototype;return E.decode=function(d,o){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},A}();function D(A){function E(d,o,l,h){return(d|0)*3600+(o|0)*60+(l|0)+parseFloat(h||0)}var w=A.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return w?parseFloat(w[2])>59?E(w[2],w[3],0,w[4]):E(w[1],w[2],w[3],w[4]):null}var H=function(){function A(){this.values=Object.create(null)}var E=A.prototype;return E.set=function(d,o){!this.get(d)&&o!==""&&(this.values[d]=o)},E.get=function(d,o,l){return l?this.has(d)?this.values[d]:o[l]:this.has(d)?this.values[d]:o},E.has=function(d){return d in this.values},E.alt=function(d,o,l){for(var h=0;h=0&&l<=100)return this.set(d,l),!0}return!1},A}();function F(A,E,w,d){var o=d?A.split(d):[A];for(var l in o){if(typeof o[l]!="string")continue;var h=o[l].split(w);if(h.length!==2)continue;var L=h[0],f=h[1];E(L,f)}}var M=new X.default(0,0,""),O=M.align==="middle"?"middle":"center";function v(A,E,w){var d=A;function o(){var L=D(A);if(L===null)throw new Error("Malformed timestamp: "+d);return A=A.replace(/^[^\sa-zA-Z-]+/,""),L}function l(L,f){var p=new H;F(L,function(g,c){var u;switch(g){case"region":for(var a=w.length-1;a>=0;a--)if(w[a].id===c){p.set(g,w[a].region);break}break;case"vertical":p.alt(g,c,["rl","lr"]);break;case"line":u=c.split(","),p.integer(g,u[0]),p.percent(g,u[0])&&p.set("snapToLines",!1),p.alt(g,u[0],["auto"]),u.length===2&&p.alt("lineAlign",u[1],["start",O,"end"]);break;case"position":u=c.split(","),p.percent(g,u[0]),u.length===2&&p.alt("positionAlign",u[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":p.percent(g,c);break;case"align":p.alt(g,c,["start",O,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");var _=p.get("line","auto");_==="auto"&&M.line===-1&&(_=-1),f.line=_,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",O);var b=p.get("position","auto");b==="auto"&&M.position===50&&(b=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=b}function h(){A=A.replace(/^\s+/,"")}if(h(),E.startTime=o(),h(),A.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);A=A.substr(3),h(),E.endTime=o(),h(),l(A,E)}function C(A){return A.replace(//gi,` `)}var k=function(){function A(){this.state="INITIAL",this.buffer="",this.decoder=new I,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var E=A.prototype;return E.parse=function(d){var o=this;d&&(o.buffer+=o.decoder.decode(d,{stream:!0}));function l(){var b=o.buffer,g=0;for(b=C(b);g")===-1){o.cue.id=L;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(L,o.cue,o.regionList)}catch(b){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var _=L.indexOf("-->")!==-1;if(!L||_&&(p=!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+=L}continue;case"BADCUE":L||(o.state="ID")}}}catch(b){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},E.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=` `,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){d.onparsingerror&&d.onparsingerror(o)}return d.onflush&&d.onflush(),this},A}()},"./src/utils/webvtt-parser.ts":function(ae,Z,R){"use strict";R.r(Z),R.d(Z,"generateCueId",function(){return k}),R.d(Z,"parseWebVTT",function(){return E});var X=R("./src/polyfills/number.ts"),I=R("./src/utils/vttparser.ts"),D=R("./src/demux/id3.ts"),H=R("./src/utils/timescale-conversion.ts"),F=R("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,O=function(d,o,l){return l===void 0&&(l=0),d.substr(l,o.length)===o},v=function(d){var o=parseInt(d.substr(-3)),l=parseInt(d.substr(-6,2)),h=parseInt(d.substr(-9,2)),L=d.length>9?parseInt(d.substr(0,d.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(l)||!Object(X.isFiniteNumber)(h)||!Object(X.isFiniteNumber)(L))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+d);return o+=1e3*l,o+=60*1e3*h,o+=60*60*1e3*L,o},C=function(d){for(var o=5381,l=d.length;l;)o=o*33^d.charCodeAt(--l);return(o>>>0).toString()};function k(w,d,o){return C(w.toString())+C(d.toString())+C(o)}var A=function(d,o,l){var h=d[o],L=d[h.prevCC];if(!L||!L.new&&h.new){d.ccOffset=d.presentationOffset=h.start,h.new=!1;return}for(;(f=L)!==null&&f!==void 0&&f.new;){var f;d.ccOffset+=h.start-L.start,h.new=!1,h=L,L=d[h.prevCC]}d.presentationOffset=l};function E(w,d,o,l,h,L,f,p){var _=new I.VTTParser,b=Object(D.utf8ArrayToStr)(new Uint8Array(w)).trim().replace(M,` `).split(` `),g=[],c=Object(H.toMpegTsClockFromTimescale)(d,o),u="00:00.000",a=0,x=0,y,S=!0,P=!1;_.oncue=function(G){var Y=l[h],Q=l.ccOffset,z=(a-c)/9e4;if(Y!=null&&Y.new&&(x!==void 0?Q=l.ccOffset=Y.start:A(l,h,z)),z&&(Q=z-l.presentationOffset),P){var j=G.endTime-G.startTime,ee=Object(F.normalizePts)((G.startTime+Q-x)*9e4,L*9e4)/9e4;G.startTime=ee,G.endTime=ee+j}var oe=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(oe)),G.id||(G.id=k(G.startTime,G.endTime,oe)),G.endTime>0&&g.push(G)},_.onparsingerror=function(G){y=G},_.onflush=function(){if(y){p(y);return}f(g)},b.forEach(function(G){if(S)if(O(G,"X-TIMESTAMP-MAP=")){S=!1,P=!0,G.substr(16).split(",").forEach(function(Y){O(Y,"LOCAL:")?u=Y.substr(6):O(Y,"MPEGTS:")&&(a=parseInt(Y.substr(7)))});try{x=v(u)/1e3}catch(Y){P=!1,y=Y}return}else G===""&&(S=!1);_.parse(G+` `)}),_.flush()}},"./src/utils/xhr-loader.ts":function(ae,Z,R){"use strict";R.r(Z);var X=R("./src/utils/logger.ts"),I=R("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,H=function(){function F(O){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=O?O.xhrSetup:null,this.stats=new I.LoadStats,this.retryDelay=0}var M=F.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var 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,A=this.stats;A.loading.first=0,A.loaded=0;var E=this.xhrSetup;try{if(E)try{E(k,C.url)}catch(o){k.open("GET",C.url,!0),E(k,C.url)}k.readyState||k.open("GET",C.url,!0);var w=this.context.headers;if(w)for(var d in w)k.setRequestHeader(d,w[d])}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 A=C.readyState,E=this.config;if(k.aborted)return;if(A>=2)if(self.clearTimeout(this.requestTimeout),k.loading.first===0&&(k.loading.first=Math.max(self.performance.now(),k.loading.start)),A===4){C.onreadystatechange=null,C.onprogress=null;var w=C.status;if(w>=200&&w<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var d,o;if(v.responseType==="arraybuffer"?(d=C.response,o=d.byteLength):(d=C.responseText,o=d.length),k.loaded=k.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(k,v,d,C),!this.callbacks)return;var h={url:C.responseURL,data:d};this.callbacks.onSuccess(h,k,v,C)}else k.retry>=E.maxRetry||w>=400&&w<499?(X.logger.error(w+" while loading "+v.url),this.callbacks.onError({code:w,text:C.statusText},v,C)):(X.logger.warn(w+" 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,E.maxRetryDelay),k.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout)},M.loadtimeout=function(){X.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&&D.test(this.loader.getAllResponseHeaders())){var C=this.loader.getResponseHeader("age");v=C?parseFloat(C):null}return v},F}();Z.default=H}}).default})},vHTk:function(Ct,dt,ie){Ct.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);