You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
361 lines
902 KiB
361 lines
902 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[272,7,9],{"+NIl":function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){"use strict";ue.defineMode("stex",function(Y,k){"use strict";function V(L,w){L.cmdState.push(w)}function I(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function D(L){var w=L.cmdState.pop();w&&w.closeBracket()}function j(L){for(var w=L.cmdState,E=w.length-1;E>=0;E--){var u=w[E];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function F(L,w,E){return function(){this.name=L,this.bracketNo=0,this.style=w,this.styles=E,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var P={};P.importmodule=F("importmodule","tag",["string","builtin"]),P.documentclass=F("documentclass","tag",["","atom"]),P.usepackage=F("usepackage","tag",["atom"]),P.begin=F("begin","tag",["atom"]),P.end=F("end","tag",["atom"]),P.label=F("label","tag",["atom"]),P.ref=F("ref","tag",["atom"]),P.eqref=F("eqref","tag",["atom"]),P.cite=F("cite","tag",["atom"]),P.bibitem=F("bibitem","tag",["atom"]),P.Bibitem=F("Bibitem","tag",["atom"]),P.RBibitem=F("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(L,w){L.f=w}function g(L,w){var E;if(L.match(/^\\[a-zA-Z@]+/)){var u=L.current().slice(1);return E=P.hasOwnProperty(u)?P[u]:P.DEFAULT,E=new E,V(w,E),O(w,R),E.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return O(w,function(s,l){return T(s,l,"\\]")}),"keyword";if(L.match("\\("))return O(w,function(s,l){return T(s,l,"\\)")}),"keyword";if(L.match("$$"))return O(w,function(s,l){return T(s,l,"$$")}),"keyword";if(L.match("$"))return O(w,function(s,l){return T(s,l,"$")}),"keyword";var o=L.next();if(o=="%")return L.skipToEnd(),"comment";if(o=="}"||o=="]"){if(E=I(w),E)E.closeBracket(o),O(w,R);else return"error";return"bracket"}else return o=="{"||o=="["?(E=P.DEFAULT,E=new E,V(w,E),"bracket"):/\d/.test(o)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),E=j(w),E.name=="begin"&&(E.argument=L.current()),E.styleIdentifier())}function T(L,w,E){if(L.eatSpace())return null;if(E&&L.match(E))return O(w,g),"keyword";if(L.match(/^\\[a-zA-Z@]+/))return"tag";if(L.match(/^[a-zA-Z]+/))return"variable-2";if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/]/))return"tag";if(L.match(/^[\^_&]/))return"tag";if(L.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(L.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=L.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(L.skipToEnd(),"comment"):"error"}function R(L,w){var E=L.peek(),u;return E=="{"||E=="["?(u=I(w),u.openBracket(E),L.eat(E),O(w,g),"bracket"):/[ \t\r]/.test(E)?(L.eat(E),null):(O(w,g),D(w),g(L,w))}return{startState:function(){var L=k.inMathMode?function(w,E){return T(w,E)}:g;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,w){return w.f(L,w)},blankLine:function(L){L.f=g,L.cmdState.length=0},lineComment:"%"}}),ue.defineMIME("text/x-stex","stex"),ue.defineMIME("text/x-latex","stex")})},"19Vz":function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){ue.defineOption("placeholder","",function(F,P,O){var g=O&&O!=ue.Init;if(P&&!g)F.on("blur",I),F.on("change",D),F.on("swapDoc",D),ue.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){V(F)}),D(F);else if(!P&&g){F.off("blur",I),F.off("change",D),F.off("swapDoc",D),ue.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),Y(F);var T=F.getWrapperElement();T.className=T.className.replace(" CodeMirror-empty","")}P&&!F.hasFocus()&&I(F)});function Y(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function k(F){Y(F);var P=F.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=F.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var O=F.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),P.appendChild(O),F.display.lineSpace.insertBefore(P,F.display.lineSpace.firstChild)}function V(F){setTimeout(function(){var P=!1,O=F.getInputField();O.nodeName=="TEXTAREA"?P=!O.value:F.lineCount()==1&&(P=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),P?k(F):Y(F)},20)}function I(F){j(F)&&k(F)}function D(F){var P=F.getWrapperElement(),O=j(F);P.className=P.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?k(F):Y(F)}function j(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){"use strict";var Y={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},k={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ue.defineMode("xml",function(V,I){var D=V.indentUnit,j={},F=I.htmlMode?Y:k;for(var P in F)j[P]=F[P];for(var P in I)j[P]=I[P];var O,g;function T(a,y){function m(G){return y.tokenize=G,G(a,y)}var x=a.next();if(x=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?m(w("atom","]]>")):null:a.match("--")?m(w("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),m(E(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),y.tokenize=w("meta","?>"),"meta"):(O=a.eat("/")?"closeTag":"openTag",y.tokenize=R,"tag bracket");if(x=="&"){var M;return a.eat("#")?a.eat("x")?M=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):M=a.eatWhile(/[\d]/)&&a.eat(";"):M=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),M?"atom":"error"}else return a.eatWhile(/[^&<]/),null}T.isInText=!0;function R(a,y){var m=a.next();if(m==">"||m=="/"&&a.eat(">"))return y.tokenize=T,O=m==">"?"endTag":"selfcloseTag","tag bracket";if(m=="=")return O="equals",null;if(m=="<"){y.tokenize=T,y.state=l,y.tagName=y.tagStart=null;var x=y.tokenize(a,y);return x?x+" tag error":"tag error"}else return/[\'\"]/.test(m)?(y.tokenize=L(m),y.stringStartCol=a.column(),y.tokenize(a,y)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(a){var y=function(m,x){for(;!m.eol();)if(m.next()==a){x.tokenize=R;break}return"string"};return y.isInAttribute=!0,y}function w(a,y){return function(m,x){for(;!m.eol();){if(m.match(y)){x.tokenize=T;break}m.next()}return a}}function E(a){return function(y,m){for(var x;(x=y.next())!=null;){if(x=="<")return m.tokenize=E(a+1),m.tokenize(y,m);if(x==">")if(a==1){m.tokenize=T;break}else return m.tokenize=E(a-1),m.tokenize(y,m)}return"meta"}}function u(a,y,m){this.prev=a.context,this.tagName=y,this.indent=a.indented,this.startOfLine=m,(j.doNotIndent.hasOwnProperty(y)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function s(a,y){for(var m;;){if(!a.context)return;if(m=a.context.tagName,!j.contextGrabbers.hasOwnProperty(m)||!j.contextGrabbers[m].hasOwnProperty(y))return;o(a)}}function l(a,y,m){return a=="openTag"?(m.tagStart=y.column(),S):a=="closeTag"?p:l}function S(a,y,m){return a=="word"?(m.tagName=y.current(),g="tag",v):j.allowMissingTagName&&a=="endTag"?(g="tag bracket",v(a,y,m)):(g="error",S)}function p(a,y,m){if(a=="word"){var x=y.current();return m.context&&m.context.tagName!=x&&j.implicitlyClosed.hasOwnProperty(m.context.tagName)&&o(m),m.context&&m.context.tagName==x||j.matchClosing===!1?(g="tag",f):(g="tag error",C)}else return j.allowMissingTagName&&a=="endTag"?(g="tag bracket",f(a,y,m)):(g="error",C)}function f(a,y,m){return a!="endTag"?(g="error",f):(o(m),l)}function C(a,y,m){return g="error",f(a,y,m)}function v(a,y,m){if(a=="word")return g="attribute",d;if(a=="endTag"||a=="selfcloseTag"){var x=m.tagName,M=m.tagStart;return m.tagName=m.tagStart=null,a=="selfcloseTag"||j.autoSelfClosers.hasOwnProperty(x)?s(m,x):(s(m,x),m.context=new u(m,x,M==m.indented)),l}return g="error",v}function d(a,y,m){return a=="equals"?c:(j.allowMissing||(g="error"),v(a,y,m))}function c(a,y,m){return a=="string"?h:a=="word"&&j.allowUnquoted?(g="string",v):(g="error",v(a,y,m))}function h(a,y,m){return a=="string"?h:v(a,y,m)}return{startState:function(a){var y={tokenize:T,state:l,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(y.baseIndent=a),y},token:function(a,y){if(!y.tagName&&a.sol()&&(y.indented=a.indentation()),a.eatSpace())return null;O=null;var m=y.tokenize(a,y);return(m||O)&&m!="comment"&&(g=null,y.state=y.state(O||m,a,y),g&&(m=g=="error"?m+" error":g)),m},indent:function(a,y,m){var x=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+D;if(x&&x.noIndent)return ue.Pass;if(a.tokenize!=R&&a.tokenize!=T)return m?m.match(/^(\s*)/)[0].length:0;if(a.tagName)return j.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+D*(j.multilineTagIndentFactor||1);if(j.alignCDATA&&/<!\[CDATA\[/.test(y))return 0;var M=y&&/^<(\/)?([\w_:\.-]*)/.exec(y);if(M&&M[1])for(;x;)if(x.tagName==M[2]){x=x.prev;break}else if(j.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(M)for(;x;){var G=j.contextGrabbers[x.tagName];if(G&&G.hasOwnProperty(M[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.indent+D:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:j.htmlMode?"html":"xml",helperType:j.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=v)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var y=[],m=a.context;m;m=m.prev)m.tagName&&y.push(m.tagName);return y.reverse()}}}),ue.defineMIME("text/xml","xml"),ue.defineMIME("application/xml","xml"),ue.mimeModes.hasOwnProperty("text/html")||ue.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"2RCv":function(ht,Ze,le){"use strict";var ue=le("Awhp"),Y=le("KrTs"),k=le("+L6B"),V=le("2/Rp"),I=le("5NDa"),D=le("5rEg"),j=le("0Owb"),F=le("oBTY"),P=le("tJVT"),O=le("PpiC"),g=le("q1tI"),T=le.n(g),R=function(w){var E=w.InputRight,u=w.value,o=u===void 0?[]:u,s=w.onChange,l=s===void 0?function(){}:s,S=Object(O.a)(w,["InputRight","value","onChange"]),p=Object(g.useState)(),f=Object(P.a)(p,2),C=f[0],v=f[1],d=function(a){var y=o.filter(function(m,x){return x!==a});l(y)},c=function(a){if(a.preventDefault(),!C)return;l([].concat(Object(F.a)(o),[C])),v(null)};return T.a.createElement("div",null,T.a.createElement(D.a,Object(j.a)({},S,{value:C,onChange:function(a){return v(a.target.value)},onPressEnter:c,onBlur:c})),E,T.a.createElement("div",{className:"mt20"},o==null?void 0:o.map(function(h,a){return T.a.createElement(Y.a,{className:"ml10 mr10",count:"x",onClick:function(){return d(a)}},T.a.createElement(V.a,{type:"primary",ghost:!0},h))})))};Ze.a=R},"7Cbv":function(ht,Ze,le){"use strict";var ue=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Y=new Uint8Array(16);function k(){if(!ue)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ue(Y)}var V=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function I(R){return typeof R=="string"&&V.test(R)}for(var D=I,j=[],F=0;F<256;++F)j.push((F+256).toString(16).substr(1));function P(R){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=(j[R[L+0]]+j[R[L+1]]+j[R[L+2]]+j[R[L+3]]+"-"+j[R[L+4]]+j[R[L+5]]+"-"+j[R[L+6]]+j[R[L+7]]+"-"+j[R[L+8]]+j[R[L+9]]+"-"+j[R[L+10]]+j[R[L+11]]+j[R[L+12]]+j[R[L+13]]+j[R[L+14]]+j[R[L+15]]).toLowerCase();if(!D(w))throw TypeError("Stringified UUID is invalid");return w}var O=P;function g(R,L,w){R=R||{};var E=R.random||(R.rng||k)();if(E[6]=E[6]&15|64,E[8]=E[8]&63|128,L){w=w||0;for(var u=0;u<16;++u)L[w+u]=E[u];return L}return O(E)}var T=Ze.a=g},"7ahc":function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return S});var ue=le("k1fw"),Y=le("0Owb"),k=le("+L6B"),V=le("2/Rp"),I=le("y8nQ"),D=le("Vl3Y"),j=le("tJVT"),F=le("OaEy"),P=le("2fM7"),O=le("q1tI"),g=le.n(O),T=le("VrN/"),R=le.n(T),L=le("p77/"),w=le.n(L),E=le("c5Ni"),u=le.n(E),o=P.a.Option,s={labelCol:{span:4},wrapperCol:{span:20}},l={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"]};Ze.b=function(p){var f=p.callback,C=p.onCancel,v=Object(O.useState)("python"),d=Object(j.a)(v,2),c=d[0],h=d[1];function a(m){h(l[m][1])}function y(m){f(m)}return g.a.createElement(D.a,Object(Y.a)({},s,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:y}),g.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},g.a.createElement(P.a,{onChange:a},Object.keys(l).map(function(m){return g.a.createElement(o,{key:m,value:m},l[m][0])}))),g.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},g.a.createElement(S,{mode:c})),g.a.createElement("div",{className:"flex-container flex-end"},g.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),g.a.createElement(V.a,{type:"ghost",onClick:C},"\u53D6\u6D88")))};function S(p){var f=p.value,C=p.onChange,v=p.mode,d=p.options,c=d===void 0?{}:d,h=Object(O.useRef)(),a=Object(O.useState)(),y=Object(j.a)(a,2),m=y[0],x=y[1];return Object(O.useEffect)(function(){if(m){function M(G){var $=G.getValue();C&&C($)}return m.on("change",M),function(){m.off("change",M)}}},[m,C]),Object(O.useEffect)(function(){m&&m.setOption("mode",v)},[m,v]),Object(O.useEffect)(function(){m&&((f!==m.getValue()||f==="")&&setTimeout(function(){m.setValue(f||" ")},300))},[m,f]),Object(O.useEffect)(function(){if(h.current&&!m){var M=R.a.fromTextArea(h.current,Object(ue.a)({mode:v,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));x(M)}},[h.current,m]),g.a.createElement("div",{className:"my-codemirror-container"},g.a.createElement("textarea",{ref:h}))}},"7ixt":function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return k});var ue={adjustX:1,adjustY:1},Y=[0,0],k={left:{points:["cr","cl"],overflow:ue,offset:[-4,0],targetOffset:Y},right:{points:["cl","cr"],overflow:ue,offset:[4,0],targetOffset:Y},top:{points:["bc","tc"],overflow:ue,offset:[0,-4],targetOffset:Y},bottom:{points:["tc","bc"],overflow:ue,offset:[0,4],targetOffset:Y},topLeft:{points:["bl","tl"],overflow:ue,offset:[0,-4],targetOffset:Y},leftTop:{points:["tr","tl"],overflow:ue,offset:[-4,0],targetOffset:Y},topRight:{points:["br","tr"],overflow:ue,offset:[0,-4],targetOffset:Y},rightTop:{points:["tl","tr"],overflow:ue,offset:[4,0],targetOffset:Y},bottomRight:{points:["tr","br"],overflow:ue,offset:[0,4],targetOffset:Y},rightBottom:{points:["bl","br"],overflow:ue,offset:[4,0],targetOffset:Y},bottomLeft:{points:["tl","bl"],overflow:ue,offset:[0,4],targetOffset:Y},leftBottom:{points:["br","bl"],overflow:ue,offset:[-4,0],targetOffset:Y}},V=k},"8EBN":function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){"use strict";ue.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 Y=0;Y<ue.modeInfo.length;Y++){var k=ue.modeInfo[Y];k.mimes&&(k.mime=k.mimes[0])}ue.findModeByMIME=function(V){V=V.toLowerCase();for(var I=0;I<ue.modeInfo.length;I++){var D=ue.modeInfo[I];if(D.mime==V)return D;if(D.mimes){for(var j=0;j<D.mimes.length;j++)if(D.mimes[j]==V)return D}}if(/\+xml$/.test(V))return ue.findModeByMIME("application/xml");if(/\+json$/.test(V))return ue.findModeByMIME("application/json")},ue.findModeByExtension=function(V){V=V.toLowerCase();for(var I=0;I<ue.modeInfo.length;I++){var D=ue.modeInfo[I];if(D.ext){for(var j=0;j<D.ext.length;j++)if(D.ext[j]==V)return D}}},ue.findModeByFileName=function(V){for(var I=0;I<ue.modeInfo.length;I++){var D=ue.modeInfo[I];if(D.file&&D.file.test(V))return D}var j=V.lastIndexOf("."),F=j>-1&&V.substring(j+1,V.length);if(F)return ue.findModeByExtension(F)},ue.findModeByName=function(V){V=V.toLowerCase();for(var I=0;I<ue.modeInfo.length;I++){var D=ue.modeInfo[I];if(D.name.toLowerCase()==V)return D;if(D.alias){for(var j=0;j<D.alias.length;j++)if(D.alias[j].toLowerCase()==V)return D}}}})},"8hTe":function(ht,Ze,le){ht.exports={button:"button___1wy9m"}},"93VE":function(ht,Ze,le){},"9Bee":function(ht,Ze,le){"use strict";var ue=le("DYRE"),Y=le("zeV3"),k=le("+L6B"),V=le("2/Rp"),I=le("k1fw"),D=le("9og8"),j=le("tJVT"),F=le("WmNS"),P=le.n(F),O=le("q1tI"),g=le.n(O),T=le("vg9a"),R=le("DlQD"),L=le.n(R),w=le("rUJ1");function E(ae,J){var Z=ae.match(/^(\s+)(?:```)/);if(Z===null)return J;var ie=Z[1];return J.split(`
|
|
`).map(function(oe){var Q=oe.match(/^\s+/);if(Q===null)return oe;var te=Object(j.a)(Q,1),se=te[0];return se.length>=ie.length?oe.slice(ie.length):oe}).join(`
|
|
`)}var u=[],o=["<ul>"],s=new L.a.Renderer,l=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function S(){u.length=0,o=["<ul>"]}var p={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function f(ae,J,Z,ie){if(J>=ae.length||ae[J].level<=Z)return J;var oe=ae[J];ie.push("<li><a href='#"+oe.anchor+"'>"+oe.text+"</a>"),J++;var Q=[];return J=f(ae,J,oe.level,Q),Q.length>0&&(ie.push("<ul>"),Q.forEach(function(te){ie.push(te)}),ie.push("</ul>")),ie.push("</li>"),J=f(ae,J,Z,ie),J}function C(){return f(u,0,0,o),o.push("</ul>"),o.join("")}var v={heading:function(J){var Z=l.exec(J);if(Z)return{type:"heading",raw:Z[0],depth:Z[1].length,text:Z[2]}},fences:function(J){var Z=this.rules.block.fences.exec(J);if(Z){var ie=Z[0],oe=E(ie,Z[3]||""),Q=Z[2]?Z[2].trim():Z[2];if(["latex","katex","math"].indexOf(Q)>=0){var te=h(),se=oe;oe=te,a[te]={type:"block",expression:se}}return{type:"code",raw:ie,lang:Q,text:oe}}}},d=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,h=function(){return"__special_katext_id_".concat(c++,"__")},a={};function y(){return a}function m(){c=0,a={}}function x(ae){return ae=ae.replace(d,function(J,Z){var ie=h();return a[ie]={type:"inline",expression:Z},ie}),ae}var M=s.listitem;s.listitem=function(ae){return M(x(ae))};var G=s.paragraph;s.paragraph=function(ae){return G(x(ae))};var $=s.tablecell;s.tablecell=function(ae,J){return $(x(ae),J)},s.code=function(ae,J,Z){var ie=(J||"").match(/\S*/)[0];return ie?["latex","katex","math"].indexOf(ie)>=0?"<p class='editormd-tex'>".concat(ae,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(J,'">').concat(Z?ae:Object(w.escape)(ae,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(Z?ae:Object(w.escape)(ae,!0))+"</code></pre>"},s.heading=function(ae,J,Z){var ie=this.options.headerPrefix+Z.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:ie,level:J,text:ae}),"<h"+J+' id="'+ie+'">'+ae+"</h"+J+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:v,renderer:s});var re=L.a,z=le("SJMd"),U=le("ulZh"),ne=le.n(U),fe=le("m3rI"),ge=le("Oy/b"),be=le("p5ED"),Me=le("ErOA"),Te=le("STEk");/* **********************************
|
|
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 De=function(ae,J){return(De=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Z,ie){Z.__proto__=ie}||function(Z,ie){for(var oe in ie)Object.prototype.hasOwnProperty.call(ie,oe)&&(Z[oe]=ie[oe])})(ae,J)};function Ce(ae,J){if(typeof J!="function"&&J!==null)throw new TypeError("Class extends value "+String(J)+" is not a constructor or null");function Z(){this.constructor=ae}De(ae,J),ae.prototype=J===null?Object.create(J):(Z.prototype=J.prototype,new Z)}function we(ae,J,Z,ie){return new(Z||(Z=Promise))(function(oe,Q){function te(me){try{he(ie.next(me))}catch(ye){Q(ye)}}function se(me){try{he(ie.throw(me))}catch(ye){Q(ye)}}function he(me){var ye;me.done?oe(me.value):(ye=me.value,ye instanceof Z?ye:new Z(function(_e){_e(ye)})).then(te,se)}he((ie=ie.apply(ae,J||[])).next())})}function ve(ae,J){var Z,ie,oe,Q,te={label:0,sent:function(){if(1&oe[0])throw oe[1];return oe[1]},trys:[],ops:[]};return Q={next:se(0),throw:se(1),return:se(2)},typeof Symbol=="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function se(he){return function(me){return function(ye){if(Z)throw new TypeError("Generator is already executing.");for(;te;)try{if(Z=1,ie&&(oe=2&ye[0]?ie.return:ye[0]?ie.throw||((oe=ie.return)&&oe.call(ie),0):ie.next)&&!(oe=oe.call(ie,ye[1])).done)return oe;switch(ie=0,oe&&(ye=[2&ye[0],oe.value]),ye[0]){case 0:case 1:oe=ye;break;case 4:return te.label++,{value:ye[1],done:!1};case 5:te.label++,ie=ye[1],ye=[0];continue;case 7:ye=te.ops.pop(),te.trys.pop();continue;default:if(!(oe=te.trys,(oe=oe.length>0&&oe[oe.length-1])||ye[0]!==6&&ye[0]!==2)){te=0;continue}if(ye[0]===3&&(!oe||ye[1]>oe[0]&&ye[1]<oe[3])){te.label=ye[1];break}if(ye[0]===6&&te.label<oe[1]){te.label=oe[1],oe=ye;break}if(oe&&te.label<oe[2]){te.label=oe[2],te.ops.push(ye);break}oe[2]&&te.ops.pop(),te.trys.pop();continue}ye=J.call(ae,te)}catch(_e){ye=[6,_e],ie=0}finally{Z=oe=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([he,me])}}}var W=function(){function ae(){}return ae.addKey=function(J){ae.key=J},Object.defineProperty(ae,"isLicensed",{get:function(){return!!ae.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(ae.key)},enumerable:!1,configurable:!0}),ae}(),A=function(){function ae(){}return ae.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},ae.setAttributes=function(J,Z){for(var ie=0,oe=Z;ie<oe.length;ie++){var Q=oe[ie],te=Q[0],se=Q[1];J.setAttribute(te,se)}},ae.createRect=function(J,Z,ie){var oe=document.createElementNS("http://www.w3.org/2000/svg","rect");return oe.setAttribute("width",J.toString()),oe.setAttribute("height",Z.toString()),ie&&ae.setAttributes(oe,ie),oe},ae.createLine=function(J,Z,ie,oe,Q){var te=document.createElementNS("http://www.w3.org/2000/svg","line");return te.setAttribute("x1",J.toString()),te.setAttribute("y1",Z.toString()),te.setAttribute("x2",ie.toString()),te.setAttribute("y2",oe.toString()),Q&&ae.setAttributes(te,Q),te},ae.createPolygon=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg","polygon");return ie.setAttribute("points",J),Z&&ae.setAttributes(ie,Z),ie},ae.createCircle=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg","circle");return ie.setAttribute("cx",(J/2).toString()),ie.setAttribute("cy",(J/2).toString()),ie.setAttribute("r",J.toString()),Z&&ae.setAttributes(ie,Z),ie},ae.createEllipse=function(J,Z,ie){var oe=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return oe.setAttribute("cx",(J/2).toString()),oe.setAttribute("cy",(Z/2).toString()),oe.setAttribute("rx",(J/2).toString()),oe.setAttribute("ry",(Z/2).toString()),ie&&ae.setAttributes(oe,ie),oe},ae.createGroup=function(J){var Z=document.createElementNS("http://www.w3.org/2000/svg","g");return J&&ae.setAttributes(Z,J),Z},ae.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},ae.createMarker=function(J,Z,ie,oe,Q,te,se){var he=document.createElementNS("http://www.w3.org/2000/svg","marker");return ae.setAttributes(he,[["id",J],["orient",Z],["markerWidth",ie.toString()],["markerHeight",oe.toString()],["refX",Q.toString()],["refY",te.toString()]]),he.appendChild(se),he},ae.createText=function(J){var Z=document.createElementNS("http://www.w3.org/2000/svg","text");return Z.setAttribute("x","0"),Z.setAttribute("y","0"),J&&ae.setAttributes(Z,J),Z},ae.createTSpan=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg","tspan");return ie.textContent=J,Z&&ae.setAttributes(ie,Z),ie},ae.createImage=function(J){var Z=document.createElementNS("http://www.w3.org/2000/svg","image");return J&&ae.setAttributes(Z,J),Z},ae.createPoint=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return ie.x=J,ie.y=Z,ie},ae.createPath=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg","path");return ie.setAttribute("d",J),Z&&ae.setAttributes(ie,Z),ie},ae.createElement=function(J,Z){var ie=document.createElementNS("http://www.w3.org/2000/svg",J);return Z&&ae.setAttributes(ie,Z),ie},ae.getHollowRectanglePath=function(J,Z,ie,oe,Q,te,se,he){return"M"+J+","+Z+"V"+(Z+oe)+"H"+(J+ie)+"V"+Z+"H"+Q+"V"+te+"H"+(Q+se)+"V"+(te+he)+"H"+Q+"V"+Z+"Z"},ae}(),_=function(){function ae(J){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+J+"_"}return Object.defineProperty(ae.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),ae.prototype.addClass=function(J){return this.styleSheet===void 0&&this.addStyleSheet(),J.name=""+this.classNamePrefix+J.localName,this.classes.push(J),this.styleSheet.sheet.insertRule("."+J.name+" {"+J.style+"}",this.styleSheet.sheet.cssRules.length),J},ae.prototype.addRule=function(J){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(J),this.styleSheet.sheet.insertRule(J.selector+" {"+J.style+"}",this.styleSheet.sheet.cssRules.length)},ae.prototype.addStyleSheet=function(){var J;this.styleSheet=document.createElement("style"),((J=this.styleSheetRoot)!==null&&J!==void 0?J:document.head).appendChild(this.styleSheet),this.addRule(new H("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new q("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new q("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},ae.prototype.removeStyleSheet=function(){var J;this.styleSheet&&(((J=this.styleSheetRoot)!==null&&J!==void 0?J:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},ae}(),H=function(ae,J){this.selector=ae,this.style=J},q=function(ae,J){this.localName=ae,this.style=J},B=function(){function ae(){this.blocks=[],this.display=""}return ae.prototype.addButtonBlock=function(J){J.className=this.blockClassName,J.buttonClassName=this.buttonClassName,J.buttonColorsClassName=this.buttonColorsClassName,J.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(J)},ae.prototype.addElementBlock=function(J){J.className===void 0&&(J.className=this.blockClassName),this.blocks.push(J)},ae.prototype.getUI=function(){var J=document.createElement("div");return J.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,J.style.display=this.display,this.blocks.forEach(function(Z){return J.appendChild(Z.getUI())}),J},ae}(),de=function(){function ae(){}return ae.prototype.getUI=function(){var J=document.createElement("div");if(J.className=this.className,this.minWidth!==void 0&&(J.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":J.style.justifyContent="flex-start";break;case"center":J.style.justifyContent="center";break;case"end":J.style.justifyContent="flex-end"}return J.style.whiteSpace="nowrap",J},ae}(),Ee=function(ae){function J(){var Z=ae!==null&&ae.apply(this,arguments)||this;return Z.buttons=[],Z}return Ce(J,ae),J.prototype.addButton=function(Z){Z.className=this.buttonClassName,Z.colorsClassName=this.buttonColorsClassName,Z.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(Z)},J.prototype.getUI=function(){var Z=ae.prototype.getUI.call(this);return this.buttons.forEach(function(ie){return Z.appendChild(ie.getUI())}),Z},J}(de),Le=function(){function ae(J,Z){this._isActive=!1,this._isHidden=!1,this._icon=J,this.title=Z,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(ae.prototype,"icon",{get:function(){return this._icon},set:function(J){this._icon=J,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isActive",{get:function(){return this._isActive},set:function(J){this._isActive=J,this.adjustClassName()},enumerable:!1,configurable:!0}),ae.prototype.getUI=function(){var J=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return J.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},ae.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},ae.prototype.hide=function(){this._isHidden=!0},ae}(),Ie=function(ae){function J(){var Z=ae!==null&&ae.apply(this,arguments)||this;return Z.elements=[],Z}return Ce(J,ae),J.prototype.addElement=function(Z){this.elements.push(Z)},J.prototype.getUI=function(){var Z=ae.prototype.getUI.call(this);return this.elements.forEach(function(ie){return Z.appendChild(ie)}),Z},J}(de),ke=function(){function ae(J,Z){this.horizontal=J,this.vertical=Z}return Object.defineProperty(ae.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),ae.prototype.getVerticalLength=function(J){return J/this.ratio},ae.prototype.getHorizontalLength=function(J){return J*this.ratio},ae}(),Oe=function(){function ae(){}return ae.getIcon=function(J,Z){if(J>0&&Z>0){var ie=new ke(J,Z),oe=ie.ratio>=1?20:ie.getHorizontalLength(20),Q=ie.ratio<1?20:ie.getVerticalLength(20),te=document.createElementNS("http://www.w3.org/2000/svg","svg");te.setAttribute("xmlns","http://www.w3.org/2000/svg"),te.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(te);var se=A.createDefs();te.appendChild(se);var he=A.createElement("clipPath",[["id","text-bg-clip"]]);se.appendChild(he);var me=A.createPath(A.getHollowRectanglePath((24-oe)/2,(24-Q)/2,oe,Q,(24-oe)/2+2,(24-Q)/2+2,oe-4,Q-4));te.appendChild(me);var ye=A.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(A.createTSpan(J+":"+Z)),te.appendChild(ye);var _e=ye.getBBox();A.setAttributes(ye,[["x",((24-_e.width)/2).toString()],["y",((24-_e.height)/2-_e.y).toString()]]);var Fe=A.createPath(A.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(_e.width))/2,(24-Math.ceil(_e.height))/2,Math.ceil(_e.width),Math.ceil(_e.height)));return he.appendChild(Fe),A.setAttributes(me,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(te),te.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},ae}(),Pe=function(ae){function J(Z,ie,oe){var Q=ae.call(this,Z,ie)||this;return Q.isDropdownOpen=!1,Q.onClick=Q.dropdownButtonClicked,Q.dropdownButtons=oe,Q}return Ce(J,ae),J.prototype.setupDropdown=function(){var Z=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(ie){ie.className=Z.className,ie.colorsClassName=Z.colorsClassName,Z.dropdownBlock.appendChild(ie.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},J.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},J.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},J.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},J.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},J.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},J}(Le),We=function(){function ae(J,Z){this.GRIP_SIZE=10,this.color=J,this.fillColor=Z,this.visual=A.createGroup(),this.visual.appendChild(A.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(A.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return ae.prototype.ownsTarget=function(J){return J===this.visual||J===this.visual.childNodes[0]||J===this.visual.childNodes[1]},ae.prototype.setCenter=function(J,Z){this.visual.childNodes.forEach(function(ie){return A.setAttributes(ie,[["cx",J.toString()],["cy",Z.toString()]])})},ae}(),He=function(){function ae(J,Z,ie,oe){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=J,this.canvasHeight=Z,this.margin=ie,this.container=oe,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(ae.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(J){this._aspectRatio=J,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(J){this._isGridVisible=J,this.gridContainer&&A.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(J){this._zoomFactor=J,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),ae.prototype.open=function(){var J=this;this.cropShadeElement=A.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=A.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var Z=0;Z<this.numberOfGridLines;Z++)this.horizontalGridLines.push(A.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(A.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(ie){return J.gridContainer.appendChild(ie)}),this.verticalGridLines.forEach(function(ie){return J.gridContainer.appendChild(ie)}),this.cropRectElement=A.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new We(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new We(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new We(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new We(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},ae.prototype.setCropRectangle=function(J){this.cropRect=J;var Z=Object.assign({},this.cropRect);this.zoomFactor!==1&&(Z.width=this.cropRect.width*this.zoomFactor,Z.height=this.cropRect.height*this.zoomFactor,Z.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-Z.width/2,Z.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-Z.height/2),A.setAttributes(this.cropRectElement,[["x",Z.x.toString()],["y",Z.y.toString()],["width",Z.width.toString()],["height",Z.height.toString()]]);var ie=Z.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(Q,te){var se=Z.y+ie*(te+1);A.setAttributes(Q,[["x1",""+Z.x],["y1",""+se],["x2",""+(Z.x+Z.width)],["y2",""+se]])});var oe=Z.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(Q,te){var se=Z.x+oe*(te+1);A.setAttributes(Q,[["x1",""+se],["y1",""+Z.y],["x2",""+se],["y2",""+(Z.y+Z.height)]])}),A.setAttributes(this.cropShadeElement,[["d",A.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,Z.x,Z.y,Z.width,Z.height)]]),this.topLeftGrip.setCenter(Z.x,Z.y),this.topRightGrip.setCenter(Z.x+Z.width,Z.y),this.bottomLeftGrip.setCenter(Z.x,Z.y+Z.height),this.bottomRightGrip.setCenter(Z.x+Z.width,Z.y+Z.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},ae.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)},ae.prototype.clientToLocalCoordinates=function(J,Z){var ie=this.container.getBoundingClientRect();return{x:J-ie.left+this.margin,y:Z-ie.top+this.margin}},ae.prototype.onPointerDown=function(J){this.container.setPointerCapture(J.pointerId),this.previousPoint=this.clientToLocalCoordinates(J.clientX,J.clientY),this.cropRectElement===J.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(J.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(J.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(J.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(J.target)&&(this.activeGrip=this.bottomRightGrip)},ae.prototype.onPointerMove=function(J){if(this.isMoving)this.move(this.clientToLocalCoordinates(J.clientX,J.clientY));else if(this.activeGrip){var Z=this.clientToLocalCoordinates(J.clientX,J.clientY);this.resize(Z)}J.preventDefault()},ae.prototype.onPointerUp=function(J){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(J.pointerId)},ae.prototype.move=function(J){var Z=J.x-this.previousPoint.x,ie=J.y-this.previousPoint.y;this.zoomFactor!==1&&(Z=-Z/this.zoomFactor,ie=-ie/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+Z),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+ie),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=J},ae.prototype.resize=function(J){var Z=Object.assign({},this.cropRect),ie=J.x-this.previousPoint.x,oe=J.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:Z.x+ie<this.margin&&(ie=this.margin-Z.x),Z.x+=ie,Z.width=this.cropRect.x+this.cropRect.width-Z.x;break;case this.bottomRightGrip:case this.topRightGrip:Z.width+ie>this.canvasWidth*this.zoomFactor&&(ie=this.canvasWidth*this.zoomFactor-Z.width),Z.width+=ie}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(Z.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(ie),Z.height=this.aspectRatio.getVerticalLength(Z.width)):(Z.y+=oe,Z.height=this.cropRect.y+this.cropRect.height-Z.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?Z.height=this.aspectRatio.getVerticalLength(Z.width):Z.height+=oe}Z.width<10&&(Z.x=this.cropRect.x,Z.width=10),Z.height<10&&(Z.y=this.cropRect.y,Z.height=10),this.previousPoint=J,Z.x>=this.margin&&Z.y>=this.margin&&Z.x-this.margin+Z.width<=this.canvasWidth&&Z.y-this.margin+Z.height<=this.canvasHeight&&(this.cropRect=Z,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},ae.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var J=this.cropRect.x+this.cropRect.width/2,Z=this.cropRect.y+this.cropRect.height/2,ie=this.aspectRatio.getHorizontalLength(this.cropRect.height),oe=this.aspectRatio.getVerticalLength(this.cropRect.width);ie/this.canvasWidth<oe/this.canvasHeight?this.cropRect.width=ie:this.cropRect.height=oe,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=J-this.cropRect.width/2,this.cropRect.y=Z-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)}},ae.prototype.getRescaledRect=function(J,Z,ie,oe,Q,te){var se=ie/J,he=oe/Z;return{x:(Q.x-te)*se+te,y:(Q.y-te)*he+te,width:Q.width*se,height:Q.height*he}},ae.prototype.scaleCanvas=function(J,Z){var ie=this.getRescaledRect(this.canvasWidth,this.canvasHeight,J,Z,this.cropRect,this.margin);this.canvasWidth=J,this.canvasHeight=Z,this.onCropChange&&this.onCropChange(ie),this.setCropRectangle(ie)},ae}(),Ve=function(){function ae(J){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=J,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(ae.prototype,"angle",{get:function(){return this._angle},set:function(J){this._angle=J,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),ae.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},ae.prototype.onPointerDown=function(J){this.controlContainer.setPointerCapture(J.pointerId),this.isDragging=!0,this.previousPoint={x:J.clientX,y:J.clientY}},ae.prototype.onPointerMove=function(J){this.isDragging&&(this.onAngleChange&&this.onAngleChange((J.clientX-this.previousPoint.x)/5),this.previousPoint.x=J.clientX)},ae.prototype.onPointerUp=function(J){this.isDragging&&this.onAngleChange&&this.onAngleChange((J.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(J.pointerId)},ae.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var J=this.angleLabelText.getBBox();A.setAttributes(this.angleLabelElement,[["x",((this.width-J.width)/2).toString()],["y",(this.height/2).toString()]])}},ae.prototype.positionScaleShape=function(){if(this.scaleShape){var J=this.scaleShape.transform.baseVal.getItem(0);J.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(J,0)}},ae.prototype.getVisual=function(){var J=document.createElementNS("http://www.w3.org/2000/svg","svg");J.setAttribute("xmlns","http://www.w3.org/2000/svg"),J.setAttribute("width",this.width+"px"),J.setAttribute("height",this.height+"px"),J.setAttribute("viewBox","0 0 "+this.width+" "+this.height),J.style.flexShrink="0",document.body.appendChild(J);for(var Z="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,ie=1;ie<=this.width/5+10;ie++){var oe=ie%5==0?this.height/3:this.height/6;Z+="h4v"+-oe+"h1v"+oe}Z+="v1H0Z",this.scaleShape=A.createPath(Z);var Q=A.createTransform();this.scaleShape.transform.baseVal.appendItem(Q),J.appendChild(this.scaleShape),this.angleLabelElement=A.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=A.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var te=A.createTSpan("");return te.innerHTML="°",this.angleLabelElement.appendChild(te),J.appendChild(this.angleLabelElement),document.body.removeChild(J),J},ae}(),Xe=function(){function ae(){this.naturalSize=!1,this.imageType="image/png"}return ae.prototype.rasterize=function(J,Z,ie,oe,Q,te,se){var he=this;return new Promise(function(me){var ye=document.createElement("canvas");ye.width=J.width.baseVal.value-2*oe,ye.height=J.height.baseVal.value-2*oe;var _e=1,Fe=1;he.naturalSize===!0?(_e=Z.naturalWidth/(J.width.baseVal.value-2*oe)/te,Fe=Z.naturalHeight/(J.height.baseVal.value-2*oe)/se,ye.width=Z.naturalWidth/te,ye.height=Z.naturalHeight/se):he.width!==void 0&&he.height!==void 0&&(_e=he.width/ie.width,Fe=he.height/ie.height,ye.width*=_e,ye.height*=Fe);var qe=ye.getContext("2d");qe.translate(ye.width/2,ye.height/2),qe.rotate(Q*Math.PI/180),qe.scale(te,se),qe.translate(-ye.width/2,-ye.height/2),qe.drawImage(Z,0,0,ye.width,ye.height);var et=document.createElement("canvas");et.width=ie.width*_e,et.height=ie.height*Fe,et.getContext("2d").putImageData(qe.getImageData((ie.x-oe)*_e,(ie.y-oe)*Fe,ie.width*_e,ie.height*Fe),0,0),me(et.toDataURL(he.imageType,he.imageQuality))})},ae}(),nt=function(){function ae(J){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=ae.instanceCounter++,this.styles=new _(this.instanceNo),this.target=J,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(ae.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(J){this._zoomToCropEnabled=J,J?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(J){this._isGridVisible=J,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"gridLines",{get:function(){return this._gridLines},set:function(J){this._gridLines=J,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(J){this._rotationAngle=J,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"aspectRatio",{get:function(){var J;return(J=this._aspectRatio)!==null&&J!==void 0?J:this.aspectRatios[0]},set:function(J){this._aspectRatio=J},enumerable:!1,configurable:!0}),ae.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},ae.prototype.show=function(){this.showUI(),this.open()},ae.prototype.close=function(J){J===void 0&&(J=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),J||this.closeEventListeners.forEach(function(Z){return Z()}),this._isOpen=!1)},ae.prototype.addRenderEventListener=function(J){this.renderEventListeners.push(J)},ae.prototype.removeRenderEventListener=function(J){this.renderEventListeners.indexOf(J)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(J),1)},ae.prototype.addCloseEventListener=function(J){this.closeEventListeners.push(J)},ae.prototype.removeCloseEventListener=function(J){this.closeEventListeners.indexOf(J)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(J),1)},ae.prototype.setupResizeObserver=function(){var J=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){J.resize(J.target.clientWidth,J.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))},ae.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var J=1*this.target.clientWidth/this.target.clientHeight,Z=this.contentDiv.clientWidth/J>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*J:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,ie=Z+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/J;this.resize(Z,ie)}},ae.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},ae.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",A.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},ae.prototype.resize=function(J,Z){this.imageWidth=Math.round(J),this.imageHeight=Math.round(Z),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},ae.prototype.setEditingTarget=function(){var J=document.createElement("canvas");J.width=this.target.naturalWidth,J.height=this.target.naturalHeight,J.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var Z=J.toDataURL();A.setAttributes(this.editingTarget,[["href",Z]]),this.setEditingTargetSize()},ae.prototype.setTopLeft=function(){var J=this.target.getBoundingClientRect(),Z=this.editorCanvas.getBoundingClientRect();this.left=J.left-Z.left-this.CANVAS_MARGIN,this.top=J.top-Z.top-this.CANVAS_MARGIN},ae.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=A.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=A.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=A.createGroup(),this.editingTargetRotationScaleContainer=A.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var J=A.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(J);var Z=A.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(Z),this.editingTargetContainer=A.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},ae.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},ae.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=A.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new He(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},ae.prototype.zoomToCrop=function(){if(this.cropRect){var J=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,Z=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=J+"px "+Z+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-J+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-Z+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},ae.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},ae.prototype.cropRectChanged=function(J){this.cropRect=J,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},ae.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},ae.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"},ae.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},ae.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var J=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,Z=this.target.offsetTop>J+this.CANVAS_MARGIN?this.target.offsetTop-(J+this.CANVAS_MARGIN):0;this.coverDiv.style.top=Z+"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},ae.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},ae.prototype.addTopToolbar=function(){var J=this;this.topToolbar=new B,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 Z=new Ee;Z.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(Z);var ie=[];this.aspectRatios.forEach(function(Fe){var qe=new Le(Oe.getIcon(Fe.horizontal,Fe.vertical),Fe.horizontal===0&&Fe.vertical===0?"FREE":Fe.horizontal+":"+Fe.vertical);qe.onClick=function(){return J.ratioButtonClicked(Fe)},ie.push(qe)}),this.aspectRatioButton=new Pe(Oe.getIcon(0,0),"Aspect ratio",ie),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,Z.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var oe=new Le('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");oe.isActive=this.isGridVisible,oe.onClick=function(){J.isGridVisible=!J.isGridVisible,oe.isActive=J.isGridVisible},Z.addButton(oe);var Q=new Le('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(Q.isActive=this.zoomToCropEnabled,Q.onClick=function(){J.zoomToCropEnabled=!J.zoomToCropEnabled,Q.isActive=J.zoomToCropEnabled},Z.addButton(Q),!W.isLicensed){var te=new Ie;this.topToolbar.addElementBlock(te);var se=document.createElement("div");se.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var he=document.createElement("a");he.style.color="currentColor",he.href="https://markerjs.com/products/cropro",he.target="_blank",he.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M16.326 14.895c0 1.126-.558 1.688-1.673 1.688H9.931c-1.116 0-1.674-.562-1.674-1.688V3.733c0-1.126.558-1.688 1.674-1.688h4.722c1.115 0 1.673.562 1.673 1.688v2.899h-1.957V3.793h-4.124v11.042h4.124v-3.242h1.957v3.302z" fill="currentColor"/><path d="M15.94 7.364a.783.783 0 00-1.065-.304l-11.01 6.126a.783.783 0 00-.303 1.065l4.498 8.085a.783.783 0 001.065.304l11.01-6.126a.783.783 0 00.303-1.065L15.94 7.364zM5.311 14.173l3.737 6.718 9.641-5.364-3.737-6.718-9.641 5.364z" fill="#eef762"/></svg>',se.appendChild(he),te.addElement(se)}var me=new Ee;me.minWidth=3*this.toolbarHeight+"px",me.contentAlign="end",this.topToolbar.addButtonBlock(me);var ye=new Le('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ye.onClick=this.startRenderAndClose,me.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var _e=new Le('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");_e.onClick=this.close,me.addButton(_e),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(_e.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},ae.prototype.addBottomToolbar=function(){var J=this;this.bottomToolbar=new B,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 Z=new Ee;Z.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(Z);var ie=new Le('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");ie.onClick=this.rotateLeftButtonClicked,Z.addButton(ie);var oe=new Le('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");oe.onClick=this.rotateRightButtonClicked,Z.addButton(oe);var Q=new Ie;Q.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(Q),this.straightener=new Ve("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(me){J.rotateBy(me),J.straightener.angle=J.rotationAngle},Q.addElement(this.straightener.getUI());var te=new Ee;te.minWidth=2*this.toolbarHeight+"px",te.contentAlign="end",this.bottomToolbar.addButtonBlock(te);var se=new Le('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");se.onClick=this.flipHorizontallyButtonClicked,te.addButton(se);var he=new Le('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");he.onClick=this.flipVerticallyButtonClicked,te.addButton(he)},ae.prototype.ratioButtonClicked=function(J){this.aspectRatio=J,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},ae.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Oe.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},ae.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new ke(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},ae.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},ae.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},ae.prototype.restoreState=function(J){if(J){var Z=this.cropLayer.getRescaledRect(J.width,J.height,this.imageWidth,this.imageHeight,J.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(Z),this.cropRectChanged(Z),this.flippedHorizontally=J.flippedHorizontally,this.flippedVertically=J.flippedVertically,this.applyFlip(),this.rotationAngle=J.rotationAngle,this.applyRotation()}},ae.prototype.clientToLocalCoordinates=function(J,Z){var ie=this.cropImage.getBoundingClientRect();return{x:J-ie.left,y:Z-ie.top}},ae.prototype.onWindowResize=function(){this.positionUI()},ae.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var J=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=J+"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()},ae.prototype.rotateLeftButtonClicked=function(){var J=this.rotationAngle-90;this.rotationAngle%90!=0&&(J+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(J)},ae.prototype.rotateRightButtonClicked=function(){var J=this.rotationAngle+90;this.rotationAngle%90!=0&&(J-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(J)},ae.prototype.rotateTo=function(J){J=(J=J>180?J-360:J)<=-180?J+360:J,this.rotationAngle=J,this.applyRotation()},ae.prototype.rotateBy=function(J){this.rotateTo((this.rotationAngle+J)%360)},ae.prototype.applyRotation=function(){var J=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var Z=this.editingTargetRotationContainer.transform.baseVal.getItem(0);Z.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(Z,0);var ie=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/ie.width,this.imageHeight/ie.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=J},ae.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},ae.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},ae.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},ae.prototype.startRenderAndClose=function(){return we(this,void 0,void 0,function(){var J,Z;return ve(this,function(ie){switch(ie.label){case 0:return[4,this.render()];case 1:return J=ie.sent(),Z=this.getState(),this.renderEventListeners.forEach(function(oe){return oe(J,Z)}),this.close(!0),[2]}})})},ae.prototype.render=function(){return we(this,void 0,void 0,function(){var J;return ve(this,function(Z){switch(Z.label){case 0:return(J=new Xe).naturalSize=this.renderAtNaturalSize,J.imageType=this.renderImageType,J.imageQuality=this.renderImageQuality,J.width=this.renderWidth,J.height=this.renderHeight,this.unzoomFromCrop(),A.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,J.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 Z.sent(),[4,J.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,Z.sent()]}})})},ae.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new q("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 q("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new q("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var J=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new q("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*J)+`px;
|
|
height: `+(this.toolbarHeight-2*J)+`px;
|
|
padding: `+J+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new q("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new q("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new q("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 q("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new q("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 q("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*J)+`px;
|
|
padding: `+J+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new q("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},ae.instanceCounter=0,ae}(),Ke=le("8hTe"),Ye=le.n(Ke),Ae=/<pre[^>]*>/g;function rt(ae){var J=document.createElement("div");return J.innerHTML=ae,J.childNodes.length===0?"":J.childNodes[0].nodeValue}var Qe=Ze.a=function(ae){var J=ae.value,Z=J===void 0?"":J,ie=ae.edit,oe=ie===void 0?!1:ie,Q=ae.className,te=ae.showTextOnly,se=ae.showLines,he=ae.replaces,me=ae.zoomImg,ye=ae.hasMask,_e=ae.style,Fe=_e===void 0?{}:_e,qe=ae.stylesPrev,et=qe===void 0?{}:qe,xt=String(Z),ot=Object(O.useRef)(),it=Object(O.useRef)(),Lt=Object(O.useState)(""),ct=Object(j.a)(Lt,2),pt=ct[0],gt=ct[1],st=Object(O.useState)("office"),Xt=Object(j.a)(st,2),Nt=Xt[0],Ut=Xt[1],rr=function(){var wt=new nt(it.current);wt.displayMode="popup",wt.addRenderEventListener(function(){var qt=Object(D.a)(P.a.mark(function bt(yt){var _t;return P.a.wrap(function(Wt){for(;;)switch(Wt.prev=Wt.next){case 0:return ot.current.style.display="none",Wt.next=3,Object(Me.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:yt}});case 3:_t=Wt.sent,_t!=null&&_t.id&&he(it.current.getAttribute("src").replace(fe.a.API_SERVER,""),"/api/attachments/".concat(_t==null?void 0:_t.id,"?type=").concat(_t.content_type));case 5:case"end":return Wt.stop()}},bt)}));return function(bt){return qt.apply(this,arguments)}}()),wt.show()},ur=function(){var wt=new Te.a(it.current);wt.settings.displayMode="popup",wt.addEventListener("render",function(){var qt=Object(D.a)(P.a.mark(function bt(yt){var _t;return P.a.wrap(function(Wt){for(;;)switch(Wt.prev=Wt.next){case 0:if(ot.current.style.display="none",!it.current){Wt.next=6;break}return Wt.next=4,Object(Me.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:yt.dataUrl}});case 4:_t=Wt.sent,_t!=null&&_t.id&&he(it.current.getAttribute("src").replace(fe.a.API_SERVER,""),"/api/attachments/".concat(_t==null?void 0:_t.id,"?type=").concat(_t.content_type));case 6:case"end":return Wt.stop()}},bt)}));return function(bt){return qt.apply(this,arguments)}}()),wt.show(),window.markerArea=wt},zt=Object(O.useMemo)(function(){ot.current&&(ot.current.style.zIndex=-1);try{var $e=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,wt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,qt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;xt=xt.replace($e,"("+fe.a.API_SERVER+"/api/attachments/").replace(wt,'"'+fe.a.API_SERVER+"/api/attachments/").replace(qt,'"'+fe.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`)}catch(br){}var bt=re(xt),yt=y();if(xt.match(/\[TOC\]/)&&(bt=bt.replace("<p>[TOC]</p>",C()),S()),bt=bt.replace(/(__special_katext_id_\d+__)/g,function(br,Wt){var Be=yt[Wt],ft=Be.type,ri=Be.expression;return Object(ge.renderToString)(rt(ri)||"",{displayMode:ft==="block",throwOnError:!1,output:"html"})}),bt=bt.replace(/▁/g,"\u2581\u2581\u2581"),m(),te){var _t=document.createElement("div");return _t.innerHTML=bt,_t.innerText}return setTimeout(function(){return ti()},500),bt},[xt]),Qt=Object(O.useRef)();p.WebkitLineClamp=se,se&&(Fe=Object(I.a)(Object(I.a)({},Fe),p));function Br($e){var wt=$e.target;if(wt.tagName.toUpperCase()==="IMG"){if(me){var qt=wt.getAttribute("src");gt(qt),Ut("image")}}else if(wt.tagName.toUpperCase()==="A"){var bt=wt.getAttribute("href");if(bt.indexOf("office")>-1)$e.preventDefault(),gt(bt),Ut("office");else if(bt.indexOf("application/pdf")>-1)$e.preventDefault(),gt(bt),Ut("pdf");else if(bt.indexOf("text/html")>-1)$e.preventDefault(),gt(bt),Ut("html");else if(bt.startsWith("#")){$e.preventDefault();var yt=document.getElementById(bt.replace("#",""));yt&&yt.scrollIntoView(!0)}}}var ti=function(){var wt,qt=(wt=Qt.current)===null||wt===void 0?void 0:wt.querySelectorAll("video");qt==null||qt.forEach(function(bt){if(bt.oncontextmenu=function(){return!1},bt.src.indexOf(".m3u8")>-1&&!bt.canPlayType("application/vnd.apple.mpegurl")){if(ne.a.isSupported()){var yt=new ne.a;yt.loadSource(bt.src),yt.attachMedia(bt)}}})};Object(O.useEffect)(function(){if(Qt.current&&zt&&(zt.match(Ae)&&window.PR.prettyPrint()),Qt.current)return Qt.current.addEventListener("click",Br),function(){Qt.current.removeEventListener("click",Br),m(),S()}},[zt,Qt.current,Br]);var Mt=function(wt){if(!oe)return;wt.target.nodeName==="IMG"?(ot.current.style.zIndex=1,ot.current.style.display="flex",ot.current.style.width=wt.target.clientWidth+"px",ot.current.style.height=wt.target.clientHeight+"px",ot.current.style.top=wt.target.offsetTop+"px",ot.current.style.left=wt.target.offsetLeft+"px",it.current.src=wt.target.getAttribute("src")):ot.current.style.display="none"};return g.a.createElement("div",{style:{position:"relative"}},g.a.createElement("div",{ref:Qt,style:Object(I.a)({},Fe),className:"".concat(Q||""," markdown-body ").concat(Ye.a.mdBody),onMouseOver:Mt,dangerouslySetInnerHTML:{__html:zt}}),g.a.createElement("div",{ref:ot,className:Ye.a.button},g.a.createElement(Y.a,null,g.a.createElement(V.a,{onClick:function(){return rr()}},"\u88C1\u526A"),g.a.createElement(V.a,{onClick:function(){return ur()}},"\u7F16\u8F91"))),g.a.createElement("img",{ref:it,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),g.a.createElement(be.a,{close:!0,data:pt,type:pt!=null&&pt.length?Nt:"",style:Object(I.a)({},et),onClose:function(){return gt("")}}))}},"9VGf":function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return k});var ue=le("q1tI"),Y=le.n(ue);function k(V,I){var D=Object(ue.useRef)();Object(ue.useEffect)(function(){D.current=V}),Object(ue.useEffect)(function(){function j(){D.current()}if(I!==null){var F=setInterval(j,I);return function(){return clearInterval(F)}}},[I])}},"9ZNV":function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return O});var ue=le("0Owb"),Y=le("+L6B"),k=le("2/Rp"),V=le("q1tI"),I=le.n(V),D=le("UUDw"),j=le.n(D),F=le("TSYQ"),P=le.n(F),O=function(T){var R=T.cancelText,L=R===void 0?"\u53D6\u6D88":R,w=T.okText,E=w===void 0?"\u786E\u5B9A":w,u=T.loading,o=u===void 0?!1:u,s=T.hasOkBtn,l=s===void 0?!0:s,S=T.okButtonProps,p=S===void 0?{}:S,f=T.onCancel,C=f===void 0?function(){}:f,v=T.onOk,d=v===void 0?function(){}:v,c=T.className,h=c===void 0?"":c;return I.a.createElement("div",{className:P()(j.a.buttonFixed,h)},I.a.createElement("div",{className:j.a.buttonWrap},I.a.createElement(k.a,{size:"large",className:"".concat(j.a.button," mr20"),onClick:C},L),l&&I.a.createElement(k.a,Object(ue.a)({size:"large",type:"primary",className:"".concat(j.a.button," mr20"),loading:o,onClick:d},p),E)))}},Bd2K:function(ht,Ze,le){(function(ue){ue(le("VrN/"),le("osHv"))})(function(ue){ue.defineOption("autoCloseTags",!1,function(P,O,g){if(g!=ue.Init&&g&&P.removeKeyMap("autoCloseTags"),!O)return;var T={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(T["'/'"]=function(R){return D(R)}),(typeof O!="object"||O.whenOpening!==!1)&&(T["'>'"]=function(R){return V(R)}),P.addKeyMap(T)});var Y=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],k=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function V(P){if(P.getOption("disableInput"))return ue.Pass;for(var O=P.listSelections(),g=[],T=P.getOption("autoCloseTags"),R=0;R<O.length;R++){if(!O[R].empty())return ue.Pass;var L=O[R].head,w=P.getTokenAt(L),E=ue.innerMode(P.getMode(),w.state),u=E.state,o=E.mode.xmlCurrentTag&&E.mode.xmlCurrentTag(u),s=o&&o.name;if(!s)return ue.Pass;var l=E.mode.configuration=="html",S=typeof T=="object"&&T.dontCloseTags||l&&Y,p=typeof T=="object"&&T.indentTags||l&&k;w.end>L.ch&&(s=s.slice(0,s.length-w.end+L.ch));var f=s.toLowerCase();if(!s||w.type=="string"&&(w.end!=L.ch||!/[\"\']/.test(w.string.charAt(w.string.length-1))||w.string.length==1)||w.type=="tag"&&o.close||w.string.indexOf("/")==L.ch-w.start-1||S&&j(S,f)>-1||F(P,E.mode.xmlCurrentContext&&E.mode.xmlCurrentContext(u)||[],s,L,!0))return ue.Pass;var C=typeof T=="object"&&T.emptyTags;if(C&&j(C,s)>-1){g[R]={text:"/>",newPos:ue.Pos(L.line,L.ch+2)};continue}var v=p&&j(p,f)>-1;g[R]={indent:v,text:">"+(v?`
|
|
|
|
`:"")+"</"+s+">",newPos:v?ue.Pos(L.line+1,0):ue.Pos(L.line,L.ch+1)}}for(var d=typeof T=="object"&&T.dontIndentOnAutoClose,R=O.length-1;R>=0;R--){var c=g[R];P.replaceRange(c.text,O[R].head,O[R].anchor,"+insert");var h=P.listSelections().slice(0);h[R]={head:c.newPos,anchor:c.newPos},P.setSelections(h),!d&&c.indent&&(P.indentLine(c.newPos.line,null,!0),P.indentLine(c.newPos.line+1,null,!0))}}function I(P,O){for(var g=P.listSelections(),T=[],R=O?"/":"</",L=P.getOption("autoCloseTags"),w=typeof L=="object"&&L.dontIndentOnSlash,E=0;E<g.length;E++){if(!g[E].empty())return ue.Pass;var u=g[E].head,o=P.getTokenAt(u),s=ue.innerMode(P.getMode(),o.state),l=s.state;if(O&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=u.ch-1))return ue.Pass;var S,p=s.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(p&&s.mode.name=="javascript")S=R+"script";else if(p&&s.mode.name=="css")S=R+"style";else{var f=s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(l);if(!f||f.length&&F(P,f,f[f.length-1],u))return ue.Pass;S=R+f[f.length-1]}P.getLine(u.line).charAt(o.end)!=">"&&(S+=">"),T[E]=S}if(P.replaceSelections(T),g=P.listSelections(),!w)for(var E=0;E<g.length;E++)(E==g.length-1||g[E].head.line<g[E+1].head.line)&&P.indentLine(g[E].head.line)}function D(P){return P.getOption("disableInput")?ue.Pass:I(P,!0)}ue.commands.closeTag=function(P){return I(P)};function j(P,O){if(P.indexOf)return P.indexOf(O);for(var g=0,T=P.length;g<T;++g)if(P[g]==O)return g;return-1}function F(P,O,g,T,R){if(!ue.scanForClosingTag)return!1;var L=Math.min(P.lastLine()+1,T.line+500),w=ue.scanForClosingTag(P,T,null,L);if(!w||w.tag!=g)return!1;for(var E=R?1:0,u=O.length-1;u>=0&&O[u]==g;u--)++E;T=w.to;for(var u=1;u<E;u++){var o=ue.scanForClosingTag(P,T,null,L);if(!o||o.tag!=g)return!1;T=o.to}return!0}})},BjJ7:function(ht,Ze,le){"use strict";le.d(Ze,"d",function(){return Y}),le.d(Ze,"c",function(){return k}),le.d(Ze,"e",function(){return V}),le.d(Ze,"b",function(){return I}),le.d(Ze,"a",function(){return j});var ue=le("m3rI");function Y(F){var P=!0;if(F.length>0){for(var O=0;O<F.length;O++)if(F[O].compile_success==0||!F[O].compile_success){P=!1;break}}else P=!1;return P}function k(F){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],g=0;g<F.length;g++){var T=F[g],R=P?"".concat(P,"/").concat(T.name):"".concat(T.name);O.push({title:T.name,isLeaf:!(T.type==="tree"),key:R})}return O}function V(F,P,O){for(var g=0;g<F.length;g++){var T=F[g];if(T.key===P){T.children=O;break}T.children&&V(T.children,P,O)}return F}function I(F,P,O){var g;return function(){var T=this,R=arguments,L=function(){g=null,O||F.apply(T,R)},w=O&&!g;clearTimeout(g),g=setTimeout(L,P),w&&F.apply(T,R)}}var D=!0,j=ue.a.API_SERVER},"C+DQ":function(ht,Ze,le){},DlQD:function(ht,Ze,le){(function(ue,Y){ht.exports=Y()})(this,function(){"use strict";function ue(Z,ie){for(var oe=0;oe<ie.length;oe++){var Q=ie[oe];Q.enumerable=Q.enumerable||!1,Q.configurable=!0,"value"in Q&&(Q.writable=!0),Object.defineProperty(Z,Q.key,Q)}}function Y(Z,ie,oe){return ie&&ue(Z.prototype,ie),oe&&ue(Z,oe),Z}function k(Z,ie){if(!Z)return;if(typeof Z=="string")return V(Z,ie);var oe=Object.prototype.toString.call(Z).slice(8,-1);if(oe==="Object"&&Z.constructor&&(oe=Z.constructor.name),oe==="Map"||oe==="Set")return Array.from(Z);if(oe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(oe))return V(Z,ie)}function V(Z,ie){(ie==null||ie>Z.length)&&(ie=Z.length);for(var oe=0,Q=new Array(ie);oe<ie;oe++)Q[oe]=Z[oe];return Q}function I(Z,ie){var oe;if(typeof Symbol=="undefined"||Z[Symbol.iterator]==null){if(Array.isArray(Z)||(oe=k(Z))||ie&&Z&&typeof Z.length=="number"){oe&&(Z=oe);var Q=0;return function(){return Q>=Z.length?{done:!0}:{done:!1,value:Z[Q++]}}}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 oe=Z[Symbol.iterator](),oe.next.bind(oe)}function D(Z,ie){return ie={exports:{}},Z(ie,ie.exports),ie.exports}var j=D(function(Z){function ie(){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 oe(Q){Z.exports.defaults=Q}Z.exports={defaults:ie(),getDefaults:ie,changeDefaults:oe}}),F=j.defaults,P=j.getDefaults,O=j.changeDefaults,g=/[&<>"']/,T=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,w={"&":"&","<":"<",">":">",'"':""","'":"'"},E=function(ie){return w[ie]};function u(Z,ie){if(ie){if(g.test(Z))return Z.replace(T,E)}else if(R.test(Z))return Z.replace(L,E);return Z}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function s(Z){return Z.replace(o,function(ie,oe){return oe=oe.toLowerCase(),oe==="colon"?":":oe.charAt(0)==="#"?oe.charAt(1)==="x"?String.fromCharCode(parseInt(oe.substring(2),16)):String.fromCharCode(+oe.substring(1)):""})}var l=/(^|[^\[])\^/g;function S(Z,ie){Z=Z.source||Z,ie=ie||"";var oe={replace:function(te,se){return se=se.source||se,se=se.replace(l,"$1"),Z=Z.replace(te,se),oe},getRegex:function(){return new RegExp(Z,ie)}};return oe}var p=/[^\w:]/g,f=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function C(Z,ie,oe){if(Z){var Q;try{Q=decodeURIComponent(s(oe)).replace(p,"").toLowerCase()}catch(te){return null}if(Q.indexOf("javascript:")===0||Q.indexOf("vbscript:")===0||Q.indexOf("data:")===0)return null}ie&&!f.test(oe)&&(oe=a(ie,oe));try{oe=encodeURI(oe).replace(/%25/g,"%")}catch(te){return null}return oe}var v={},d=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(Z,ie){v[" "+Z]||(d.test(Z)?v[" "+Z]=Z+"/":v[" "+Z]=M(Z,"/",!0)),Z=v[" "+Z];var oe=Z.indexOf(":")===-1;return ie.substring(0,2)==="//"?oe?ie:Z.replace(c,"$1")+ie:ie.charAt(0)==="/"?oe?ie:Z.replace(h,"$1")+ie:Z+ie}var y={exec:function(){}};function m(Z){for(var ie=1,oe,Q;ie<arguments.length;ie++){oe=arguments[ie];for(Q in oe)Object.prototype.hasOwnProperty.call(oe,Q)&&(Z[Q]=oe[Q])}return Z}function x(Z,ie){var oe=Z.replace(/\|/g,function(se,he,me){for(var ye=!1,_e=he;--_e>=0&&me[_e]==="\\";)ye=!ye;return ye?"|":" |"}),Q=oe.split(/ \|/),te=0;if(Q.length>ie)Q.splice(ie);else for(;Q.length<ie;)Q.push("");for(;te<Q.length;te++)Q[te]=Q[te].trim().replace(/\\\|/g,"|");return Q}function M(Z,ie,oe){var Q=Z.length;if(Q===0)return"";for(var te=0;te<Q;){var se=Z.charAt(Q-te-1);if(se===ie&&!oe)te++;else if(se!==ie&&oe)te++;else break}return Z.substr(0,Q-te)}function G(Z,ie){if(Z.indexOf(ie[1])===-1)return-1;for(var oe=Z.length,Q=0,te=0;te<oe;te++)if(Z[te]==="\\")te++;else if(Z[te]===ie[0])Q++;else if(Z[te]===ie[1]&&(Q--,Q<0))return te;return-1}function $(Z){Z&&Z.sanitize&&!Z.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var re={escape:u,unescape:s,edit:S,cleanUrl:C,resolveUrl:a,noopTest:y,merge:m,splitCells:x,rtrim:M,findClosingBracket:G,checkSanitizeDeprecation:$},z=j.defaults,U=re.rtrim,ne=re.splitCells,fe=re.escape,ge=re.findClosingBracket;function be(Z,ie,oe){var Q=ie.href,te=ie.title?fe(ie.title):null,se=Z[1].replace(/\\([\[\]])/g,"$1");return Z[0].charAt(0)!=="!"?{type:"link",raw:oe,href:Q,title:te,text:se}:{type:"image",raw:oe,href:Q,title:te,text:fe(se)}}function Me(Z,ie){var oe=Z.match(/^(\s+)(?:```)/);if(oe===null)return ie;var Q=oe[1];return ie.split(`
|
|
`).map(function(te){var se=te.match(/^\s+/);if(se===null)return te;var he=se[0];return he.length>=Q.length?te.slice(Q.length):te}).join(`
|
|
`)}var Te=function(){function Z(oe){this.options=oe||z}var ie=Z.prototype;return ie.space=function(Q){var te=this.rules.block.newline.exec(Q);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},ie.code=function(Q,te){var se=this.rules.block.code.exec(Q);if(se){var he=te[te.length-1];if(he&&he.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var me=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?me:U(me,`
|
|
`)}}},ie.fences=function(Q){var te=this.rules.block.fences.exec(Q);if(te){var se=te[0],he=Me(se,te[3]||"");return{type:"code",raw:se,lang:te[2]?te[2].trim():te[2],text:he}}},ie.heading=function(Q){var te=this.rules.block.heading.exec(Q);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},ie.nptable=function(Q){var te=this.rules.block.nptable.exec(Q);if(te){var se={type:"table",header:ne(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(se.header.length===se.align.length){var he=se.align.length,me;for(me=0;me<he;me++)/^ *-+: *$/.test(se.align[me])?se.align[me]="right":/^ *:-+: *$/.test(se.align[me])?se.align[me]="center":/^ *:-+ *$/.test(se.align[me])?se.align[me]="left":se.align[me]=null;for(he=se.cells.length,me=0;me<he;me++)se.cells[me]=ne(se.cells[me],se.header.length);return se}}},ie.hr=function(Q){var te=this.rules.block.hr.exec(Q);if(te)return{type:"hr",raw:te[0]}},ie.blockquote=function(Q){var te=this.rules.block.blockquote.exec(Q);if(te){var se=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:se}}},ie.list=function(Q){var te=this.rules.block.list.exec(Q);if(te){for(var se=te[0],he=te[2],me=he.length>1,ye=he[he.length-1]===")",_e={type:"list",raw:se,ordered:me,start:me?+he.slice(0,-1):"",loose:!1,items:[]},Fe=te[0].match(this.rules.block.item),qe=!1,et,xt,ot,it,Lt,ct,pt,gt=Fe.length,st=0;st<gt;st++)et=Fe[st],se=et,xt=et.length,et=et.replace(/^ *([*+-]|\d+[.)]) */,""),~et.indexOf(`
|
|
`)&&(xt-=et.length,et=this.options.pedantic?et.replace(/^ {1,4}/gm,""):et.replace(new RegExp("^ {1,"+xt+"}","gm"),"")),st!==gt-1&&(ot=this.rules.block.bullet.exec(Fe[st+1])[0],(me?ot.length===1||!ye&&ot[ot.length-1]===")":ot.length>1||this.options.smartLists&&ot!==he)&&(it=Fe.slice(st+1).join(`
|
|
`),_e.raw=_e.raw.substring(0,_e.raw.length-it.length),st=gt-1)),Lt=qe||/\n\n(?!\s*$)/.test(et),st!==gt-1&&(qe=et.charAt(et.length-1)===`
|
|
`,Lt||(Lt=qe)),Lt&&(_e.loose=!0),ct=/^\[[ xX]\] /.test(et),pt=void 0,ct&&(pt=et[1]!==" ",et=et.replace(/^\[[ xX]\] +/,"")),_e.items.push({type:"list_item",raw:se,task:ct,checked:pt,loose:Lt,text:et});return _e}},ie.html=function(Q){var te=this.rules.block.html.exec(Q);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):fe(te[0]):te[0]}},ie.def=function(Q){var te=this.rules.block.def.exec(Q);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var se=te[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:te[0],href:te[2],title:te[3]}}},ie.table=function(Q){var te=this.rules.block.table.exec(Q);if(te){var se={type:"table",header:ne(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(se.header.length===se.align.length){se.raw=te[0];var he=se.align.length,me;for(me=0;me<he;me++)/^ *-+: *$/.test(se.align[me])?se.align[me]="right":/^ *:-+: *$/.test(se.align[me])?se.align[me]="center":/^ *:-+ *$/.test(se.align[me])?se.align[me]="left":se.align[me]=null;for(he=se.cells.length,me=0;me<he;me++)se.cells[me]=ne(se.cells[me].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},ie.lheading=function(Q){var te=this.rules.block.lheading.exec(Q);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},ie.paragraph=function(Q){var te=this.rules.block.paragraph.exec(Q);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},ie.text=function(Q,te){var se=this.rules.block.text.exec(Q);if(se){var he=te[te.length-1];return he&&he.type==="text"?{raw:se[0],text:se[0]}:{type:"text",raw:se[0],text:se[0]}}},ie.escape=function(Q){var te=this.rules.inline.escape.exec(Q);if(te)return{type:"escape",raw:te[0],text:fe(te[1])}},ie.tag=function(Q,te,se){var he=this.rules.inline.tag.exec(Q);if(he)return!te&&/^<a /i.test(he[0])?te=!0:te&&/^<\/a>/i.test(he[0])&&(te=!1),!se&&/^<(pre|code|kbd|script)(\s|>)/i.test(he[0])?se=!0:se&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(he[0])&&(se=!1),{type:this.options.sanitize?"text":"html",raw:he[0],inLink:te,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(he[0]):fe(he[0]):he[0]}},ie.link=function(Q){var te=this.rules.inline.link.exec(Q);if(te){var se=ge(te[2],"()");if(se>-1){var he=te[0].indexOf("!")===0?5:4,me=he+te[1].length+se;te[2]=te[2].substring(0,se),te[0]=te[0].substring(0,me).trim(),te[3]=""}var ye=te[2],_e="";if(this.options.pedantic){var Fe=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ye);Fe?(ye=Fe[1],_e=Fe[3]):_e=""}else _e=te[3]?te[3].slice(1,-1):"";ye=ye.trim().replace(/^<([\s\S]*)>$/,"$1");var qe=be(te,{href:ye&&ye.replace(this.rules.inline._escapes,"$1"),title:_e&&_e.replace(this.rules.inline._escapes,"$1")},te[0]);return qe}},ie.reflink=function(Q,te){var se;if((se=this.rules.inline.reflink.exec(Q))||(se=this.rules.inline.nolink.exec(Q))){var he=(se[2]||se[1]).replace(/\s+/g," ");if(he=te[he.toLowerCase()],!he||!he.href){var me=se[0].charAt(0);return{type:"text",raw:me,text:me}}var ye=be(se,he,se[0]);return ye}},ie.strong=function(Q,te,se){se===void 0&&(se="");var he=this.rules.inline.strong.start.exec(Q);if(he&&(!he[1]||he[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){te=te.slice(-1*Q.length);var me=he[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;me.lastIndex=0;for(var ye;(he=me.exec(te))!=null;)if(ye=this.rules.inline.strong.middle.exec(te.slice(0,he.index+3)),ye)return{type:"strong",raw:Q.slice(0,ye[0].length),text:Q.slice(2,ye[0].length-2)}}},ie.em=function(Q,te,se){se===void 0&&(se="");var he=this.rules.inline.em.start.exec(Q);if(he&&(!he[1]||he[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){te=te.slice(-1*Q.length);var me=he[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;me.lastIndex=0;for(var ye;(he=me.exec(te))!=null;)if(ye=this.rules.inline.em.middle.exec(te.slice(0,he.index+2)),ye)return{type:"em",raw:Q.slice(0,ye[0].length),text:Q.slice(1,ye[0].length-1)}}},ie.codespan=function(Q){var te=this.rules.inline.code.exec(Q);if(te){var se=te[2].replace(/\n/g," "),he=/[^ ]/.test(se),me=se.startsWith(" ")&&se.endsWith(" ");return he&&me&&(se=se.substring(1,se.length-1)),se=fe(se,!0),{type:"codespan",raw:te[0],text:se}}},ie.br=function(Q){var te=this.rules.inline.br.exec(Q);if(te)return{type:"br",raw:te[0]}},ie.del=function(Q){var te=this.rules.inline.del.exec(Q);if(te)return{type:"del",raw:te[0],text:te[1]}},ie.autolink=function(Q,te){var se=this.rules.inline.autolink.exec(Q);if(se){var he,me;return se[2]==="@"?(he=fe(this.options.mangle?te(se[1]):se[1]),me="mailto:"+he):(he=fe(se[1]),me=he),{type:"link",raw:se[0],text:he,href:me,tokens:[{type:"text",raw:he,text:he}]}}},ie.url=function(Q,te){var se;if(se=this.rules.inline.url.exec(Q)){var he,me;if(se[2]==="@")he=fe(this.options.mangle?te(se[0]):se[0]),me="mailto:"+he;else{var ye;do ye=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(ye!==se[0]);he=fe(se[0]),se[1]==="www."?me="http://"+he:me=he}return{type:"link",raw:se[0],text:he,href:me,tokens:[{type:"text",raw:he,text:he}]}}},ie.inlineText=function(Q,te,se){var he=this.rules.inline.text.exec(Q);if(he){var me;return te?me=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(he[0]):fe(he[0]):he[0]:me=fe(this.options.smartypants?se(he[0]):he[0]),{type:"text",raw:he[0],text:me}}},Z}(),De=re.noopTest,Ce=re.edit,we=re.merge,ve={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:De,table:De,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=Ce(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ve.item=Ce(ve.item,"gm").replace(/bull/g,ve.bullet).getRegex(),ve.list=Ce(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?-->/,ve.html=Ce(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=Ce(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=Ce(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal=we({},ve),ve.gfm=we({},ve.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ve.gfm.nptable=Ce(ve.gfm.nptable).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.table=Ce(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic=we({},ve.normal,{html:Ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:De,paragraph:Ce(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var W={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:De,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:De,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};W._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",W.punctuation=Ce(W.punctuation).replace(/punctuation/g,W._punctuation).getRegex(),W._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",W._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",W.em.start=Ce(W.em.start).replace(/punctuation/g,W._punctuation).getRegex(),W.em.middle=Ce(W.em.middle).replace(/punctuation/g,W._punctuation).replace(/overlapSkip/g,W._overlapSkip).getRegex(),W.em.endAst=Ce(W.em.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.em.endUnd=Ce(W.em.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.start=Ce(W.strong.start).replace(/punctuation/g,W._punctuation).getRegex(),W.strong.middle=Ce(W.strong.middle).replace(/punctuation/g,W._punctuation).replace(/blockSkip/g,W._blockSkip).getRegex(),W.strong.endAst=Ce(W.strong.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.endUnd=Ce(W.strong.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.blockSkip=Ce(W._blockSkip,"g").getRegex(),W.overlapSkip=Ce(W._overlapSkip,"g").getRegex(),W._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,W._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,W._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])?)+(?![-_])/,W.autolink=Ce(W.autolink).replace("scheme",W._scheme).replace("email",W._email).getRegex(),W._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,W.tag=Ce(W.tag).replace("comment",ve._comment).replace("attribute",W._attribute).getRegex(),W._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,W._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,W._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,W.link=Ce(W.link).replace("label",W._label).replace("href",W._href).replace("title",W._title).getRegex(),W.reflink=Ce(W.reflink).replace("label",W._label).getRegex(),W.reflinkSearch=Ce(W.reflinkSearch,"g").replace("reflink",W.reflink).replace("nolink",W.nolink).getRegex(),W.normal=we({},W),W.pedantic=we({},W.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ce(/^!?\[(label)\]\((.*?)\)/).replace("label",W._label).getRegex(),reflink:Ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W._label).getRegex()}),W.gfm=we({},W.normal,{escape:Ce(W.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),W.gfm.url=Ce(W.gfm.url,"i").replace("email",W.gfm._extended_email).getRegex(),W.breaks=we({},W.gfm,{br:Ce(W.br).replace("{2,}","*").getRegex(),text:Ce(W.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var A={block:ve,inline:W},_=j.defaults,H=A.block,q=A.inline;function B(Z){return Z.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function de(Z){var ie="",oe,Q,te=Z.length;for(oe=0;oe<te;oe++)Q=Z.charCodeAt(oe),Math.random()>.5&&(Q="x"+Q.toString(16)),ie+="&#"+Q+";";return ie}var Ee=function(){function Z(oe){this.tokens=[],this.tokens.links=Object.create(null),this.options=oe||_,this.options.tokenizer=this.options.tokenizer||new Te,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var Q={block:H.normal,inline:q.normal};this.options.pedantic?(Q.block=H.pedantic,Q.inline=q.pedantic):this.options.gfm&&(Q.block=H.gfm,this.options.breaks?Q.inline=q.breaks:Q.inline=q.gfm),this.tokenizer.rules=Q}Z.lex=function(Q,te){var se=new Z(te);return se.lex(Q)};var ie=Z.prototype;return ie.lex=function(Q){return Q=Q.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(Q,this.tokens,!0),this.inline(this.tokens),this.tokens},ie.blockTokens=function(Q,te,se){te===void 0&&(te=[]),se===void 0&&(se=!0),Q=Q.replace(/^ +$/gm,"");for(var he,me,ye,_e;Q;){if(he=this.tokenizer.space(Q)){Q=Q.substring(he.raw.length),he.type&&te.push(he);continue}if(he=this.tokenizer.code(Q,te)){Q=Q.substring(he.raw.length),he.type?te.push(he):(_e=te[te.length-1],_e.raw+=`
|
|
`+he.raw,_e.text+=`
|
|
`+he.text);continue}if(he=this.tokenizer.fences(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.heading(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.nptable(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.hr(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.blockquote(Q)){Q=Q.substring(he.raw.length),he.tokens=this.blockTokens(he.text,[],se),te.push(he);continue}if(he=this.tokenizer.list(Q)){for(Q=Q.substring(he.raw.length),ye=he.items.length,me=0;me<ye;me++)he.items[me].tokens=this.blockTokens(he.items[me].text,[],!1);te.push(he);continue}if(he=this.tokenizer.html(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(se&&(he=this.tokenizer.def(Q))){Q=Q.substring(he.raw.length),this.tokens.links[he.tag]||(this.tokens.links[he.tag]={href:he.href,title:he.title});continue}if(he=this.tokenizer.table(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.lheading(Q)){Q=Q.substring(he.raw.length),te.push(he);continue}if(se&&(he=this.tokenizer.paragraph(Q))){Q=Q.substring(he.raw.length),te.push(he);continue}if(he=this.tokenizer.text(Q,te)){Q=Q.substring(he.raw.length),he.type?te.push(he):(_e=te[te.length-1],_e.raw+=`
|
|
`+he.raw,_e.text+=`
|
|
`+he.text);continue}if(Q){var Fe="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(Fe);break}else throw new Error(Fe)}}return te},ie.inline=function(Q){var te,se,he,me,ye,_e,Fe=Q.length;for(te=0;te<Fe;te++){_e=Q[te];switch(_e.type){case"paragraph":case"text":case"heading":{_e.tokens=[],this.inlineTokens(_e.text,_e.tokens);break}case"table":{for(_e.tokens={header:[],cells:[]},me=_e.header.length,se=0;se<me;se++)_e.tokens.header[se]=[],this.inlineTokens(_e.header[se],_e.tokens.header[se]);for(me=_e.cells.length,se=0;se<me;se++)for(ye=_e.cells[se],_e.tokens.cells[se]=[],he=0;he<ye.length;he++)_e.tokens.cells[se][he]=[],this.inlineTokens(ye[he],_e.tokens.cells[se][he]);break}case"blockquote":{this.inline(_e.tokens);break}case"list":{for(me=_e.items.length,se=0;se<me;se++)this.inline(_e.items[se].tokens);break}}}return Q},ie.inlineTokens=function(Q,te,se,he,me){te===void 0&&(te=[]),se===void 0&&(se=!1),he===void 0&&(he=!1),me===void 0&&(me="");var ye,_e=Q,Fe;if(this.tokens.links){var qe=Object.keys(this.tokens.links);if(qe.length>0)for(;(Fe=this.tokenizer.rules.inline.reflinkSearch.exec(_e))!=null;)qe.includes(Fe[0].slice(Fe[0].lastIndexOf("[")+1,-1))&&(_e=_e.slice(0,Fe.index)+"["+"a".repeat(Fe[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Fe=this.tokenizer.rules.inline.blockSkip.exec(_e))!=null;)_e=_e.slice(0,Fe.index)+"["+"a".repeat(Fe[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;Q;){if(ye=this.tokenizer.escape(Q)){Q=Q.substring(ye.raw.length),te.push(ye);continue}if(ye=this.tokenizer.tag(Q,se,he)){Q=Q.substring(ye.raw.length),se=ye.inLink,he=ye.inRawBlock,te.push(ye);continue}if(ye=this.tokenizer.link(Q)){Q=Q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,he)),te.push(ye);continue}if(ye=this.tokenizer.reflink(Q,this.tokens.links)){Q=Q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,he)),te.push(ye);continue}if(ye=this.tokenizer.strong(Q,_e,me)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),te.push(ye);continue}if(ye=this.tokenizer.em(Q,_e,me)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),te.push(ye);continue}if(ye=this.tokenizer.codespan(Q)){Q=Q.substring(ye.raw.length),te.push(ye);continue}if(ye=this.tokenizer.br(Q)){Q=Q.substring(ye.raw.length),te.push(ye);continue}if(ye=this.tokenizer.del(Q)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),te.push(ye);continue}if(ye=this.tokenizer.autolink(Q,de)){Q=Q.substring(ye.raw.length),te.push(ye);continue}if(!se&&(ye=this.tokenizer.url(Q,de))){Q=Q.substring(ye.raw.length),te.push(ye);continue}if(ye=this.tokenizer.inlineText(Q,he,B)){Q=Q.substring(ye.raw.length),me=ye.raw.slice(-1),te.push(ye);continue}if(Q){var et="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(et);break}else throw new Error(et)}}return te},Y(Z,null,[{key:"rules",get:function(){return{block:H,inline:q}}}]),Z}(),Le=j.defaults,Ie=re.cleanUrl,ke=re.escape,Oe=function(){function Z(oe){this.options=oe||Le}var ie=Z.prototype;return ie.code=function(Q,te,se){var he=(te||"").match(/\S*/)[0];if(this.options.highlight){var me=this.options.highlight(Q,he);me!=null&&me!==Q&&(se=!0,Q=me)}return he?'<pre><code class="'+this.options.langPrefix+ke(he,!0)+'">'+(se?Q:ke(Q,!0))+`</code></pre>
|
|
`:"<pre><code>"+(se?Q:ke(Q,!0))+`</code></pre>
|
|
`},ie.blockquote=function(Q){return`<blockquote>
|
|
`+Q+`</blockquote>
|
|
`},ie.html=function(Q){return Q},ie.heading=function(Q,te,se,he){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+he.slug(se)+'">'+Q+"</h"+te+`>
|
|
`:"<h"+te+">"+Q+"</h"+te+`>
|
|
`},ie.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},ie.list=function(Q,te,se){var he=te?"ol":"ul",me=te&&se!==1?' start="'+se+'"':"";return"<"+he+me+`>
|
|
`+Q+"</"+he+`>
|
|
`},ie.listitem=function(Q){return"<li>"+Q+`</li>
|
|
`},ie.checkbox=function(Q){return"<input "+(Q?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ie.paragraph=function(Q){return"<p>"+Q+`</p>
|
|
`},ie.table=function(Q,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+Q+`</thead>
|
|
`+te+`</table>
|
|
`},ie.tablerow=function(Q){return`<tr>
|
|
`+Q+`</tr>
|
|
`},ie.tablecell=function(Q,te){var se=te.header?"th":"td",he=te.align?"<"+se+' align="'+te.align+'">':"<"+se+">";return he+Q+"</"+se+`>
|
|
`},ie.strong=function(Q){return"<strong>"+Q+"</strong>"},ie.em=function(Q){return"<em>"+Q+"</em>"},ie.codespan=function(Q){return"<code>"+Q+"</code>"},ie.br=function(){return this.options.xhtml?"<br/>":"<br>"},ie.del=function(Q){return"<del>"+Q+"</del>"},ie.link=function(Q,te,se){if(Q=Ie(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var he='<a href="'+ke(Q)+'"';return te&&(he+=' title="'+te+'"'),he+=">"+se+"</a>",he},ie.image=function(Q,te,se){if(Q=Ie(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var he='<img src="'+Q+'" alt="'+se+'"';return te&&(he+=' title="'+te+'"'),he+=this.options.xhtml?"/>":">",he},ie.text=function(Q){return Q},Z}(),Pe=function(){function Z(){}var ie=Z.prototype;return ie.strong=function(Q){return Q},ie.em=function(Q){return Q},ie.codespan=function(Q){return Q},ie.del=function(Q){return Q},ie.html=function(Q){return Q},ie.text=function(Q){return Q},ie.link=function(Q,te,se){return""+se},ie.image=function(Q,te,se){return""+se},ie.br=function(){return""},Z}(),We=function(){function Z(){this.seen={}}var ie=Z.prototype;return ie.slug=function(Q){var te=Q.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var se=te;do this.seen[se]++,te=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},Z}(),He=j.defaults,Ve=re.unescape,Xe=function(){function Z(oe){this.options=oe||He,this.options.renderer=this.options.renderer||new Oe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pe,this.slugger=new We}Z.parse=function(Q,te){var se=new Z(te);return se.parse(Q)};var ie=Z.prototype;return ie.parse=function(Q,te){te===void 0&&(te=!0);var se="",he,me,ye,_e,Fe,qe,et,xt,ot,it,Lt,ct,pt,gt,st,Xt,Nt,Ut,rr=Q.length;for(he=0;he<rr;he++){it=Q[he];switch(it.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline(it.tokens),it.depth,Ve(this.parseInline(it.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code(it.text,it.lang,it.escaped);continue}case"table":{for(xt="",et="",_e=it.header.length,me=0;me<_e;me++)et+=this.renderer.tablecell(this.parseInline(it.tokens.header[me]),{header:!0,align:it.align[me]});for(xt+=this.renderer.tablerow(et),ot="",_e=it.cells.length,me=0;me<_e;me++){for(qe=it.tokens.cells[me],et="",Fe=qe.length,ye=0;ye<Fe;ye++)et+=this.renderer.tablecell(this.parseInline(qe[ye]),{header:!1,align:it.align[ye]});ot+=this.renderer.tablerow(et)}se+=this.renderer.table(xt,ot);continue}case"blockquote":{ot=this.parse(it.tokens),se+=this.renderer.blockquote(ot);continue}case"list":{for(Lt=it.ordered,ct=it.start,pt=it.loose,_e=it.items.length,ot="",me=0;me<_e;me++)st=it.items[me],Xt=st.checked,Nt=st.task,gt="",st.task&&(Ut=this.renderer.checkbox(Xt),pt?st.tokens.length>0&&st.tokens[0].type==="text"?(st.tokens[0].text=Ut+" "+st.tokens[0].text,st.tokens[0].tokens&&st.tokens[0].tokens.length>0&&st.tokens[0].tokens[0].type==="text"&&(st.tokens[0].tokens[0].text=Ut+" "+st.tokens[0].tokens[0].text)):st.tokens.unshift({type:"text",text:Ut}):gt+=Ut),gt+=this.parse(st.tokens,pt),ot+=this.renderer.listitem(gt,Nt,Xt);se+=this.renderer.list(ot,Lt,ct);continue}case"html":{se+=this.renderer.html(it.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline(it.tokens));continue}case"text":{for(ot=it.tokens?this.parseInline(it.tokens):it.text;he+1<rr&&Q[he+1].type==="text";)it=Q[++he],ot+=`
|
|
`+(it.tokens?this.parseInline(it.tokens):it.text);se+=te?this.renderer.paragraph(ot):ot;continue}default:{var ur='Token with "'+it.type+'" type was not found.';if(this.options.silent){console.error(ur);return}else throw new Error(ur)}}}return se},ie.parseInline=function(Q,te){te=te||this.renderer;var se="",he,me,ye=Q.length;for(he=0;he<ye;he++){me=Q[he];switch(me.type){case"escape":{se+=te.text(me.text);break}case"html":{se+=te.html(me.text);break}case"link":{se+=te.link(me.href,me.title,this.parseInline(me.tokens,te));break}case"image":{se+=te.image(me.href,me.title,me.text);break}case"strong":{se+=te.strong(this.parseInline(me.tokens,te));break}case"em":{se+=te.em(this.parseInline(me.tokens,te));break}case"codespan":{se+=te.codespan(me.text);break}case"br":{se+=te.br();break}case"del":{se+=te.del(this.parseInline(me.tokens,te));break}case"text":{se+=te.text(me.text);break}default:{var _e='Token with "'+me.type+'" type was not found.';if(this.options.silent){console.error(_e);return}else throw new Error(_e)}}}return se},Z}(),nt=re.merge,Ke=re.checkSanitizeDeprecation,Ye=re.escape,Ae=j.getDefaults,rt=j.changeDefaults,Qe=j.defaults;function ae(Z,ie,oe){if(typeof Z=="undefined"||Z===null)throw new Error("marked(): input parameter is undefined or null");if(typeof Z!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(Z)+", string expected");if(typeof ie=="function"&&(oe=ie,ie=null),ie=nt({},ae.defaults,ie||{}),Ke(ie),oe){var Q=ie.highlight,te;try{te=Ee.lex(Z,ie)}catch(ye){return oe(ye)}var se=function(_e){var Fe;if(!_e)try{Fe=Xe.parse(te,ie)}catch(qe){_e=qe}return ie.highlight=Q,_e?oe(_e):oe(null,Fe)};if(!Q||Q.length<3)return se();if(delete ie.highlight,!te.length)return se();var he=0;ae.walkTokens(te,function(ye){ye.type==="code"&&(he++,setTimeout(function(){Q(ye.text,ye.lang,function(_e,Fe){if(_e)return se(_e);Fe!=null&&Fe!==ye.text&&(ye.text=Fe,ye.escaped=!0),he--,he===0&&se()})},0))}),he===0&&se();return}try{var me=Ee.lex(Z,ie);return ie.walkTokens&&ae.walkTokens(me,ie.walkTokens),Xe.parse(me,ie)}catch(ye){if(ye.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,ie.silent)return"<p>An error occurred:</p><pre>"+Ye(ye.message+"",!0)+"</pre>";throw ye}}ae.options=ae.setOptions=function(Z){return nt(ae.defaults,Z),rt(ae.defaults),ae},ae.getDefaults=Ae,ae.defaults=Qe,ae.use=function(Z){var ie=nt({},Z);if(Z.renderer&&function(){var Q=ae.defaults.renderer||new Oe,te=function(me){var ye=Q[me];Q[me]=function(){for(var _e=arguments.length,Fe=new Array(_e),qe=0;qe<_e;qe++)Fe[qe]=arguments[qe];var et=Z.renderer[me].apply(Q,Fe);return et===!1&&(et=ye.apply(Q,Fe)),et}};for(var se in Z.renderer)te(se);ie.renderer=Q}(),Z.tokenizer&&function(){var Q=ae.defaults.tokenizer||new Te,te=function(me){var ye=Q[me];Q[me]=function(){for(var _e=arguments.length,Fe=new Array(_e),qe=0;qe<_e;qe++)Fe[qe]=arguments[qe];var et=Z.tokenizer[me].apply(Q,Fe);return et===!1&&(et=ye.apply(Q,Fe)),et}};for(var se in Z.tokenizer)te(se);ie.tokenizer=Q}(),Z.walkTokens){var oe=ae.defaults.walkTokens;ie.walkTokens=function(Q){Z.walkTokens(Q),oe&&oe(Q)}}ae.setOptions(ie)},ae.walkTokens=function(Z,ie){for(var oe=I(Z),Q;!(Q=oe()).done;){var te=Q.value;ie(te);switch(te.type){case"table":{for(var se=I(te.tokens.header),he;!(he=se()).done;){var me=he.value;ae.walkTokens(me,ie)}for(var ye=I(te.tokens.cells),_e;!(_e=ye()).done;)for(var Fe=_e.value,qe=I(Fe),et;!(et=qe()).done;){var xt=et.value;ae.walkTokens(xt,ie)}break}case"list":{ae.walkTokens(te.items,ie);break}default:te.tokens&&ae.walkTokens(te.tokens,ie)}}},ae.Parser=Xe,ae.parser=Xe.parse,ae.Renderer=Oe,ae.TextRenderer=Pe,ae.Lexer=Ee,ae.lexer=Ee.lex,ae.Tokenizer=Te,ae.Slugger=We,ae.parse=ae;var J=ae;return J})},ELLl:function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){var Y={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},k=ue.Pos;ue.defineOption("autoCloseBrackets",!1,function(w,E,u){u&&u!=ue.Init&&(w.removeKeyMap(I),w.state.closeBrackets=null),E&&(D(V(E,"pairs")),w.state.closeBrackets=E,w.addKeyMap(I))});function V(w,E){return E=="pairs"&&typeof w=="string"?w:typeof w=="object"&&w[E]!=null?w[E]:Y[E]}var I={Backspace:P,Enter:O};function D(w){for(var E=0;E<w.length;E++){var u=w.charAt(E),o="'"+u+"'";I[o]||(I[o]=j(u))}}D(Y.pairs+"`");function j(w){return function(E){return T(E,w)}}function F(w){var E=w.state.closeBrackets;if(!E||E.override)return E;var u=w.getModeAt(w.getCursor());return u.closeBrackets||E}function P(w){var E=F(w);if(!E||w.getOption("disableInput"))return ue.Pass;for(var u=V(E,"pairs"),o=w.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return ue.Pass;var l=R(w,o[s].head);if(!l||u.indexOf(l)%2!=0)return ue.Pass}for(var s=o.length-1;s>=0;s--){var S=o[s].head;w.replaceRange("",k(S.line,S.ch-1),k(S.line,S.ch+1),"+delete")}}function O(w){var E=F(w),u=E&&V(E,"explode");if(!u||w.getOption("disableInput"))return ue.Pass;for(var o=w.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return ue.Pass;var l=R(w,o[s].head);if(!l||u.indexOf(l)%2!=0)return ue.Pass}w.operation(function(){var S=w.lineSeparator()||`
|
|
`;w.replaceSelection(S+S,null),w.execCommand("goCharLeft"),o=w.listSelections();for(var p=0;p<o.length;p++){var f=o[p].head.line;w.indentLine(f,null,!0),w.indentLine(f+1,null,!0)}})}function g(w){var E=ue.cmpPos(w.anchor,w.head)>0;return{anchor:new k(w.anchor.line,w.anchor.ch+(E?-1:1)),head:new k(w.head.line,w.head.ch+(E?1:-1))}}function T(w,E){var u=F(w);if(!u||w.getOption("disableInput"))return ue.Pass;var o=V(u,"pairs"),s=o.indexOf(E);if(s==-1)return ue.Pass;for(var l=V(u,"closeBefore"),S=V(u,"triples"),p=o.charAt(s+1)==E,f=w.listSelections(),C=s%2==0,v,d=0;d<f.length;d++){var c=f[d],h=c.head,a,y=w.getRange(h,k(h.line,h.ch+1));if(C&&!c.empty())a="surround";else if((p||!C)&&y==E)p&&L(w,h)?a="both":S.indexOf(E)>=0&&w.getRange(h,k(h.line,h.ch+3))==E+E+E?a="skipThree":a="skip";else if(p&&h.ch>1&&S.indexOf(E)>=0&&w.getRange(k(h.line,h.ch-2),h)==E+E){if(h.ch>2&&/\bstring/.test(w.getTokenTypeAt(k(h.line,h.ch-2))))return ue.Pass;a="addFour"}else if(p){var m=h.ch==0?" ":w.getRange(k(h.line,h.ch-1),h);if(!ue.isWordChar(y)&&m!=E&&!ue.isWordChar(m))a="both";else return ue.Pass}else if(C&&(y.length===0||/\s/.test(y)||l.indexOf(y)>-1))a="both";else return ue.Pass;if(!v)v=a;else if(v!=a)return ue.Pass}var x=s%2?o.charAt(s-1):E,M=s%2?E:o.charAt(s+1);w.operation(function(){if(v=="skip")w.execCommand("goCharRight");else if(v=="skipThree")for(var G=0;G<3;G++)w.execCommand("goCharRight");else if(v=="surround"){for(var $=w.getSelections(),G=0;G<$.length;G++)$[G]=x+$[G]+M;w.replaceSelections($,"around"),$=w.listSelections().slice();for(var G=0;G<$.length;G++)$[G]=g($[G]);w.setSelections($)}else v=="both"?(w.replaceSelection(x+M,null),w.triggerElectric(x+M),w.execCommand("goCharLeft")):v=="addFour"&&(w.replaceSelection(x+x+x+x,"before"),w.execCommand("goCharRight"))})}function R(w,E){var u=w.getRange(k(E.line,E.ch-1),k(E.line,E.ch+1));return u.length==2?u:null}function L(w,E){var u=w.getTokenAt(k(E.line,E.ch+1));return/\bstring/.test(u.type)&&u.start==E.ch&&(E.ch==0||!/\bstring/.test(w.getTokenTypeAt(E)))}})},F8wB:function(ht,Ze,le){ht.exports={loading:"loading___1SIOG"}},Gytx:function(ht,Ze){ht.exports=function(ue,Y,k,V){var I=k?k.call(V,ue,Y):void 0;if(I!==void 0)return!!I;if(ue===Y)return!0;if(typeof ue!="object"||!ue||typeof Y!="object"||!Y)return!1;var D=Object.keys(ue),j=Object.keys(Y);if(D.length!==j.length)return!1;for(var F=Object.prototype.hasOwnProperty.bind(Y),P=0;P<D.length;P++){var O=D[P];if(!F(O))return!1;var g=ue[O],T=Y[O];if(I=k?k.call(V,g,T,O):void 0,I===!1||I===void 0&&g!==T)return!1}return!0}},HV1I:function(ht,Ze,le){ht.exports={flex_box_center:"flex_box_center___1nEOe",flex_space_between:"flex_space_between___21gJ7",flex_box_vertical_center:"flex_box_vertical_center___2iHIq",flex_box_center_end:"flex_box_center_end___19LSZ",flex_box_column:"flex_box_column___2zG50",bg:"bg___u_uqy",formWrap:"formWrap___3rl8w"}},HmJG:function(ht,Ze,le){},LdHM:function(ht,Ze,le){"use strict";le.d(Ze,"b",function(){return l}),le.d(Ze,"a",function(){return p});var ue=le("1OyB"),Y=le("vuIU"),k=le("Ji7U"),V=le("LK+K"),I=le("q1tI"),D=le("rePB"),j=le("Ff2n"),F=le("ODXe"),P=le("4IlW"),O=le("bX4T"),g=le("YrtM"),T=le("TSYQ"),R=le.n(T),L=le("+nKL"),w=le("8OUc"),E=function(ne,fe){var ge=ne.prefixCls,be=ne.id,Me=ne.flattenOptions,Te=ne.childrenAsData,De=ne.values,Ce=ne.searchValue,we=ne.multiple,ve=ne.defaultActiveFirstOption,W=ne.height,A=ne.itemHeight,_=ne.notFoundContent,H=ne.open,q=ne.menuItemSelectedIcon,B=ne.virtual,de=ne.onSelect,Ee=ne.onToggleOpen,Le=ne.onActiveValue,Ie=ne.onScroll,ke=ne.onMouseEnter,Oe="".concat(ge,"-item"),Pe=Object(g.a)(function(){return Me},[H,Me],function(J,Z){return Z[0]&&J[1]!==Z[1]}),We=I.useRef(null),He=function(Z){Z.preventDefault()},Ve=function(Z){We.current&&We.current.scrollTo({index:Z})},Xe=function(Z){for(var ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,oe=Pe.length,Q=0;Q<oe;Q+=1){var te=(Z+Q*ie+oe)%oe,se=Pe[te],he=se.group,me=se.data;if(!he&&!me.disabled)return te}return-1},nt=I.useState(function(){return Xe(0)}),Ke=Object(F.a)(nt,2),Ye=Ke[0],Ae=Ke[1],rt=function(Z){Ae(Z);var ie=Pe[Z];if(!ie){Le(null,-1);return}Le(ie.data.value,Z)};I.useEffect(function(){rt(ve!==!1?Xe(0):-1)},[Pe.length,Ce]),I.useEffect(function(){var J=setTimeout(function(){if(!we&&H&&De.size===1){var Z=Array.from(De)[0],ie=Pe.findIndex(function(oe){var Q=oe.data;return Q.value===Z});rt(ie),Ve(ie)}});return function(){return clearTimeout(J)}},[H]);var Qe=function(Z){Z!==void 0&&de(Z,{selected:!De.has(Z)}),we||Ee(!1)};if(I.useImperativeHandle(fe,function(){return{onKeyDown:function(Z){var ie=Z.which;switch(ie){case P.a.UP:case P.a.DOWN:{var oe=0;if(ie===P.a.UP?oe=-1:ie===P.a.DOWN&&(oe=1),oe!==0){var Q=Xe(Ye+oe,oe);Ve(Q),rt(Q)}break}case P.a.ENTER:{var te=Pe[Ye];te&&!te.data.disabled?Qe(te.data.value):Qe(void 0),H&&Z.preventDefault();break}case P.a.ESC:Ee(!1)}},onKeyUp:function(){},scrollTo:function(Z){Ve(Z)}}}),Pe.length===0)return I.createElement("div",{role:"listbox",id:"".concat(be,"_list"),className:"".concat(Oe,"-empty"),onMouseDown:He},_);function ae(J){var Z=Pe[J];if(!Z)return null;var ie=Z.data||{},oe=ie.value,Q=ie.label,te=ie.children,se=Object(O.a)(ie,!0),he=Te?te:Q;return Z?I.createElement("div",Object.assign({"aria-label":typeof he=="string"?he:null},se,{key:J,role:"option",id:"".concat(be,"_list_").concat(J),"aria-selected":De.has(oe)}),oe):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(be,"_list"),style:{height:0,width:0,overflow:"hidden"}},ae(Ye-1),ae(Ye),ae(Ye+1)),I.createElement(L.a,{itemKey:"key",ref:We,data:Pe,height:W,itemHeight:A,fullHeight:!1,onMouseDown:He,onScroll:Ie,virtual:B,onMouseEnter:ke},function(J,Z){var ie,oe=J.group,Q=J.groupOption,te=J.data,se=te.label,he=te.key;if(oe)return I.createElement("div",{className:R()(Oe,"".concat(Oe,"-group"))},se!==void 0?se:he);var me=te.disabled,ye=te.value,_e=te.title,Fe=te.children,qe=te.style,et=te.className,xt=Object(j.a)(te,["disabled","value","title","children","style","className"]),ot=De.has(ye),it="".concat(Oe,"-option"),Lt=R()(Oe,it,et,(ie={},Object(D.a)(ie,"".concat(it,"-grouped"),Q),Object(D.a)(ie,"".concat(it,"-active"),Ye===Z&&!me),Object(D.a)(ie,"".concat(it,"-disabled"),me),Object(D.a)(ie,"".concat(it,"-selected"),ot),ie)),ct=Te?Fe:se,pt=!q||typeof q=="function"||ot;return I.createElement("div",Object.assign({},xt,{"aria-selected":ot,className:Lt,title:_e,onMouseMove:function(){if(Ye===Z||me)return;rt(Z)},onClick:function(){me||Qe(ye)},style:qe}),I.createElement("div",{className:"".concat(it,"-content")},ct||ye),I.isValidElement(q)||ot,pt&&I.createElement(w.a,{className:"".concat(Oe,"-option-state"),customizeIcon:q,customizeIconProps:{isSelected:ot}},ot?"\u2713":null))}))},u=I.forwardRef(E);u.displayName="OptionList";var o=u,s=function(){return null};s.isSelectOption=!0;var l=s,S=function(){return null};S.isSelectOptGroup=!0;var p=S,f=le("VTBJ"),C=le("Zm9Q");function v(U){var ne=U.key,fe=U.props,ge=fe.children,be=fe.value,Me=Object(j.a)(fe,["children","value"]);return Object(f.a)({key:ne,value:be!==void 0?be:ne,children:ge},Me)}function d(U){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(C.a)(U).map(function(fe,ge){if(!I.isValidElement(fe)||!fe.type)return null;var be=fe.type.isSelectOptGroup,Me=fe.key,Te=fe.props,De=Te.children,Ce=Object(j.a)(Te,["children"]);return ne||!be?v(fe):Object(f.a)(Object(f.a)({key:"__RC_SELECT_GRP__".concat(Me===null?ge:Me,"__"),label:Me},Ce),{},{options:d(De)})}).filter(function(fe){return fe})}var c=le("2Qr1"),h=le("qNPg"),a=le("U8pU"),y=le("Kwbf"),m=le("WKfj");function x(U){var ne=U.mode,fe=U.options,ge=U.children,be=U.backfill,Me=U.allowClear,Te=U.placeholder,De=U.getInputElement,Ce=U.showSearch,we=U.onSearch,ve=U.defaultOpen,W=U.autoFocus,A=U.labelInValue,_=U.value,H=U.inputValue,q=U.optionLabelProp,B=ne==="multiple"||ne==="tags",de=Ce!==void 0?Ce:B||ne==="combobox",Ee=fe||d(ge);if(Object(y.a)(ne!=="tags"||Ee.every(function(Oe){return!Oe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ne==="tags"||ne==="combobox"){var Le=Ee.some(function(Oe){return Oe.options?Oe.options.some(function(Pe){return typeof("value"in Pe?Pe.value:Pe.key)=="number"}):typeof("value"in Oe?Oe.value:Oe.key)=="number"});Object(y.a)(!Le,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(y.a)(ne!=="combobox"||!q,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(y.a)(ne==="combobox"||!be,"`backfill` only works with `combobox` mode."),Object(y.a)(ne==="combobox"||!De,"`getInputElement` only work with `combobox` mode."),Object(y.b)(ne!=="combobox"||!De||!Me||!Te,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),we&&!de&&ne!=="combobox"&&ne!=="tags"&&Object(y.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(y.b)(!ve||W,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),_!=null){var Ie=Object(m.d)(_);Object(y.a)(!A||Ie.every(function(Oe){return Object(a.a)(Oe)==="object"&&("key"in Oe||"value"in Oe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(y.a)(!B||Array.isArray(_),"`value` should be array when `mode` is `multiple` or `tags`")}if(ge){var ke=null;Object(C.a)(ge).some(function(Oe){if(!I.isValidElement(Oe)||!Oe.type)return!1;var Pe=Oe.type;if(Pe.isSelectOption)return!1;if(Pe.isSelectOptGroup){var We=Object(C.a)(Oe.props.children).every(function(He){return!I.isValidElement(He)||!Oe.type||He.type.isSelectOption?!0:(ke=He.type,!1)});return!We}return ke=Pe,!0}),ke&&Object(y.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(ke.displayName||ke.name||ke,"`.")),Object(y.a)(H===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=x,G=Object(h.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:d,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:M,fillOptionsWithMissingValue:c.a}),$=function(U){Object(k.a)(fe,U);var ne=Object(V.a)(fe);function fe(){var ge;return Object(ue.a)(this,fe),ge=ne.apply(this,arguments),ge.selectRef=I.createRef(),ge.focus=function(){ge.selectRef.current.focus()},ge.blur=function(){ge.selectRef.current.blur()},ge}return Object(Y.a)(fe,[{key:"render",value:function(){return I.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),fe}(I.Component);$.Option=l,$.OptGroup=p;var re=$,z=Ze.c=re},Ly88:function(ht,Ze,le){"use strict";le.r(Ze);var ue=le("14J3"),Y=le("BMrR"),k=le("jCWc"),V=le("kPKH"),I=le("OaEy"),D=le("2fM7"),j=le("7Kak"),F=le("9yH6"),P=le("5NDa"),O=le("5rEg"),g=le("2qtc"),T=le("kLXV"),R=le("miYZ"),L=le("tsqr"),w=le("9og8"),E=le("k1fw"),u=le("y8nQ"),o=le("Vl3Y"),s=le("tJVT"),l=le("PpiC"),S=le("WmNS"),p=le.n(S),f=le("q1tI"),C=le.n(f),v=le("9kvl"),d=le("Ot1p"),c=le("HBuW"),h=le("HV1I"),a=le.n(h),y=le("LvDl"),m=le.n(y),x=le("9ZNV"),M=le("nuEh"),G=le("fnXi"),$=le("UqFu"),re=le("2RCv"),z={1:[100,200],2:[300,400,500,600],3:[700,800,900,1e3]},U=function(fe){var ge,be,Me,Te=fe.shixunsDetail,De=fe.dispatch,Ce=fe.match,we=fe.practiceSetting,ve=Object(l.a)(fe,["shixunsDetail","dispatch","match","practiceSetting"]),W=o.a.useForm(),A=Object(s.a)(W,1),_=A[0],H=Object(f.useState)({}),q=Object(s.a)(H,2),B=q[0],de=q[1],Ee=Object(f.useState)([100,200]),Le=Object(s.a)(Ee,2),Ie=Le[0],ke=Le[1],Oe=Te.challengesNew,Pe=Object(f.useState)(),We=Object(s.a)(Pe,2),He=We[0],Ve=We[1],Xe=Object(f.useState)(),nt=Object(s.a)(Xe,2),Ke=nt[0],Ye=nt[1],Ae=Object(f.useState)(!0),rt=Object(s.a)(Ae,2),Qe=rt[0],ae=rt[1],J=Object(f.useState)(1),Z=Object(s.a)(J,2),ie=Z[0],oe=Z[1],Q=Object(f.useRef)({subject:"",difficulty:1,score:100,task_pass:Object($.a)(Oe.task_pass_default)}),te=Object(f.useRef)(null),se=we.selectQuestionParams,he=we.id,me=we.newQuestion;Object(f.useEffect)(function(){Ce.params.challengesId?(Ye(!0),ye()):(ae(!0),Ye(!1),De({type:"shixunsDetail/getChallengesNew",payload:Object(E.a)({},Ce.params)}),ae(!1)),setTimeout(function(){document.getElementById("practice-scroll").scrollTo(0,0)},300)},[Ce.params]),Object(f.useEffect)(function(){return ot(),function(){clearTimeout(te.current)}},[B]);var ye=function(){var ct=Object(w.a)(p.a.mark(function pt(){var gt,st;return p.a.wrap(function(Nt){for(;;)switch(Nt.prev=Nt.next){case 0:return ae(!0),Nt.next=3,Object(c.J)({id:Ce.params.id,challengeId:Ce.params.challengesId,tab:0});case 3:gt=Nt.sent,gt&&(st=Object(E.a)(Object(E.a)({},gt),{},{task_pass:Object($.a)(gt.task_pass)}),Ve(st),_e(st),ae(!1),Q.current={subject:st.subject,difficulty:st.difficulty,score:st.score,task_pass:st.task_pass});case 5:case"end":return Nt.stop()}},pt)}));return function(){return ct.apply(this,arguments)}}(),_e=function(pt){var gt={subject:pt.name,difficulty:pt.difficulty,score:pt.score,challenge_tag:pt.tags,task_pass:pt.task_pass},st=z[pt.difficulty];ke(st),_.setFieldsValue(Object(E.a)({},gt)),de(Object(E.a)({},gt))},Fe=function(pt){var gt=z[pt],st=gt==null?void 0:gt[0];ke(gt),_.setFieldsValue({score:st}),de(Object(E.a)(Object(E.a)({},_.getFieldsValue()),{score:st}))},qe=function(pt,gt){de(Object(E.a)({},_.getFieldsValue())),"difficulty"in pt&&Fe(pt.difficulty)},et=function(){var ct=Object(w.a)(p.a.mark(function pt(){var gt,st,Xt,Nt,Ut,rr=arguments;return p.a.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:if(st=rr.length>0&&rr[0]!==void 0?rr[0]:{},!(!Ke&&((gt=Te.detail)===null||gt===void 0?void 0:gt.shixun_status)===2)){zt.next=4;break}return L.b.info("\u8BE5\u5B9E\u8BAD\u5DF2\u7ECF\u53D1\u5E03\u4E0D\u80FD\u65B0\u5EFA"),zt.abrupt("return");case 4:if(!Ke){zt.next=10;break}return zt.next=7,Object(c.Ob)(Object(E.a)(Object(E.a)({},Ce.params),{},{tab:0,challenge:Object(E.a)({},st),challenge_tag:st.challenge_tag}));case 7:return Xt=zt.sent,Xt&&(De({type:"practiceSetting/setUpdateIndex"}),v.d.replace("/shixuns/".concat(Ce.params.id,"/edit/").concat(Ce.params.challengesId,"/tab=2"))),zt.abrupt("return");case 10:return Nt=Object(E.a)({},B),Nt.identifier=Ce.params.id,Nt.st=0,zt.next=15,Object(c.b)(Object(E.a)({},Nt));case 15:Ut=zt.sent,Ut.status===1&&(v.d.replace("/shixuns/".concat(Ce.params.id,"/edit/").concat(Ut.challenge_id,"/tab=2")),setTimeout(function(){De({type:"practiceSetting/setParams",payload:{newQuestion:null}}),De({type:"practiceSetting/setUpdateIndex"})},200));case 17:case"end":return zt.stop()}},pt)}));return function(){return ct.apply(this,arguments)}}(),xt=function(){Lt()},ot=function(){clearTimeout(te.current),te.current=setTimeout(it,500)},it=function(){"subject"in B&&me&&De({type:"practiceSetting/setParams",payload:{newQuestion:{st:0,name:B==null?void 0:B.subject}}});var pt=["subject","difficulty","score","task_pass"],gt=pt.some(function(st){var Xt=Object(y.isNumber)(B[st])?String(B[st]):B[st],Nt=Object(y.isNumber)(Q.current[st])?String(Q.current[st]):Q.current[st];return!Object(y.isEqual)(Xt,Nt)});De(gt?{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}:{type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},Lt=function(){var pt,gt=function(){v.d.push("/shixuns/".concat(he,"/challenges")),De({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};we!=null&&(pt=we.sideBar)!==null&&pt!==void 0&&pt.confirmLeave?T.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){gt()}}):gt()};return C.a.createElement(C.a.Fragment,null,C.a.createElement("section",{key:1,className:a.a.bg,id:"practice-scroll"},C.a.createElement(o.a,{key:ie,form:_,className:a.a.formWrap,scrollToFirstError:!0,layout:"vertical",onValuesChange:qe,onFinish:et},C.a.createElement(G.a,{activeIndex:0,isEdit:Ke}),C.a.createElement(o.a.Item,{initialValue:"",name:"subject",label:"\u4EFB\u52A1\u540D\u79F0:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EFB\u52A1\u540D\u79F0"}]},C.a.createElement(O.a,{bordered:!1,maxLength:60,suffix:"".concat(((ge=B.subject)===null||ge===void 0?void 0:ge.length)||0,"/60"),placeholder:"\u4F8B\u5982\uFF1A\u4ECEPython\u7A0B\u5E8F\u8BBE\u8BA1-\u5165\u95E8\u7CBE\u901A"})),C.a.createElement(o.a.Item,{name:"task_pass",label:"\u4EFB\u52A1\u8981\u6C42:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F5C\u4E1A\u7684\u7B80\u4ECB"},{max:35e3,message:"\u8FC7\u5173\u4EFB\u52A1\u7B80\u4ECB\u6700\u5927\u9650\u523635000\u4E2A\u5B57\u7B26"}]},C.a.createElement(d.a,{key:Ce.params.challengesId||"3",watch:!0,defaultValue:Ke?He==null?void 0:He.task_pass:Oe.task_pass_default})),C.a.createElement(o.a.Item,{initialValue:1,name:"difficulty",label:"\u96BE\u5EA6\u7CFB\u6570:",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u96BE\u5EA6\u7CFB\u6570"}]},C.a.createElement(F.a.Group,{disabled:((be=Te.detail)===null||be===void 0?void 0:be.shixun_status)===2},C.a.createElement(F.a,{value:1},"\u7B80\u5355"),C.a.createElement(F.a,{style:{marginLeft:70},value:2},"\u4E2D\u7B49"),C.a.createElement(F.a,{style:{marginLeft:70},value:3},"\u56F0\u96BE"))),C.a.createElement(o.a.Item,{name:"challenge_tag",label:C.a.createElement("div",null,"\u6280\u80FD\u6807\u7B7E"," ",C.a.createElement("span",{className:"pl20 font12 c-light-black"},"\u5B66\u5458\u7B54\u9898\u6B63\u786E\u5C06\u83B7\u5F97\u6280\u80FD\uFF0C\u5426\u5219\u4E0D\u80FD\u83B7\u5F97\u6280\u80FD\uFF08\u56DE\u8F66\u6DFB\u52A0\u6807\u7B7E\uFF09")),rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6280\u80FD\u6807\u7B7E"}]},C.a.createElement(re.a,{placeholder:"\u6DFB\u52A0\u6807\u7B7E",style:{width:"260px"},InputRight:C.a.createElement("span",{className:"ml5"},"(\u56DE\u8F66\u6DFB\u52A0\u6807\u7B7E)")})),C.a.createElement(Y.a,{className:"customItemSelect"},C.a.createElement(V.a,null,C.a.createElement(o.a.Item,{name:"score",initialValue:100,label:"\u5956\u52B1\u91D1\u5E01:",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u5956\u52B1\u7ECF\u9A8C\u503C"}]},C.a.createElement(D.a,{disabled:((Me=Te.detail)===null||Me===void 0?void 0:Me.shixun_status)===2,bordered:!1,style:{width:260}},Ie==null?void 0:Ie.map(function(ct,pt){return C.a.createElement(D.a.Option,{key:pt,value:ct},ct)})))),C.a.createElement(V.a,{flex:1},C.a.createElement("div",{style:{marginTop:88},className:"font12 c-light-black ml10"}," ","\u5B66\u5458\u6B63\u786E\u7B54\u9898\u65F6\u83B7\u5F97\u91D1\u5E01\uFF0C\u5E76\u4E14\u83B7\u5F97\u7B49\u91CF\u7684\u7ECF\u9A8C\u503C\u3002\u5982\uFF1A+100\u91D1\u5E01\u3001+100\u7ECF\u9A8C\u503C"))))),C.a.createElement(x.a,{key:2,onOk:function(){return _.submit()},className:"customFixedButton",onCancel:xt}),C.a.createElement(M.a,{loading:Qe}))};Ze.default=Object(v.a)(function(ne){var fe=ne.shixunsDetail,ge=ne.newCourse,be=ne.globalSetting,Me=ne.practiceSetting;return{shixunsDetail:fe,newCourse:ge,globalSetting:be,practiceSetting:Me}})(U)},M8RZ:function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return P});var ue=le("fWQN"),Y=le("mtLc"),k=le("yKVA"),V=le("879j"),I=le("q1tI"),D=le.n(I),j=le("i8i4"),F=le.n(j),P=function(O){Object(k.a)(T,O);var g=Object(V.a)(T);function T(R){var L;Object(ue.a)(this,T),L=g.call(this,R);var w=window.document;return L.node=w.createElement("div"),w.body.appendChild(L.node),L}return Object(Y.a)(T,[{key:"render",value:function(){var L=this.props.children;return Object(j.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),T}(D.a.Component)},OLES:function(ht,Ze,le){"use strict";var ue=le("U8pU"),Y=le("VTBJ"),k=le("Ff2n"),V=le("q1tI"),I=le("uciX"),D=le("7ixt"),j=function(R){var L=R.overlay,w=R.prefixCls,E=R.id,u=R.overlayInnerStyle;return V.createElement("div",{className:"".concat(w,"-inner"),id:E,role:"tooltip",style:u},typeof L=="function"?L():L)},F=j,P=function(R,L){var w=R.overlayClassName,E=R.trigger,u=E===void 0?["hover"]:E,o=R.mouseEnterDelay,s=o===void 0?0:o,l=R.mouseLeaveDelay,S=l===void 0?.1:l,p=R.overlayStyle,f=R.prefixCls,C=f===void 0?"rc-tooltip":f,v=R.children,d=R.onVisibleChange,c=R.afterVisibleChange,h=R.transitionName,a=R.animation,y=R.placement,m=y===void 0?"right":y,x=R.align,M=x===void 0?{}:x,G=R.destroyTooltipOnHide,$=G===void 0?!1:G,re=R.defaultVisible,z=R.getTooltipContainer,U=R.overlayInnerStyle,ne=Object(k.a)(R,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),fe=Object(V.useRef)(null);Object(V.useImperativeHandle)(L,function(){return fe.current});var ge=Object(Y.a)({},ne);"visible"in R&&(ge.popupVisible=R.visible);var be=function(){var we=R.arrowContent,ve=we===void 0?null:we,W=R.overlay,A=R.id;return[V.createElement("div",{className:"".concat(C,"-arrow"),key:"arrow"},ve),V.createElement(F,{key:"content",prefixCls:C,id:A,overlay:W,overlayInnerStyle:U})]},Me=!1,Te=!1;if(typeof $=="boolean")Me=$;else if($&&Object(ue.a)($)==="object"){var De=$.keepParent;Me=De===!0,Te=De===!1}return V.createElement(I.a,Object.assign({popupClassName:w,prefixCls:C,popup:be,action:u,builtinPlacements:D.a,popupPlacement:m,ref:fe,popupAlign:M,getPopupContainer:z,onPopupVisibleChange:d,afterPopupVisibleChange:c,popupTransitionName:h,popupAnimation:a,defaultPopupVisible:re,destroyPopupOnHide:Me,autoDestroy:Te,mouseLeaveDelay:S,popupStyle:p,mouseEnterDelay:s},ge),v)},O=Object(V.forwardRef)(P),g=Ze.a=O},Ot1p:function(ht,Ze,le){"use strict";var ue=le("2qtc"),Y=le("kLXV"),k=le("rAM+"),V=le("miYZ"),I=le("tsqr"),D=le("9og8"),j=le("tJVT"),F=le("jrin"),P=le("WmNS"),O=le.n(P),g=le("q1tI"),T=le.n(g),R=le("VrN/"),L=le.n(R),w=le("bdgK"),E=le("p77/"),u=le("Bd2K"),o=le("ELLl"),s=le("19Vz"),l=le("lZu9"),S=le("+NIl"),p=le("kSUc"),f=le("9Bee"),C=function(me){var ye=me.value,_e=ye===void 0?"":ye,Fe=me.className,qe=me.showTextOnly,et=me.showLines,xt=me.style,ot=xt===void 0?{}:xt,it=Object(g.useMemo)(function(){return""},[_e]);return T.a.createElement(T.a.Fragment,null,T.a.createElement("div",{dangerouslySetInnerHTML:{__html:it}}))},v=le("0Owb"),d=le("dejd"),c=le("C+DQ"),h=le("1vsH"),a=le("m3rI"),y=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function m(me){var ye=me.onActionCallback,_e=me.title,Fe=me.icon,qe=me.actionName,et=me.className,xt=et===void 0?"":et,ot=me.children;function it(){ye(qe)}return T.a.createElement("a",{title:_e,className:xt,onClick:it},T.a.createElement("i",{className:"md-iconfont ".concat(Fe)}),ot)}var x=function(me){var ye=me.watch,_e=me.showNullButton,Fe=me.onActionCallback,qe=me.fullScreen,et=me.insertTemp,xt=me.hidetoolBar,ot=me.uuid,it=me.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(h.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(h.F)("_educoder_session"),"&key=").concat(ot,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Lt=[].concat(y,[{title:"".concat(ye?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(ye?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return T.a.createElement("ul",{className:"markdown-toolbar-container"},!xt&&Lt.map(function(ct,pt){return T.a.createElement("li",{key:pt},ct.actionName?T.a.createElement(m,Object(v.a)({},ct,{onActionCallback:Fe})):T.a.createElement("span",{className:"v-line"}))}),_e?T.a.createElement("li",null,T.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Fe},T.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,et&&T.a.createElement("li",null,T.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(et),onActionCallback:Fe},T.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),T.a.createElement("li",{className:"btn-full-screen"},T.a.createElement(m,{icon:"".concat(qe?"icon-shrink":"icon-enlarge"),title:qe?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Fe})))},M=le("M8RZ"),G=le("+L6B"),$=le("2/Rp"),re=le("y8nQ"),z=le("Vl3Y"),U=le("5NDa"),ne=le("5rEg"),fe={labelCol:{span:4},wrapperCol:{span:20}},ge=function(me){var ye=me.callback,_e=me.onCancel;function Fe(qe){ye(qe)}return T.a.createElement(z.a,Object(v.a)({},fe,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Fe}),T.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},T.a.createElement(ne.a,null)),T.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},T.a.createElement(ne.a,null)),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement($.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement($.a,{type:"ghost",onClick:_e},"\u53D6\u6D88")))},be=le("7ahc"),Me=le("HmJG"),Te=le("BjJ7"),De=z.a.useForm,Ce={width:280,marginRight:10},we={labelCol:{span:5},wrapperCol:{span:19}},ve=function(me){var ye=me.callback,_e=me.onCancel,Fe=De(),qe=Object(j.a)(Fe,1),et=qe[0];function xt(Lt){ye(Lt)}function ot(Lt,ct){if(Lt.status===-1){I.b.error(Lt.message);return}et.setFieldsValue({src:"/api/attachments/".concat(Lt.id),type:ct.type})}function it(Lt){var ct=Lt.target.files[0];A(ct,ot)}return T.a.createElement(z.a,Object(v.a)({form:et},we,{className:"upload-image-panel",onFinish:xt}),T.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},T.a.createElement("div",{className:"flex-container"},T.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},T.a.createElement(ne.a,{style:Ce})),T.a.createElement(W,{onFileChange:it}))),T.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},T.a.createElement(ne.a,{style:{width:264}})),T.a.createElement(z.a.Item,{style:{textAlign:"right"}},T.a.createElement($.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement($.a,{type:"ghost",onClick:_e},"\u53D6\u6D88")))};function W(me){var ye=me.onFileChange;return T.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",T.a.createElement("input",{type:"file",onChange:ye}))}function A(me,ye){if(!me)throw new String("\u6CA1\u6709\u6587\u4EF6");var _e=new FormData;_e.append("editormd-image-file",me),_e.append("file_param_name","editormd-image-file"),_e.append("byxhr","true");var Fe=new window.XMLHttpRequest;Fe.withCredentials=!0,Fe.addEventListener("load",function(qe){ye(JSON.parse(qe.target.responseText),me)},!1),Fe.addEventListener("error",function(qe){console.error(qe)},!1),Fe.open("POST","".concat(Te.a,"/api/attachments.json")),Fe.send(_e)}var _=le("giR+"),H=le("fyUT"),q=le("7Kak"),B=le("9yH6"),de=B.a.Group,Ee={margin:"0 8px"},Le=function(me){var ye=me.callback,_e=me.onCancel;function Fe(qe){ye(qe)}return T.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Fe},T.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},T.a.createElement("span",{style:Ee},"\u5355\u5143\u683C\u6570\uFF1A"),T.a.createElement("span",{style:Ee},"\u884C\u6570"),T.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},T.a.createElement(H.a,null)),T.a.createElement("span",{style:Ee},"\u5217\u6570"),T.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},T.a.createElement(H.a,null))),T.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},T.a.createElement("span",{style:Ee},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),T.a.createElement(z.a.Item,{name:"align"},T.a.createElement(de,null,T.a.createElement(B.a,{value:"default"},T.a.createElement("i",{className:"fa fa-align-justify"})),T.a.createElement(B.a,{value:"left"},T.a.createElement("i",{className:"fa fa-align-left"})),T.a.createElement(B.a,{value:"center"},T.a.createElement("i",{className:"fa fa-align-center"})),T.a.createElement(B.a,{value:"right"},T.a.createElement("i",{className:"fa fa-align-right"}))))),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement($.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement($.a,{type:"ghost",onClick:_e},"\u53D6\u6D88")))},Ie=le("ErOA"),ke=le("7Cbv"),Oe="link",Pe="upload-image",We="code-block",He="add-table",Ve="------------",Xe={default:Ve,left:":".concat(Ve),center:":".concat(Ve,":"),right:"".concat(Ve,":")},nt=le("9VGf"),Ke,Ye;function Ae(){}var rt=0,Qe=1e4,ae="\u2581",J=`
|
|
**\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 Z(me){return/^\d+$/.test(me)?"".concat(me,"px"):me}var ie=navigator.platform.toUpperCase().indexOf("MAC")>=0,oe=ie?"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"],te=(Ke={},Object(F.a)(Ke,oe+"-B","bold"),Object(F.a)(Ke,oe+"-I","italic"),Ke),se=(Ye={},Object(F.a)(Ye,Oe,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Ye,We,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Ye,Pe,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Ye,He,"\u6DFB\u52A0\u8868\u683C"),Ye),he=Ze.a=function(me){var ye=me.defaultValue,_e=ye===void 0?"":ye,Fe=me.onChange,qe=me.width,et=qe===void 0?"100%":qe,xt=me.height,ot=xt===void 0?400:xt,it=me.miniToolbar,Lt=it===void 0?!1:it,ct=me.isFocus,pt=ct===void 0?!1:ct,gt=me.watch,st=me.insertTemp,Xt=me.mode,Nt=Xt===void 0?"markdown":Xt,Ut=me.id,rr=Ut===void 0?"markdown-editor-id":Ut,ur=me.showResizeBar,zt=ur===void 0?!1:ur,Qt=me.noStorage,Br=Qt===void 0?!1:Qt,ti=me.showNullButton,Mt=ti===void 0?!1:ti,$e=me.hidetoolBar,wt=$e===void 0?!1:$e,qt=me.fullScreen,bt=qt===void 0?!1:qt,yt=me.onBlur,_t=me.onCMBeforeChange,br=me.onFullScreen,Wt=me.className,Be=Wt===void 0?"":Wt,ft=me.disablePaste,ri=ft===void 0?!1:ft,bi=me.placeholder,xi=bi===void 0?"":bi,ii=me.values,Ei=ii===void 0?"":ii,vt=Object(g.useState)(null),Ln=Object(j.a)(vt,2),Ue=Ln[0],Si=Ln[1],Tr=Object(g.useState)(_e),Ki=Object(j.a)(Tr,2),ni=Ki[0],wr=Ki[1],Vi=Object(g.useState)(gt),Xi=Object(j.a)(Vi,2),Ar=Xi[0],Yi=Xi[1],_n=Object(g.useState)(bt),$i=Object(j.a)(_n,2),Lr=$i[0],kn=$i[1],aa=Object(g.useState)(""),Zi=Object(j.a)(aa,2),or=Zi[0],Kr=Zi[1],oa=Object(g.useState)(0),ai=Object(j.a)(oa,2),_r=ai[0],Ji=ai[1],sa=Object(g.useState)(ot),Dn=Object(j.a)(sa,2),Rn=Dn[0],Ti=Dn[1],On=Object(g.useState)(!1),Pn=Object(j.a)(On,2),la=Pn[0],Ci=Pn[1],oi=Object(g.useRef)(Object(ke.a)()),si=Object(g.useRef)(!1),wi=Object(g.useRef)(),Fr=Object(g.useRef)(),Ur=Object(g.useRef)(),jr=Object(g.useRef)(),Ai=Object(g.useRef)(),Mn=function(){var at=Object(D.a)(O.a.mark(function mt(){var ut,St;return O.a.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:return Ot.next=2,Object(Ie.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:oi.current}});case 2:St=Ot.sent,St!=null&&(ut=St.attachments)!==null&&ut!==void 0&&ut.length&&(console.log("cm:",Ue,Fr),St.attachments.map(function(Ct){Ct.content_type.indexOf("image")>-1?Ue.replaceSelection(".concat(Ct.content_type,")")):Ct.content_type.indexOf("video")>-1?Ue.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Ct.content_type.indexOf("pdf")>-1?Ue.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ct.id,"?type=").concat(Ct.content_type,'&disposition=inline" target="_blank">').concat(Ct.name,"</a>")):Ue.replaceSelection("[".concat(Ct.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ct.id,"?type=").concat(Ct.content_type,")"))}));case 4:case"end":return Ot.stop()}},mt)}));return function(){return at.apply(this,arguments)}}();Object(g.useEffect)(function(){wr(Ei),Ue==null||Ue.setValue(Ei)},[Ei]),Object(g.useEffect)(function(){br==null||br(Lr)},[Lr]),Object(g.useEffect)(function(){if(Fr.current){var at=L.a.fromTextArea(Fr.current,{mode:Nt,lineNumbers:!Lt,lineWrapping:!0,value:_e,autoCloseTags:!0,autoCloseBrackets:!0});pt&&at.focus();function mt(ut,St){if(ri){St.preventDefault();return}var At=St.clipboardData;if(At){var Ot=At.types.toString(),Ct=At.items;if(Ot==="Files"||At.types.indexOf("Files")>-1){if(St.preventDefault(),Nt=="stex")return;try{var Kt,hr=Ct[1];((Kt=Ct[0])===null||Kt===void 0?void 0:Kt.kind)==="file"&&(hr=Ct[0]);var Tt=hr.getAsFile(),Wr=Tt.name.split(".").pop();A(Tt,function(kt){if(kt.id){var dr,ir,Cr;(Tt==null||((dr=Tt.type)===null||dr===void 0)?void 0:dr.indexOf("image"))>-1?at.replaceSelection(".concat(kt.content_type,")")):(Tt==null||((ir=Tt.type)===null||ir===void 0)?void 0:ir.indexOf("video"))>-1?at.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,'"></video>')):(Tt==null||((Cr=Tt.type)===null||Cr===void 0)?void 0:Cr.indexOf("pdf"))>-1?at.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(Tt.type,'&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):Q.includes(Wr)?at.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,'?type=office&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):at.replaceSelection("[".concat(Tt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(kt.content_type,")"))}else(kt==null?void 0:kt.status)===401&&(document.location.href="/user/login")})}catch(kt){I.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return at.on("paste",mt),at.on("dragleave",function(ut,St){Ur.current.classList.remove("mouse-hover-md")}),at.on("dragover",function(ut,St){Ur.current.classList.add("mouse-hover-md")}),at.on("drop",function(ut,St){Ur.current.classList.add("mouse-hover-md");var At;if(At=St.dataTransfer.files,At.length>0){St.preventDefault(),St.stopPropagation();for(var Ot=function(hr){var Tt=At[hr],Wr=Tt.name.split(".").pop();A(Tt,function(kt){if(kt.id){var dr,ir,Cr;(Tt==null||((dr=Tt.type)===null||dr===void 0)?void 0:dr.indexOf("image"))>-1?at.replaceSelection(".concat(kt.content_type,")")):(Tt==null||((ir=Tt.type)===null||ir===void 0)?void 0:ir.indexOf("video"))>-1?at.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,'"></video>')):(Tt==null||((Cr=Tt.type)===null||Cr===void 0)?void 0:Cr.indexOf("pdf"))>-1?at.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(Tt.type,'&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):Q.includes(Wr)?at.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,'?type=office&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):at.replaceSelection("[".concat(Tt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(kt.content_type,")"))}else(kt==null?void 0:kt.status)===401&&(document.location.href="/user/login")})},Ct=0;Ct<At.length;Ct++)Ot(Ct)}}),Si(at),function(){at.off("paste",mt)}}},[]);var xr=Object(g.useCallback)(function(){if(Ur.current)try{}catch(at){console.log(at,"---- to set md editor body height")}},[Rn,Ur,Lr]);Object(g.useEffect)(function(){function at(){var ut=new w.default(function(St){var At=Object(k.a)(St),Ot;try{for(At.s();!(Ot=At.n()).done;){var Ct=Ot.value;(Ct.target.offsetHeight>0||Ct.target.offsetWidth>0)&&(xr(),Ue.setSize("100%","100%"),Ue.refresh())}}catch(Kt){At.e(Kt)}finally{At.f()}});return ut.observe(Fr.current.parentElement),ut}if(Ue){var mt=at();return function(){mt.unobserve(Fr.current.parentElement)}}},[Ue,xr]),Object(g.useEffect)(function(){if(Ue){for(var at=[],mt=function(){var Ct=St[ut];At=Object(j.a)(Ct,2);var Kt=At[0],hr=At[1],Tt=Object(F.a)({},Kt,function(){In(hr)});at.push(Tt),Ue.addKeyMap(Tt)},ut=0,St=Object.entries(te);ut<St.length;ut++){var At;mt()}return wi.current=setInterval(function(){si.current&&Mn()},4e3),function(){clearInterval(wi.current);var Ot=Object(k.a)(at),Ct;try{for(Ot.s();!(Ct=Ot.n()).done;){var Kt=Ct.value;Ue.removeKeyMap(Kt)}}catch(hr){Ot.e(hr)}finally{Ot.f()}}}},[Ue]),Object(g.useEffect)(function(){bt!==Lr&&kn(bt)},[bt]),Object(nt.a)(function(){if(!Br&&_r>0){var at=new Date().getTime(),mt=window.sessionStorage.getItem(rr);at>=_r+Qe&&(!mt||mt!==ni)&&(window.sessionStorage.setItem(rr,ni),Ci(!0))}},Qe),Object(g.useEffect)(function(){Yi(gt)},[Ue,gt]),Object(g.useEffect)(function(){Ue&&(pt&&Ue.focus())},[Ue,pt]),Object(g.useEffect)(function(){if(Ar&&Ue){var at=Ue.getScrollerElement();function mt(ut){var St=ut.target;if(Ai.current){var At=St.scrollTop/St.scrollHeight;Ai.current.scrollTop=Ai.current.scrollHeight*At}}return at.addEventListener("scroll",mt),function(){at.removeEventListener("scroll",mt)}}},[Ue,Ar]),Object(g.useEffect)(function(){if(Ue&&_t){function at(mt,ut){_t(mt,ut)}return Ue.on("beforeChange",at),function(){Ue.off("beforeChange",at)}}},[Ue,_t]),Object(g.useEffect)(function(){if(Ue&&yt){function at(){yt(Ue.getValue())}return Ue.on("blur",at),function(){Ue.off("blur",at)}}},[Ue,yt]),Object(g.useEffect)(function(){if(Ue){function at(mt){var ut=mt.getValue();wr(ut),Ji(new Date().getTime()),mt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Fe&&Fe(ut)}return Ue.on("change",at),function(){Ue.off("change",at)}}},[Ue,Fe]),Object(g.useEffect)(function(){Ue&&(_e==null?(Ue.setValue(""),wr("")):_e!==Ue.getValue()&&(Ue.setValue(_e),wr(_e),Ue.setCursor(Ue.lineCount(),0)))},[Ue,_e]);var In=Object(g.useCallback)(function(at){var mt=Ue.getCursor(),ut=Ue.getSelection(),St=ut.split(`
|
|
`);switch(at){case"bold":return Ue.replaceSelection("**"+ut+"**"),ut===""&&Ue.setCursor(mt.line,mt.ch+2),Ue.focus();case"italic":return Ue.replaceSelection("*"+ut+"*"),ut===""&&Ue.setCursor(mt.line,mt.ch+1),Ue.focus();case"code":return Ue.replaceSelection("`"+ut+"`"),ut===""&&Ue.setCursor(mt.line,mt.ch+1),Ue.focus();case"inline-latex":return Ue.replaceSelection("`$$"+ut+"$$`"),ut===""&&Ue.setCursor(mt.line,mt.ch+3),Ue.focus();case"latex":return Ue.replaceSelection("```latex\n"+ut+"\n```"),Ue.setCursor(mt.line+1,ut.length+1),Ue.focus();case"line-break":return Ue.replaceSelection(`<br/>
|
|
`),Ue.focus();case"list-ul":return ut===""?Ue.replaceSelection("- "+ut):Ue.replaceSelection(St.map(function(At){return At===""?"":"- ".concat(At)}).join(`
|
|
`)),Ue.focus();case"list-ol":return ut===""?Ue.replaceSelection("1. "+ut):Ue.replaceSelection(St.map(function(At,Ot){return At===""?"":"".concat(Ot+1,". ").concat(At)}).join(`
|
|
`)),Ue.focus();case"add-null-ch":return ut===""&&Ue.setCursor(mt.line,mt.ch+1),Ue.replaceSelection(ae),Ue.focus();case"inster-template-1":return ut===""&&Ue.setCursor(mt.line,mt.ch),Ue.replaceSelection(J),Ue.focus();case"eraser":return Ue.setValue(""),Ue.focus();case"trigger-watch":return Yi(!Ar),Ue.focus();case"trigger-full-screen":return kn(!Lr),Ue.focus();case Oe:Kr(Oe);return;case We:Kr(We);return;case Pe:Kr(Pe);return;case He:Kr(He);return;default:throw new Error}},[Ue,Ar,Lr]),Li=Object(g.useCallback)(function(at){Kr("");switch(or){case Oe:var mt=at.title,ut=at.link;return Ue.replaceSelection("[".concat(mt,"](").concat(ut,")")),Ue.focus();case We:var St=at.language,At=at.content;return Ue.replaceSelection(["```"+St,At,"```"].join(`
|
|
`)),Ue.focus();case Pe:var Ot=at.src,Ct=at.alt;return Ct?Ue.replaceSelection(".concat(Ot,' "').concat(Ct,'" )')):Ue.replaceSelection("")),Ue.focus();case He:for(var Kt=at.row,hr=at.col,Tt=at.align,Wr=`
|
|
`,kt=0;kt<Kt;kt++){for(var dr=[],ir=[],Cr=0;Cr<hr;Cr++)kt===1&&ir.push(Xe[Tt]),dr.push(" ");kt===1&&(Wr+="| ".concat(ir.join(" | "),` |
|
|
`)),Wr+="| ".concat(dr.join(hr===1?"":" | "),` |
|
|
`)}return Ue.replaceSelection(Wr+`
|
|
`),Ue.focus();default:throw new Error}},[Ue,or]),Qi=Object(g.useMemo)(function(){switch(or){case Oe:return T.a.createElement(ge,{callback:Li,onCancel:Vr});case We:return T.a.createElement(be.b,{callback:Li,onCancel:Vr});case Pe:return T.a.createElement(ve,{callback:Li,onCancel:Vr});case He:return T.a.createElement(Le,{callback:Li,onCancel:Vr});default:return null}},[or]);function Vr(){Kr("")}Object(g.useEffect)(function(){if(jr.current){var at=jr.current,mt=!1,ut=0;function St(Ct){mt=!0,ut=Ct.pageY}function At(){mt=!1}function Ot(Ct){if(mt){var Kt=Ct.pageY-ut;Kt<0&&(Kt=0),Kt>300&&(Kt=300);var hr=ot+Kt+"px";Ti(hr)}}return at.addEventListener("mousedown",St),document.addEventListener("mousemove",Ot),document.addEventListener("mouseup",At),function(){at.removeEventListener("mousedown",St),document.removeEventListener("mousemove",Ot),document.removeEventListener("mouseup",At)}}},[Ue,jr]),Object(g.useEffect)(function(){Ti(ot)},[ot]);var Pr=Z(et),qi=Z(Rn),kr={width:Pr,height:qi},en=Object(g.useMemo)(function(){if(_r){var at=new Date(_r),mt=at.getHours(),ut=at.getMinutes(),St=at.getSeconds();return mt=mt<10?"0"+mt:mt,ut=ut<10?"0"+ut:ut,St=St<10?"0"+St:St,"".concat(mt,":").concat(ut,":").concat(St)}return 0},[_r]);function Nn(){window.sessionStorage.removeItem(rr),Ci(!1),Ji(0)}function li(){Ci(!1),Ji(0),Ue.setValue(window.sessionStorage.getItem(rr))}function ua(at,mt){var ut=Ue.getValue();ut=ut.replace(at,mt),wr(ut),Ue==null||Ue.setValue(ut)}return T.a.createElement(g.Fragment,null,T.a.createElement("div",{className:"markdown-editor-wrapper",ref:Ur},T.a.createElement("div",{className:"markdown-editor-container ".concat(Be," ").concat(Ar?"on-preview":""," ").concat(Lt?"mini":""," ").concat(Lr?"full-screen":""),style:kr},T.a.createElement(x,{insertTemp:st,watch:Ar,fullScreen:Lr,showNullButton:Mt,onActionCallback:In,hidetoolBar:wt,uuid:oi.current,setOpenPhones:function(){si.current=!0}}),T.a.createElement("div",{className:"markdown-editor-body"},T.a.createElement("div",{className:"codemirror-container"},T.a.createElement("textarea",{ref:Fr,placeholder:xi})),Ar?T.a.createElement("div",{ref:Ai,className:"preview-container"},Nt==="stex"&&T.a.createElement(C,{value:ni}),Nt!=="stex"&&T.a.createElement(f.a,{edit:!0,value:ni,replaces:ua})):null))),zt?T.a.createElement("a",{ref:jr,className:"editor-resize"}):null,T.a.createElement(M.a,null,se[or]?T.a.createElement(Y.a,{centered:!0,title:se[or],visible:!0,onCancel:Vr,footer:null,className:"markdown-popup-form"},Qi):null))}},SJMd:function(ht,Ze){/**
|
|
* @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 le,ue,Y,k=!1,V,I;window.PR_SHOULD_USE_CONTINUATION=!0;var D,j;(function(){var F=window,P=["break,continue,do,else,for,if,return,while"],O=[P,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],g=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],T=[g,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],R=[g,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[g,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],w="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",E=[g,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],s=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],l=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],S=[T,L,R,E,u,o,s,l],p=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,f="str",C="kwd",v="com",d="typ",c="lit",h="pun",a="pln",y="tag",m="dec",x="src",M="atn",G="atv",$="nocode",re="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(de){for(var Ee=0,Le=!1,Ie=!1,ke=0,Oe=de.length;ke<Oe;++ke){var Pe=de[ke];if(Pe.ignoreCase)Ie=!0;else if(/[a-z]/i.test(Pe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Le=!0,Ie=!1;break}}var We={b:8,t:9,n:10,v:11,f:12,r:13};function He(Ye){var Ae=Ye.charCodeAt(0);if(Ae!==92)return Ae;var rt=Ye.charAt(1);return Ae=We[rt],Ae||("0"<=rt&&rt<="7"?parseInt(Ye.substring(1),8):rt==="u"||rt==="x"?parseInt(Ye.substring(2),16):Ye.charCodeAt(1))}function Ve(Ye){if(Ye<32)return(Ye<16?"\\x0":"\\x")+Ye.toString(16);var Ae=String.fromCharCode(Ye);return Ae==="\\"||Ae==="-"||Ae==="]"||Ae==="^"?"\\"+Ae:Ae}function Xe(Ye){var Ae=Ye.substring(1,Ye.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),rt=[],Qe=Ae[0]==="^",ae=["["];Qe&&ae.push("^");for(var J=Qe?1:0,Z=Ae.length;J<Z;++J){var ie=Ae[J];if(/\\[bdsw]/i.test(ie))ae.push(ie);else{var oe=He(ie),Q;J+2<Z&&Ae[J+1]==="-"?(Q=He(Ae[J+2]),J+=2):Q=oe,rt.push([oe,Q]),Q<65||oe>122||(Q<65||oe>90||rt.push([Math.max(65,oe)|32,Math.min(Q,90)|32]),Q<97||oe>122||rt.push([Math.max(97,oe)&~32,Math.min(Q,122)&~32]))}}rt.sort(function(me,ye){return me[0]-ye[0]||ye[1]-me[1]});for(var te=[],se=[],J=0;J<rt.length;++J){var he=rt[J];he[0]<=se[1]+1?se[1]=Math.max(se[1],he[1]):te.push(se=he)}for(var J=0;J<te.length;++J){var he=te[J];ae.push(Ve(he[0])),he[1]>he[0]&&(he[1]+1>he[0]&&ae.push("-"),ae.push(Ve(he[1])))}return ae.push("]"),ae.join("")}function nt(Ye){for(var Ae=Ye.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")),rt=Ae.length,Qe=[],ae=0,J=0;ae<rt;++ae){var Z=Ae[ae];if(Z==="(")++J;else if(Z.charAt(0)==="\\"){var ie=+Z.substring(1);ie&&(ie<=J?Qe[ie]=-1:Ae[ae]=Ve(ie))}}for(var ae=1;ae<Qe.length;++ae)Qe[ae]===-1&&(Qe[ae]=++Ee);for(var ae=0,J=0;ae<rt;++ae){var Z=Ae[ae];if(Z==="(")++J,Qe[J]||(Ae[ae]="(?:");else if(Z.charAt(0)==="\\"){var ie=+Z.substring(1);ie&&ie<=J&&(Ae[ae]="\\"+Qe[ie])}}for(var ae=0;ae<rt;++ae)Ae[ae]==="^"&&Ae[ae+1]!=="^"&&(Ae[ae]="");if(Ye.ignoreCase&&Le)for(var ae=0;ae<rt;++ae){var Z=Ae[ae],oe=Z.charAt(0);Z.length>=2&&oe==="["?Ae[ae]=Xe(Z):oe!=="\\"&&(Ae[ae]=Z.replace(/[a-zA-Z]/g,function(se){var he=se.charCodeAt(0);return"["+String.fromCharCode(he&~32,he|32)+"]"}))}return Ae.join("")}for(var Ke=[],ke=0,Oe=de.length;ke<Oe;++ke){var Pe=de[ke];if(Pe.global||Pe.multiline)throw new Error(""+Pe);Ke.push("(?:"+nt(Pe)+")")}return new RegExp(Ke.join("|"),Ie?"gi":"g")}function U(de,Ee){var Le=/(?:^|\s)nocode(?:\s|$)/,Ie=[],ke=0,Oe=[],Pe=0;function We(He){var Ve=He.nodeType;if(Ve==1){if(Le.test(He.className))return;for(var Xe=He.firstChild;Xe;Xe=Xe.nextSibling)We(Xe);var nt=He.nodeName.toLowerCase();(nt==="br"||nt==="li")&&(Ie[Pe]=`
|
|
`,Oe[Pe<<1]=ke++,Oe[Pe++<<1|1]=He)}else if(Ve==3||Ve==4){var Ke=He.nodeValue;Ke.length&&(Ee?Ke=Ke.replace(/\r\n?/g,`
|
|
`):Ke=Ke.replace(/[ \t\r\n]+/g," "),Ie[Pe]=Ke,Oe[Pe<<1]=ke,ke+=Ke.length,Oe[Pe++<<1|1]=He)}}return We(de),{sourceCode:Ie.join("").replace(/\n$/,""),spans:Oe}}function ne(de,Ee,Le,Ie,ke){if(!Le)return;var Oe={sourceNode:de,pre:1,langExtension:null,numberLines:null,sourceCode:Le,spans:null,basePos:Ee,decorations:null};Ie(Oe),ke.push.apply(ke,Oe.decorations)}var fe=/\S/;function ge(de){for(var Ee=void 0,Le=de.firstChild;Le;Le=Le.nextSibling){var Ie=Le.nodeType;Ee=Ie===1?Ee?de:Le:Ie===3&&fe.test(Le.nodeValue)?de:Ee}return Ee===de?void 0:Ee}function be(de,Ee){var Le={},Ie;(function(){for(var Pe=de.concat(Ee),We=[],He={},Ve=0,Xe=Pe.length;Ve<Xe;++Ve){var nt=Pe[Ve],Ke=nt[3];if(Ke)for(var Ye=Ke.length;--Ye>=0;)Le[Ke.charAt(Ye)]=nt;var Ae=nt[1],rt=""+Ae;He.hasOwnProperty(rt)||(We.push(Ae),He[rt]=null)}We.push(/[\0-\uffff]/),Ie=z(We)})();var ke=Ee.length,Oe=function(Pe){for(var We=Pe.sourceCode,He=Pe.basePos,Ve=Pe.sourceNode,Xe=[He,a],nt=0,Ke=We.match(Ie)||[],Ye={},Ae=0,rt=Ke.length;Ae<rt;++Ae){var Qe=Ke[Ae],ae=Ye[Qe],J=void 0,Z;if(typeof ae=="string")Z=!1;else{var ie=Le[Qe.charAt(0)];if(ie)J=Qe.match(ie[1]),ae=ie[0];else{for(var oe=0;oe<ke;++oe)if(ie=Ee[oe],J=Qe.match(ie[1]),J){ae=ie[0];break}J||(ae=a)}Z=ae.length>=5&&ae.substring(0,5)==="lang-",Z&&!(J&&typeof J[1]=="string")&&(Z=!1,ae=x),Z||(Ye[Qe]=ae)}var Q=nt;if(nt+=Qe.length,!Z)Xe.push(He+Q,ae);else{var te=J[1],se=Qe.indexOf(te),he=se+te.length;J[2]&&(he=Qe.length-J[2].length,se=he-te.length);var me=ae.substring(5);ne(Ve,He+Q,Qe.substring(0,se),Oe,Xe),ne(Ve,He+Q+se,te,W(me,te),Xe),ne(Ve,He+Q+he,Qe.substring(he),Oe,Xe)}}Pe.decorations=Xe};return Oe}function Me(de){var Ee=[],Le=[];de.tripleQuotedStrings?Ee.push([f,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):de.multiLineStrings?Ee.push([f,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ee.push([f,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),de.verbatimStrings&&Le.push([f,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ie=de.hashComments;Ie&&(de.cStyleComments?(Ie>1?Ee.push([v,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ee.push([v,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Le.push([f,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ee.push([v,/^#[^\r\n]*/,null,"#"])),de.cStyleComments&&(Le.push([v,/^\/\/[^\r\n]*/,null]),Le.push([v,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var ke=de.regexLiterals;if(ke){var Oe=ke>1?"":`
|
|
\r`,Pe=Oe?".":"[\\S\\s]",We="/(?=[^/*"+Oe+"])(?:[^/\\x5B\\x5C"+Oe+"]|\\x5C"+Pe+"|\\x5B(?:[^\\x5C\\x5D"+Oe+"]|\\x5C"+Pe+")*(?:\\x5D|$))+/";Le.push(["lang-regex",RegExp("^"+re+"("+We+")")])}var He=de.types;He&&Le.push([d,He]);var Ve=(""+de.keywords).replace(/^ | $/g,"");Ve.length&&Le.push([C,new RegExp("^(?:"+Ve.replace(/[\s,]+/g,"|")+")\\b"),null]),Ee.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var Xe="^.[^\\s\\w.$@'\"`/\\\\]*";return de.regexLiterals&&(Xe+="(?!s*/)"),Le.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[d,/^(?:[@_]?[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],[h,new RegExp(Xe),null]),be(Ee,Le)}var Te=Me({keywords:S,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function De(de,Ee,Le){for(var Ie=/(?:^|\s)nocode(?:\s|$)/,ke=/\r\n?|\n/,Oe=de.ownerDocument,Pe=Oe.createElement("li");de.firstChild;)Pe.appendChild(de.firstChild);var We=[Pe];function He(Ae){var rt=Ae.nodeType;if(rt==1&&!Ie.test(Ae.className))if(Ae.nodeName==="br")Ve(Ae),Ae.parentNode&&Ae.parentNode.removeChild(Ae);else for(var Qe=Ae.firstChild;Qe;Qe=Qe.nextSibling)He(Qe);else if((rt==3||rt==4)&&Le){var ae=Ae.nodeValue,J=ae.match(ke);if(J){var Z=ae.substring(0,J.index);Ae.nodeValue=Z;var ie=ae.substring(J.index+J[0].length);if(ie){var oe=Ae.parentNode;oe.insertBefore(Oe.createTextNode(ie),Ae.nextSibling)}Ve(Ae),Z||Ae.parentNode.removeChild(Ae)}}}function Ve(Ae){for(;!Ae.nextSibling;)if(Ae=Ae.parentNode,!Ae)return;function rt(J,Z){var ie=Z?J.cloneNode(!1):J,oe=J.parentNode;if(oe){var Q=rt(oe,1),te=J.nextSibling;Q.appendChild(ie);for(var se=te;se;se=te)te=se.nextSibling,Q.appendChild(se)}return ie}for(var Qe=rt(Ae.nextSibling,0),ae;(ae=Qe.parentNode)&&ae.nodeType===1;)Qe=ae;We.push(Qe)}for(var Xe=0;Xe<We.length;++Xe)He(We[Xe]);Ee===(Ee|0)&&We[0].setAttribute("value",Ee);var nt=Oe.createElement("ol");nt.className="linenums";for(var Ke=Math.max(0,Ee-1|0)||0,Xe=0,Ye=We.length;Xe<Ye;++Xe)Pe=We[Xe],Pe.className="L"+(Xe+Ke)%10,Pe.firstChild||Pe.appendChild(Oe.createTextNode("\xA0")),nt.appendChild(Pe);de.appendChild(nt)}function Ce(de){var Ee=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ee=Ee&&+Ee[1]<=8;var Le=/\n/g,Ie=de.sourceCode,ke=Ie.length,Oe=0,Pe=de.spans,We=Pe.length,He=0,Ve=de.decorations,Xe=Ve.length,nt=0;Ve[Xe]=ke;var Ke,Ye;for(Ye=Ke=0;Ye<Xe;)Ve[Ye]!==Ve[Ye+2]?(Ve[Ke++]=Ve[Ye++],Ve[Ke++]=Ve[Ye++]):Ye+=2;for(Xe=Ke,Ye=Ke=0;Ye<Xe;){for(var Ae=Ve[Ye],rt=Ve[Ye+1],Qe=Ye+2;Qe+2<=Xe&&Ve[Qe+1]===rt;)Qe+=2;Ve[Ke++]=Ae,Ve[Ke++]=rt,Ye=Qe}Xe=Ve.length=Ke;var ae=de.sourceNode,J="";ae&&(J=ae.style.display,ae.style.display="none");try{for(var Z=null;He<We;){var ie=Pe[He],oe=Pe[He+2]||ke,Q=Ve[nt+2]||ke,Qe=Math.min(oe,Q),te=Pe[He+1],se;if(te.nodeType!==1&&(se=Ie.substring(Oe,Qe))){Ee&&(se=se.replace(Le,"\r")),te.nodeValue=se;var he=te.ownerDocument,me=he.createElement("span");me.className=Ve[nt+1];var ye=te.parentNode;ye.replaceChild(me,te),me.appendChild(te),Oe<oe&&(Pe[He+1]=te=he.createTextNode(Ie.substring(Qe,oe)),ye.insertBefore(te,me.nextSibling))}Oe=Qe,Oe>=oe&&(He+=2),Oe>=Q&&(nt+=2)}}finally{ae&&(ae.style.display=J)}}var we={};function ve(de,Ee){for(var Le=Ee.length;--Le>=0;){var Ie=Ee[Le];we.hasOwnProperty(Ie)?F.console&&console.warn("cannot override language handler %s",Ie):we[Ie]=de}}function W(de,Ee){return de&&we.hasOwnProperty(de)||(de=/^\s*</.test(Ee)?"default-markup":"default-code"),we[de]}ve(Te,["default-code"]),ve(be([],[[a,/^[^<?]+/],[m,/^<!\w[^>]*(?:>|$)/],[v,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[h,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),ve(be([[a,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[y,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[h,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),ve(be([],[[G,/^[\s\S]+/]]),["uq.val"]),ve(Me({keywords:T,hashComments:!0,cStyleComments:!0,types:p}),["c","cc","cpp","cxx","cyc","m"]),ve(Me({keywords:"null,true,false"}),["json"]),ve(Me({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:p}),["cs"]),ve(Me({keywords:R,cStyleComments:!0}),["java"]),ve(Me({keywords:l,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(Me({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(Me({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(Me({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(Me({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(Me({keywords:w,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(be([],[[f,/^[\s\S]+/]]),["regex"]);function A(de){var Ee=de.langExtension;try{var Le=U(de.sourceNode,de.pre),Ie=Le.sourceCode;de.sourceCode=Ie,de.spans=Le.spans,de.basePos=0,W(Ee,Ie)(de),Ce(de)}catch(ke){F.console&&console.log(ke&&ke.stack||ke)}}function _(de,Ee,Le){var Ie=Le||!1,ke=Ee||null,Oe=document.createElement("div");Oe.innerHTML="<pre>"+de+"</pre>",Oe=Oe.firstChild,Ie&&De(Oe,Ie,!0);var Pe={langExtension:ke,numberLines:Ie,sourceNode:Oe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return A(Pe),Oe.innerHTML}function H(de,Ee){var Le=Ee||document.body,Ie=Le.ownerDocument||document;function ke(ie){return Le.getElementsByTagName(ie)}for(var Oe=[ke("pre"),ke("code"),ke("xmp")],Pe=[],We=0;We<Oe.length;++We)for(var He=0,Ve=Oe[We].length;He<Ve;++He)Pe.push(Oe[We][He]);Oe=null;var Xe=Date;Xe.now||(Xe={now:function(){return+new Date}});var nt=0,Ke=/\blang(?:uage)?-([\w.]+)(?!\S)/,Ye=/\bprettyprint\b/,Ae=/\bprettyprinted\b/,rt=/pre|xmp/i,Qe=/^code$/i,ae=/^(?:pre|code|xmp)$/i,J={};function Z(){for(var ie=F.PR_SHOULD_USE_CONTINUATION?Xe.now()+250:Infinity;nt<Pe.length&&Xe.now()<ie;nt++){for(var oe=Pe[nt],Q=J,te=oe;te=te.previousSibling;){var se=te.nodeType,he=(se===7||se===8)&&te.nodeValue;if(he?!/^\??prettify\b/.test(he):se!==3||/\S/.test(te.nodeValue))break;if(he){Q={},he.replace(/\b(\w+)=([\w:.%+-]+)/g,function(gt,st,Xt){Q[st]=Xt});break}}var me=oe.className;if((Q!==J||Ye.test(me))&&!Ae.test(me)){for(var ye=!1,_e=oe.parentNode;_e;_e=_e.parentNode){var Fe=_e.tagName;if(ae.test(Fe)&&_e.className&&Ye.test(_e.className)){ye=!0;break}}if(!ye){oe.className+=" prettyprinted";var qe=Q.lang;if(!qe){qe=me.match(Ke);var et;!qe&&(et=ge(oe))&&Qe.test(et.tagName)&&(qe=et.className.match(Ke)),qe&&(qe=qe[1])}var xt;if(rt.test(oe.tagName))xt=1;else{var ot=oe.currentStyle,it=Ie.defaultView,Lt=ot?ot.whiteSpace:it&&it.getComputedStyle?it.getComputedStyle(oe,null).getPropertyValue("white-space"):0;xt=Lt&&Lt.substring(0,3)==="pre"}var ct=Q.linenums;(ct=ct==="true"||+ct)||(ct=me.match(/\blinenums\b(?::(\d+))?/),ct=ct?ct[1]&&ct[1].length?+ct[1]:!0:!1),ct&&De(oe,ct,xt);var pt={langExtension:qe,sourceNode:oe,numberLines:ct,pre:xt,sourceCode:null,basePos:null,spans:null,decorations:null};A(pt)}}}nt<Pe.length?F.setTimeout(Z,250):typeof de=="function"&&de()}Z()}var q=F.PR={createSimpleLexer:be,registerLangHandler:ve,sourceDecorator:Me,PR_ATTRIB_NAME:M,PR_ATTRIB_VALUE:G,PR_COMMENT:v,PR_DECLARATION:m,PR_KEYWORD:C,PR_LITERAL:c,PR_NOCODE:$,PR_PLAIN:a,PR_PUNCTUATION:h,PR_SOURCE:x,PR_STRING:f,PR_TAG:y,PR_TYPE:d,prettyPrintOne:k?F.prettyPrintOne=_:D=_,prettyPrint:j=k?F.prettyPrint=H:j=H},B=F.define;typeof B=="function"&&B.amd&&B("google-code-prettify",[],function(){return q})})()},STEk:function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return ve});/*! *****************************************************************************
|
|
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 ue=function(W,A){return(ue=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,H){_.__proto__=H}||function(_,H){for(var q in H)Object.prototype.hasOwnProperty.call(H,q)&&(_[q]=H[q])})(W,A)};function Y(W,A){function _(){this.constructor=W}ue(W,A),W.prototype=A===null?Object.create(A):(_.prototype=A.prototype,new _)}function k(W,A,_,H){return new(_||(_=Promise))(function(q,B){function de(Ie){try{Le(H.next(Ie))}catch(ke){B(ke)}}function Ee(Ie){try{Le(H.throw(Ie))}catch(ke){B(ke)}}function Le(Ie){var ke;Ie.done?q(Ie.value):(ke=Ie.value,ke instanceof _?ke:new _(function(Oe){Oe(ke)})).then(de,Ee)}Le((H=H.apply(W,A||[])).next())})}function V(W,A){var _,H,q,B,de={label:0,sent:function(){if(1&q[0])throw q[1];return q[1]},trys:[],ops:[]};return B={next:Ee(0),throw:Ee(1),return:Ee(2)},typeof Symbol=="function"&&(B[Symbol.iterator]=function(){return this}),B;function Ee(Le){return function(Ie){return function(ke){if(_)throw new TypeError("Generator is already executing.");for(;de;)try{if(_=1,H&&(q=2&ke[0]?H.return:ke[0]?H.throw||((q=H.return)&&q.call(H),0):H.next)&&!(q=q.call(H,ke[1])).done)return q;switch(H=0,q&&(ke=[2&ke[0],q.value]),ke[0]){case 0:case 1:q=ke;break;case 4:return de.label++,{value:ke[1],done:!1};case 5:de.label++,H=ke[1],ke=[0];continue;case 7:ke=de.ops.pop(),de.trys.pop();continue;default:if(!(q=de.trys,(q=q.length>0&&q[q.length-1])||ke[0]!==6&&ke[0]!==2)){de=0;continue}if(ke[0]===3&&(!q||ke[1]>q[0]&&ke[1]<q[3])){de.label=ke[1];break}if(ke[0]===6&&de.label<q[1]){de.label=q[1],q=ke;break}if(q&&de.label<q[2]){de.label=q[2],de.ops.push(ke);break}q[2]&&de.ops.pop(),de.trys.pop();continue}ke=A.call(W,de)}catch(Oe){ke=[6,Oe],H=0}finally{_=q=0}if(5&ke[0])throw ke[1];return{value:ke[0]?ke[1]:void 0,done:!0}}([Le,Ie])}}}function I(){for(var W=0,A=0,_=arguments.length;A<_;A++)W+=arguments[A].length;var H=Array(W),q=0;for(A=0;A<_;A++)for(var B=arguments[A],de=0,Ee=B.length;de<Ee;de++,q++)H[q]=B[de];return H}var D=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(A,_){for(var H=0,q=_;H<q.length;H++){var B=q[H],de=B[0],Ee=B[1];A.setAttribute(de,Ee)}},W.createRect=function(A,_,H){var q=document.createElementNS("http://www.w3.org/2000/svg","rect");return q.setAttribute("width",A.toString()),q.setAttribute("height",_.toString()),H&&W.setAttributes(q,H),q},W.createLine=function(A,_,H,q,B){var de=document.createElementNS("http://www.w3.org/2000/svg","line");return de.setAttribute("x1",A.toString()),de.setAttribute("y1",_.toString()),de.setAttribute("x2",H.toString()),de.setAttribute("y2",q.toString()),B&&W.setAttributes(de,B),de},W.createPolygon=function(A,_){var H=document.createElementNS("http://www.w3.org/2000/svg","polygon");return H.setAttribute("points",A),_&&W.setAttributes(H,_),H},W.createCircle=function(A,_){var H=document.createElementNS("http://www.w3.org/2000/svg","circle");return H.setAttribute("cx",(A/2).toString()),H.setAttribute("cy",(A/2).toString()),H.setAttribute("r",A.toString()),_&&W.setAttributes(H,_),H},W.createEllipse=function(A,_,H){var q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return q.setAttribute("cx",(A/2).toString()),q.setAttribute("cy",(_/2).toString()),q.setAttribute("rx",(A/2).toString()),q.setAttribute("ry",(_/2).toString()),H&&W.setAttributes(q,H),q},W.createGroup=function(A){var _=document.createElementNS("http://www.w3.org/2000/svg","g");return A&&W.setAttributes(_,A),_},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(A,_,H,q,B,de,Ee){var Le=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Le,[["id",A],["orient",_],["markerWidth",H.toString()],["markerHeight",q.toString()],["refX",B.toString()],["refY",de.toString()]]),Le.appendChild(Ee),Le},W.createText=function(A){var _=document.createElementNS("http://www.w3.org/2000/svg","text");return _.setAttribute("x","0"),_.setAttribute("y","0"),A&&W.setAttributes(_,A),_},W.createTSpan=function(A,_){var H=document.createElementNS("http://www.w3.org/2000/svg","tspan");return H.textContent=A,_&&W.setAttributes(H,_),H},W.createImage=function(A){var _=document.createElementNS("http://www.w3.org/2000/svg","image");return A&&W.setAttributes(_,A),_},W.createPoint=function(A,_){var H=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return H.x=A,H.y=_,H},W.createPath=function(A,_){var H=document.createElementNS("http://www.w3.org/2000/svg","path");return H.setAttribute("d",A),_&&W.setAttributes(H,_),H},W}(),j=function(){function W(){}return W.addKey=function(A){W.key=A},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),F=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(A,_,H){var q=this;return new Promise(function(B){var de=H!==void 0?H:document.createElement("canvas");A===null&&(q.markersOnly=!0,q.naturalSize=!1);var Ee=document.createElementNS("http://www.w3.org/2000/svg","svg");Ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),Ee.setAttribute("width",_.width.baseVal.valueAsString),Ee.setAttribute("height",_.height.baseVal.valueAsString),Ee.setAttribute("viewBox","0 0 "+_.viewBox.baseVal.width.toString()+" "+_.viewBox.baseVal.height.toString()),Ee.innerHTML=_.innerHTML,q.naturalSize===!0?(Ee.width.baseVal.value=A.naturalWidth,Ee.height.baseVal.value=A.naturalHeight):q.width!==void 0&&q.height!==void 0&&(Ee.width.baseVal.value=q.width,Ee.height.baseVal.value=q.height),de.width=Ee.width.baseVal.value,de.height=Ee.height.baseVal.value;var Le=Ee.outerHTML,Ie=de.getContext("2d");q.markersOnly!==!0&&Ie.drawImage(A,0,0,de.width,de.height);var ke=window.URL,Oe=new Image(de.width,de.height);Oe.setAttribute("crossOrigin","anonymous");var Pe=new Blob([Le],{type:"image/svg+xml"}),We=ke.createObjectURL(Pe);Oe.onload=function(){Ie.drawImage(Oe,0,0),ke.revokeObjectURL(We);var He=de.toDataURL(q.imageType,q.imageQuality);B(He)},Oe.src=We})},W}(),P=function(){},O=function(){function W(A){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+A+"_"}return Object.defineProperty(W.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),W.prototype.addClass=function(A){return this.styleSheet===void 0&&this.addStyleSheet(),A.name=""+this.classNamePrefix+A.localName,this.classes.push(A),this.styleSheet.sheet.insertRule("."+A.name+" {"+A.style+"}",this.styleSheet.sheet.cssRules.length),A},W.prototype.addRule=function(A){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(A),this.styleSheet.sheet.insertRule(A.selector+" {"+A.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var A;this.styleSheet=document.createElement("style"),((A=this.styleSheetRoot)!==null&&A!==void 0?A:document.head).appendChild(this.styleSheet),this.addRule(new g("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new g("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new g("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new T("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new T("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},W.prototype.removeStyleSheet=function(){var A;this.styleSheet&&(((A=this.styleSheetRoot)!==null&&A!==void 0?A:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),g=function(W,A){this.selector=W,this.style=A},T=function(W,A){this.localName=W,this.style=A},R=function(){function W(A,_,H,q,B){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=A,this.displayMode=_,this.markerItems=H,this.uiStyleSettings=q,this.styles=B,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return W.prototype.show=function(A){var _=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=A,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var H=document.createElement("div");H.className=this.toolbarBlockStyleClass.name,H.style.whiteSpace="nowrap",this.uiContainer.appendChild(H),this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(B){var de=document.createElement("div");de.className=""+_.toolbarButtonStyleClass.name,de.setAttribute("data-type-name",B.typeName),de.innerHTML=B.icon,de.addEventListener("click",function(){_.markerToolbarButtonClicked(de,B)}),_.buttons.push(de),_.markerButtons.push(de)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var q=document.createElement("div");q.className=this.toolbarBlockStyleClass.name,q.style.whiteSpace="nowrap",q.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(q),this.addActionButton(q,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(q,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},W.prototype.addButtonClickListener=function(A){this.buttonClickListeners.push(A)},W.prototype.removeButtonClickListener=function(A){this.buttonClickListeners.indexOf(A)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(A),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var A=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var _=0;_<this.markerButtons.length;_++)_<A||_===A&&this.markerButtons.length-1===A?this.markerButtonBlock.appendChild(this.markerButtons[_]):(_===A&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[_]))}},W.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},W.prototype.resetButtonStyles=function(){var A=this;this.buttons.forEach(function(_){_.className=_.className.replace(A.uiStyleSettings.toolbarButtonStyleColorsClassName?A.uiStyleSettings.toolbarButtonStyleColorsClassName:A.toolbarButtonStyleColorsClass.name,"").trim(),_.className=_.className.replace(A.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?A.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:A.toolbarActiveButtonStyleColorsClass.name,"").trim(),_.className+=" "+(A.uiStyleSettings.toolbarButtonStyleColorsClassName?A.uiStyleSettings.toolbarButtonStyleColorsClassName:A.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(A,_,H){var q=this,B=document.createElement("div");switch(B.className=""+this.toolbarButtonStyleClass.name,B.innerHTML=_,B.setAttribute("data-action",H),B.addEventListener("click",function(){q.actionToolbarButtonClicked(B,H)}),H){case"select":B.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":B.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":B.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":B.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":B.style.fill=this.uiStyleSettings.closeButtonColor}A.appendChild(B),this.buttons.push(B)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new T("toolbar",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new T("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new T("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new T("toolbar-overflow-block",`
|
|
position: absolute;
|
|
top: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
|
|
z-index: 10;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new T("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var A=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new T("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*A)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*A)+`px;
|
|
padding: `+A+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new T("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new T("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new g("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new g("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},W.prototype.markerToolbarButtonClicked=function(A,_){this.setActiveButton(A),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("marker",_)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(A,_){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("action",_)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(A){this.resetButtonStyles(),A.className=A.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),A.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(A){var _=this.markerButtons.find(function(H){return H.getAttribute("data-type-name")===A});_&&this.setActiveButton(_)},W.prototype.setCurrentMarker=function(A){var _=this;this.currentMarker=A,this.buttons.filter(function(H){return/delete|notes/.test(H.getAttribute("data-action"))}).forEach(function(H){_.currentMarker===void 0?(H.style.fillOpacity="0.4",H.style.pointerEvents="none"):(H.style.fillOpacity="1",H.style.pointerEvents="all")})},W}(),L=function(){function W(A,_,H,q){this.panels=[],this.panelButtons=[],this.markerjsContainer=A,this.displayMode=_,this.uiStyleSettings=H,this.styles=q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var A;this.toolboxStyleClass=this.styles.addClass(new T("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 T("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var _=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new T("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new T("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new T("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 T("toolbox-panel-row_colors",`
|
|
background-color: `+((A=this.uiStyleSettings.toolboxBackgroundColor)!==null&&A!==void 0?A:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new T("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*_)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*_)+`px;
|
|
padding: `+_+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new T("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new T("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new g("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new g("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},W.prototype.show=function(A){var _;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=A,this.uiContainer.className=this.toolboxStyleClass.name+" "+((_=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&_!==void 0?_:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(A){var _,H,q=this;this.panels=A,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((_=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&_!==void 0?_:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((H=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&H!==void 0?H:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(B){var de;B.uiStyleSettings=q.uiStyleSettings;var Ee=document.createElement("div");Ee.className=q.toolboxButtonStyleClass.name+" "+((de=q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&de!==void 0?de:q.toolboxButtonStyleColorsClass.name),Ee.innerHTML=B.icon,Ee.title=B.title,Ee.addEventListener("click",function(){q.panelButtonClick(B)}),q.panelButtons.push(Ee),q.buttonRow.appendChild(Ee)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(A){var _=this,H=-1;if(A!==this.activePanel){H=this.panels.indexOf(A),this.panelRow.innerHTML="";var q=A.getUi();q.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(q),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=A}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){_.displayMode==="inline"?_.panelRow.style.display="none":_.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(B,de){var Ee,Le;B.className=_.toolboxButtonStyleClass.name+" "+(de===H?""+((Ee=_.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Ee!==void 0?Ee:_.toolboxActiveButtonStyleColorsClass.name):""+((Le=_.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Le!==void 0?Le:_.toolboxButtonStyleColorsClass.name))})},W}(),w=function(W,A){this.title=W,this.icon=A},E=function(W){function A(_,H,q,B){var de=W.call(this,_,B||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return de.colors=[],de.addTransparent=!1,de.colorBoxes=[],de.colors=H,de.currentColor=q,de.setCurrentColor=de.setCurrentColor.bind(de),de.getColorBox=de.getColorBox.bind(de),de}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.whiteSpace="nowrap",this.colors.forEach(function(q){var B=_.getColorBox(q);H.appendChild(B),_.colorBoxes.push(B)}),H},A.prototype.getColorBox=function(_){var H=this,q=this.uiStyleSettings.toolbarHeight/4,B=this.uiStyleSettings.toolbarHeight-q,de=document.createElement("div");de.style.display="inline-block",de.style.boxSizing="content-box",de.style.width=B-2+"px",de.style.height=B-2+"px",de.style.padding="1px",de.style.marginRight="2px",de.style.marginBottom="2px",de.style.borderWidth="2px",de.style.borderStyle="solid",de.style.borderRadius=(B+2)/2+"px",de.style.borderColor=_===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",de.addEventListener("click",function(){H.setCurrentColor(_,de)});var Ee=document.createElement("div");return Ee.style.display="inline-block",Ee.style.width=B-2+"px",Ee.style.height=B-2+"px",Ee.style.backgroundColor=_,Ee.style.borderRadius=B/2+"px",_==="transparent"&&(Ee.style.fill=this.uiStyleSettings.toolboxAccentColor,Ee.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),de.appendChild(Ee),de},A.prototype.setCurrentColor=function(_,H){var q=this;this.currentColor=_,this.colorBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(_)},A}(w),u=function(){function W(A,_,H){this._state="new",this._isSelected=!1,this._container=A,this._overlayContainer=_,this.globalSettings=H,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(A){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(A,_){},W.prototype.dblClick=function(A,_){},W.prototype.manipulate=function(A){},W.prototype.pointerUp=function(A){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(A){this.container.childNodes.length>0?this.container.insertBefore(A,this.container.childNodes[0]):this.container.appendChild(A)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(A){this._state=A.state,this.notes=A.notes},W.prototype.scale=function(A,_){},W.prototype.colorChanged=function(A){this.onColorChanged&&this.onColorChanged(A),this.stateChanged()},W.prototype.fillColorChanged=function(A){this.onFillColorChanged&&this.onFillColorChanged(A),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var A=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),A.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(A)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),o=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(A){return this.topLeft.ownsTarget(A)?this.topLeft:this.topCenter.ownsTarget(A)?this.topCenter:this.topRight.ownsTarget(A)?this.topRight:this.centerLeft.ownsTarget(A)?this.centerLeft:this.centerRight.ownsTarget(A)?this.centerRight:this.bottomLeft.ownsTarget(A)?this.bottomLeft:this.bottomCenter.ownsTarget(A)?this.bottomCenter:this.bottomRight.ownsTarget(A)?this.bottomRight:void 0},W}(),s=function(){function W(){this.GRIP_SIZE=10,this.visual=D.createGroup(),this.visual.appendChild(D.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(D.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(A){return A===this.visual||A===this.visual.childNodes[0]||A===this.visual.childNodes[1]},W}(),l=function(){function W(){}return W.toITransformMatrix=function(A){return{a:A.a,b:A.b,c:A.c,d:A.d,e:A.e,f:A.f}},W.toSVGMatrix=function(A,_){return A.a=_.a,A.b=_.b,A.c=_.c,A.d=_.d,A.e=_.e,A.f=_.f,A},W}(),S=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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(D.createTransform()),B.setupControlBox(),B}return Y(A,W),Object.defineProperty(A.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"visual",{get:function(){return this._visual},set:function(_){this._visual=_;var H=D.createTransform();this._visual.transform.baseVal.appendItem(H)},enumerable:!1,configurable:!0}),A.prototype.ownsTarget=function(_){return!!W.prototype.ownsTarget.call(this,_)||!!(this.controlGrips.findGripByVisual(_)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(_))},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="new"&&(this.left=_.x,this.top=_.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var q=this.unrotatePoint(_);if(this.manipulationStartX=q.x,this.manipulationStartY=q.y,this.offsetX=q.x-this.left,this.offsetY=q.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(H),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(H)){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 de=this.container.transform.baseVal.getItem(0);de.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(de,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},A.prototype.pointerUp=function(_){var H=this.state;W.prototype.pointerUp.call(this,_),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(_),this._state="select",H==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},A.prototype.moveVisual=function(_){this.visual.style.transform="translate("+_.x+"px, "+_.y+"px)"},A.prototype.manipulate=function(_){var H=this.unrotatePoint(_);this.state==="creating"?this.resize(_):this.state==="move"?(this.left=this.manipulationStartLeft+(H.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(H.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(H):this.state==="rotate"&&this.rotate(_)},A.prototype.resize=function(_){var H=this.manipulationStartLeft,q=this.manipulationStartWidth,B=this.manipulationStartTop,de=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:H=this.manipulationStartLeft+_.x-this.manipulationStartX,q=this.manipulationStartWidth+this.manipulationStartLeft-H;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:q=this.manipulationStartWidth+_.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:B=this.manipulationStartTop+_.y-this.manipulationStartY,de=this.manipulationStartHeight+this.manipulationStartTop-B;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:de=this.manipulationStartHeight+_.y-this.manipulationStartY}q>=0?(this.left=H,this.width=q):(this.left=H+q,this.width=-q),de>=0?(this.top=B,this.height=de):(this.top=B+de,this.height=-de),this.setSize()},A.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},A.prototype.rotate=function(_){if(Math.abs(_.x-this.centerX)>.1){var H=Math.sign(_.x-this.centerX);this.rotationAngle=180*Math.atan((_.y-this.centerY)/(_.x-this.centerX))/Math.PI+90*H,this.applyRotation()}},A.prototype.applyRotation=function(){var _=this.container.transform.baseVal.getItem(0);_.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(_,0)},A.prototype.rotatePoint=function(_){if(this.rotationAngle===0)return _;var H=this.container.getCTM(),q=D.createPoint(_.x,_.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},A.prototype.unrotatePoint=function(_){if(this.rotationAngle===0)return _;var H=this.container.getCTM();H=H.inverse();var q=D.createPoint(_.x,_.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},A.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},A.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},A.prototype.setupControlBox=function(){this.controlBox=D.createGroup();var _=D.createTransform();_.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(_),this.container.appendChild(this.controlBox),this.controlRect=D.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=D.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 o,this.addControlGrips(),this.controlBox.style.display="none"},A.prototype.adjustControlBox=function(){var _=this.controlBox.transform.baseVal.getItem(0);_.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(_,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()},A.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()},A.prototype.createGrip=function(){var _=new s;return _.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(_.visual),_},A.prototype.positionGrips=function(){var _=this.controlGrips.topLeft.GRIP_SIZE,H=-_/2,q=H,B=(this.width+this.CB_DISTANCE)/2-_/2,de=(this.height+this.CB_DISTANCE)/2-_/2,Ee=this.height+this.CB_DISTANCE-_/2,Le=this.width+this.CB_DISTANCE-_/2;this.positionGrip(this.controlGrips.topLeft.visual,H,q),this.positionGrip(this.controlGrips.topCenter.visual,B,q),this.positionGrip(this.controlGrips.topRight.visual,Le,q),this.positionGrip(this.controlGrips.centerLeft.visual,H,de),this.positionGrip(this.controlGrips.centerRight.visual,Le,de),this.positionGrip(this.controlGrips.bottomLeft.visual,H,Ee),this.positionGrip(this.controlGrips.bottomCenter.visual,B,Ee),this.positionGrip(this.controlGrips.bottomRight.visual,Le,Ee),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,B,q-3*this.CB_DISTANCE)},A.prototype.positionGrip=function(_,H,q){var B=_.transform.baseVal.getItem(0);B.setTranslate(H,q),_.transform.baseVal.replaceItem(B,0)},A.prototype.hideControlBox=function(){this.controlBox.style.display="none"},A.prototype.showControlBox=function(){this.controlBox.style.display=""},A.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:l.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:l.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_);var H=_;this.left=H.left,this.top=H.top,this.width=H.width,this.height=H.height,this.rotationAngle=H.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(l.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,H.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(l.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,H.containerTransformMatrix))},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H);var q=this.rotatePoint({x:this.left,y:this.top}),B=this.unrotatePoint({x:q.x*_,y:q.y*H});this.left=B.x,this.top=B.y,this.width=this.width*_,this.height=this.height*H,this.adjustControlBox()},A}(u),p=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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 Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.visual)},A.prototype.createVisual=function(){this.visual=D.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)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="new"&&(this.createVisual(),this.moveVisual(_),this._state="creating")},A.prototype.manipulate=function(_){W.prototype.manipulate.call(this,_)},A.prototype.resize=function(_){W.prototype.resize.call(this,_),this.setSize()},A.prototype.setSize=function(){W.prototype.setSize.call(this),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},A.prototype.pointerUp=function(_){W.prototype.pointerUp.call(this,_),this.setSize()},A.prototype.setStrokeColor=function(_){this.strokeColor=_,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(_),this.stateChanged()},A.prototype.setFillColor=function(_){this.fillColor=_,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},A.prototype.setStrokeWidth=function(_){this.strokeWidth=_,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},A.prototype.setStrokeDasharray=function(_){this.strokeDasharray=_,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},A.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))},A.prototype.restoreState=function(_){var H=_;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,_),this.setSize()},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.setSize()},A.title="Rectangle marker",A}(S),f=function(W){function A(_,H,q,B){var de=W.call(this,_,B||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return de.widths=[],de.widthBoxes=[],de.widths=H,de.currentWidth=q,de.setCurrentWidth=de.setCurrentWidth.bind(de),de}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.widths.forEach(function(q){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=q===_.currentWidth?_.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){_.setCurrentWidth(q,B)}),H.appendChild(B);var de=document.createElement("div");de.innerText=q.toString(),de.style.marginRight="5px",B.appendChild(de);var Ee=document.createElement("div");Ee.style.minHeight="20px",Ee.style.flexGrow="2",Ee.style.display="flex",Ee.style.alignItems="center";var Le=document.createElement("hr");Le.style.minWidth="20px",Le.style.border="0px",Le.style.borderTop=q+"px solid "+_.uiStyleSettings.toolboxColor,Le.style.flexGrow="2",Ee.appendChild(Le),B.appendChild(Ee),_.widthBoxes.push(B)}),H},A.prototype.setCurrentWidth=function(_,H){var q=this;this.currentWidth=_,this.widthBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},A}(w),C=function(W){function A(_,H,q,B){var de=W.call(this,_,B||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return de.styles=[],de.styleBoxes=[],de.styles=H,de.currentStyle=q,de.setCurrentStyle=de.setCurrentStyle.bind(de),de}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.styles.forEach(function(q){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/_.styles.length-5+"%",B.style.borderColor=q===_.currentStyle?_.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){_.setCurrentStyle(q,B)}),H.appendChild(B);var de=document.createElement("div");de.style.minHeight="20px",de.style.flexGrow="2",de.style.overflow="hidden";var Ee=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+_.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(q!==""?'stroke-dasharray="'+q+'"':"")+` />
|
|
</svg>`;de.innerHTML=Ee,B.appendChild(de),_.styleBoxes.push(B)}),H},A.prototype.setCurrentStyle=function(_,H){var q=this;this.currentStyle=_,this.styleBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},A}(w),v=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new E("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new C("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Y(A,W),Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=W.prototype.getState.call(this);return _.typeName=A.typeName,_},A.typeName="FrameMarker",A.title="Frame marker",A.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',A}(p),d=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},c=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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 Y(A,W),A.prototype.ownsTarget=function(_){return!!W.prototype.ownsTarget.call(this,_)||!(!this.grip1.ownsTarget(_)&&!this.grip2.ownsTarget(_))},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.manipulationStartX=_.x,this.manipulationStartY=_.y,this.state==="new"&&(this.x1=_.x,this.y1=_.y,this.x2=_.x,this.y2=_.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(H)?this.activeGrip=this.grip1:this.grip2.ownsTarget(H)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},A.prototype.pointerUp=function(_){var H=this.state;W.prototype.pointerUp.call(this,_),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(_),this._state="select",H==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},A.prototype.adjustVisual=function(){},A.prototype.manipulate=function(_){this.state==="creating"?this.resize(_):this.state==="move"?(this.x1=this.manipulationStartX1+_.x-this.manipulationStartX,this.y1=this.manipulationStartY1+_.y-this.manipulationStartY,this.x2=this.manipulationStartX2+_.x-this.manipulationStartX,this.y2=this.manipulationStartY2+_.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(_)},A.prototype.resize=function(_){switch(this.activeGrip){case this.grip1:this.x1=_.x,this.y1=_.y;break;case this.grip2:case void 0:this.x2=_.x,this.y2=_.y}this.adjustVisual(),this.adjustControlBox()},A.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},A.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},A.prototype.setupControlBox=function(){this.controlBox=D.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},A.prototype.adjustControlBox=function(){this.positionGrips()},A.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},A.prototype.createGrip=function(){var _=new s;return _.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(_.visual),_},A.prototype.positionGrips=function(){var _=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-_/2,this.y1-_/2),this.positionGrip(this.grip2.visual,this.x2-_/2,this.y2-_/2)},A.prototype.positionGrip=function(_,H,q){var B=_.transform.baseVal.getItem(0);B.setTranslate(H,q),_.transform.baseVal.replaceItem(B,0)},A.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_);var H=_;this.x1=H.x1,this.y1=H.y1,this.x2=H.x2,this.y2=H.y2},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.x1=this.x1*_,this.y1=this.y1*H,this.x2=this.x2*_,this.y2=this.y2*H,this.adjustVisual(),this.adjustControlBox()},A}(u),h=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new E("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new C("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.visual&&_!==this.selectorLine&&_!==this.visibleLine)},A.prototype.createVisual=function(){this.visual=D.createGroup(),this.selectorLine=D.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=D.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)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},A.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()),D.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),D.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},A.prototype.setStrokeColor=function(_){this.strokeColor=_,this.adjustVisual(),this.colorChanged(_)},A.prototype.setStrokeWidth=function(_){this.strokeWidth=_,this.adjustVisual()},A.prototype.setStrokeDasharray=function(_){this.strokeDasharray=_,this.adjustVisual(),this.stateChanged()},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_);var H=_;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.createVisual(),this.adjustVisual()},A.typeName="LineMarker",A.title="Line marker",A.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',A}(c),a=function(W){function A(_,H,q,B){var de=W.call(this,_,B||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return de.fonts=[],de.fontBoxes=[],de.fonts=H,de.currentFont=q,de.setCurrentFont=de.setCurrentFont.bind(de),de}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.flexGrow="2",this.fonts.forEach(function(q){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/_.fonts.length-5+"%",B.style.borderColor=q===_.currentFont?_.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){_.setCurrentFont(q,B)}),H.appendChild(B);var de=document.createElement("div");de.style.display="flex",de.style.minHeight="20px",de.style.flexGrow="2",de.style.fontFamily=q,de.style.overflow="hidden";var Ee=document.createElement("div");Ee.style.whiteSpace="nowrap",Ee.style.overflow="hidden",Ee.style.textOverflow="ellipsis",Ee.innerHTML="The quick brown fox jumps over the lazy dog",de.appendChild(Ee),B.appendChild(de),_.fontBoxes.push(B)}),H},A.prototype.setCurrentFont=function(_,H){var q=this;this.currentFont=_,this.fontBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},A}(w),y=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.color="transparent",B.padding=5,B.DEFAULT_TEXT="your text here",B.text=B.DEFAULT_TEXT,B.isMoved=!1,B.color=q.defaultColor,B.fontFamily=q.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 E("Color",q.defaultColorSet,q.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.fontFamilyPanel=new a("Font",q.defaultFontFamilies,q.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B}return Y(A,W),A.prototype.ownsTarget=function(_){if(W.prototype.ownsTarget.call(this,_)||_===this.visual||_===this.textElement||_===this.bgRectangle)return!0;var H=!1;return this.textElement.childNodes.forEach(function(q){q===_&&(H=!0)}),H},A.prototype.createVisual=function(){this.visual=D.createGroup(),this.bgRectangle=D.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=D.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(D.createTransform()),this.textElement.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.isMoved=!1,this.pointerDownPoint=_,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(_),this._state="creating")},A.prototype.renderText=function(){var _=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(H){_.textElement.appendChild(D.createTSpan(H.trim()===""?" ":H.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},A.prototype.getTextScale=function(){var _=this.textElement.getBBox(),H=1;if(_.width>0&&_.height>0){var q=(1*this.width-this.width*this.padding*2/100)/_.width,B=(1*this.height-this.height*this.padding*2/100)/_.height;H=Math.min(q,B)}return H},A.prototype.getTextPosition=function(_){var H=this.textElement.getBBox(),q=0,B=0;return H.width>0&&H.height>0&&(q=(this.width-H.width*_)/2,B=this.height/2-H.height*_/2),{x:q,y:B}},A.prototype.sizeText=function(){var _=this.textElement.getBBox(),H=this.getTextScale(),q=this.getTextPosition(H);q.y-=_.y*H,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+q.x+"px, "+q.y+"px) scale("+H+", "+H+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(q.x,q.y),this.textElement.transform.baseVal.getItem(1).setScale(H,H))},A.prototype.manipulate=function(_){W.prototype.manipulate.call(this,_),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(_.x-this.pointerDownPoint.x)>5||Math.abs(_.y-this.pointerDownPoint.y)>5)},A.prototype.resize=function(_){W.prototype.resize.call(this,_),this.isMoved=!0,this.setSize(),this.sizeText()},A.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},A.prototype.pointerUp=function(_){var H=this.state;H==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,_),this.setSize(),(H==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},A.prototype.showTextEditor=function(){var _=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(H){H.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var H=Number.parseFloat(_.textEditor.style.fontSize);_.textEditor.clientWidth>=Number.parseInt(_.textEditor.style.maxWidth)&&H>.9;)H-=.1,_.textEditor.style.fontSize=Math.max(H,.9)+"em"}),this.textEditor.addEventListener("keyup",function(H){H.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(H){if(H.clipboardData){var q=H.clipboardData.getData("text"),B=window.getSelection();if(!B.rangeCount)return!1;B.deleteFromDocument(),B.getRangeAt(0).insertNode(document.createTextNode(q)),H.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){_.textEditDivClicked(_.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},A.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var _=this.getTextScale(),H=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),q=this.textElement.getBBox(),B={x:q.width*_,y:q.height*_};H.x-=B.x/2,H.y-=B.y/2,this.textEditor.style.top=H.y+"px",this.textEditor.style.left=H.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-H.x+"px",this.textEditor.style.fontSize=Math.max(16*_,12)+"px",this.textElement.style.display="none"}},A.prototype.textEditDivClicked=function(_){this.text=_.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},A.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},A.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},A.prototype.dblClick=function(_,H){W.prototype.dblClick.call(this,_,H),this.showTextEditor()},A.prototype.setColor=function(_){this.textElement&&D.setAttributes(this.textElement,[["fill",_]]),this.color=_,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(_)},A.prototype.setFont=function(_){this.textElement&&D.setAttributes(this.textElement,[["font-family",_]]),this.fontFamily=_,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},A.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},A.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){var H=_;this.color=H.color,this.fontFamily=H.fontFamily,this.padding=H.padding,this.text=H.text,this.createVisual(),W.prototype.restoreState.call(this,_),this.setSize()},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.setSize(),this.sizeText(),this.positionTextEditor()},A.typeName="TextMarker",A.title="Text marker",A.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',A}(S),m=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.color="transparent",B.lineWidth=3,B.drawing=!1,B.pixelRatio=1,B.color=q.defaultColor,B.lineWidth=q.defaultStrokeWidth,B.pixelRatio=q.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 E("Color",q.defaultColorSet,q.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.lineWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.lineWidthPanel.onWidthChanged=B.setLineWidth,B}return Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.visual&&_!==this.drawingImage)},A.prototype.createVisual=function(){this.visual=D.createGroup(),this.drawingImage=D.createImage(),this.visual.appendChild(this.drawingImage);var _=D.createTransform();this.visual.transform.baseVal.appendItem(_),this.addMarkerVisualToContainer(this.visual)},A.prototype.pointerDown=function(_,H){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(_.x,_.y),this.drawing=!0):W.prototype.pointerDown.call(this,_,H)},A.prototype.manipulate=function(_){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(_.x,_.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,_)},A.prototype.resize=function(_){W.prototype.resize.call(this,_),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},A.prototype.pointerUp=function(_){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,_)},A.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)},A.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},A.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},A.prototype.finishCreation=function(){for(var _=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),H=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],q=H[0],B=H[1],de=H[2],Ee=H[3],Le=!1,Ie=0;Ie<this.canvasElement.height;Ie++)for(var ke=0;ke<this.canvasElement.width;ke++)_.data[Ie*this.canvasElement.width*4+4*ke+3]>0&&(Le=!0,Ie<B&&(B=Ie),ke<q&&(q=ke),Ie>Ee&&(Ee=Ie),ke>de&&(de=ke));if(Le){this.left=q/this.pixelRatio,this.top=B/this.pixelRatio,this.width=(de-q)/this.pixelRatio,this.height=(Ee-B)/this.pixelRatio;var Oe=document.createElement("canvas");Oe.width=de-q,Oe.height=Ee-B,Oe.getContext("2d").putImageData(this.canvasContext.getImageData(q,B,de-q,Ee-B),0,0),this.drawingImgUrl=Oe.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},A.prototype.setDrawingImage=function(){D.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},A.prototype.setColor=function(_){this.color=_,this.colorChanged(_)},A.prototype.setLineWidth=function(_){this.lineWidth=_},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){this.createVisual(),W.prototype.restoreState.call(this,_),this.drawingImgUrl=_.drawingImgUrl,this.setDrawingImage()},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.setDrawingImage()},A.typeName="FreehandMarker",A.title="Freehand marker",A.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',A}(S),x=function(W){function A(_,H,q){var B=W.call(this,_,q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return B.typeBoxes=[],B.currentType=H,B.setCurrentType=B.setCurrentType.bind(B),B}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2";for(var q=function(Ee){var Le="both";switch(Ee){case 0:Le="both";break;case 1:Le="start";break;case 2:Le="end";break;case 3:Le="none"}var Ie=document.createElement("div");if(Ie.style.display="flex",Ie.style.flexGrow="2",Ie.style.alignItems="center",Ie.style.justifyContent="space-between",Ie.style.padding="5px",Ie.style.borderWidth="2px",Ie.style.borderStyle="solid",Ie.style.borderColor=Le===B.currentType?B.uiStyleSettings.toolboxAccentColor:"transparent",Ie.addEventListener("click",function(){_.setCurrentType(Le,Ie)}),H.appendChild(Ie),Le==="both"||Le==="start"){var ke=document.createElement("div");ke.style.display="flex",ke.style.alignItems="center",ke.style.minHeight="20px",ke.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,ke.style.marginLeft="5px",Ie.appendChild(ke)}var Oe=document.createElement("div");Oe.style.display="flex",Oe.style.alignItems="center",Oe.style.minHeight="20px",Oe.style.flexGrow="2";var Pe=document.createElement("hr");if(Pe.style.minWidth="20px",Pe.style.border="0px",Pe.style.borderTop="3px solid "+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee"),Pe.style.flexGrow="2",Oe.appendChild(Pe),Ie.appendChild(Oe),Le==="both"||Le==="end"){var We=document.createElement("div");We.style.display="flex",We.style.alignItems="center",We.style.minHeight="20px",We.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,We.style.marginRight="5px",Ie.appendChild(We)}B.typeBoxes.push(Ie)},B=this,de=0;de<4;de++)q(de);return H},A.prototype.setCurrentType=function(_,H){var q=this;this.currentType=_,this.typeBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings!==void 0?q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},A}(w),M=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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 x("Arrow type","end"),B.arrowTypePanel.onArrowTypeChanged=B.setArrowType,B}return Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.arrow1&&_!==this.arrow2)},A.prototype.getArrowPoints=function(_,H){var q=this.arrowBaseWidth+2*this.strokeWidth,B=this.arrowBaseHeight+2*this.strokeWidth;return _-q/2+","+(H+B/2)+" "+_+","+(H-B/2)+" "+(_+q/2)+","+(H+B/2)},A.prototype.createTips=function(){this.arrow1=D.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=D.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.arrow2)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="creating"&&this.createTips()},A.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",D.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),D.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var _=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.arrow1.transform.baseVal.getItem(0);H.setRotate(_,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(H,0);var q=this.arrow2.transform.baseVal.getItem(0);q.setRotate(_+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(q,0)}},A.prototype.setArrowType=function(_){this.arrowType=_,this.adjustVisual(),this.stateChanged()},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_);var H=_;this.arrowType=H.arrowType,this.createTips(),this.adjustVisual()},A.typeName="ArrowMarker",A.title="Arrow marker",A.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',A}(h),G=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.fillColor=q.defaultFillColor,B.strokeWidth=0,B.fillPanel=new E("Color",q.defaultColorSet,q.defaultFillColor),B.fillPanel.onColorChanged=B.setFillColor,B}return Y(A,W),Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=W.prototype.getState.call(this);return _.typeName=A.typeName,_},A.typeName="CoverMarker",A.title="Cover marker",A.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',A}(p),$=function(W){function A(_,H,q,B){var de=W.call(this,_,B||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return de.opacities=[],de.opacityBoxes=[],de.opacities=H,de.currentOpacity=q,de.setCurrentOpacity=de.setCurrentOpacity.bind(de),de}return Y(A,W),A.prototype.getUi=function(){var _=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",H.style.justifyContent="space-between",this.opacities.forEach(function(q){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=q===_.currentOpacity?_.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){_.setCurrentOpacity(q,B)}),H.appendChild(B);var de=document.createElement("div");de.innerText=100*q+"%",B.appendChild(de),_.opacityBoxes.push(B)}),H},A.prototype.setCurrentOpacity=function(_,H){var q=this;this.currentOpacity=_,this.opacityBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},A}(w),re=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.setOpacity=B.setOpacity.bind(B),B.fillColor=q.defaultHighlightColor,B.strokeWidth=0,B.opacity=q.defaultHighlightOpacity,B.fillPanel=new E("Color",q.defaultColorSet,B.fillColor),B.fillPanel.onColorChanged=B.setFillColor,B.opacityPanel=new $("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return Y(A,W),A.prototype.setOpacity=function(_){this.opacity=_,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=W.prototype.getState.call(this);return _.typeName=A.typeName,_},A.typeName="HighlightMarker",A.title="Highlight marker",A.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',A}(G),z='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',U=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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=q.defaultStrokeColor,B.bgColor=q.defaultFillColor,B.fontFamily=q.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 E("Text color",q.defaultColorSet,B.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),B.colorPanel.onColorChanged=B.setColor,B.bgColorPanel=new E("Fill color",q.defaultColorSet,B.bgColor,z),B.bgColorPanel.onColorChanged=B.setBgColor,B.fontFamilyPanel=new a("Font",q.defaultFontFamilies,q.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B.tipGrip=new s,B.tipGrip.visual.transform.baseVal.appendItem(D.createTransform()),B.controlBox.appendChild(B.tipGrip.visual),B}return Y(A,W),A.prototype.ownsTarget=function(_){return W.prototype.ownsTarget.call(this,_)||this.tipGrip.ownsTarget(_)||this.tip===_},A.prototype.createTip=function(){D.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=D.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},A.prototype.pointerDown=function(_,H){this.state==="new"&&W.prototype.pointerDown.call(this,_,H),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(H)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,_,H)},A.prototype.pointerUp=function(_){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,_);else{var H=this.state==="creating";W.prototype.pointerUp.call(this,_),this.setTipPoints(H),this.positionTip()}},A.prototype.manipulate=function(_){if(this.tipMoving){var H=this.unrotatePoint(_);this.tipPosition={x:H.x-this.manipulationStartLeft,y:H.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,_)},A.prototype.setBgColor=function(_){this.bgRectangle&&this.tip&&(D.setAttributes(this.bgRectangle,[["fill",_]]),D.setAttributes(this.tip,[["fill",_]])),this.bgColor=_,this.fillColorChanged(_)},A.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},A.prototype.setTipPoints=function(_){_===void 0&&(_=!1);var H=Math.min(this.height/2,15),q=this.height/5;_&&(this.tipPosition={x:H+q/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.height/2?B<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:0},this.tipBase2Position={x:H+q,y:0}):(this.tipBase1Position={x:0,y:H},this.tipBase2Position={x:0,y:H+q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?B<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-q,y:0},this.tipBase2Position={x:this.width-H,y:0}):(this.tipBase1Position={x:this.width,y:H},this.tipBase2Position={x:this.width,y:H+q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?B<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-q,y:this.height},this.tipBase2Position={x:this.width-H,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-H-q},this.tipBase2Position={x:this.width,y:this.height-H}):B<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:this.height},this.tipBase2Position={x:H+q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-H},this.tipBase2Position={x:0,y:this.height-H-q})},A.prototype.resize=function(_){W.prototype.resize.call(this,_),this.positionTip()},A.prototype.positionTip=function(){D.setAttributes(this.tip,[["points",this.getTipPoints()]]);var _=this.tipGrip.visual.transform.baseVal.getItem(0);_.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(_,0)},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),A.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},A.prototype.getState=function(){var _=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){var H=_;this.bgColor=H.bgColor,this.tipPosition=H.tipPosition,W.prototype.restoreState.call(this,_),this.createTip(),this.setTipPoints()},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.tipPosition={x:this.tipPosition.x*_,y:this.tipPosition.y*H},this.positionTip()},A.typeName="CalloutMarker",A.title="Callout marker",A.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',A}(y),ne=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.fillColor="transparent",B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.opacity=1,B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.fillColor=q.defaultFillColor,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.setOpacity=B.setOpacity.bind(B),B.createVisual=B.createVisual.bind(B),B.strokePanel=new E("Line color",I(q.defaultColorSet,["transparent"]),q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.fillPanel=new E("Fill color",I(q.defaultColorSet,["transparent"]),B.fillColor,z),B.fillPanel.onColorChanged=B.setFillColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new C("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B.opacityPanel=new $("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.visual)},A.prototype.createVisual=function(){this.visual=D.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="new"&&(this.createVisual(),this.moveVisual(_),this._state="creating")},A.prototype.manipulate=function(_){W.prototype.manipulate.call(this,_)},A.prototype.resize=function(_){W.prototype.resize.call(this,_),this.setSize()},A.prototype.setSize=function(){W.prototype.setSize.call(this),D.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},A.prototype.pointerUp=function(_){W.prototype.pointerUp.call(this,_),this.setSize()},A.prototype.setStrokeColor=function(_){this.strokeColor=_,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(_),this.stateChanged()},A.prototype.setFillColor=function(_){this.fillColor=_,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(_),this.stateChanged()},A.prototype.setStrokeWidth=function(_){this.strokeWidth=_,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},A.prototype.setStrokeDasharray=function(_){this.strokeDasharray=_,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},A.prototype.setOpacity=function(_){this.opacity=_,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){var H=_;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,_),this.setSize()},A.prototype.scale=function(_,H){W.prototype.scale.call(this,_,H),this.setSize()},A.typeName="EllipseMarker",A.title="Ellipse marker",A.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',A}(S),fe=function(W){function A(_,H,q){return W.call(this,_,H,q)||this}return Y(A,W),Object.defineProperty(A.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.tip1&&_!==this.tip2)},A.prototype.createTips=function(){this.tip1=D.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.tip1),this.tip2=D.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.tip2)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.state==="creating"&&this.createTips()},A.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(D.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var _=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.tip1.transform.baseVal.getItem(0);H.setRotate(_,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(H,0);var q=this.tip2.transform.baseVal.getItem(0);q.setRotate(_+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(q,0)}},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=W.prototype.getState.call(this);return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_),this.createTips(),this.adjustVisual()},A.typeName="MeasurementMarker",A.title="Measurement marker",A.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',A}(h),ge=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||this;return B.strokePanel.colors=q.defaultColorSet,B.fillColor="transparent",B}return Y(A,W),Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=W.prototype.getState.call(this);return _.typeName=A.typeName,_},A.typeName="EllipseFrameMarker",A.title="Ellipse frame marker",A.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',A}(ne),be=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(A){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(A)||(this.undoStack.push(A),JSON.stringify(this.lastRedoStep)!==JSON.stringify(A)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(A){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=A)},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 A=this.undoStack.pop();return A!==void 0&&this.redoStack.push(A),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}(),Me=function(W){function A(_,H,q){var B=W.call(this,_,H,q)||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=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new E("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new C("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return Y(A,W),A.prototype.ownsTarget=function(_){return!(!W.prototype.ownsTarget.call(this,_)&&_!==this.visual&&_!==this.selectorCurve&&_!==this.visibleCurve&&!this.curveGrip.ownsTarget(_))},A.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},A.prototype.createVisual=function(){this.visual=D.createGroup(),this.selectorCurve=D.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=D.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)},A.prototype.pointerDown=function(_,H){W.prototype.pointerDown.call(this,_,H),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=_.x,this.curveY=_.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(H)&&(this.activeGrip=this.curveGrip,this._state="resize")},A.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),D.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),D.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},A.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=D.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=D.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)},A.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},A.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var _=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-_/2,this.curveY-_/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()))},A.prototype.manipulate=function(_){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+_.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+_.y-this.manipulationStartY),W.prototype.manipulate.call(this,_)},A.prototype.resize=function(_){this.activeGrip===this.curveGrip&&(this.curveX=_.x,this.curveY=_.y),W.prototype.resize.call(this,_),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},A.prototype.setStrokeColor=function(_){this.strokeColor=_,this.adjustVisual(),this.colorChanged(_)},A.prototype.setStrokeWidth=function(_){this.strokeWidth=_,this.adjustVisual()},A.prototype.setStrokeDasharray=function(_){this.strokeDasharray=_,this.adjustVisual()},A.prototype.scale=function(_,H){this.curveX=this.curveX*_,this.curveY=this.curveY*H,W.prototype.scale.call(this,_,H)},Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),A.prototype.getState=function(){var _=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return _.typeName=A.typeName,_},A.prototype.restoreState=function(_){W.prototype.restoreState.call(this,_);var H=_;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.curveX=H.curveX,this.curveY=H.curveY,this.createVisual(),this.adjustVisual()},A.typeName="CurveMarker",A.title="Curve marker",A.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',A}(c),Te=function(){function W(A,_){_===void 0&&(_=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=A,this.cancelable=_}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),De=function(W){function A(_,H,q){var B=W.call(this,_,!1)||this;return B.dataUrl=H,B.state=q,B}return Y(A,W),A}(Te),Ce=function(W){function A(_,H,q){q===void 0&&(q=!1);var B=W.call(this,_,q)||this;return B.marker=H,B}return Y(A,W),A}(Te),we=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(A,_){this[A].push(_)},W.prototype.removeEventListener=function(A,_){var H=this[A].indexOf(_);H>-1&&this[A].splice(H,1)},W}(),ve=function(){function W(A){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new d,this._isOpen=!1,this.undoRedoManager=new be,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 we,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new O(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=A,this.targetRoot=document.body,this.width=A.clientWidth,this.height=A.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[v,m,M,y,ge,ne,re,U,fe,G,h,Me]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[v,m,M,y,ne,re,U]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[v,m,M,y,re]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(A){var _=this;this._availableMarkerTypes.splice(0),A.forEach(function(H){if(typeof H=="string"){var q=_.ALL_MARKER_TYPES.find(function(B){return B.typeName===H});q!==void 0&&_._availableMarkerTypes.push(q)}else _._availableMarkerTypes.push(H)})},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(A){this._zoomLevel=A,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(),j.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var A=this;this.styles.styleSheetRoot===void 0&&P.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=P.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(_){return _(new Te(A))})},W.prototype.render=function(){return k(this,void 0,void 0,function(){var A;return V(this,function(_){switch(_.label){case 0:return this.setCurrentMarker(),(A=new F).naturalSize=this.renderAtNaturalSize,A.imageType=this.renderImageType,A.imageQuality=this.renderImageQuality,A.markersOnly=this.renderMarkersOnly,A.width=this.renderWidth,A.height=this.renderHeight,[4,A.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return _.sent(),[4,A.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,_.sent()]}})})},W.prototype.close=function(A){var _=this;if(A===void 0&&(A=!1),this.isOpen){var H=!1;A||this.eventListeners.beforeclose.forEach(function(q){var B=new Te(_,!0);q(B),B.defaultPrevented&&(H=!0)}),H||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(q){return q(new Te(_))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var A,_=[],H=0;H<arguments.length;H++)_[H]=arguments[H];(A=this._availableMarkerTypes).push.apply(A,_)},W.prototype.addRenderEventListener=function(A){this.addEventListener("render",function(_){A(_.dataUrl,_.state)})},W.prototype.removeRenderEventListener=function(A){},W.prototype.addCloseEventListener=function(A){this.addEventListener("close",function(){A()})},W.prototype.removeCloseEventListener=function(A){},W.prototype.setupResizeObserver=function(){var A=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){A.resize(A.target.clientWidth,A.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return A.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var A=1*this.target.clientWidth/this.target.clientHeight,_=this.editorCanvas.clientWidth/A>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*A:this.editorCanvas.clientWidth,H=_<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/A;this.resize(_,H)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(A,_){this._isResizing=!0;var H=A/this.imageWidth,q=_/this.imageHeight;this.imageWidth=Math.round(A),this.imageHeight=Math.round(_),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(H,q),this._isResizing=!1},W.prototype.scaleMarkers=function(A,_){var H,q=this;this._currentMarker&&this._currentMarker instanceof y?this._currentMarker.scale(A,_):(H=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(B){B!==q._currentMarker&&B.scale(A,_)}),H!==void 0&&this.setCurrentMarker(H)},W.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},W.prototype.setTopLeft=function(){var A=this.editingTarget.getBoundingClientRect(),_=this.editorCanvas.getBoundingClientRect();this.left=A.left-_.left,this.top=A.top-_.top},W.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},W.prototype.addDefs=function(){for(var A,_=[],H=0;H<arguments.length;H++)_[H]=arguments[H];this.defs=D.createDefs(),this.addDefsToImage(),(A=this.defs).append.apply(A,_)},W.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},W.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},W.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},W.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},W.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},W.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},W.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},W.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var A=document.createElement("a");A.href="https://markerjs.com/",A.target="_blank",A.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',A.title="Powered by marker.js",A.style.display="grid",A.style.alignItems="center",A.style.justifyItems="center",A.style.padding="3px",A.style.width="20px",A.style.height="20px",this.logoUI.appendChild(A),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 A=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=A+"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 R(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new L(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},W.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.removeMarker=function(A){this.markerImage.removeChild(A.container),this.markers.indexOf(A)>-1&&this.markers.splice(this.markers.indexOf(A),1),A.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(A,_){if(A==="marker"&&_!==void 0)this.createNewMarker(_);else if(A==="action")switch(_){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 A=this;if(this._currentMarker!==void 0){var _=!1;if(this.eventListeners.markerbeforedelete.forEach(function(q){var B=new Ce(A,A._currentMarker,!0);q(B),B.defaultPrevented&&(_=!0)}),!_){var H=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(q){return q(new Ce(A,H))})}}},W.prototype.clear=function(){var A=this,_=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(de){var Ee=new Ce(A,void 0,!0);de(Ee),Ee.defaultPrevented&&(_=!0)}),!_)){this.setCurrentMarker();for(var H=function(de){var Ee=q.markers[de];q.setCurrentMarker(q.markers[de]),q._currentMarker.dispose(),q.markerImage.removeChild(q._currentMarker.container),q.markers.splice(q.markers.indexOf(q._currentMarker),1),q.eventListeners.markerdelete.forEach(function(Le){return Le(new Ce(A,Ee))})},q=this,B=this.markers.length-1;B>=0;B--)H(B);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.prototype.showNotesEditor=function(){var A;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=(A=this._currentMarker.notes)!==null&&A!==void 0?A:"",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 A=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var _=this.getState(),H=this.undoRedoManager.getLastUndoStep();if(!H||H.width===_.width&&H.height===_.height){var q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(_),q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(B){return B(new Te(A))})}else this.undoRedoManager.replaceLastUndoStep(_),this.eventListeners.statechange.forEach(function(B){return B(new Te(A))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var A=this,_=this.undoRedoManager.undo();_!==void 0&&(this.restoreState(_),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(A))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var A=this,_=this.undoRedoManager.redo();_!==void 0&&(this.restoreState(_),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(A))}))},W.prototype.stepZoom=function(){var A=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=A<this.zoomSteps.length-1?this.zoomSteps[A+1]:this.zoomSteps[0]},W.prototype.panTo=function(A){this.contentDiv.scrollBy({left:this.prevPanPoint.x-A.x,top:this.prevPanPoint.y-A.y}),this.prevPanPoint=A},W.prototype.startRenderAndClose=function(){return k(this,void 0,void 0,function(){var A,_,H=this;return V(this,function(q){switch(q.label){case 0:return[4,this.render()];case 1:return A=q.sent(),_=this.getState(),this.eventListeners.render.forEach(function(B){return B(new De(H,A,_))}),this.close(!0),[2]}})})},W.prototype.getState=function(A){A===!0&&this.setCurrentMarker();var _={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(H){return _.markers.push(H.getState())}),_},W.prototype.restoreState=function(A){var _=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);A.markers.forEach(function(H){var q=_._availableMarkerTypes.find(function(de){return de.typeName===H.typeName});if(q!==void 0){var B=_.addNewMarker(q);B.restoreState(H),_.markers.push(B)}}),A.width&&A.height&&(A.width!==this.imageWidth||A.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/A.width,this.imageHeight/A.height),this.eventListeners.restorestate.forEach(function(H){return H(new Te(_))})},W.prototype.addNewMarker=function(A){var _=D.createGroup();return this.markerImage.appendChild(_),new A(_,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(A){var _,H=this;(_=typeof A=="string"?this._availableMarkerTypes.find(function(q){return q.typeName===A}):A)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(_),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(_.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(q){return q(new Ce(H,H._currentMarker))}))},W.prototype.markerCreated=function(A){var _=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(A),this.setCurrentMarker(A),A instanceof m&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(m):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(H){return H(new Ce(_,_._currentMarker))})},W.prototype.colorChanged=function(A){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=A,this.settings.defaultStrokeColor=A)},W.prototype.fillColorChanged=function(A){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=A)},W.prototype.markerStateChanged=function(A){var _=this;this.eventListeners.markerchange.forEach(function(H){return H(new Ce(_,A))})},W.prototype.setCurrentMarker=function(A){var _=this;this._currentMarker!==A&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(H){return H(new Ce(_,_._currentMarker))})),this._currentMarker=A,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(H){return H(new Ce(_,_._currentMarker))}))},W.prototype.onPointerDown=function(A){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||A.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var _=this.markers.find(function(H){return H.ownsTarget(A.target)});_!==void 0?(this.setCurrentMarker(_),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(A.clientX,A.clientY),A.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:A.clientX,y:A.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(A.clientX,A.clientY))},W.prototype.onDblClick=function(A){if(this._isFocused||this.focus(),this.mode==="select"){var _=this.markers.find(function(H){return H.ownsTarget(A.target)});_!==void 0&&_!==this._currentMarker&&this.setCurrentMarker(_),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(A.clientX,A.clientY),A.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(A){this.touchPoints!==1&&A.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||A.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(A.clientX,A.clientY)):this.zoomLevel>1&&this.panTo({x:A.clientX,y:A.clientY}))},W.prototype.onPointerUp=function(A){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(A.clientX,A.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(A){this._currentMarker===void 0||this.notesArea!==void 0||A.key!=="Delete"&&A.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(A,_){var H=this.markerImage.getBoundingClientRect();return{x:(A-H.left)/this.zoomLevel,y:(_-H.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var A=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=A+"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(A){j.addKey(A)},W.prototype.addEventListener=function(A,_){this.eventListeners.addEventListener(A,_)},W.prototype.removeEventListener=function(A,_){this.eventListeners.removeEventListener(A,_)},W.prototype.renderState=function(A){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(A),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var A=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(_){return _(new Te(A))}))},W.prototype.blur=function(){var A=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(_){return _(new Te(A))}))},W.instanceCounter=0,W}()},UUDw:function(ht,Ze,le){ht.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return ue});var ue=function(k){var V=document.createElement("textarea");return V.value=k,V.value}},"VrN/":function(ht,Ze,le){(function(ue,Y){ht.exports=Y()})(this,function(){"use strict";var ue=navigator.userAgent,Y=navigator.platform,k=/gecko\/\d/i.test(ue),V=/MSIE \d/.test(ue),I=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ue),D=/Edge\/(\d+)/.exec(ue),j=V||I||D,F=j&&(V?document.documentMode||6:+(D||I)[1]),P=!D&&/WebKit\//.test(ue),O=P&&/Qt\/\d+\.\d+/.test(ue),g=!D&&/Chrome\//.test(ue),T=/Opera\//.test(ue),R=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ue),w=/PhantomJS/.test(ue),E=!D&&/AppleWebKit/.test(ue)&&/Mobile\/\w+/.test(ue),u=/Android/.test(ue),o=E||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ue),s=E||/Mac/.test(Y),l=/\bCrOS\b/.test(ue),S=/win/i.test(Y),p=T&&ue.match(/Version\/(\d*\.\d*)/);p&&(p=Number(p[1])),p&&p>=15&&(T=!1,P=!0);var f=s&&(O||T&&(p==null||p<12.11)),C=k||j&&F>=9;function v(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var d=function(e,t){var i=e.className,r=v(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 h(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 b=0;b<t.length;++b)n.appendChild(t[b]);return n}function y(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var m;document.createRange?m=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:m=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function x(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function M(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;v(t).test(i)||(e.className+=(i?" ":"")+t)}function $(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!v(i[r]).test(t)&&(t+=" "+i[r]);return t}var re=function(e){e.select()};E?re=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:j&&(re=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function U(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function ne(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var b=r||0,N=n||0;;){var K=e.indexOf(" ",b);if(K<0||K>=t)return N+(t-b);N+=K-b,N+=i-N%i,b=K+1}}var fe=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};fe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},fe.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ge(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var be=50,Me={toString:function(){return"CodeMirror.Pass"}},Te={scroll:!1},De={origin:"*mouse"},Ce={origin:"+move"};function we(e,t,i){for(var r=0,n=0;;){var b=e.indexOf(" ",r);b==-1&&(b=e.length);var N=b-r;if(b==e.length||n+N>=t)return r+Math.min(N,t-n);if(n+=b-r,n+=i-n%i,r=b+1,n>=t)return r}}var ve=[""];function W(e){for(;ve.length<=e;)ve.push(A(ve)+" ");return ve[e]}function A(e){return e[e.length-1]}function _(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function H(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function q(){}function B(e,t){var i;return Object.create?i=Object.create(e):(q.prototype=e,i=new q),t&&U(t,i),i}var de=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ee(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||de.test(e))}function Le(e,t){return t?t.source.indexOf("\\w")>-1&&Ee(e)?!0:t.test(e):Ee(e)}function Ie(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ke=/[\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 Oe(e){return e.charCodeAt(0)>=768&&ke.test(e)}function Pe(e,t,i){for(;(i<0?t>0:t<e.length)&&Oe(e.charAt(t));)t+=i;return t}function We(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,b=r<0?Math.ceil(n):Math.floor(n);if(b==t)return e(b)?t:i;e(b)?i=b:t=b+r}}function He(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,b=0;b<e.length;++b){var N=e[b];(N.from<i&&N.to>t||t==i&&N.to==t)&&(r(Math.max(N.from,t),Math.min(N.to,i),N.level==1?"rtl":"ltr",b),n=!0)}n||r(t,i,"ltr")}var Ve=null;function Xe(e,t,i){var r;Ve=null;for(var n=0;n<e.length;++n){var b=e[n];if(b.from<t&&b.to>t)return n;b.to==t&&(b.from!=b.to&&i=="before"?r=n:Ve=n),b.from==t&&(b.from!=b.to&&i!="before"?r=n:Ve=n)}return r!=null?r:Ve}var nt=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(ee){return ee<=247?e.charAt(ee):1424<=ee&&ee<=1524?"R":1536<=ee&&ee<=1785?t.charAt(ee-1536):1774<=ee&&ee<=2220?"r":8192<=ee&&ee<=8203?"w":ee==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,b=/[LRr]/,N=/[Lb1n]/,K=/[1n]/;function X(ee,ce,pe){this.level=ee,this.from=ce,this.to=pe}return function(ee,ce){var pe=ce=="ltr"?"L":"R";if(ee.length==0||ce=="ltr"&&!r.test(ee))return!1;for(var Se=ee.length,xe=[],Re=0;Re<Se;++Re)xe.push(i(ee.charCodeAt(Re)));for(var Ne=0,je=pe;Ne<Se;++Ne){var Ge=xe[Ne];Ge=="m"?xe[Ne]=je:je=Ge}for(var Je=0,ze=pe;Je<Se;++Je){var tt=xe[Je];tt=="1"&&ze=="r"?xe[Je]="n":b.test(tt)&&(ze=tt,tt=="r"&&(xe[Je]="R"))}for(var dt=1,lt=xe[0];dt<Se-1;++dt){var Et=xe[dt];Et=="+"&<=="1"&&xe[dt+1]=="1"?xe[dt]="1":Et==","&<==xe[dt+1]&&(lt=="1"||lt=="n")&&(xe[dt]=lt),lt=Et}for(var Pt=0;Pt<Se;++Pt){var Zt=xe[Pt];if(Zt==",")xe[Pt]="N";else if(Zt=="%"){var Bt=void 0;for(Bt=Pt+1;Bt<Se&&xe[Bt]=="%";++Bt);for(var yr=Pt&&xe[Pt-1]=="!"||Bt<Se&&xe[Bt]=="1"?"1":"N",pr=Pt;pr<Bt;++pr)xe[pr]=yr;Pt=Bt-1}}for(var Ht=0,mr=pe;Ht<Se;++Ht){var tr=xe[Ht];mr=="L"&&tr=="1"?xe[Ht]="L":b.test(tr)&&(mr=tr)}for(var Vt=0;Vt<Se;++Vt)if(n.test(xe[Vt])){var Gt=void 0;for(Gt=Vt+1;Gt<Se&&n.test(xe[Gt]);++Gt);for(var Ft=(Vt?xe[Vt-1]:pe)=="L",gr=(Gt<Se?xe[Gt]:pe)=="L",Gi=Ft==gr?Ft?"L":"R":pe,ei=Vt;ei<Gt;++ei)xe[ei]=Gi;Vt=Gt-1}for(var ar=[],Nr,Jt=0;Jt<Se;)if(N.test(xe[Jt])){var Va=Jt;for(++Jt;Jt<Se&&N.test(xe[Jt]);++Jt);ar.push(new X(0,Va,Jt))}else{var zr=Jt,vi=ar.length,yi=ce=="rtl"?1:0;for(++Jt;Jt<Se&&xe[Jt]!="L";++Jt);for(var lr=zr;lr<Jt;)if(K.test(xe[lr])){zr<lr&&(ar.splice(vi,0,new X(1,zr,lr)),vi+=yi);var zi=lr;for(++lr;lr<Jt&&K.test(xe[lr]);++lr);ar.splice(vi,0,new X(2,zi,lr)),vi+=yi,zr=lr}else++lr;zr<Jt&&ar.splice(vi,0,new X(1,zr,Jt))}return ce=="ltr"&&(ar[0].level==1&&(Nr=ee.match(/^\s+/))&&(ar[0].from=Nr[0].length,ar.unshift(new X(0,0,Nr[0].length))),A(ar).level==1&&(Nr=ee.match(/\s+$/))&&(A(ar).to-=Nr[0].length,ar.push(new X(0,Se-Nr[0].length,Se)))),ce=="rtl"?ar.reverse():ar}}();function Ke(e,t){var i=e.order;return i==null&&(i=e.order=nt(e.text,t)),i}var Ye=[],Ae=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Ye).concat(i)}};function rt(e,t){return e._handlers&&e._handlers[t]||Ye}function Qe(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var b=ge(n,i);b>-1&&(r[t]=n.slice(0,b).concat(n.slice(b+1)))}}}function ae(e,t){var i=rt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function J(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),ae(e,i||t.type,e,t),se(t)||t.codemirrorIgnore}function Z(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ge(i,t[r])==-1&&i.push(t[r])}function ie(e,t){return rt(e,t).length>0}function oe(e){e.prototype.on=function(t,i){Ae(this,t,i)},e.prototype.off=function(t,i){Qe(this,t,i)}}function Q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function he(e){Q(e),te(e)}function me(e){return e.target||e.srcElement}function ye(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),s&&e.ctrlKey&&t==1&&(t=3),t}var _e=function(){if(j&&F<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Fe;function qe(e){if(Fe==null){var t=a("span","\u200B");h(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Fe=t.offsetWidth<=1&&t.offsetHeight>2&&!(j&&F<8))}var i=Fe?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var et;function xt(e){if(et!=null)return et;var t=h(e,document.createTextNode("A\u062EA")),i=m(t,0,1).getBoundingClientRect(),r=m(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:et=r.right-i.right<3}var ot=`
|
|
|
|
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 b=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=b.indexOf("\r");N!=-1?(i.push(b.slice(0,N)),t+=N+1):(i.push(b),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},it=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},Lt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),ct=null;function pt(e){if(ct!=null)return ct;var t=h(e,a("span","x")),i=t.getBoundingClientRect(),r=m(t,0,1).getBoundingClientRect();return ct=Math.abs(i.left-r.left)>1}var gt={},st={};function Xt(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),gt[e]=t}function Nt(e,t){st[e]=t}function Ut(e){if(typeof e=="string"&&st.hasOwnProperty(e))e=st[e];else if(e&&typeof e.name=="string"&&st.hasOwnProperty(e.name)){var t=st[e.name];typeof t=="string"&&(t={name:t}),e=B(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ut("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ut("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function rr(e,t){t=Ut(t);var i=gt[t.name];if(!i)return rr(e,"text/plain");var r=i(e,t);if(ur.hasOwnProperty(t.name)){var n=ur[t.name];for(var b in n){if(!n.hasOwnProperty(b))continue;r.hasOwnProperty(b)&&(r["_"+b]=r[b]),r[b]=n[b]}}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 ur={};function zt(e,t){var i=ur.hasOwnProperty(e)?ur[e]:ur[e]={};U(t,i)}function Qt(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 Br(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 ti(e,t,i){return e.startState?e.startState(t,i):!0}var Mt=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};Mt.prototype.eol=function(){return this.pos>=this.string.length},Mt.prototype.sol=function(){return this.pos==this.lineStart},Mt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Mt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Mt.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},Mt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Mt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Mt.prototype.skipToEnd=function(){this.pos=this.string.length},Mt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Mt.prototype.backUp=function(e){this.pos-=e},Mt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ne(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},Mt.prototype.indentation=function(){return ne(this.string,null,this.tabSize)-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},Mt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(N){return i?N.toLowerCase():N},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var b=this.string.slice(this.pos).match(e);return b&&b.index>0?null:(b&&t!==!1&&(this.pos+=b[0].length),b)}},Mt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Mt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Mt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Mt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function $e(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],b=n.chunkSize();if(t<b){i=n;break}t-=b}return i.lines[t]}function wt(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(b){var N=b.text;n==i.line&&(N=N.slice(0,i.ch)),n==t.line&&(N=N.slice(t.ch)),r.push(N),++n}),r}function qt(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function bt(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function yt(e){if(e.parent==null)return null;for(var t=e.parent,i=ge(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function _t(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],b=n.height;if(t<b){e=n;continue e}t-=b,i+=n.chunkSize()}return i}while(!e.lines);for(var N=0;N<e.lines.length;++N){var K=e.lines[N],X=K.height;if(t<X)break;t-=X}return i+N}function br(e,t){return t>=e.first&&t<e.first+e.size}function Wt(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Be(e,t,i){if(i===void 0&&(i=null),!(this instanceof Be))return new Be(e,t,i);this.line=e,this.ch=t,this.sticky=i}function ft(e,t){return e.line-t.line||e.ch-t.ch}function ri(e,t){return e.sticky==t.sticky&&ft(e,t)==0}function bi(e){return Be(e.line,e.ch)}function xi(e,t){return ft(e,t)<0?t:e}function ii(e,t){return ft(e,t)<0?e:t}function Ei(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function vt(e,t){if(t.line<e.first)return Be(e.first,0);var i=e.first+e.size-1;return t.line>i?Be(i,$e(e,i).text.length):Ln(t,$e(e,t.line).text.length)}function Ln(e,t){var i=e.ch;return i==null||i>t?Be(e.line,t):i<0?Be(e.line,0):e}function Ue(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=vt(e,t[r]);return i}var Si=function(e,t){this.state=e,this.lookAhead=t},Tr=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};Tr.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Tr.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}},Tr.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Tr.fromSaved=function(e,t,i){return t instanceof Si?new Tr(e,Qt(e.mode,t.state),i,t.lookAhead):new Tr(e,Qt(e.mode,t),i)},Tr.prototype.save=function(e){var t=e!==!1?Qt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Si(t,this.maxLookAhead):t};function Ki(e,t,i,r){var n=[e.state.modeGen],b={};Lr(e,t.text,e.doc.mode,i,function(ee,ce){return n.push(ee,ce)},b,r);for(var N=i.state,K=function(ee){i.baseTokens=n;var ce=e.state.overlays[ee],pe=1,Se=0;i.state=!0,Lr(e,t.text,ce.mode,i,function(xe,Re){for(var Ne=pe;Se<xe;){var je=n[pe];je>xe&&n.splice(pe,1,xe,n[pe+1],je),pe+=2,Se=Math.min(xe,je)}if(!Re)return;if(ce.opaque)n.splice(Ne,pe-Ne,xe,"overlay "+Re),pe=Ne+2;else for(;Ne<pe;Ne+=2){var Ge=n[Ne+1];n[Ne+1]=(Ge?Ge+" ":"")+"overlay "+Re}},b),i.state=N,i.baseTokens=null,i.baseTokenPos=1},X=0;X<e.state.overlays.length;++X)K(X);return{styles:n,classes:b.bgClass||b.textClass?b:null}}function ni(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=wr(e,yt(t)),n=t.text.length>e.options.maxHighlightLength&&Qt(e.doc.mode,r.state),b=Ki(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=b.styles,b.classes?t.styleClasses=b.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 wr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Tr(r,!0,t);var b=kn(e,t,i),N=b>r.first&&$e(r,b-1).stateAfter,K=N?Tr.fromSaved(r,N,b):new Tr(r,ti(r.mode),b);return r.iter(b,t,function(X){Vi(e,X.text,K);var ee=K.line;X.stateAfter=ee==t-1||ee%5==0||ee>=n.viewFrom&&ee<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function Vi(e,t,i,r){var n=e.doc.mode,b=new Mt(t,e.options.tabSize,i);for(b.start=b.pos=r||0,t==""&&Xi(n,i.state);!b.eol();)Ar(n,b,i.state),b.start=b.pos}function Xi(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=Br(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function Ar(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=Br(e,i).mode);var b=e.token(t,i);if(t.pos>t.start)return b}throw new Error("Mode "+e.name+" failed to advance stream.")}var Yi=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function _n(e,t,i,r){var n=e.doc,b=n.mode,N;t=vt(n,t);var K=$e(n,t.line),X=wr(e,t.line,i),ee=new Mt(K.text,e.options.tabSize,X),ce;for(r&&(ce=[]);(r||ee.pos<t.ch)&&!ee.eol();)ee.start=ee.pos,N=Ar(b,ee,X.state),r&&ce.push(new Yi(ee,N,Qt(n.mode,X.state)));return r?ce:new Yi(ee,N,X.state)}function $i(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function Lr(e,t,i,r,n,b,N){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var X=0,ee=null,ce=new Mt(t,e.options.tabSize,r),pe,Se=e.options.addModeClass&&[null];for(t==""&&$i(Xi(i,r.state),b);!ce.eol();){if(ce.pos>e.options.maxHighlightLength?(K=!1,N&&Vi(e,t,r,ce.pos),ce.pos=t.length,pe=null):pe=$i(Ar(i,ce,r.state,Se),b),Se){var xe=Se[0].name;xe&&(pe="m-"+(pe?xe+" "+pe:xe))}if(!K||ee!=pe){for(;X<ce.start;)X=Math.min(ce.start,X+5e3),n(X,ee);ee=pe}ce.start=ce.pos}for(;X<ce.pos;){var Re=Math.min(ce.pos,X+5e3);n(Re,ee),X=Re}}function kn(e,t,i){for(var r,n,b=e.doc,N=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>N;--K){if(K<=b.first)return b.first;var X=$e(b,K-1),ee=X.stateAfter;if(ee&&(!i||K+(ee instanceof Si?ee.lookAhead:0)<=b.modeFrontier))return K;var ce=ne(X.text,null,e.options.tabSize);(n==null||r>ce)&&(n=K-1,r=ce)}return n}function aa(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=$e(e,r).stateAfter;if(n&&(!(n instanceof Si)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Zi=!1,or=!1;function Kr(){Zi=!0}function oa(){or=!0}function ai(e,t,i){this.marker=e,this.from=t,this.to=i}function _r(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Ji(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function sa(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Dn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var b=e[n],N=b.marker,K=b.from==null||(N.inclusiveLeft?b.from<=t:b.from<t);if(K||b.from==t&&N.type=="bookmark"&&(!i||!b.marker.insertLeft)){var X=b.to==null||(N.inclusiveRight?b.to>=t:b.to>t);(r||(r=[])).push(new ai(N,b.from,X?null:b.to))}}return r}function Rn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var b=e[n],N=b.marker,K=b.to==null||(N.inclusiveRight?b.to>=t:b.to>t);if(K||b.from==t&&N.type=="bookmark"&&(!i||b.marker.insertLeft)){var X=b.from==null||(N.inclusiveLeft?b.from<=t:b.from<t);(r||(r=[])).push(new ai(N,X?null:b.from-t,b.to==null?null:b.to-t))}}return r}function Ti(e,t){if(t.full)return null;var i=br(e,t.from.line)&&$e(e,t.from.line).markedSpans,r=br(e,t.to.line)&&$e(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,b=t.to.ch,N=ft(t.from,t.to)==0,K=Dn(i,n,N),X=Rn(r,b,N),ee=t.text.length==1,ce=A(t.text).length+(ee?n:0);if(K)for(var pe=0;pe<K.length;++pe){var Se=K[pe];if(Se.to==null){var xe=_r(X,Se.marker);xe?ee&&(Se.to=xe.to==null?null:xe.to+ce):Se.to=n}}if(X)for(var Re=0;Re<X.length;++Re){var Ne=X[Re];if(Ne.to!=null&&(Ne.to+=ce),Ne.from==null){var je=_r(K,Ne.marker);je||(Ne.from=ce,ee&&(K||(K=[])).push(Ne))}else Ne.from+=ce,ee&&(K||(K=[])).push(Ne)}K&&(K=On(K)),X&&X!=K&&(X=On(X));var Ge=[K];if(!ee){var Je=t.text.length-2,ze;if(Je>0&&K)for(var tt=0;tt<K.length;++tt)K[tt].to==null&&(ze||(ze=[])).push(new ai(K[tt].marker,null,null));for(var dt=0;dt<Je;++dt)Ge.push(ze);Ge.push(X)}return Ge}function On(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Pn(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(xe){if(xe.markedSpans)for(var Re=0;Re<xe.markedSpans.length;++Re){var Ne=xe.markedSpans[Re].marker;Ne.readOnly&&(!r||ge(r,Ne)==-1)&&(r||(r=[])).push(Ne)}}),!r)return null;for(var n=[{from:t,to:i}],b=0;b<r.length;++b)for(var N=r[b],K=N.find(0),X=0;X<n.length;++X){var ee=n[X];if(ft(ee.to,K.from)<0||ft(ee.from,K.to)>0)continue;var ce=[X,1],pe=ft(ee.from,K.from),Se=ft(ee.to,K.to);(pe<0||!N.inclusiveLeft&&!pe)&&ce.push({from:ee.from,to:K.from}),(Se>0||!N.inclusiveRight&&!Se)&&ce.push({from:K.to,to:ee.to}),n.splice.apply(n,ce),X+=ce.length-3}return n}function la(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function Ci(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function oi(e){return e.inclusiveLeft?-1:0}function si(e){return e.inclusiveRight?1:0}function wi(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),b=ft(r.from,n.from)||oi(e)-oi(t);if(b)return-b;var N=ft(r.to,n.to)||si(e)-si(t);return N||t.id-e.id}function Fr(e,t){var i=or&&e.markedSpans,r;if(i)for(var n=void 0,b=0;b<i.length;++b)n=i[b],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||wi(r,n.marker)<0)&&(r=n.marker);return r}function Ur(e){return Fr(e,!0)}function jr(e){return Fr(e,!1)}function Ai(e,t){var i=or&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var b=i[n];b.marker.collapsed&&(b.from==null||b.from<t)&&(b.to==null||b.to>t)&&(!r||wi(r,b.marker)<0)&&(r=b.marker)}return r}function Mn(e,t,i,r,n){var b=$e(e,t),N=or&&b.markedSpans;if(N)for(var K=0;K<N.length;++K){var X=N[K];if(!X.marker.collapsed)continue;var ee=X.marker.find(0),ce=ft(ee.from,i)||oi(X.marker)-oi(n),pe=ft(ee.to,r)||si(X.marker)-si(n);if(ce>=0&&pe<=0||ce<=0&&pe>=0)continue;if(ce<=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?ft(ee.to,i)>=0:ft(ee.to,i)>0)||ce>=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?ft(ee.from,r)<=0:ft(ee.from,r)<0))return!0}}function xr(e){for(var t;t=Ur(e);)e=t.find(-1,!0).line;return e}function In(e){for(var t;t=jr(e);)e=t.find(1,!0).line;return e}function Li(e){for(var t,i;t=jr(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Qi(e,t){var i=$e(e,t),r=xr(i);return i==r?t:yt(r)}function Vr(e,t){if(t>e.lastLine())return t;var i=$e(e,t),r;if(!Pr(e,i))return t;for(;r=jr(i);)i=r.find(1,!0).line;return yt(i)+1}function Pr(e,t){var i=or&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&qi(e,t,r))return!0}}function qi(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return qi(e,r.line,_r(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,b=0;b<t.markedSpans.length;++b)if(n=t.markedSpans[b],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&qi(e,t,n))return!0}function kr(e){e=xr(e);for(var t=0,i=e.parent,r=0;r<i.lines.length;++r){var n=i.lines[r];if(n==e)break;t+=n.height}for(var b=i.parent;b;i=b,b=i.parent)for(var N=0;N<b.children.length;++N){var K=b.children[N];if(K==i)break;t+=K.height}return t}function en(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=Ur(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=jr(r);){var b=i.find(0,!0);t-=r.text.length-b.from.ch,r=b.to.line,t+=r.text.length-b.to.ch}return t}function Nn(e){var t=e.display,i=e.doc;t.maxLine=$e(i,i.first),t.maxLineLength=en(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=en(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var li=function(e,t,i){this.text=e,Ci(this,t),this.height=i?i(this):1};li.prototype.lineNo=function(){return yt(this)},oe(li);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),la(e),Ci(e,i);var n=r?r(e):1;n!=e.height&&bt(e,n)}function at(e){e.parent=null,la(e)}var mt={},ut={};function St(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?ut:mt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function At(e,t){var i=y("span",null,null,P?"padding-right: .1px":null),r={pre:y("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 b=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=Ct,xt(e.display.measure)&&(N=Ke(b,e.doc.direction))&&(r.addToken=hr(r.addToken,N)),r.map=[];var K=t!=e.display.externalMeasured&&yt(b);Wr(b,r,ni(e,b,K)),b.styleClasses&&(b.styleClasses.bgClass&&(r.bgClass=$(b.styleClasses.bgClass,r.bgClass||"")),b.styleClasses.textClass&&(r.textClass=$(b.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(qe(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(P){var X=r.content.lastChild;(/\bcm-tab\b/.test(X.className)||X.querySelector&&X.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=$(r.pre.className,r.textClass||"")),r}function Ot(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 Ct(e,t,i,r,n,b,N){if(!t)return;var K=e.splitSpaces?Kt(t,e.trailingSpace):t,X=e.cm.state.specialChars,ee=!1,ce;if(!X.test(t))e.col+=t.length,ce=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,ce),j&&F<9&&(ee=!0),e.pos+=t.length;else{ce=document.createDocumentFragment();for(var pe=0;;){X.lastIndex=pe;var Se=X.exec(t),xe=Se?Se.index-pe:t.length-pe;if(xe){var Re=document.createTextNode(K.slice(pe,pe+xe));j&&F<9?ce.appendChild(a("span",[Re])):ce.appendChild(Re),e.map.push(e.pos,e.pos+xe,Re),e.col+=xe,e.pos+=xe}if(!Se)break;pe+=xe+1;var Ne=void 0;if(Se[0]==" "){var je=e.cm.options.tabSize,Ge=je-e.col%je;Ne=ce.appendChild(a("span",W(Ge),"cm-tab")),Ne.setAttribute("role","presentation"),Ne.setAttribute("cm-text"," "),e.col+=Ge}else Se[0]=="\r"||Se[0]==`
|
|
`?(Ne=ce.appendChild(a("span",Se[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ne.setAttribute("cm-text",Se[0]),e.col+=1):(Ne=e.cm.options.specialCharPlaceholder(Se[0]),Ne.setAttribute("cm-text",Se[0]),j&&F<9?ce.appendChild(a("span",[Ne])):ce.appendChild(Ne),e.col+=1);e.map.push(e.pos,e.pos+1,Ne),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||ee||b||N){var Je=i||"";r&&(Je+=r),n&&(Je+=n);var ze=a("span",[ce],Je,b);if(N)for(var tt in N)N.hasOwnProperty(tt)&&tt!="style"&&tt!="class"&&ze.setAttribute(tt,N[tt]);return e.content.appendChild(ze)}e.content.appendChild(ce)}function Kt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var b=e.charAt(n);b==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(b="\xA0"),r+=b,i=b==" "}return r}function hr(e,t){return function(i,r,n,b,N,K,X){n=n?n+" cm-force-border":"cm-force-border";for(var ee=i.pos,ce=ee+r.length;;){for(var pe=void 0,Se=0;Se<t.length&&!(pe=t[Se],pe.to>ee&&pe.from<=ee);Se++);if(pe.to>=ce)return e(i,r,n,b,N,K,X);e(i,r.slice(0,pe.to-ee),n,b,null,K,X),b=null,r=r.slice(pe.to-ee),ee=pe.to}}}function Tt(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 Wr(e,t,i){var r=e.markedSpans,n=e.text,b=0;if(!r){for(var N=1;N<i.length;N+=2)t.addToken(t,n.slice(b,b=i[N]),St(i[N+1],t.cm.options));return}for(var K=n.length,X=0,ee=1,ce="",pe,Se,xe=0,Re,Ne,je,Ge,Je;;){if(xe==X){Re=Ne=je=Se="",Je=null,Ge=null,xe=Infinity;for(var ze=[],tt=void 0,dt=0;dt<r.length;++dt){var lt=r[dt],Et=lt.marker;if(Et.type=="bookmark"&<.from==X&&Et.widgetNode)ze.push(Et);else if(lt.from<=X&&(lt.to==null||lt.to>X||Et.collapsed&<.to==X&<.from==X)){if(lt.to!=null&<.to!=X&&xe>lt.to&&(xe=lt.to,Ne=""),Et.className&&(Re+=" "+Et.className),Et.css&&(Se=(Se?Se+";":"")+Et.css),Et.startStyle&<.from==X&&(je+=" "+Et.startStyle),Et.endStyle&<.to==xe&&(tt||(tt=[])).push(Et.endStyle,lt.to),Et.title&&((Je||(Je={})).title=Et.title),Et.attributes)for(var Pt in Et.attributes)(Je||(Je={}))[Pt]=Et.attributes[Pt];Et.collapsed&&(!Ge||wi(Ge.marker,Et)<0)&&(Ge=lt)}else lt.from>X&&xe>lt.from&&(xe=lt.from)}if(tt)for(var Zt=0;Zt<tt.length;Zt+=2)tt[Zt+1]==xe&&(Ne+=" "+tt[Zt]);if(!Ge||Ge.from==X)for(var Bt=0;Bt<ze.length;++Bt)Tt(t,0,ze[Bt]);if(Ge&&(Ge.from||0)==X){if(Tt(t,(Ge.to==null?K+1:Ge.to)-X,Ge.marker,Ge.from==null),Ge.to==null)return;Ge.to==X&&(Ge=!1)}}if(X>=K)break;for(var yr=Math.min(K,xe);;){if(ce){var pr=X+ce.length;if(!Ge){var Ht=pr>yr?ce.slice(0,yr-X):ce;t.addToken(t,Ht,pe?pe+Re:Re,je,X+Ht.length==xe?Ne:"",Se,Je)}if(pr>=yr){ce=ce.slice(yr-X),X=yr;break}X=pr,je=""}ce=n.slice(b,b=i[ee++]),pe=St(i[ee++],t.cm.options)}}}function kt(e,t,i){this.line=t,this.rest=Li(t),this.size=this.rest?yt(A(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Pr(e,t)}function dr(e,t,i){for(var r=[],n,b=t;b<i;b=n){var N=new kt(e.doc,$e(e.doc,b),b);n=b+N.size,r.push(N)}return r}var ir=null;function Cr(e){ir?ir.ops.push(e):e.ownsGroup=ir={ops:[e],delayedCallbacks:[]}}function Ds(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function Rs(e,t){var i=e.ownsGroup;if(!i)return;try{Ds(i)}finally{ir=null,t(i)}}var tn=null;function er(e,t){var i=rt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;ir?n=ir.delayedCallbacks:tn?n=tn:(n=tn=[],setTimeout(Os,0));for(var b=function(K){n.push(function(){return i[K].apply(null,r)})},N=0;N<i.length;++N)b(N)}function Os(){var e=tn;tn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var b=t.changes[n];b=="text"?Ms(e,t):b=="gutter"?Za(e,t,i,r):b=="class"?ha(e,t):b=="widget"&&Is(e,t,r)}t.changes=null}function rn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),j&&F<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=rn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):At(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(e,t),t.line.wrapClass?rn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=rn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var b=t.line.gutterMarkers;if(e.options.lineNumbers||b){var N=rn(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),N.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!b||!b["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",Wt(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),b)for(var X=0;X<e.display.gutterSpecs.length;++X){var ee=e.display.gutterSpecs[X].className,ce=b.hasOwnProperty(ee)&&b[ee];ce&&K.appendChild(a("div",[ce],"CodeMirror-gutter-elt","left: "+r.gutterLeft[ee]+"px; width: "+r.gutterWidth[ee]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=v("CodeMirror-linewidget"),n=t.node.firstChild,b=void 0;n;n=b)b=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Ja(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ha(e,t),Za(e,t,i,r),Ja(e,t,r),t.node}function Ja(e,t,i){if(Qa(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Qa(e,t.rest[r],t,i,!1)}function Qa(e,t,i,r,n){if(!t.widgets)return;for(var b=rn(i),N=0,K=t.widgets;N<K.length;++N){var X=K[N],ee=a("div",[X.node],"CodeMirror-linewidget"+(X.className?" "+X.className:""));X.handleMouseEvents||ee.setAttribute("cm-ignore-events","true"),Bs(X,ee,i,r),e.display.input.setUneditable(ee),n&&X.above?b.insertBefore(ee,i.gutter||i.text):b.appendChild(ee),er(X,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function nn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!x(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),h(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function Hr(e,t){for(var i=me(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Bn(e){return e.lineSpace.offsetTop}function da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=h(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Mr(e){return be-e.display.nativeBarWidth}function ui(e){return e.display.scroller.clientWidth-Mr(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-Mr(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&ui(e);if(!t.measure.heights||r&&t.measure.width!=n){var b=t.measure.heights=[];if(r){t.measure.width=n;for(var N=t.text.firstChild.getClientRects(),K=0;K<N.length-1;K++){var X=N[K],ee=N[K+1];Math.abs(X.bottom-ee.bottom)>2&&b.push((X.bottom+ee.top)/2-i.top)}}b.push(i.bottom-i.top)}}function eo(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(yt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=xr(t);var i=yt(t),r=e.display.externalMeasured=new kt(e.doc,t,i);r.lineN=i;var n=r.built=At(e,r);return r.text=n.pre,h(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return Ir(e,_i(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[ci(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function _i(e,t){var i=yt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function Ir(e,t,i,r,n){t.before&&(i=-1);var b=i+(r||""),N;return t.cache.hasOwnProperty(b)?N=t.cache[b]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),N=Ws(e,t,i,r),N.bogus||(t.cache[b]=N)),{left:N.left,right:N.right,top:n?N.rtop:N.top,bottom:n?N.rbottom:N.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,b,N,K,X,ee=0;ee<e.length;ee+=3)if(K=e[ee],X=e[ee+1],t<K?(n=0,b=1,N="left"):t<X?(n=t-K,b=n+1):(ee==e.length-3||t==X&&e[ee+3]>t)&&(b=X-K,n=b-1,t>=X&&(N="right")),n!=null){if(r=e[ee+2],K==X&&i==(r.insertLeft?"left":"right")&&(N=i),i=="left"&&n==0)for(;ee&&e[ee-2]==e[ee-3]&&e[ee-1].insertLeft;)r=e[(ee-=3)+2],N="left";if(i=="right"&&n==X-K)for(;ee<e.length-3&&e[ee+3]==e[ee+4]&&!e[ee+5].insertLeft;)r=e[(ee+=3)+2],N="right";break}return{node:r,start:n,end:b,collapse:N,coverStart:K,coverEnd:X}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),b=n.node,N=n.start,K=n.end,X=n.collapse,ee;if(b.nodeType==3){for(var ce=0;ce<4;ce++){for(;N&&Oe(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+K<n.coverEnd&&Oe(t.line.text.charAt(n.coverStart+K));)++K;if(j&&F<9&&N==0&&K==n.coverEnd-n.coverStart?ee=b.parentNode.getBoundingClientRect():ee=js(m(b,N,K).getClientRects(),r),ee.left||ee.right||N==0)break;K=N,N=N-1,X="right"}j&&F<11&&(ee=Hs(e.display.measure,ee))}else{N>0&&(X=r="right");var pe;e.options.lineWrapping&&(pe=b.getClientRects()).length>1?ee=pe[r=="right"?pe.length-1:0]:ee=b.getBoundingClientRect()}if(j&&F<9&&!N&&(!ee||!ee.left&&!ee.right)){var Se=b.parentNode.getClientRects()[0];Se?ee={left:Se.left,right:Se.left+Di(e.display),top:Se.top,bottom:Se.bottom}:ee=ro}for(var xe=ee.top-t.rect.top,Re=ee.bottom-t.rect.top,Ne=(xe+Re)/2,je=t.view.measure.heights,Ge=0;Ge<je.length-1&&!(Ne<je[Ge]);Ge++);var Je=Ge?je[Ge-1]:0,ze=je[Ge],tt={left:(X=="right"?ee.right:ee.left)-t.rect.left,right:(X=="left"?ee.left:ee.right)-t.rect.left,top:Je,bottom:ze};return!ee.left&&!ee.right&&(tt.bogus=!0),e.options.singleCursorHeightPerLine||(tt.rtop=xe,tt.rbottom=Re),tt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!pt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function an(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return g&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return g&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=nn(e.widgets[i]));return t}function Fn(e,t,i,r,n){if(!n){var b=pa(t);i.top+=b,i.bottom+=b}if(r=="line")return i;r||(r="local");var N=kr(t);if(r=="local"?N+=Bn(e.display):N-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();N+=K.top+(r=="window"?0:so());var X=K.left+(r=="window"?0:oo());i.left+=X,i.right+=X}return i.top+=N,i.bottom+=N,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var b=e.display.sizer.getBoundingClientRect();r+=b.left,n+=b.top}var N=e.display.lineSpace.getBoundingClientRect();return{left:r-N.left,top:n-N.top}}function ma(e,t,i,r,n){return r||(r=$e(e.doc,t.line)),Fn(e,r,to(e,r,t.ch,n),i)}function Dr(e,t,i,r,n,b){r=r||$e(e.doc,t.line),n||(n=_i(e,r));function N(Re,Ne){var je=Ir(e,n,Re,Ne?"right":"left",b);return Ne?je.left=je.right:je.right=je.left,Fn(e,r,je,i)}var K=Ke(r,e.doc.direction),X=t.ch,ee=t.sticky;if(X>=r.text.length?(X=r.text.length,ee="before"):X<=0&&(X=0,ee="after"),!K)return N(ee=="before"?X-1:X,ee=="before");function ce(Re,Ne,je){var Ge=K[Ne],Je=Ge.level==1;return N(je?Re-1:Re,Je!=je)}var pe=Xe(K,X,ee),Se=Ve,xe=ce(X,pe,ee=="before");return Se!=null&&(xe.other=ce(X,Se,ee!="before")),xe}function uo(e,t){var i=0;t=vt(e.doc,t),e.options.lineWrapping||(i=Di(e.display)*t.ch);var r=$e(e.doc,t.line),n=kr(r)+Bn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var b=Be(e,t,i);return b.xRel=n,r&&(b.outside=r),b}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=_t(r,i),b=r.first+r.size-1;if(n>b)return ga(r.first+r.size-1,$e(r,b).text.length,null,1,1);t<0&&(t=0);for(var N=$e(r,n);;){var K=Gs(e,N,n,t,i),X=Ai(N,K.ch+(K.xRel>0||K.outside>0?1:0));if(!X)return K;var ee=X.find(1);if(ee.line==n)return ee;N=$e(r,n=ee.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,b=We(function(N){return Ir(e,i,N-1).bottom<=r},n,0);return n=We(function(N){return Ir(e,i,N).top>r},b,n),{begin:b,end:n}}function co(e,t,i,r){i||(i=_i(e,t));var n=Fn(e,t,Ir(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=kr(t);var b=_i(e,t),N=pa(t),K=0,X=t.text.length,ee=!0,ce=Ke(t,e.doc.direction);if(ce){var pe=(e.options.lineWrapping?Ks:zs)(e,t,i,b,ce,r,n);ee=pe.level!=1,K=ee?pe.from:pe.to-1,X=ee?pe.to:pe.from-1}var Se=null,xe=null,Re=We(function(dt){var lt=Ir(e,b,dt);return lt.top+=N,lt.bottom+=N,ya(lt,r,n,!1)?(lt.top<=n&<.left<=r&&(Se=dt,xe=lt),!0):!1},K,X),Ne,je,Ge=!1;if(xe){var Je=r-xe.left<xe.right-r,ze=Je==ee;Re=Se+(ze?0:1),je=ze?"after":"before",Ne=Je?xe.left:xe.right}else{!ee&&(Re==X||Re==K)&&Re++,je=Re==0?"after":Re==t.text.length?"before":Ir(e,b,Re-(ee?1:0)).bottom+N<=n==ee?"after":"before";var tt=Dr(e,Be(i,Re,je),"line",t,b);Ne=tt.left,Ge=n<tt.top?-1:n>=tt.bottom?1:0}return Re=Pe(t.text,Re,1),ga(i,Re,je,Ge,r-Ne)}function zs(e,t,i,r,n,b,N){var K=We(function(pe){var Se=n[pe],xe=Se.level!=1;return ya(Dr(e,Be(i,xe?Se.to:Se.from,xe?"before":"after"),"line",t,r),b,N,!0)},0,n.length-1),X=n[K];if(K>0){var ee=X.level!=1,ce=Dr(e,Be(i,ee?X.from:X.to,ee?"after":"before"),"line",t,r);ya(ce,b,N,!0)&&ce.top>N&&(X=n[K-1])}return X}function Ks(e,t,i,r,n,b,N){var K=ho(e,t,r,N),X=K.begin,ee=K.end;/\s/.test(t.text.charAt(ee-1))&&ee--;for(var ce=null,pe=null,Se=0;Se<n.length;Se++){var xe=n[Se];if(xe.from>=ee||xe.to<=X)continue;var Re=xe.level!=1,Ne=Ir(e,r,Re?Math.min(ee,xe.to)-1:Math.max(X,xe.from)).right,je=Ne<b?b-Ne+1e9:Ne-b;(!ce||pe>je)&&(ce=xe,pe=je)}return ce||(ce=n[n.length-1]),ce.from<X&&(ce={from:X,to:ce.to,level:ce.level}),ce.to>ee&&(ce={from:ce.from,to:ee,level:ce.level}),ce}var hi;function ki(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(hi==null){hi=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)hi.appendChild(document.createTextNode("x")),hi.appendChild(a("br"));hi.appendChild(document.createTextNode("x"))}h(e.measure,hi);var i=hi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function Di(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");h(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,b=t.gutters.firstChild,N=0;b;b=b.nextSibling,++N){var K=e.display.gutterSpecs[N].className;i[K]=b.offsetLeft+b.clientLeft+n,r[K]=b.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=ki(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Di(e.display)-3);return function(n){if(Pr(e.doc,n))return 0;var b=0;if(n.widgets)for(var N=0;N<n.widgets.length;N++)n.widgets[N].height&&(b+=n.widgets[N].height);return i?b+(Math.ceil(n.text.length/r)||1)*t:b+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&bt(r,n)})}function di(e,t,i,r){var n=e.display;if(!i&&me(t).getAttribute("cm-not-content")=="true")return null;var b,N,K=n.lineSpace.getBoundingClientRect();try{b=t.clientX-K.left,N=t.clientY-K.top}catch(pe){return null}var X=va(e,b,N),ee;if(r&&X.xRel>0&&(ee=$e(e.doc,X.line).text).length==X.ch){var ce=ne(ee,ee.length,e.options.tabSize)-ee.length;X=Be(X.line,Math.max(0,Math.round((b-qa(e.display).left)/Di(e.display))-ce))}return X}function ci(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function cr(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)or&&Qi(e.doc,t)<n.viewTo&&Yr(e);else if(i<=n.viewFrom)or&&Vr(e.doc,i+r)>n.viewFrom?Yr(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Yr(e);else if(t<=n.viewFrom){var b=Un(e,i,i+r,1);b?(n.view=n.view.slice(b.index),n.viewFrom=b.lineN,n.viewTo+=r):Yr(e)}else if(i>=n.viewTo){var N=Un(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):Yr(e)}else{var K=Un(e,t,t,-1),X=Un(e,i,i+r,1);K&&X?(n.view=n.view.slice(0,K.index).concat(dr(e,K.lineN,X.lineN)).concat(n.view.slice(X.index)),n.viewTo+=r):Yr(e)}var ee=n.externalMeasured;ee&&(i<ee.lineN?ee.lineN+=r:t<ee.lineN+ee.size&&(n.externalMeasured=null))}function Xr(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var b=r.view[ci(e,t)];if(b.node==null)return;var N=b.changes||(b.changes=[]);ge(N,i)==-1&&N.push(i)}function Yr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Un(e,t,i,r){var n=ci(e,t),b,N=e.display.view;if(!or||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,X=0;X<n;X++)K+=N[X].size;if(K!=t){if(r>0){if(n==N.length-1)return null;b=K+N[n].size-t,n++}else b=K-t;t+=b,i+=b}for(;Qi(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=dr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=dr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(ci(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(dr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,ci(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function on(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),b=r.selection=document.createDocumentFragment(),N=0;N<i.sel.ranges.length;N++){if(!t&&N==i.sel.primIndex)continue;var K=i.sel.ranges[N];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var X=K.empty();(X||e.options.showCursorWhenSelecting)&&go(e,K.head,n),X||Xs(e,K,b)}return r}function go(e,t,i){var r=Dr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var b=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));b.style.display="",b.style.left=r.other.left+"px",b.style.top=r.other.top+"px",b.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function jn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,b=document.createDocumentFragment(),N=qa(e.display),K=N.left,X=Math.max(r.sizerWidth,ui(e)-r.sizer.offsetLeft)-N.right,ee=n.direction=="ltr";function ce(ze,tt,dt,lt){tt<0&&(tt=0),tt=Math.round(tt),lt=Math.round(lt),b.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+ze+`px;
|
|
top: `+tt+"px; width: "+(dt==null?X-ze:dt)+`px;
|
|
height: `+(lt-tt)+"px"))}function pe(ze,tt,dt){var lt=$e(n,ze),Et=lt.text.length,Pt,Zt;function Bt(Ht,mr){return ma(e,Be(ze,Ht),"div",lt,mr)}function yr(Ht,mr,tr){var Vt=co(e,lt,null,Ht),Gt=mr=="ltr"==(tr=="after")?"left":"right",Ft=tr=="after"?Vt.begin:Vt.end-(/\s/.test(lt.text.charAt(Vt.end-1))?2:1);return Bt(Ft,Gt)[Gt]}var pr=Ke(lt,n.direction);return He(pr,tt||0,dt==null?Et:dt,function(Ht,mr,tr,Vt){var Gt=tr=="ltr",Ft=Bt(Ht,Gt?"left":"right"),gr=Bt(mr-1,Gt?"right":"left"),Gi=tt==null&&Ht==0,ei=dt==null&&mr==Et,ar=Vt==0,Nr=!pr||Vt==pr.length-1;if(gr.top-Ft.top<=3){var Jt=(ee?Gi:ei)&&ar,Va=(ee?ei:Gi)&&Nr,zr=Jt?K:(Gt?Ft:gr).left,vi=Va?X:(Gt?gr:Ft).right;ce(zr,Ft.top,vi-zr,Ft.bottom)}else{var yi,lr,zi,Xa;Gt?(yi=ee&&Gi&&ar?K:Ft.left,lr=ee?X:yr(Ht,tr,"before"),zi=ee?K:yr(mr,tr,"after"),Xa=ee&&ei&&Nr?X:gr.right):(yi=ee?yr(Ht,tr,"before"):K,lr=!ee&&Gi&&ar?X:Ft.right,zi=!ee&&ei&&Nr?K:gr.left,Xa=ee?yr(mr,tr,"after"):X),ce(yi,Ft.top,lr-yi,Ft.bottom),Ft.bottom<gr.top&&ce(K,Ft.bottom,null,gr.top),ce(zi,gr.top,Xa-zi,gr.bottom)}(!Pt||jn(Ft,Pt)<0)&&(Pt=Ft),jn(gr,Pt)<0&&(Pt=gr),(!Zt||jn(Ft,Zt)<0)&&(Zt=Ft),jn(gr,Zt)<0&&(Zt=gr)}),{start:Pt,end:Zt}}var Se=t.from(),xe=t.to();if(Se.line==xe.line)pe(Se.line,Se.ch,xe.ch);else{var Re=$e(n,Se.line),Ne=$e(n,xe.line),je=xr(Re)==xr(Ne),Ge=pe(Se.line,Se.ch,je?Re.text.length+1:null).end,Je=pe(xe.line,je?0:null,xe.ch).start;je&&(Ge.top<Je.top-2?(ce(Ge.right,Ge.top,null,Ge.bottom),ce(K,Je.top,Je.left,Je.bottom)):ce(Ge.right,Ge.top,Je.left-Ge.right,Ge.bottom)),Ge.bottom<Je.top&&ce(K,Ge.bottom,null,Je.top)}i.appendChild(b)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Ri(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Ri(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),P&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Ri(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(ae(e,"blur",e,t),e.state.focused=!1,d(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Wn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],b=e.options.lineWrapping,N=void 0,K=0;if(n.hidden)continue;if(j&&F<8){var X=n.node.offsetTop+n.node.offsetHeight;N=X-i,i=X}else{var ee=n.node.getBoundingClientRect();N=ee.bottom-ee.top,!b&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-ee.left-1)}var ce=n.line.height-N;if((ce>.005||ce<-.005)&&(bt(n.line,N),bo(n.line),n.rest))for(var pe=0;pe<n.rest.length;pe++)bo(n.rest[pe]);if(K>e.display.sizerWidth){var Se=Math.ceil(K/Di(e.display));Se>e.display.maxLineLength&&(e.display.maxLineLength=Se,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Hn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Bn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,b=_t(t,r),N=_t(t,n);if(i&&i.ensure){var K=i.ensure.from.line,X=i.ensure.to.line;K<b?(b=K,N=_t(t,kr($e(t,K))+e.wrapper.clientHeight)):Math.min(X,t.lastLine())>=N&&(b=_t(t,kr($e(t,X))-e.wrapper.clientHeight),N=X)}return{from:b,to:Math.max(N,b+1)}}function Ys(e,t){if(J(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&&!w){var b=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Bn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+Mr(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(b),b.scrollIntoView(n),e.display.lineSpace.removeChild(b)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Be(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Be(t.line,t.ch+1,"before"):t);for(var b=0;b<5;b++){var N=!1,K=Dr(e,t),X=!i||i==t?K:Dr(e,i);n={left:Math.min(K.left,X.left),top:Math.min(K.top,X.top)-r,right:Math.max(K.left,X.left),bottom:Math.max(K.bottom,X.bottom)+r};var ee=Ca(e,n),ce=e.doc.scrollTop,pe=e.doc.scrollLeft;if(ee.scrollTop!=null&&(ln(e,ee.scrollTop),Math.abs(e.doc.scrollTop-ce)>1&&(N=!0)),ee.scrollLeft!=null&&(fi(e,ee.scrollLeft),Math.abs(e.doc.scrollLeft-pe)>1&&(N=!0)),!N)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&ln(e,i.scrollTop),i.scrollLeft!=null&&fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=ki(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,b=ca(e),N={};t.bottom-t.top>b&&(t.bottom=t.top+b);var K=e.doc.height+da(i),X=t.top<r,ee=t.bottom>K-r;if(t.top<n)N.scrollTop=X?0:t.top;else if(t.bottom>n+b){var ce=Math.min(t.top,(ee?K:t.bottom)-b);ce!=n&&(N.scrollTop=ce)}var pe=e.options.fixedGutter?0:i.gutters.offsetWidth,Se=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-pe,xe=ui(e)-i.gutters.offsetWidth,Re=t.right-t.left>xe;return Re&&(t.right=t.left+xe),t.left<10?N.scrollLeft=0:t.left<Se?N.scrollLeft=Math.max(0,t.left+pe-(Re?0:10)):t.right>xe+Se-3&&(N.scrollLeft=t.right+(Re?0:10)-xe),N}function wa(e,t){if(t==null)return;Gn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Oi(e){Gn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function sn(e,t,i){(t!=null||i!=null)&&Gn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Gn(e),e.curOp.scrollToPos=t}function Gn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});sn(e,n.scrollLeft,n.scrollTop)}function ln(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;k||La(e,{top:t}),Eo(e,t,!0),k&&La(e),dn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function fi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function un(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+Mr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var pi=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),Ae(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ae(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,j&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};pi.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 b=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+b)+"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}},pi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},pi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},pi.prototype.zeroWidthHack=function(){var e=s&&!L?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new fe,this.disableVert=new fe},pi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),b=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);b!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},pi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var hn=function(){};hn.prototype.update=function(){return{bottom:0,right:0}},hn.prototype.setScrollLeft=function(){},hn.prototype.setScrollTop=function(){},hn.prototype.clear=function(){};function Pi(e,t){t||(t=un(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Wn(e),So(e,un(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var To={native:pi,null:hn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&d(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ae(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?fi(e,t):ln(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function mi(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},Cr(e.curOp)}function gi(e){var t=e.curOp;t&&Rs(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var b=0;b<t.length;b++)il(t[b]);for(var N=0;N<t.length;N++)nl(t[N])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&Nn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new zn(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&&Wn(t),e.barMeasure=un(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+Mr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-ui(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==M();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Pi(t,e.barMeasure),e.updatedDisplay&&ka(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,vt(r,e.scrollToPos.from),vt(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var b=e.maybeHiddenMarkers,N=e.maybeUnhiddenMarkers;if(b)for(var K=0;K<b.length;++K)b[K].lines.length||ae(b[K],"hide");if(N)for(var X=0;X<N.length;++X)N[X].lines.length&&ae(N[X],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function vr(e,t){if(e.curOp)return t();mi(e);try{return t()}finally{gi(e)}}function Yt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mi(e);try{return t.apply(e,arguments)}finally{gi(e)}}}function sr(e){return function(){if(this.curOp)return e.apply(this,arguments);mi(this);try{return e.apply(this,arguments)}finally{gi(this)}}}function $t(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mi(t);try{return e.apply(this,arguments)}finally{gi(t)}}}function dn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=wr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(b){if(r.line>=e.display.viewFrom){var N=b.styles,K=b.text.length>e.options.maxHighlightLength?Qt(t.mode,r.state):null,X=Ki(e,b,r,!0);K&&(r.state=K),b.styles=X.styles;var ee=b.styleClasses,ce=X.classes;ce?b.styleClasses=ce:ee&&(b.styleClasses=null);for(var pe=!N||N.length!=b.styles.length||ee!=ce&&(!ee||!ce||ee.bgClass!=ce.bgClass||ee.textClass!=ce.textClass),Se=0;!pe&&Se<N.length;++Se)pe=N[Se]!=b.styles[Se];pe&&n.push(r.line),b.stateAfter=r.save(),r.nextLine()}else b.text.length<=e.options.maxHighlightLength&&Vi(e,b.text,r),b.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return dn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&vr(e,function(){for(var b=0;b<n.length;b++)Xr(e,n[b],"text")})}var zn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Hn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=ui(e),this.force=i,this.dims=ba(e),this.events=[]};zn.prototype.signal=function(e,t){ie(e,t)&&this.events.push(arguments)},zn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)ae.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Mr(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Mr(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=M();if(!t||!x(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&x(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==M())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&x(document.body,e.anchorNode)&&x(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Yr(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Lo(e)&&(Yr(e),t.dims=ba(e));var n=r.first+r.size,b=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<b&&b-i.viewFrom<20&&(b=Math.max(r.first,i.viewFrom)),i.viewTo>N&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),or&&(b=Qi(e.doc,b),N=Vr(e.doc,N));var K=b!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,b,N),i.viewOffset=kr($e(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var X=po(e);if(!K&&X==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var ee=sl(e);return X>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),X>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(ee),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,dn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==ui(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(e),i.top)}),t.visible=Hn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Hn(e.display,e.doc,i));if(!Aa(e,t))break;Wn(e);var n=un(e);on(e),Pi(e,n),ka(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function La(e,t){var i=new zn(e,t);if(Aa(e,i)){Wn(e),wo(e,i);var r=un(e);on(e),Pi(e,r),ka(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,b=r.lineDiv,N=b.firstChild;function K(Re){var Ne=Re.nextSibling;return P&&s&&e.display.currentWheelTarget==Re?Re.style.display="none":Re.parentNode.removeChild(Re),Ne}for(var X=r.view,ee=r.viewFrom,ce=0;ce<X.length;ce++){var pe=X[ce];if(!pe.hidden)if(!pe.node||pe.node.parentNode!=b){var Se=Ns(e,pe,ee,i);b.insertBefore(Se,N)}else{for(;N!=pe.node;)N=K(N);var xe=n&&t!=null&&t<=ee&&pe.lineNumber;pe.changes&&(ge(pe.changes,"gutter")>-1&&(xe=!1),Ya(e,pe,ee,i)),xe&&(c(pe.lineNumber),pe.lineNumber.appendChild(document.createTextNode(Wt(e.options,ee)))),N=pe.node.nextSibling}ee+=pe.size}for(;N;)N=K(N)}function _a(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function ka(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+Mr(e)+"px"}function Ao(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,b=r+"px",N=0;N<i.length;N++)if(!i[N].hidden){e.options.fixedGutter&&(i[N].gutter&&(i[N].gutter.style.left=b),i[N].gutterBackground&&(i[N].gutterBackground.style.left=b));var K=i[N].alignable;if(K)for(var X=0;X<K.length;X++)K[X].style.left=b}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=Wt(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),b=n.firstChild.offsetWidth,N=n.offsetWidth-b;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(b,r.lineGutter.offsetWidth-N)+1,r.lineNumWidth=r.lineNumInnerWidth+N,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_a(e.display),!0}return!1}function Da(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var b=e[n],N=null;if(typeof b!="string"&&(N=b.style,b=b.className),b=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:b,style:N})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function _o(e){var t=e.gutters,i=e.gutterSpecs;c(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],b=n.className,N=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+b));N&&(K.style.cssText=N),b=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",_a(e)}function cn(e){_o(e.display),cr(e),Ao(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=y("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=y("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var b=y("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[b],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+be+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),j&&F<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(k&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Da(r.gutters,r.lineNumbers),_o(n),i.init(n)}var Kn=0,Er=null;j?Er=-.53:k?Er=15:g?Er=-.7:R&&(Er=-1/3);function ko(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function dl(e){var t=ko(e);return t.x*=Er,t.y*=Er,t}function Do(e,t){var i=ko(t),r=i.x,n=i.y,b=e.display,N=b.scroller,K=N.scrollWidth>N.clientWidth,X=N.scrollHeight>N.clientHeight;if(!(r&&K||n&&X))return;if(n&&s&&P){e:for(var ee=t.target,ce=b.view;ee!=N;ee=ee.parentNode)for(var pe=0;pe<ce.length;pe++)if(ce[pe].node==ee){e.display.currentWheelTarget=ee;break e}}if(r&&!k&&!T&&Er!=null){n&&X&&ln(e,Math.max(0,N.scrollTop+n*Er)),fi(e,Math.max(0,N.scrollLeft+r*Er)),(!n||n&&X)&&Q(t),b.wheelStartX=null;return}if(n&&Er!=null){var Se=n*Er,xe=e.doc.scrollTop,Re=xe+b.wrapper.clientHeight;Se<0?xe=Math.max(0,xe+Se-50):Re=Math.min(e.doc.height,Re+Se+50),La(e,{top:xe,bottom:Re})}Kn<20&&(b.wheelStartX==null?(b.wheelStartX=N.scrollLeft,b.wheelStartY=N.scrollTop,b.wheelDX=r,b.wheelDY=n,setTimeout(function(){if(b.wheelStartX==null)return;var Ne=N.scrollLeft-b.wheelStartX,je=N.scrollTop-b.wheelStartY,Ge=je&&b.wheelDY&&je/b.wheelDY||Ne&&b.wheelDX&&Ne/b.wheelDX;if(b.wheelStartX=b.wheelStartY=null,!Ge)return;Er=(Er*Kn+Ge)/(Kn+1),++Kn},200)):(b.wheelDX+=r,b.wheelDY+=n))}var Sr=function(e,t){this.ranges=e,this.primIndex=t};Sr.prototype.primary=function(){return this.ranges[this.primIndex]},Sr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var i=this.ranges[t],r=e.ranges[t];if(!ri(i.anchor,r.anchor)||!ri(i.head,r.head))return!1}return!0},Sr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Dt(bi(this.ranges[t].anchor),bi(this.ranges[t].head));return new Sr(e,this.primIndex)},Sr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Sr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(ft(t,r.from())>=0&&ft(e,r.to())<=0)return i}return-1};var Dt=function(e,t){this.anchor=e,this.head=t};Dt.prototype.from=function(){return ii(this.anchor,this.head)},Dt.prototype.to=function(){return xi(this.anchor,this.head)},Dt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Rr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(Se,xe){return ft(Se.from(),xe.from())}),i=ge(t,n);for(var b=1;b<t.length;b++){var N=t[b],K=t[b-1],X=ft(K.to(),N.from());if(r&&!N.empty()?X>0:X>=0){var ee=ii(K.from(),N.from()),ce=xi(K.to(),N.to()),pe=K.empty()?N.from()==N.head:K.from()==K.head;b<=i&&--i,t.splice(--b,2,new Dt(pe?ce:ee,pe?ee:ce))}}return new Sr(t,i)}function $r(e,t){return new Sr([new Dt(e,t||e)],0)}function Zr(e){return e.text?Be(e.from.line+e.text.length-1,A(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(ft(e,t.from)<0)return e;if(ft(e,t.to)<=0)return Zr(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+=Zr(t).ch-t.to.ch),Be(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Dt(Ro(n.anchor,t),Ro(n.head,t)))}return Rr(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?Be(i.line,e.ch-t.ch+i.ch):Be(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Be(e.first,0),b=n,N=0;N<t.length;N++){var K=t[N],X=Oo(K.from,n,b),ee=Oo(Zr(K),n,b);if(n=K.to,b=ee,i=="around"){var ce=e.sel.ranges[N],pe=ft(ce.head,ce.anchor)<0;r[N]=new Dt(pe?ee:X,pe?X:ee)}else r[N]=new Dt(X,X)}return new Sr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=rr(e.options,e.doc.modeOption),fn(e)}function fn(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,dn(e,100),e.state.modeGen++,e.curOp&&cr(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&A(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(Je){return i?i[Je]:null}function b(Je,ze,tt){ua(Je,ze,tt,r),er(Je,"change",Je,t)}function N(Je,ze){for(var tt=[],dt=Je;dt<ze;++dt)tt.push(new li(ee[dt],n(dt),r));return tt}var K=t.from,X=t.to,ee=t.text,ce=$e(e,K.line),pe=$e(e,X.line),Se=A(ee),xe=n(ee.length-1),Re=X.line-K.line;if(t.full)e.insert(0,N(0,ee.length)),e.remove(ee.length,e.size-ee.length);else if(Po(e,t)){var Ne=N(0,ee.length-1);b(pe,pe.text,xe),Re&&e.remove(K.line,Re),Ne.length&&e.insert(K.line,Ne)}else if(ce==pe)if(ee.length==1)b(ce,ce.text.slice(0,K.ch)+Se+ce.text.slice(X.ch),xe);else{var je=N(1,ee.length-1);je.push(new li(Se+ce.text.slice(X.ch),xe,r)),b(ce,ce.text.slice(0,K.ch)+ee[0],n(0)),e.insert(K.line+1,je)}else if(ee.length==1)b(ce,ce.text.slice(0,K.ch)+ee[0]+pe.text.slice(X.ch),n(0)),e.remove(K.line+1,Re);else{b(ce,ce.text.slice(0,K.ch)+ee[0],n(0)),b(pe,Se+pe.text.slice(X.ch),xe);var Ge=N(1,ee.length-1);Re>1&&e.remove(K.line+1,Re-1),e.insert(K.line+1,Ge)}er(e,"change",e,t)}function Jr(e,t,i){function r(n,b,N){if(n.linked)for(var K=0;K<n.linked.length;++K){var X=n.linked[K];if(X.doc==b)continue;var ee=N&&X.sharedHist;if(i&&!ee)continue;t(X.doc,ee),r(X.doc,n,ee)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Oa(e),Io(e),e.options.lineWrapping||Nn(e),e.options.mode=t.modeOption,cr(e)}function Io(e){(e.doc.direction=="rtl"?G:d)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){vr(e,function(){Io(e),cr(e)})}function Vn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var i={from:bi(t.from),to:Zr(t),text:wt(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Jr(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=A(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),A(e.done);if(e.done.length&&!A(e.done).ranges)return A(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),A(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var b=+new Date,N,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>b-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))K=A(N.changes),ft(t.from,t.to)==0&&ft(t.from,K.to)==0?K.to=Zr(t):N.changes.push(Ma(e,t));else{var X=A(n.done);for((!X||!X.ranges)&&Xn(e.sel,n.done),N={changes:[Ma(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=b,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,b=r&&r.origin;i==n.lastSelOp||b&&n.lastSelOrigin==b&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==b||ml(e,b,A(n.done),t))?n.done[n.done.length-1]=t:Xn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=b,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Xn(e,t){var i=A(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],b=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]={}))[b]=N.markedSpans),++b})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Ti(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var b=i[n],N=r[n];if(b&&N){e:for(var K=0;K<N.length;++K){for(var X=N[K],ee=0;ee<b.length;++ee)if(b[ee].marker==X.marker)continue e;b.push(X)}}else N&&(i[n]=N)}return i}function Mi(e,t,i){for(var r=[],n=0;n<e.length;++n){var b=e[n];if(b.ranges){r.push(i?Sr.prototype.deepCopy.call(b):b);continue}var N=b.changes,K=[];r.push({changes:K});for(var X=0;X<N.length;++X){var ee=N[X],ce=void 0;if(K.push({from:ee.from,to:ee.to,text:ee.text}),t)for(var pe in ee)(ce=pe.match(/^spans_(\d+)$/))&&(ge(t,Number(ce[1]))>-1&&(A(K)[pe]=ee[pe],delete ee[pe]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var b=ft(t,n)<0;b!=ft(i,n)<0?(n=t,t=i):b!=ft(t,i)<0&&(t=i)}return new Dt(n,t)}else return new Dt(i||t,t)}function Yn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),nr(e,new Sr([Ia(e.sel.primary(),t,i,n)],0),r)}function jo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),b=0;b<e.sel.ranges.length;b++)r[b]=Ia(e.sel.ranges[b],t[b],null,n);var N=Rr(e.cm,r,e.sel.primIndex);nr(e,N,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,nr(e,Rr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){nr(e,$r(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var b=0;b<n.length;b++)this.ranges[b]=new Dt(vt(e,n[b].anchor),vt(e,n[b].head))},origin:i&&i.origin};return ae(e,"beforeSelectionChange",e,r),e.cm&&ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Rr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=A(r);n&&n.ranges?(r[r.length-1]=t,$n(e,t,i)):nr(e,t,i)}function nr(e,t,i){$n(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function $n(e,t,i){(ie(e,"beforeSelectionChange")||e.cm&&ie(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(ft(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Oi(e.cm)}function Go(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,Z(e.cm)),er(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,b=0;b<t.ranges.length;b++){var N=t.ranges[b],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[b],X=Zn(e,N.anchor,K&&K.anchor,i,r),ee=Zn(e,N.head,K&&K.head,i,r);(n||X!=N.anchor||ee!=N.head)&&(n||(n=t.ranges.slice(0,b)),n[b]=new Dt(X,ee))}return n?Rr(e.cm,n,t.primIndex):t}function Ii(e,t,i,r,n){var b=$e(e,t.line);if(b.markedSpans)for(var N=0;N<b.markedSpans.length;++N){var K=b.markedSpans[N],X=K.marker,ee="selectLeft"in X?!X.selectLeft:X.inclusiveLeft,ce="selectRight"in X?!X.selectRight:X.inclusiveRight;if((K.from==null||(ee?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(ce?K.to>=t.ch:K.to>t.ch))){if(n&&(ae(X,"beforeCursorEnter"),X.explicitlyCleared))if(b.markedSpans){--N;continue}else break;if(!X.atomic)continue;if(i){var pe=X.find(r<0?1:-1),Se=void 0;if((r<0?ce:ee)&&(pe=Vo(e,pe,-r,pe&&pe.line==t.line?b:null)),pe&&pe.line==t.line&&(Se=ft(pe,i))&&(r<0?Se<0:Se>0))return Ii(e,pe,t,r,n)}var xe=X.find(r<0?-1:1);return(r<0?ee:ce)&&(xe=Vo(e,xe,r,xe.line==t.line?b:null)),xe?Ii(e,xe,t,r,n):null}}return t}function Zn(e,t,i,r,n){var b=r||1,N=Ii(e,t,i,b,n)||!n&&Ii(e,t,i,b,!0)||Ii(e,t,i,-b,n)||!n&&Ii(e,t,i,-b,!0);return N||(e.cantEdit=!0,Be(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?vt(e,Be(t.line-1)):null:i>0&&t.ch==(r||$e(e,t.line)).text.length?t.line<e.first+e.size-1?Be(t.line+1,0):null:new Be(t.line,t.ch+i)}function Xo(e){e.setSelection(Be(e.firstLine(),0),Be(e.lastLine()),Te)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,b,N,K){n&&(r.from=vt(e,n)),b&&(r.to=vt(e,b)),N&&(r.text=N),K!==void 0&&(r.origin=K)}),ae(e,"beforeChange",e,r),e.cm&&ae(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Ni(e,t,i){if(e.cm){if(!e.cm.curOp)return Yt(e.cm,Ni)(e,t,i);if(e.cm.state.suppressEdits)return}if((ie(e,"beforeChange")||e.cm&&ie(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Zi&&!i&&Pn(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&ft(t.from,t.to)==0)return;var i=Ra(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),pn(e,t,i,Ti(e,t));var r=[];Jr(e,function(n,b){!b&&ge(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),pn(n,t,null,Ti(n,t))})}function Jn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,b,N=e.sel,K=t=="undo"?n.done:n.undone,X=t=="undo"?n.undone:n.done,ee=0;ee<K.length&&!(b=K[ee],i?b.ranges&&!b.equals(e.sel):!b.ranges);ee++);if(ee==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(b=K.pop(),b.ranges){if(Xn(b,X),i&&!b.equals(e.sel)){nr(e,b,{clearRedo:!1});return}N=b}else if(r){K.push(b);return}else break;var ce=[];Xn(N,X),X.push({changes:ce,generation:n.generation}),n.generation=b.generation||++n.maxGeneration;for(var pe=ie(e,"beforeChange")||e.cm&&ie(e.cm,"beforeChange"),Se=function(Ne){var je=b.changes[Ne];if(je.origin=t,pe&&!Yo(e,je,!1))return K.length=0,{};ce.push(Ma(e,je));var Ge=Ne?Ra(e,je):A(K);pn(e,je,Ge,Uo(e,je)),!Ne&&e.cm&&e.cm.scrollIntoView({from:je.from,to:Zr(je)});var Je=[];Jr(e,function(ze,tt){!tt&&ge(Je,ze.history)==-1&&(qo(ze.history,je),Je.push(ze.history)),pn(ze,je,null,Uo(ze,je))})},xe=b.changes.length-1;xe>=0;--xe){var Re=Se(xe);if(Re)return Re.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Sr(_(e.sel.ranges,function(n){return new Dt(Be(n.anchor.line+t,n.anchor.ch),Be(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){cr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Xr(e.cm,r,"gutter")}}function pn(e,t,i,r){if(e.cm&&!e.cm.curOp)return Yt(e.cm,pn)(e,t,i,r);if(t.to.line<e.first){Zo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:Be(e.first,0),to:Be(t.to.line+n,t.to.ch),text:[A(t.text)],origin:t.origin}}var b=e.lastLine();t.to.line>b&&(t={from:t.from,to:Be(b,$e(e,b).text.length),text:[t.text[0]],origin:t.origin}),t.removed=wt(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),$n(e,i,Te),e.cantEdit&&Zn(e,Be(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,b=t.from,N=t.to,K=!1,X=b.line;e.options.lineWrapping||(X=yt(xr($e(r,b.line))),r.iter(X,N.line+1,function(xe){if(xe==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Z(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(X,b.line+t.text.length,function(xe){var Re=en(xe);Re>n.maxLineLength&&(n.maxLine=xe,n.maxLineLength=Re,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),aa(r,b.line),dn(e,400);var ee=t.text.length-(N.line-b.line)-1;t.full?cr(e):b.line==N.line&&t.text.length==1&&!Po(e.doc,t)?Xr(e,b.line,"text"):cr(e,b.line,N.line+1,ee);var ce=ie(e,"changes"),pe=ie(e,"change");if(pe||ce){var Se={from:b,to:N,text:t.text,removed:t.removed,origin:t.origin};pe&&er(e,"change",e,Se),ce&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Se)}e.display.selForContextMenu=null}function Bi(e,t,i,r,n){var b;r||(r=i),ft(r,i)<0&&(b=[r,i],i=b[0],r=b[1]),typeof t=="string"&&(t=e.splitLines(t)),Ni(e,{from:i,to:r,text:t,origin:n})}function Jo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Qo(e,t,i,r){for(var n=0;n<e.length;++n){var b=e[n],N=!0;if(b.ranges){b.copied||(b=e[n]=b.deepCopy(),b.copied=!0);for(var K=0;K<b.ranges.length;K++)Jo(b.ranges[K].anchor,t,i,r),Jo(b.ranges[K].head,t,i,r);continue}for(var X=0;X<b.changes.length;++X){var ee=b.changes[X];if(i<ee.from.line)ee.from=Be(ee.from.line+r,ee.from.ch),ee.to=Be(ee.to.line+r,ee.to.ch);else if(t<=ee.to.line){N=!1;break}}N||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function mn(e,t,i,r){var n=t,b=t;return typeof t=="number"?b=$e(e,Ei(e,t)):n=yt(t),n==null?null:(r(b,n)&&e.cm&&Xr(e.cm,n,i),b)}function gn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}gn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,at(n),er(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function vn(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}vn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var b=Math.min(t,n-e),N=r.height;if(r.removeInner(e,b),this.height-=N-r.height,n==b&&(this.children.splice(i--,1),r.parent=null),(t-=b)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof gn))){var K=[];this.collapse(K),this.children=[new gn(K)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],b=n.chunkSize();if(e<=b){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var N=n.lines.length%25+25,K=N;K<n.lines.length;){var X=new gn(n.lines.slice(K,K+=25));n.height-=X.height,this.children.splice(++r,0,X),X.parent=this}n.lines=n.lines.slice(0,N),this.maybeSpill()}break}e-=b}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new vn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ge(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new vn(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],b=n.chunkSize();if(e<b){var N=Math.min(t,b-e);if(n.iterN(e,N,i))return!0;if((t-=N)==0)break;e=0}else e-=b}}};var yn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};yn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=yt(i);if(r==null||!t)return;for(var n=0;n<t.length;++n)t[n]==this&&t.splice(n--,1);t.length||(i.widgets=null);var b=nn(this);bt(i,Math.max(0,i.height-b)),e&&(vr(e,function(){es(e,i,-b),Xr(e,r,"widget")}),er(e,"lineWidgetCleared",e,this,r))},yn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=nn(this)-t;if(!n)return;Pr(this.doc,r)||bt(r,r.height+n),i&&vr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),er(i,"lineWidgetChanged",i,e,yt(r))})},oe(yn);function es(e,t,i){kr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new yn(e,i,r),b=e.cm;return b&&n.noHScroll&&(b.display.alignWidgets=!0),mn(e,t,"widget",function(N){var K=N.widgets||(N.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=N,b&&!Pr(e,N)){var X=kr(N)<e.scrollTop;bt(N,N.height+nn(n)),X&&wa(b,n.height),b.curOp.forceUpdate=!0}return!0}),b&&er(b,"lineWidgetAdded",b,n,typeof t=="number"?t:yt(t)),n}var ts=0,Qr=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};Qr.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&mi(e),ie(this,"clear")){var i=this.find();i&&er(this,"clear",i.from,i.to)}for(var r=null,n=null,b=0;b<this.lines.length;++b){var N=this.lines[b],K=_r(N.markedSpans,this);e&&!this.collapsed?Xr(e,yt(N),"text"):e&&(K.to!=null&&(n=yt(N)),K.from!=null&&(r=yt(N))),N.markedSpans=Ji(N.markedSpans,K),K.from==null&&this.collapsed&&!Pr(this.doc,N)&&e&&bt(N,ki(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var X=0;X<this.lines.length;++X){var ee=xr(this.lines[X]),ce=en(ee);ce>e.display.maxLineLength&&(e.display.maxLine=ee,e.display.maxLineLength=ce,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&cr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&zo(e.doc)),e&&er(e,"markerCleared",e,this,r,n),t&&gi(e),this.parent&&this.parent.clear()},Qr.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var b=this.lines[n],N=_r(b.markedSpans,this);if(N.from!=null&&(i=Be(t?b:yt(b),N.from),e==-1))return i;if(N.to!=null&&(r=Be(t?b:yt(b),N.to),e==1))return r}return i&&{from:i,to:r}},Qr.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;vr(r,function(){var n=t.line,b=yt(t.line),N=fa(r,b);if(N&&(no(N),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Pr(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var X=nn(i)-K;X&&bt(n,n.height+X)}er(r,"markerChanged",r,e)})},Qr.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ge(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Qr.prototype.detachLine=function(e){if(this.lines.splice(ge(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},oe(Qr);function Fi(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return Yt(e.cm,Fi)(e,t,i,r,n);var b=new Qr(e,n),N=ft(t,i);if(r&&U(r,b,!1),N>0||N==0&&b.clearWhenEmpty!==!1)return b;if(b.replacedWith&&(b.collapsed=!0,b.widgetNode=y("span",[b.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||b.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(b.widgetNode.insertLeft=!0)),b.collapsed){if(Mn(e,t.line,t,i,b)||t.line!=i.line&&Mn(e,i.line,t,i,b))throw new Error("Inserting collapsed marker partially overlapping an existing one");oa()}b.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,X=e.cm,ee;if(e.iter(K,i.line+1,function(pe){X&&b.collapsed&&!X.options.lineWrapping&&xr(pe)==X.display.maxLine&&(ee=!0),b.collapsed&&K!=t.line&&bt(pe,0),sa(pe,new ai(b,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),b.collapsed&&e.iter(t.line,i.line+1,function(pe){Pr(e,pe)&&bt(pe,0)}),b.clearOnEnter&&Ae(b,"beforeCursorEnter",function(){return b.clear()}),b.readOnly&&(Kr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),b.collapsed&&(b.id=++ts,b.atomic=!0),X){if(ee&&(X.curOp.updateMaxLine=!0),b.collapsed)cr(X,t.line,i.line+1);else if(b.className||b.startStyle||b.endStyle||b.css||b.attributes||b.title)for(var ce=t.line;ce<=i.line;ce++)Xr(X,ce,"text");b.atomic&&zo(X.doc),er(X,"markerAdded",X,b)}return b}var bn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};bn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();er(this,"clear")},bn.prototype.find=function(e,t){return this.primary.find(e,t)},oe(bn);function Sl(e,t,i,r,n){r=U(r),r.shared=!1;var b=[Fi(e,t,i,r,n)],N=b[0],K=r.widgetNode;return Jr(e,function(X){K&&(r.widgetNode=K.cloneNode(!0)),b.push(Fi(X,vt(X,t),vt(X,i),r,n));for(var ee=0;ee<X.linked.length;++ee)if(X.linked[ee].isParent)return;N=A(b)}),new bn(b,N)}function rs(e){return e.findMarks(Be(e.first,0),e.clipPos(Be(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),b=e.clipPos(n.from),N=e.clipPos(n.to);if(ft(b,N)){var K=Fi(e,b,N,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],b=[n.primary.doc];Jr(n.primary.doc,function(X){return b.push(X)});for(var N=0;N<n.markers.length;N++){var K=n.markers[N];ge(b,K.doc)==-1&&(K.parent=null,n.markers.splice(N--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,fr=function(e,t,i,r,n){if(!(this instanceof fr))return new fr(e,t,i,r,n);i==null&&(i=0),vn.call(this,[new gn([new li("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var b=Be(i,0);this.sel=$r(b),this.history=new Vn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:b,to:b,text:e}),nr(this,$r(b),Te)};fr.prototype=B(vn.prototype,{constructor:fr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=qt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:$t(function(e){var t=Be(this.first,0),i=this.first+this.size-1;Ni(this,{from:t,to:Be(i,$e(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&sn(this.cm,0,0),nr(this,$r(t),Te)}),replaceRange:function(e,t,i,r){t=vt(this,t),i=i?vt(this,i):t,Bi(this,e,t,i,r)},getRange:function(e,t,i){var r=wt(this,vt(this,e),vt(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(br(this,e))return $e(this,e)},getLineNumber:function(e){return yt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=$e(this,e)),xr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return vt(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:$t(function(e,t,i){Wo(this,vt(this,typeof e=="number"?Be(e,t||0):e),null,i)}),setSelection:$t(function(e,t,i){Wo(this,vt(this,e),vt(this,t||e),i)}),extendSelection:$t(function(e,t,i){Yn(this,vt(this,e),t&&vt(this,t),i)}),extendSelections:$t(function(e,t){jo(this,Ue(this,e),t)}),extendSelectionsBy:$t(function(e,t){var i=_(this.sel.ranges,e);jo(this,Ue(this,i),t)}),setSelections:$t(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new Dt(vt(this,e[n].anchor),vt(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),nr(this,Rr(this.cm,r,t),i)}),addSelection:$t(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Dt(vt(this,e),vt(this,t||e))),nr(this,Rr(this.cm,r,r.length-1),i)}),getSelection:function(e){for(var t=this.sel.ranges,i,r=0;r<t.length;r++){var n=wt(this,t[r].from(),t[r].to());i=i?i.concat(n):n}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],i=this.sel.ranges,r=0;r<i.length;r++){var n=wt(this,i[r].from(),i[r].to());e!==!1&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){for(var r=[],n=0;n<this.sel.ranges.length;n++)r[n]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:$t(function(e,t,i){for(var r=[],n=this.sel,b=0;b<n.ranges.length;b++){var N=n.ranges[b];r[b]={from:N.from(),to:N.to(),text:this.splitLines(e[b]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),X=r.length-1;X>=0;X--)Ni(this,r[X]);K?Ho(this,K):this.cm&&Oi(this.cm)}),undo:$t(function(){Jn(this,"undo")}),redo:$t(function(){Jn(this,"redo")}),undoSelection:$t(function(){Jn(this,"undo",!0)}),redoSelection:$t(function(){Jn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Vn(this.history.maxGeneration),Jr(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Mi(this.history.done),undone:Mi(this.history.undone)}},setHistory:function(e){var t=this.history=new Vn(this.history.maxGeneration);t.done=Mi(e.done.slice(0),null,!0),t.undone=Mi(e.undone.slice(0),null,!0)},setGutterMarker:$t(function(e,t,i){return mn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ie(n)&&(r.gutterMarkers=null),!0})}),clearGutter:$t(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&mn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ie(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!br(this,e))return null;if(t=e,e=$e(this,e),!e)return null}else if(t=yt(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:$t(function(e,t,i){return mn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[n])r[n]=i;else{if(v(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:$t(function(e,t,i){return mn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",b=r[n];if(b)if(i==null)r[n]=null;else{var N=b.match(v(i));if(!N)return!1;var K=N.index+N[0].length;r[n]=b.slice(0,N.index)+(!N.index||K==b.length?"":" ")+b.slice(K)||null}else return!1;return!0})}),addLineWidget:$t(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Fi(this,vt(this,e),vt(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=vt(this,e),Fi(this,e,e,i,"bookmark")},findMarksAt:function(e){e=vt(this,e);var t=[],i=$e(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=vt(this,e),t=vt(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(b){var N=b.markedSpans;if(N)for(var K=0;K<N.length;K++){var X=N[K];!(X.to!=null&&n==e.line&&e.ch>=X.to||X.from==null&&n!=e.line||X.from!=null&&n==t.line&&X.from>=t.ch)&&(!i||i(X.marker))&&r.push(X.marker.parent||X.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var b=n.text.length+r;if(b>e)return t=e,!0;e-=b,++i}),vt(this,Be(i,t))},indexFromPos:function(e){e=vt(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new fr(qt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new fr(qt(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof It&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Jr(e,function(n){return r.push(n.id)},!0),e.history=new Vn(null),e.history.done=Mi(this.history.done,r),e.history.undone=Mi(this.history.undone,r)}},iterLinkedDocs:function(e){Jr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ot(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:$t(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&fl(this.cm)})}),fr.prototype.eachLine=fr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),J(t,e)||Hr(t.display,e))return;Q(e),j&&(is=+new Date);var i=di(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,b=Array(n),N=0,K=function(){++N==n&&Yt(t,function(){i=vt(t.doc,i);var xe={from:i,to:i,text:t.doc.splitLines(b.filter(function(Re){return Re!=null}).join(t.doc.lineSeparator())),origin:"paste"};Ni(t.doc,xe),Ho(t.doc,$r(vt(t.doc,i),vt(t.doc,Zr(xe))))})()},X=function(xe,Re){if(t.options.allowDropFileTypes&&ge(t.options.allowDropFileTypes,xe.type)==-1){K();return}var Ne=new FileReader;Ne.onerror=function(){return K()},Ne.onload=function(){var je=Ne.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(je)){K();return}b[Re]=je,K()},Ne.readAsText(xe)},ee=0;ee<r.length;ee++)X(r[ee],ee);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var ce=e.dataTransfer.getData("Text");if(ce){var pe;if(t.state.draggingText&&!t.state.draggingText.copy&&(pe=t.listSelections()),$n(t.doc,$r(i,i)),pe)for(var Se=0;Se<pe.length;++Se)Bi(t.doc,"",pe[Se].anchor,pe[Se].head,"drag");t.replaceSelection(ce,"around","paste"),t.display.input.focus()}}catch(xe){}}}function Ll(e,t){if(j&&(!e.state.draggingText||+new Date-is<100)){he(t);return}if(J(e,t)||Hr(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!R){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",T&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),T&&i.parentNode.removeChild(i)}}function _l(e,t){var i=di(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),h(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var b=0;b<i.length;b++)e(i[b])})}var os=!1;function kl(){if(os)return;Dl(),os=!0}function Dl(){var e;Ae(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),Ae(window,"blur",function(){return as(Ri)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var qr={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},xn=0;xn<10;xn++)qr[xn+48]=qr[xn+96]=String(xn);for(var Qn=65;Qn<=90;Qn++)qr[Qn]=String.fromCharCode(Qn);for(var En=1;En<=12;En++)qr[En+111]=qr[En+63235]="F"+En;var Gr={};Gr.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Gr.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Gr.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Gr.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Gr.default=s?Gr.macDefault:Gr.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,b,N=0;N<t.length-1;N++){var K=t[N];if(/^(cmd|meta|m)$/i.test(K))b=!0;else if(/^a(lt)?$/i.test(K))i=!0;else if(/^(c|ctrl|control)$/i.test(K))r=!0;else if(/^s(hift)?$/i.test(K))n=!0;else throw new Error("Unrecognized modifier name: "+K)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),b&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=_(i.split(" "),Ol),b=0;b<n.length;b++){var N=void 0,K=void 0;b==n.length-1?(K=n.join(" "),N=r):(K=n.slice(0,b+1).join(" "),N="...");var X=t[K];if(!X)t[K]=N;else if(X!=N)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var ee in t)e[ee]=t[ee];return e}function Ui(e,t,i,r){t=qn(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return Ui(e,t.fallthrough,i,r);for(var b=0;b<t.fallthrough.length;b++){var N=Ui(e,t.fallthrough[b],i,r);if(N)return N}}}function ss(e){var t=typeof e=="string"?e:qr[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(f?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(f?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(T&&e.keyCode==34&&e.char)return!1;var i=qr[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function qn(e){return typeof e=="string"?Gr[e]:e}function ji(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var b=t(i[n]);r.length&&ft(b.from,A(r).to)<=0;){var N=r.pop();if(ft(N.from,b.from)<0){b.from=N.from;break}}r.push(b)}vr(e,function(){for(var K=r.length-1;K>=0;K--)Bi(e.doc,"",r[K].from,r[K].to,"+delete");Oi(e)})}function Ba(e,t,i){var r=Pe(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 Be(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var b=Ke(i,t.doc.direction);if(b){var N=n<0?A(b):b[0],K=n<0==(N.level==1),X=K?"after":"before",ee;if(N.level>0||t.doc.direction=="rtl"){var ce=_i(t,i);ee=n<0?i.text.length-1:0;var pe=Ir(t,ce,ee).top;ee=We(function(Se){return Ir(t,ce,Se).top==pe},n<0==(N.level==1)?N.from:N.to-1,ee),X=="before"&&(ee=Ba(i,ee,1))}else ee=n<0?N.to:N.from;return new Be(r,ee,X)}}return new Be(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=Ke(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 b=Xe(n,i.ch,i.sticky),N=n[b];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from<i.ch))return Fa(t,i,r);var K=function(Ge,Je){return Ba(t,Ge instanceof Be?Ge.ch:Ge,Je)},X,ee=function(Ge){return e.options.lineWrapping?(X=X||_i(e,t),co(e,t,X,Ge)):{begin:0,end:t.text.length}},ce=ee(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||N.level==1){var pe=N.level==1==r<0,Se=K(i,pe?1:-1);if(Se!=null&&(pe?Se<=N.to&&Se<=ce.end:Se>=N.from&&Se>=ce.begin)){var xe=pe?"before":"after";return new Be(i.line,Se,xe)}}var Re=function(Ge,Je,ze){for(var tt=function(Pt,Zt){return Zt?new Be(i.line,K(Pt,1),"before"):new Be(i.line,Pt,"after")};Ge>=0&&Ge<n.length;Ge+=Je){var dt=n[Ge],lt=Je>0==(dt.level!=1),Et=lt?ze.begin:K(ze.end,-1);if(dt.from<=Et&&Et<dt.to)return tt(Et,lt);if(Et=lt?dt.from:K(dt.to,-1),ze.begin<=Et&&Et<ze.end)return tt(Et,lt)}},Ne=Re(b+r,r,ce);if(Ne)return Ne;var je=r>0?ce.end:K(ce.begin,-1);return je!=null&&!(r>0&&je==t.text.length)&&(Ne=Re(r>0?0:n.length-1,r,ee(je)),Ne)?Ne:null}var Sn={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Te)},killLine:function(e){return ji(e,function(t){if(t.empty()){var i=$e(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Be(t.head.line+1,0)}:{from:t.head,to:Be(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return ji(e,function(t){return{from:Be(t.from().line,0),to:vt(e.doc,Be(t.to().line+1,0))}})},delLineLeft:function(e){return ji(e,function(t){return{from:Be(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return ji(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return ji(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Be(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Be(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Ce)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Ce)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?ds(e,t.head):r},Ce)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var b=i[n].from(),N=ne(e.getLine(b.line),b.ch,r);t.push(W(r-N%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return vr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,b=$e(e.doc,n.line).text;if(b){if(n.ch==b.length&&(n=new Be(n.line,n.ch-1)),n.ch>0)n=new Be(n.line,n.ch+1),e.replaceRange(b.charAt(n.ch-1)+b.charAt(n.ch-2),Be(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=$e(e.doc,n.line-1).text;N&&(n=new Be(n.line,1),e.replaceRange(b.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),Be(n.line-1,N.length-1),n,"+transpose"))}}i.push(new Dt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return vr(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Oi(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=$e(e.doc,t),r=xr(i);return r!=i&&(t=yt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=$e(e.doc,t),r=In(i);return r!=i&&(t=yt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=$e(e.doc,i.line),n=Ke(r,e.doc.direction);if(!n||n[0].level==0){var b=Math.max(i.ch,r.text.search(/\S/)),N=t.line==i.line&&t.ch<=b&&t.ch;return Be(i.line,N?0:b,i.sticky)}return i}function ea(e,t,i){if(typeof t=="string"&&(t=Sn[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=Me}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=Ui(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&Ui(t,e.options.extraKeys,i,e)||Ui(t,e.options.keyMap,i,e)}var Bl=new fe;function Tn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&er(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(Q(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Tn(e,"Shift-"+i,t,function(r){return ea(e,r,!0)})||Tn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return ea(e,r)}):Tn(e,i,t,function(r){return ea(e,r)}):!1}function Fl(e,t,i){return Tn(e,"'"+i+"'",t,function(r){return ea(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=M(),J(t,e))return;j&&F<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);T&&(ja=r?i:null,!r&&i==88&&!Lt&&(s?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),k&&!s&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(d(t,"CodeMirror-crosshair"),Qe(document,"keyup",i),Qe(document,"mouseover",i))}Ae(document,"keyup",i),Ae(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),J(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(Hr(t.display,e)||J(t,e)||e.ctrlKey&&!e.altKey||s&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(T&&i==ja){ja=null,Q(e);return}if(T&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&ft(t,this.pos)==0&&i==this.button};var Cn,wn;function Wl(e,t){var i=+new Date;return wn&&wn.compare(i,e,t)?(Cn=wn=null,"triple"):Cn&&Cn.compare(i,e,t)?(wn=new Wa(i,e,t),Cn=null,"double"):(Cn=new Wa(i,e,t),wn=null,"single")}function vs(e){var t=this,i=t.display;if(J(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,Hr(i,e)){P||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=di(t,e),n=ye(e),b=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,b,e))return;n==1?r?zl(t,r,b,e):me(e)==i.scroller&&Q(e):n==2?(r&&Yn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(C?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var b="Click";return r=="double"?b="Double"+b:r=="triple"&&(b="Triple"+b),b=(t==1?"Left":t==2?"Middle":"Right")+b,Tn(e,ls(b,n),n,function(N){if(typeof N=="string"&&(N=Sn[N]),!N)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=N(e,i)!=Me}finally{e.state.suppressEdits=!1}return K})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var b=l?i.shiftKey&&i.metaKey:i.altKey;n.unit=b?"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=s?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(s?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){j?setTimeout(z(vo,e),0):e.curOp.focus=M();var n=Gl(e,i,r),b=e.doc.sel,N;e.options.dragDrop&&_e&&!e.isReadOnly()&&i=="single"&&(N=b.contains(t))>-1&&(ft((N=b.ranges[N]).from(),t)<0||t.xRel>0)&&(ft(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,b=!1,N=Yt(e,function(ee){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,Qe(n.wrapper.ownerDocument,"mouseup",N),Qe(n.wrapper.ownerDocument,"mousemove",K),Qe(n.scroller,"dragstart",X),Qe(n.scroller,"drop",N),b||(Q(ee),r.addNew||Yn(e.doc,i,null,null,r.extend),P&&!R||j&&F==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(ee){b=b||Math.abs(t.clientX-ee.clientX)+Math.abs(t.clientY-ee.clientY)>=10},X=function(){return b=!0};P&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Ae(n.wrapper.ownerDocument,"mouseup",N),Ae(n.wrapper.ownerDocument,"mousemove",K),Ae(n.scroller,"dragstart",X),Ae(n.scroller,"drop",N),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new Dt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Dt(Be(t.line,0),vt(e.doc,Be(t.line+1,0)));var r=i(e,t);return new Dt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,b=e.doc;Q(t);var N,K,X=b.sel,ee=X.ranges;if(r.addNew&&!r.extend?(K=b.sel.contains(i),K>-1?N=ee[K]:N=new Dt(i,i)):(N=b.sel.primary(),K=b.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new Dt(i,i)),i=di(e,t,!0,!0),K=-1;else{var ce=ys(e,i,r.unit);r.extend?N=Ia(N,ce.anchor,ce.head,r.extend):N=ce}r.addNew?K==-1?(K=ee.length,nr(b,Rr(e,ee.concat([N]),K),{scroll:!1,origin:"*mouse"})):ee.length>1&&ee[K].empty()&&r.unit=="char"&&!r.extend?(nr(b,Rr(e,ee.slice(0,K).concat(ee.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),X=b.sel):Na(b,K,N,De):(K=0,nr(b,new Sr([N],0),De),X=b.sel);var pe=i;function Se(ze){if(ft(pe,ze)==0)return;if(pe=ze,r.unit=="rectangle"){for(var tt=[],dt=e.options.tabSize,lt=ne($e(b,i.line).text,i.ch,dt),Et=ne($e(b,ze.line).text,ze.ch,dt),Pt=Math.min(lt,Et),Zt=Math.max(lt,Et),Bt=Math.min(i.line,ze.line),yr=Math.min(e.lastLine(),Math.max(i.line,ze.line));Bt<=yr;Bt++){var pr=$e(b,Bt).text,Ht=we(pr,Pt,dt);Pt==Zt?tt.push(new Dt(Be(Bt,Ht),Be(Bt,Ht))):pr.length>Ht&&tt.push(new Dt(Be(Bt,Ht),Be(Bt,we(pr,Zt,dt))))}tt.length||tt.push(new Dt(i,i)),nr(b,Rr(e,X.ranges.slice(0,K).concat(tt),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(ze)}else{var mr=N,tr=ys(e,ze,r.unit),Vt=mr.anchor,Gt;ft(tr.anchor,Vt)>0?(Gt=tr.head,Vt=ii(mr.from(),tr.anchor)):(Gt=tr.anchor,Vt=xi(mr.to(),tr.head));var Ft=X.ranges.slice(0);Ft[K]=Xl(e,new Dt(vt(b,Vt),Gt)),nr(b,Rr(e,Ft,K),De)}}var xe=n.wrapper.getBoundingClientRect(),Re=0;function Ne(ze){var tt=++Re,dt=di(e,ze,!0,r.unit=="rectangle");if(!dt)return;if(ft(dt,pe)!=0){e.curOp.focus=M(),Se(dt);var lt=Hn(n,b);(dt.line>=lt.to||dt.line<lt.from)&&setTimeout(Yt(e,function(){Re==tt&&Ne(ze)}),150)}else{var Et=ze.clientY<xe.top?-20:ze.clientY>xe.bottom?20:0;Et&&setTimeout(Yt(e,function(){if(Re!=tt)return;n.scroller.scrollTop+=Et,Ne(ze)}),50)}}function je(ze){e.state.selectingText=!1,Re=Infinity,ze&&(Q(ze),n.input.focus()),Qe(n.wrapper.ownerDocument,"mousemove",Ge),Qe(n.wrapper.ownerDocument,"mouseup",Je),b.history.lastSelOrigin=null}var Ge=Yt(e,function(ze){ze.buttons===0||!ye(ze)?je(ze):Ne(ze)}),Je=Yt(e,je);e.state.selectingText=Je,Ae(n.wrapper.ownerDocument,"mousemove",Ge),Ae(n.wrapper.ownerDocument,"mouseup",Je)}function Xl(e,t){var i=t.anchor,r=t.head,n=$e(e.doc,i.line);if(ft(i,r)==0&&i.sticky==r.sticky)return t;var b=Ke(n);if(!b)return t;var N=Xe(b,i.ch,i.sticky),K=b[N];if(K.from!=i.ch&&K.to!=i.ch)return t;var X=N+(K.from==i.ch==(K.level!=1)?0:1);if(X==0||X==b.length)return t;var ee;if(r.line!=i.line)ee=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var ce=Xe(b,r.ch,r.sticky),pe=ce-N||(r.ch-i.ch)*(K.level==1?-1:1);ce==X-1||ce==X?ee=pe<0:ee=pe>0}var Se=b[X+(ee?-1:0)],xe=ee==(Se.level==1),Re=xe?Se.from:Se.to,Ne=xe?"after":"before";return i.ch==Re&&i.sticky==Ne?t:new Dt(new Be(i.line,Re,Ne),r)}function bs(e,t,i,r){var n,b;if(t.touches)n=t.touches[0].clientX,b=t.touches[0].clientY;else try{n=t.clientX,b=t.clientY}catch(Se){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Q(t);var N=e.display,K=N.lineDiv.getBoundingClientRect();if(b>K.bottom||!ie(e,i))return se(t);b-=K.top-N.viewOffset;for(var X=0;X<e.display.gutterSpecs.length;++X){var ee=N.gutters.childNodes[X];if(ee&&ee.getBoundingClientRect().right>=n){var ce=_t(e.doc,b),pe=e.display.gutterSpecs[X];return ae(e,i,e,ce,pe.className,t),se(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(Hr(e.display,t)||Yl(e,t))return;if(J(e,t,"contextmenu"))return;C||e.display.input.onContextMenu(t)}function Yl(e,t){return ie(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),an(e)}var Wi={toString:function(){return"CodeMirror.Init"}},Ss={},ta={};function $l(e){var t=e.optionHandlers;function i(r,n,b,N){e.defaults[r]=n,b&&(t[r]=N?function(K,X,ee){ee!=Wi&&b(K,X,ee)}:b)}e.defineOption=i,e.Init=Wi,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){fn(r),an(r),cr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var b=[],N=r.doc.first;r.doc.iter(function(X){for(var ee=0;;){var ce=X.text.indexOf(n,ee);if(ce==-1)break;ee=ce+n.length,b.push(Be(N,ce))}N++});for(var K=b.length-1;K>=0;K--)Bi(r.doc,n,b[K],Be(b[K].line,b[K].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,b){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),b!=Wi&&r.refresh()}),i("specialCharPlaceholder",Ot,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",!S),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),cn(r)},!0),i("keyMap","default",function(r,n,b){var N=qn(n),K=b!=Wi&&qn(b);K&&K.detach&&K.detach(r,N),N.attach&&N.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Da(n,r.options.lineNumbers),cn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Pi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Pi(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=Da(r.options.gutters,n),cn(r)},!0),i("firstLineNumber",1,cn,!0),i("lineNumberFormatter",function(r){return r},cn,!0),i("showCursorWhenSelecting",!1,on,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Ri(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,on,!0),i("singleCursorHeightPerLine",!0,on,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,fn,!0),i("addModeClass",!1,fn,!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,fn,!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!=Wi;if(!t!=!r){var n=e.display.dragFunctions,b=t?Ae:Qe;b(e.display.scroller,"dragstart",n.start),b(e.display.scroller,"dragenter",n.enter),b(e.display.scroller,"dragover",n.over),b(e.display.scroller,"dragleave",n.leave),b(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):(d(e.display.wrapper,"CodeMirror-wrap"),Nn(e)),Ea(e),cr(e),an(e),setTimeout(function(){return Pi(e)},100)}function It(e,t){var i=this;if(!(this instanceof It))return new It(e,t);this.options=t=t?U(t):{},U(Ss,t,!1);var r=t.value;typeof r=="string"?r=new fr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new It.inputStyles[t.inputStyle](this),b=this.display=new hl(e,r,n,t);b.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Co(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new fe,keySeq:null,specialChars:null},t.autofocus&&!o&&b.input.focus(),j&&F<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),kl(),mi(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Ri(this);for(var N in ta)ta.hasOwnProperty(N)&&ta[N](this,t[N],Wi);Lo(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);gi(this),P&&t.lineWrapping&&getComputedStyle(b.lineDiv).textRendering=="optimizelegibility"&&(b.lineDiv.style.textRendering="auto")}It.defaults=Ss,It.optionHandlers=ta;function Ql(e){var t=e.display;Ae(t.scroller,"mousedown",Yt(e,vs)),j&&F<11?Ae(t.scroller,"dblclick",Yt(e,function(X){if(J(e,X))return;var ee=di(e,X);if(!ee||Ha(e,X)||Hr(e.display,X))return;Q(X);var ce=e.findWordAt(ee);Yn(e.doc,ce.anchor,ce.head)})):Ae(t.scroller,"dblclick",function(X){return J(e,X)||Q(X)}),Ae(t.scroller,"contextmenu",function(X){return xs(e,X)}),Ae(t.input.getField(),"contextmenu",function(X){t.scroller.contains(X.target)||xs(e,X)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function b(X){if(X.touches.length!=1)return!1;var ee=X.touches[0];return ee.radiusX<=1&&ee.radiusY<=1}function N(X,ee){if(ee.left==null)return!0;var ce=ee.left-X.left,pe=ee.top-X.top;return ce*ce+pe*pe>20*20}Ae(t.scroller,"touchstart",function(X){if(!J(e,X)&&!b(X)&&!Ha(e,X)){t.input.ensurePolled(),clearTimeout(i);var ee=+new Date;t.activeTouch={start:ee,moved:!1,prev:ee-r.end<=300?r:null},X.touches.length==1&&(t.activeTouch.left=X.touches[0].pageX,t.activeTouch.top=X.touches[0].pageY)}}),Ae(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ae(t.scroller,"touchend",function(X){var ee=t.activeTouch;if(ee&&!Hr(t,X)&&ee.left!=null&&!ee.moved&&new Date-ee.start<300){var ce=e.coordsChar(t.activeTouch,"page"),pe;!ee.prev||N(ee,ee.prev)?pe=new Dt(ce,ce):!ee.prev.prev||N(ee,ee.prev.prev)?pe=e.findWordAt(ce):pe=new Dt(Be(ce.line,0),vt(e.doc,Be(ce.line+1,0))),e.setSelection(pe.anchor,pe.head),e.focus(),Q(X)}n()}),Ae(t.scroller,"touchcancel",n),Ae(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ln(e,t.scroller.scrollTop),fi(e,t.scroller.scrollLeft,!0),ae(e,"scroll",e))}),Ae(t.scroller,"mousewheel",function(X){return Do(e,X)}),Ae(t.scroller,"DOMMouseScroll",function(X){return Do(e,X)}),Ae(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(X){J(e,X)||he(X)},over:function(X){J(e,X)||(_l(e,X),he(X))},start:function(X){return Ll(e,X)},drop:Yt(e,Al),leave:function(X){J(e,X)||ns(e)}};var K=t.input.getField();Ae(K,"keyup",function(X){return ms.call(e,X)}),Ae(K,"keydown",Yt(e,ps)),Ae(K,"keypress",Yt(e,gs)),Ae(K,"focus",function(X){return Ta(e,X)}),Ae(K,"blur",function(X){return Ri(e,X)})}var Ga=[];It.defineInitHook=function(e){return Ga.push(e)};function An(e,t,i,r){var n=e.doc,b;i==null&&(i="add"),i=="smart"&&(n.mode.indent?b=wr(e,t).state:i="prev");var N=e.options.tabSize,K=$e(n,t),X=ne(K.text,null,N);K.stateAfter&&(K.stateAfter=null);var ee=K.text.match(/^\s*/)[0],ce;if(!r&&!/\S/.test(K.text))ce=0,i="not";else if(i=="smart"&&(ce=n.mode.indent(b,K.text.slice(ee.length),K.text),ce==Me||ce>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?ce=ne($e(n,t-1).text,null,N):ce=0:i=="add"?ce=X+e.options.indentUnit:i=="subtract"?ce=X-e.options.indentUnit:typeof i=="number"&&(ce=X+i),ce=Math.max(0,ce);var pe="",Se=0;if(e.options.indentWithTabs)for(var xe=Math.floor(ce/N);xe;--xe)Se+=N,pe+=" ";if(Se<ce&&(pe+=W(ce-Se)),pe!=ee)return Bi(n,pe,Be(t,0),Be(t,ee.length),"+input"),K.stateAfter=null,!0;for(var Re=0;Re<n.sel.ranges.length;Re++){var Ne=n.sel.ranges[Re];if(Ne.head.line==t&&Ne.head.ch<ee.length){var je=Be(t,ee.length);Na(n,Re,new Dt(je,je));break}}}var Or=null;function ra(e){Or=e}function za(e,t,i,r,n){var b=e.doc;e.display.shift=!1,r||(r=b.sel);var N=+new Date-200,K=n=="paste"||e.state.pasteIncoming>N,X=ot(t),ee=null;if(K&&r.ranges.length>1)if(Or&&Or.text.join(`
|
|
`)==t){if(r.ranges.length%Or.text.length==0){ee=[];for(var ce=0;ce<Or.text.length;ce++)ee.push(b.splitLines(Or.text[ce]))}}else X.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(ee=_(X,function(Ge){return[Ge]}));for(var pe=e.curOp.updateInput,Se=r.ranges.length-1;Se>=0;Se--){var xe=r.ranges[Se],Re=xe.from(),Ne=xe.to();xe.empty()&&(i&&i>0?Re=Be(Re.line,Re.ch-i):e.state.overwrite&&!K?Ne=Be(Ne.line,Math.min($e(b,Ne.line).text.length,Ne.ch+A(X).length)):K&&Or&&Or.lineWise&&Or.text.join(`
|
|
`)==X.join(`
|
|
`)&&(Re=Ne=Be(Re.line,0)));var je={from:Re,to:Ne,text:ee?ee[Se%ee.length]:X,origin:n||(K?"paste":e.state.cutIncoming>N?"cut":"+input")};Ni(e.doc,je),er(e,"inputRead",e,je)}t&&!K&&Cs(e,t),Oi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=pe),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ts(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&vr(t,function(){return za(t,i,0,null,"paste")}),!0}function Cs(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var b=e.getModeAt(n.head),N=!1;if(b.electricChars){for(var K=0;K<b.electricChars.length;K++)if(t.indexOf(b.electricChars.charAt(K))>-1){N=An(e,n.head.line,"smart");break}}else b.electricInput&&(b.electricInput.test($e(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=An(e,n.head.line,"smart")));N&&er(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,b={anchor:Be(n,0),head:Be(n+1,0)};i.push(b),t.push(e.getRange(b.anchor,b.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return P?e.style.width="1000px":e.setAttribute("wrap","off"),E&&(e.style.border="1px solid black"),As(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var b=this.options,N=b[r];if(b[r]==n&&r!="mode")return;b[r]=n,t.hasOwnProperty(r)&&Yt(this,t[r])(this,n,N),ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](qn(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,b=0;b<n.length;++b)if(n[b]==r||n[b].name==r)return n.splice(b,1),!0},addOverlay:sr(function(r,n){var b=r.token?r:e.getMode(this.options,r);if(b.startState)throw new Error("Overlays may not be stateful.");H(this.state.overlays,{mode:b,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(N){return N.priority}),this.state.modeGen++,cr(this)}),removeOverlay:sr(function(r){for(var n=this.state.overlays,b=0;b<n.length;++b){var N=n[b].modeSpec;if(N==r||typeof r=="string"&&N.name==r){n.splice(b,1),this.state.modeGen++,cr(this);return}}}),indentLine:sr(function(r,n,b){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),br(this.doc,r)&&An(this,r,n,b)}),indentSelection:sr(function(r){for(var n=this.doc.sel.ranges,b=-1,N=0;N<n.length;N++){var K=n[N];if(K.empty())K.head.line>b&&(An(this,K.head.line,r,!0),b=K.head.line,N==this.doc.sel.primIndex&&Oi(this));else{var X=K.from(),ee=K.to(),ce=Math.max(b,X.line);b=Math.min(this.lastLine(),ee.line-(ee.ch?0:1))+1;for(var pe=ce;pe<b;++pe)An(this,pe,r);var Se=this.doc.sel.ranges;X.ch==0&&n.length==Se.length&&Se[N].from().ch>0&&Na(this.doc,N,new Dt(X,Se[N].to()),Te)}}}),getTokenAt:function(r,n){return _n(this,r,n)},getLineTokens:function(r,n){return _n(this,Be(r),n,!0)},getTokenTypeAt:function(r){r=vt(this.doc,r);var n=ni(this,$e(this.doc,r.line)),b=0,N=(n.length-1)/2,K=r.ch,X;if(K==0)X=n[2];else for(;;){var ee=b+N>>1;if((ee?n[ee*2-1]:0)>=K)N=ee;else if(n[ee*2+1]<K)b=ee+1;else{X=n[ee*2+2];break}}var ce=X?X.indexOf("overlay "):-1;return ce<0?X:ce==0?null:X.slice(0,ce-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var b=[];if(!i.hasOwnProperty(n))return b;var N=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")N[K[n]]&&b.push(N[K[n]]);else if(K[n])for(var X=0;X<K[n].length;X++){var ee=N[K[n][X]];ee&&b.push(ee)}else K.helperType&&N[K.helperType]?b.push(N[K.helperType]):N[K.name]&&b.push(N[K.name]);for(var ce=0;ce<N._global.length;ce++){var pe=N._global[ce];pe.pred(K,this)&&ge(b,pe.val)==-1&&b.push(pe.val)}return b},getStateAfter:function(r,n){var b=this.doc;return r=Ei(b,r==null?b.first+b.size-1:r),wr(this,r+1,n).state},cursorCoords:function(r,n){var b,N=this.doc.sel.primary();return r==null?b=N.head:typeof r=="object"?b=vt(this.doc,r):b=r?N.from():N.to(),Dr(this,b,n||"page")},charCoords:function(r,n){return ma(this,vt(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,_t(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,b){var N=!1,K;if(typeof r=="number"){var X=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>X&&(r=X,N=!0),K=$e(this.doc,r)}else K=r;return Fn(this,K,{top:0,left:0},n||"page",b||N).top+(N?this.doc.height-kr(K):0)},defaultTextHeight:function(){return ki(this.display)},defaultCharWidth:function(){return Di(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,b,N,K){var X=this.display;r=Dr(this,vt(this.doc,r));var ee=r.bottom,ce=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),X.sizer.appendChild(n),N=="over")ee=r.top;else if(N=="above"||N=="near"){var pe=Math.max(X.wrapper.clientHeight,this.doc.height),Se=Math.max(X.sizer.clientWidth,X.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>pe)&&r.top>n.offsetHeight?ee=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=pe&&(ee=r.bottom),ce+n.offsetWidth>Se&&(ce=Se-n.offsetWidth)}n.style.top=ee+"px",n.style.left=n.style.right="",K=="right"?(ce=X.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?ce=0:K=="middle"&&(ce=(X.sizer.clientWidth-n.offsetWidth)/2),n.style.left=ce+"px"),b&&Zs(this,{left:ce,top:ee,right:ce+n.offsetWidth,bottom:ee+n.offsetHeight})},triggerOnKeyDown:sr(ps),triggerOnKeyPress:sr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:sr(vs),execCommand:function(r){if(Sn.hasOwnProperty(r))return Sn[r].call(null,this)},triggerElectric:sr(function(r){Cs(this,r)}),findPosH:function(r,n,b,N){var K=1;n<0&&(K=-1,n=-n);for(var X=vt(this.doc,r),ee=0;ee<n&&!(X=Ka(this.doc,X,K,b,N),X.hitSide);++ee);return X},moveH:sr(function(r,n){var b=this;this.extendSelectionsBy(function(N){return b.display.shift||b.doc.extend||N.empty()?Ka(b.doc,N.head,r,n,b.options.rtlMoveVisually):r<0?N.from():N.to()},Ce)}),deleteH:sr(function(r,n){var b=this.doc.sel,N=this.doc;b.somethingSelected()?N.replaceSelection("",null,"+delete"):ji(this,function(K){var X=Ka(N,K.head,r,n,!1);return r<0?{from:X,to:K.head}:{from:K.head,to:X}})}),findPosV:function(r,n,b,N){var K=1,X=N;n<0&&(K=-1,n=-n);for(var ee=vt(this.doc,r),ce=0;ce<n;++ce){var pe=Dr(this,ee,"div");if(X==null?X=pe.left:pe.left=X,ee=_s(this,pe,K,b),ee.hitSide)break}return ee},moveV:sr(function(r,n){var b=this,N=this.doc,K=[],X=!this.display.shift&&!N.extend&&N.sel.somethingSelected();if(N.extendSelectionsBy(function(ce){if(X)return r<0?ce.from():ce.to();var pe=Dr(b,ce.head,"div");ce.goalColumn!=null&&(pe.left=ce.goalColumn),K.push(pe.left);var Se=_s(b,pe,r,n);return n=="page"&&ce==N.sel.primary()&&wa(b,ma(b,Se,"div").top-pe.top),Se},Ce),K.length)for(var ee=0;ee<N.sel.ranges.length;ee++)N.sel.ranges[ee].goalColumn=K[ee]}),findWordAt:function(r){var n=this.doc,b=$e(n,r.line).text,N=r.ch,K=r.ch;if(b){var X=this.getHelper(r,"wordChars");(r.sticky=="before"||K==b.length)&&N?--N:++K;for(var ee=b.charAt(N),ce=Le(ee,X)?function(pe){return Le(pe,X)}:/\s/.test(ee)?function(pe){return/\s/.test(pe)}:function(pe){return!/\s/.test(pe)&&!Le(pe)};N>0&&ce(b.charAt(N-1));)--N;for(;K<b.length&&ce(b.charAt(K));)++K}return new Dt(Be(r.line,N),Be(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):d(this.display.cursorDiv,"CodeMirror-overwrite"),ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==M()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:sr(function(r,n){sn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-Mr(this)-this.display.barHeight,width:r.scrollWidth-Mr(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:ui(this)}},scrollIntoView:sr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Be(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Js(this,r):xo(this,r.from,r.to,r.margin)}),setSize:sr(function(r,n){var b=this,N=function(X){return typeof X=="number"||/^\d+$/.test(String(X))?X+"px":X};r!=null&&(this.display.wrapper.style.width=N(r)),n!=null&&(this.display.wrapper.style.height=N(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(X){if(X.widgets){for(var ee=0;ee<X.widgets.length;ee++)if(X.widgets[ee].noHScroll){Xr(b,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,ae(this,"refresh",this)}),operation:function(r){return vr(this,r)},startOperation:function(){return mi(this)},endOperation:function(){return gi(this)},refresh:sr(function(){var r=this.display.cachedTextHeight;cr(this),this.curOp.forceUpdate=!0,an(this),sn(this,this.doc.scrollLeft,this.doc.scrollTop),_a(this.display),(r==null||Math.abs(r-ki(this.display))>.5||this.options.lineWrapping)&&Ea(this),ae(this,"refresh",this)}),swapDoc:sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),an(this),this.display.input.reset(),sn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,er(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}},oe(e),e.registerHelper=function(r,n,b){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=b},e.registerGlobalHelper=function(r,n,b,N){e.registerHelper(r,n,N),i[r]._global.push({pred:b,val:N})}}function Ka(e,t,i,r,n){var b=t,N=i,K=$e(e,t.line),X=n&&e.direction=="rtl"?-i:i;function ee(){var Je=t.line+X;return Je<e.first||Je>=e.first+e.size?!1:(t=new Be(Je,t.ch,t.sticky),K=$e(e,Je))}function ce(Je){var ze;if(r=="codepoint"){var tt=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(tt)?ze=null:ze=new Be(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(tt>=55296&&tt<56320?2:1))),-i)}else n?ze=Ml(e.cm,K,t,i):ze=Fa(K,t,i);if(ze==null)if(!Je&&ee())t=Ua(n,e.cm,K,t.line,X);else return!1;else t=ze;return!0}if(r=="char"||r=="codepoint")ce();else if(r=="column")ce(!0);else if(r=="word"||r=="group")for(var pe=null,Se=r=="group",xe=e.cm&&e.cm.getHelper(t,"wordChars"),Re=!0;!(i<0&&!ce(!Re));Re=!1){var Ne=K.text.charAt(t.ch)||`
|
|
`,je=Le(Ne,xe)?"w":Se&&Ne==`
|
|
`?"n":!Se||/\s/.test(Ne)?null:"p";if(Se&&!Re&&!je&&(je="s"),pe&&pe!=je){i<0&&(i=1,ce(),t.sticky="after");break}if(je&&(pe=je),i>0&&!ce(!Re))break}var Ge=Zn(e,t,b,N,!0);return ri(b,Ge)&&(Ge.hitSide=!0),Ge}function _s(e,t,i,r){var n=e.doc,b=t.left,N;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),X=Math.max(K-.5*ki(e.display),3);N=(i>0?t.bottom:t.top)+i*X}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var ee;!(ee=va(e,b,N),!ee.outside);){if(i<0?N<=0:N>=n.height){ee.hitSide=!0;break}N+=i*5}return ee}var Rt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new fe,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Rt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function b(K){for(var X=K.target;X;X=X.parentNode){if(X==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(X.className))break}return!1}Ae(n,"paste",function(K){if(!b(K)||J(r,K)||Ts(K,r))return;F<=11&&setTimeout(Yt(r,function(){return t.updateFromDOM()}),20)}),Ae(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),Ae(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),Ae(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ae(n,"touchstart",function(){return i.forceCompositionEnd()}),Ae(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(K){if(!b(K)||J(r,K))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var X=ws(r);ra({lineWise:!0,text:X.text}),K.type=="cut"&&r.operation(function(){r.setSelections(X.ranges,0,Te),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var ee=Or.text.join(`
|
|
`);if(K.clipboardData.setData("Text",ee),K.clipboardData.getData("Text")==ee){K.preventDefault();return}}var ce=Ls(),pe=ce.firstChild;r.display.lineSpace.insertBefore(ce,r.display.lineSpace.firstChild),pe.value=Or.text.join(`
|
|
`);var Se=document.activeElement;re(pe),setTimeout(function(){r.display.lineSpace.removeChild(ce),Se.focus(),Se==n&&i.showPrimarySelection()},50)}Ae(n,"copy",N),Ae(n,"cut",N)},Rt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Rt.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Rt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Rt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Rt.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line<t.display.viewFrom){e.removeAllRanges();return}var b=ia(t,e.anchorNode,e.anchorOffset),N=ia(t,e.focusNode,e.focusOffset);if(b&&!b.bad&&N&&!N.bad&&ft(ii(b,N),r)==0&&ft(xi(b,N),n)==0)return;var K=t.display.view,X=r.line>=t.display.viewFrom&&ks(t,r)||{node:K[0].measure.map[2],offset:0},ee=n.line<t.display.viewTo&&ks(t,n);if(!ee){var ce=K[K.length-1].measure,pe=ce.maps?ce.maps[ce.maps.length-1]:ce.map;ee={node:pe[pe.length-1],offset:pe[pe.length-2]-pe[pe.length-3]}}if(!X||!ee){e.removeAllRanges();return}var Se=e.rangeCount&&e.getRangeAt(0),xe;try{xe=m(X.node,X.offset,ee.offset,ee.node)}catch(Re){}xe&&(!k&&t.state.focused?(e.collapse(X.node,X.offset),xe.collapsed||(e.removeAllRanges(),e.addRange(xe))):(e.removeAllRanges(),e.addRange(xe)),Se&&e.anchorNode==null?e.addRange(Se):k&&this.startGracePeriod()),this.rememberSelection()},Rt.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Rt.prototype.showMultipleSelections=function(e){h(this.cm.display.cursorDiv,e.cursors),h(this.cm.display.selectionDiv,e.selection)},Rt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Rt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return x(this.div,t)},Rt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Rt.prototype.blur=function(){this.div.blur()},Rt.prototype.getField=function(){return this.div},Rt.prototype.supportsTouch=function(){return!0},Rt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():vr(this.cm,function(){return e.cm.curOp.selectionChanged=!0});function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}this.polling.set(this.cm.options.pollInterval,t)},Rt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Rt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&g&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=ia(t,e.anchorNode,e.anchorOffset),r=ia(t,e.focusNode,e.focusOffset);i&&r&&vr(t,function(){nr(t.doc,$r(i,r),Te),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Rt.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,i=e.doc.sel.primary(),r=i.from(),n=i.to();if(r.ch==0&&r.line>e.firstLine()&&(r=Be(r.line-1,$e(e.doc,r.line-1).length)),n.ch==$e(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Be(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var b,N,K;r.line==t.viewFrom||(b=ci(e,r.line))==0?(N=yt(t.view[0].line),K=t.view[0].node):(N=yt(t.view[b].line),K=t.view[b-1].node.nextSibling);var X=ci(e,n.line),ee,ce;if(X==t.view.length-1?(ee=t.viewTo-1,ce=t.lineDiv.lastChild):(ee=yt(t.view[X+1].line)-1,ce=t.view[X+1].node.previousSibling),!K)return!1;for(var pe=e.doc.splitLines(tu(e,K,ce,N,ee)),Se=wt(e.doc,Be(N,0),Be(ee,$e(e.doc,ee).text.length));pe.length>1&&Se.length>1;)if(A(pe)==A(Se))pe.pop(),Se.pop(),ee--;else if(pe[0]==Se[0])pe.shift(),Se.shift(),N++;else break;for(var xe=0,Re=0,Ne=pe[0],je=Se[0],Ge=Math.min(Ne.length,je.length);xe<Ge&&Ne.charCodeAt(xe)==je.charCodeAt(xe);)++xe;for(var Je=A(pe),ze=A(Se),tt=Math.min(Je.length-(pe.length==1?xe:0),ze.length-(Se.length==1?xe:0));Re<tt&&Je.charCodeAt(Je.length-Re-1)==ze.charCodeAt(ze.length-Re-1);)++Re;if(pe.length==1&&Se.length==1&&N==r.line)for(;xe&&xe>r.ch&&Je.charCodeAt(Je.length-Re-1)==ze.charCodeAt(ze.length-Re-1);)xe--,Re++;pe[pe.length-1]=Je.slice(0,Je.length-Re).replace(/^\u200b+/,""),pe[0]=pe[0].slice(xe).replace(/\u200b+$/,"");var dt=Be(N,xe),lt=Be(ee,Se.length?A(Se).length-Re:0);if(pe.length>1||pe[0]||ft(dt,lt))return Bi(e.doc,pe,dt,lt,"+input"),!0},Rt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Rt.prototype.reset=function(){this.forceCompositionEnd()},Rt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Rt.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)},Rt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&vr(this.cm,function(){return cr(e.cm)})},Rt.prototype.setUneditable=function(e){e.contentEditable="false"},Rt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||Yt(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Rt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Rt.prototype.onContextMenu=function(){},Rt.prototype.resetPosition=function(){},Rt.prototype.needsContentAttribute=!0;function ks(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=$e(e.doc,t.line),n=eo(i,r,t.line),b=Ke(r,e.doc.direction),N="left";if(b){var K=Xe(b,t.ch);N=K%2?"right":"left"}var X=io(n.map,t.ch,N);return X.offset=X.collapse=="right"?X.end:X.start,X}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hi(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var b="",N=!1,K=e.doc.lineSeparator(),X=!1;function ee(xe){return function(Re){return Re.id==xe}}function ce(){N&&(b+=K,X&&(b+=K),N=X=!1)}function pe(xe){xe&&(ce(),b+=xe)}function Se(xe){if(xe.nodeType==1){var Re=xe.getAttribute("cm-text");if(Re){pe(Re);return}var Ne=xe.getAttribute("cm-marker"),je;if(Ne){var Ge=e.findMarks(Be(r,0),Be(n+1,0),ee(+Ne));Ge.length&&(je=Ge[0].find(0))&&pe(wt(e.doc,je.from,je.to).join(K));return}if(xe.getAttribute("contenteditable")=="false")return;var Je=/^(pre|div|p|li|table|br)$/i.test(xe.nodeName);if(!/^br$/i.test(xe.nodeName)&&xe.textContent.length==0)return;Je&&ce();for(var ze=0;ze<xe.childNodes.length;ze++)Se(xe.childNodes[ze]);/^(pre|p)$/i.test(xe.nodeName)&&(X=!0),Je&&(N=!0)}else xe.nodeType==3&&pe(xe.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Se(t),t==i);)t=t.nextSibling,X=!1;return b}function ia(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return Hi(e.clipPos(Be(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var n=0;n<e.display.view.length;n++){var b=e.display.view[n];if(b.node==r)return ru(b,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!x(r,t))return Hi(Be(yt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var b=e.rest?A(e.rest):e.line;return Hi(Be(yt(b),b.text.length),n)}var N=t.nodeType==3?t:null,K=t;for(!N&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(N=t.firstChild,i&&(i=N.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var X=e.measure,ee=X.maps;function ce(je,Ge,Je){for(var ze=-1;ze<(ee?ee.length:0);ze++)for(var tt=ze<0?X.map:ee[ze],dt=0;dt<tt.length;dt+=3){var lt=tt[dt+2];if(lt==je||lt==Ge){var Et=yt(ze<0?e.line:e.rest[ze]),Pt=tt[dt]+Je;return(Je<0||lt!=je)&&(Pt=tt[dt+(Je?1:0)]),Be(Et,Pt)}}}var pe=ce(N,K,i);if(pe)return Hi(pe,n);for(var Se=K.nextSibling,xe=N?N.nodeValue.length-i:0;Se;Se=Se.nextSibling){if(pe=ce(Se,Se.firstChild,0),pe)return Hi(Be(pe.line,pe.ch-xe),n);xe+=Se.textContent.length}for(var Re=K.previousSibling,Ne=i;Re;Re=Re.previousSibling){if(pe=ce(Re,Re.firstChild,-1),pe)return Hi(Be(pe.line,pe.ch+Ne),n);Ne+=Re.textContent.length}}var jt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new fe,this.hasSelection=!1,this.composing=null};jt.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),E&&(n.style.width="0px"),Ae(n,"input",function(){j&&F>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Ae(n,"paste",function(N){if(J(r,N)||Ts(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function b(N){if(J(r,N))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);ra({lineWise:!0,text:K.text}),N.type=="cut"?r.setSelections(K.ranges,null,Te):(i.prevInput="",n.value=K.text.join(`
|
|
`),re(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Ae(n,"cut",b),Ae(n,"copy",b),Ae(e.scroller,"paste",function(N){if(Hr(e,N)||J(r,N))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=N.clipboardData,n.dispatchEvent(K)}),Ae(e.lineSpace,"selectstart",function(N){Hr(e,N)||Q(N)}),Ae(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"})}}),Ae(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},jt.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},jt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},jt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Dr(e,i.sel.primary().head,"div"),b=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-b.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-b.left))}return r},jt.prototype.showSelection=function(e){var t=this.cm,i=t.display;h(i.cursorDiv,e.cursors),h(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},jt.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&&re(this.textarea),j&&F>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",j&&F>=9&&(this.hasSelection=null))},jt.prototype.getField=function(){return this.textarea},jt.prototype.supportsTouch=function(){return!1},jt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||M()!=this.textarea))try{this.textarea.focus()}catch(e){}},jt.prototype.blur=function(){this.textarea.blur()},jt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},jt.prototype.receivedFocus=function(){this.slowPoll()},jt.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()})},jt.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)},jt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||it(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(j&&F>=9&&this.hasSelection===n||s&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var b=n.charCodeAt(0);if(b==8203&&!r&&(r="\u200B"),b==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,K=Math.min(r.length,n.length);N<K&&r.charCodeAt(N)==n.charCodeAt(N);)++N;return vr(t,function(){za(t,n.slice(N),r.length-N,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
|
|
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},jt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},jt.prototype.onKeyPress=function(){j&&F>=9&&(this.hasSelection=null),this.fastPoll()},jt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var b=di(i,e),N=r.scroller.scrollTop;if(!b||T)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(b)==-1&&Yt(i,nr)(i.doc,$r(b),Te);var X=n.style.cssText,ee=t.wrapper.style.cssText,ce=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-ce.top-5)+"px; left: "+(e.clientX-ce.left-5)+`px;
|
|
z-index: 1000; background: `+(j?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var pe;P&&(pe=window.scrollY),r.input.focus(),P&&window.scrollTo(null,pe),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=xe,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function Se(){if(n.selectionStart!=null){var Ne=i.somethingSelected(),je="\u200B"+(Ne?n.value:"");n.value="\u21DA",n.value=je,t.prevInput=Ne?"":"\u200B",n.selectionStart=1,n.selectionEnd=je.length,r.selForContextMenu=i.doc.sel}}function xe(){if(t.contextMenuPending!=xe)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=ee,n.style.cssText=X,j&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!j||j&&F<9)&&Se();var Ne=0,je=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?Yt(i,Xo)(i):Ne++<10?r.detectingSelectAll=setTimeout(je,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(je,200)}}if(j&&F>=9&&Se(),C){he(e);var Re=function(){Qe(window,"mouseup",Re),setTimeout(xe,20)};Ae(window,"mouseup",Re)}else setTimeout(xe,50)},jt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},jt.prototype.setUneditable=function(){},jt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?U(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=M();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(Ae(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var b=e.form;n=b.submit;try{var N=b.submit=function(){r(),b.submit=n,b.submit(),b.submit=N}}catch(X){}}t.finishInit=function(X){X.save=r,X.getTextArea=function(){return e},X.toTextArea=function(){X.toTextArea=isNaN,r(),e.parentNode.removeChild(X.getWrapperElement()),e.style.display="",e.form&&(Qe(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=It(function(X){return e.parentNode.insertBefore(X,e.nextSibling)},t);return K}function nu(e){e.off=Qe,e.on=Ae,e.wheelEventPixels=dl,e.Doc=fr,e.splitLines=ot,e.countColumn=ne,e.findColumn=we,e.isWordChar=Ee,e.Pass=Me,e.signal=ae,e.Line=li,e.changeEnd=Zr,e.scrollbarModel=To,e.Pos=Be,e.cmpPos=ft,e.modes=gt,e.mimeModes=st,e.resolveMode=Ut,e.getMode=rr,e.modeExtensions=ur,e.extendMode=zt,e.copyState=Qt,e.startState=ti,e.innerMode=Br,e.commands=Sn,e.keyMap=Gr,e.keyName=us,e.isModifierKey=ss,e.lookupKey=Ui,e.normalizeKeyMap=Pl,e.StringStream=Mt,e.SharedTextMarker=bn,e.TextMarker=Qr,e.LineWidget=yn,e.e_preventDefault=Q,e.e_stopPropagation=te,e.e_stop=he,e.addClass=G,e.contains=x,e.rmClass=d,e.keyNames=qr}$l(It),ql(It);var au="iter insert remove copy getEditor constructor".split(" ");for(var na in fr.prototype)fr.prototype.hasOwnProperty(na)&&ge(au,na)<0&&(It.prototype[na]=function(e){return function(){return e.apply(this.doc,arguments)}}(fr.prototype[na]));return oe(fr),It.inputStyles={textarea:jt,contenteditable:Rt},It.defineMode=function(e){!It.defaults.mode&&e!="null"&&(It.defaults.mode=e),Xt.apply(this,arguments)},It.defineMIME=Nt,It.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),It.defineMIME("text/plain","null"),It.defineExtension=function(e,t){It.prototype[e]=t},It.defineDocExtension=function(e,t){fr.prototype[e]=t},It.fromTextArea=iu,nu(It),It.version="5.58.2",It})},Y1PL:function(ht,Ze,le){"use strict";le.r(Ze),le.d(Ze,"ResizableTextArea",function(){return ge});var ue=le("wx14"),Y=le("1OyB"),k=le("vuIU"),V=le("Ji7U"),I=le("LK+K"),D=le("q1tI"),j=le("VTBJ"),F=le("rePB"),P=le("Zm9Q"),O=le("Kwbf"),g=le("c+Xe"),T=le("m+aA"),R=le("bdgK"),L=new Map;function w(Te){Te.forEach(function(De){var Ce,we=De.target;(Ce=L.get(we))===null||Ce===void 0||Ce.forEach(function(ve){return ve(we)})})}var E=new R.default(w),u=null,o=null;function s(Te,De){L.has(Te)||(L.set(Te,new Set),E.observe(Te)),L.get(Te).add(De)}function l(Te,De){L.has(Te)&&(L.get(Te).delete(De),L.get(Te).size||(E.unobserve(Te),L.delete(Te)))}var S=function(Te){Object(V.a)(Ce,Te);var De=Object(I.a)(Ce);function Ce(){return Object(Y.a)(this,Ce),De.apply(this,arguments)}return Object(k.a)(Ce,[{key:"render",value:function(){return this.props.children}}]),Ce}(D.Component),p=D.createContext(null);function f(Te){var De=Te.children,Ce=Te.onBatchResize,we=D.useRef(0),ve=D.useRef([]),W=D.useContext(p),A=D.useCallback(function(_,H,q){we.current+=1;var B=we.current;ve.current.push({size:_,element:H,data:q}),Promise.resolve().then(function(){B===we.current&&(Ce==null||Ce(ve.current),ve.current=[])}),W==null||W(_,H,q)},[Ce,W]);return D.createElement(p.Provider,{value:A},De)}function C(Te){var De=Te.children,Ce=Te.disabled,we=D.useRef(null),ve=D.useRef(null),W=D.useContext(p),A=D.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),_=D.isValidElement(De)&&Object(g.c)(De),H=_?De.ref:null,q=D.useMemo(function(){return Object(g.a)(H,we)},[H,we]),B=D.useRef(Te);B.current=Te;var de=D.useCallback(function(Ee){var Le=B.current,Ie=Le.onResize,ke=Le.data,Oe=Ee.getBoundingClientRect(),Pe=Oe.width,We=Oe.height,He=Ee.offsetWidth,Ve=Ee.offsetHeight,Xe=Math.floor(Pe),nt=Math.floor(We);if(A.current.width!==Xe||A.current.height!==nt||A.current.offsetWidth!==He||A.current.offsetHeight!==Ve){var Ke={width:Xe,height:nt,offsetWidth:He,offsetHeight:Ve};A.current=Ke;var Ye=He===Math.round(Pe)?Pe:He,Ae=Ve===Math.round(We)?We:Ve,rt=Object(j.a)(Object(j.a)({},Ke),{},{offsetWidth:Ye,offsetHeight:Ae});W==null||W(rt,Ee,ke),Ie&&Promise.resolve().then(function(){Ie(rt,Ee)})}},[]);return D.useEffect(function(){var Ee=Object(T.a)(we.current)||Object(T.a)(ve.current);return Ee&&!Ce&&s(Ee,de),function(){return l(Ee,de)}},[we.current,Ce]),D.createElement(S,{ref:ve},_?D.cloneElement(De,{ref:q}):De)}var v="rc-observer-key";function d(Te){var De=Te.children,Ce=Object(P.a)(De);return Ce.map(function(we,ve){var W=(we==null?void 0:we.key)||"".concat(v,"-").concat(ve);return D.createElement(C,Object(ue.a)({},Te,{key:W}),we)})}d.Collection=f;var c=d,h=le("bT9E"),a=le("TSYQ"),y=le.n(a),m=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,x=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],M={},G;function $(Te){var De=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=Te.getAttribute("id")||Te.getAttribute("data-reactid")||Te.getAttribute("name");if(De&&M[Ce])return M[Ce];var we=window.getComputedStyle(Te),ve=we.getPropertyValue("box-sizing")||we.getPropertyValue("-moz-box-sizing")||we.getPropertyValue("-webkit-box-sizing"),W=parseFloat(we.getPropertyValue("padding-bottom"))+parseFloat(we.getPropertyValue("padding-top")),A=parseFloat(we.getPropertyValue("border-bottom-width"))+parseFloat(we.getPropertyValue("border-top-width")),_=x.map(function(q){return"".concat(q,":").concat(we.getPropertyValue(q))}).join(";"),H={sizingStyle:_,paddingSize:W,borderSize:A,boxSizing:ve};return De&&Ce&&(M[Ce]=H),H}function re(Te){var De=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,we=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)),Te.getAttribute("wrap")?G.setAttribute("wrap",Te.getAttribute("wrap")):G.removeAttribute("wrap");var ve=$(Te,De),W=ve.paddingSize,A=ve.borderSize,_=ve.boxSizing,H=ve.sizingStyle;G.setAttribute("style","".concat(H,";").concat(m)),G.value=Te.value||Te.placeholder||"";var q=Number.MIN_SAFE_INTEGER,B=Number.MAX_SAFE_INTEGER,de=G.scrollHeight,Ee;if(_==="border-box"?de+=A:_==="content-box"&&(de-=W),Ce!==null||we!==null){G.value=" ";var Le=G.scrollHeight-W;Ce!==null&&(q=Le*Ce,_==="border-box"&&(q=q+W+A),de=Math.max(q,de)),we!==null&&(B=Le*we,_==="border-box"&&(B=B+W+A),Ee=de>B?"":"hidden",de=Math.min(B,de))}return{height:de,minHeight:q,maxHeight:B,overflowY:Ee,resize:"none"}}var z=le("Gytx"),U=le.n(z),ne;(function(Te){Te[Te.NONE=0]="NONE",Te[Te.RESIZING=1]="RESIZING",Te[Te.RESIZED=2]="RESIZED"})(ne||(ne={}));var fe=function(Te){Object(V.a)(Ce,Te);var De=Object(I.a)(Ce);function Ce(we){var ve;return Object(Y.a)(this,Ce),ve=De.call(this,we),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(W){ve.textArea=W},ve.handleResize=function(W){var A=ve.state.resizeStatus,_=ve.props,H=_.autoSize,q=_.onResize;if(A!==ne.NONE)return;typeof q=="function"&&q(W),H&&ve.resizeOnNextFrame()},ve.resizeOnNextFrame=function(){cancelAnimationFrame(ve.nextFrameActionId),ve.nextFrameActionId=requestAnimationFrame(ve.resizeTextarea)},ve.resizeTextarea=function(){var W=ve.props.autoSize;if(!W||!ve.textArea)return;var A=W.minRows,_=W.maxRows,H=re(ve.textArea,!1,A,_);ve.setState({textareaStyles:H,resizeStatus:ne.RESIZING},function(){cancelAnimationFrame(ve.resizeFrameId),ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.RESIZED},function(){ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.NONE}),ve.fixFirefoxAutoScroll()})})})})},ve.renderTextArea=function(){var W=ve.props,A=W.prefixCls,_=A===void 0?"rc-textarea":A,H=W.autoSize,q=W.onResize,B=W.className,de=W.disabled,Ee=ve.state,Le=Ee.textareaStyles,Ie=Ee.resizeStatus,ke=Object(h.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Oe=y()(_,B,Object(F.a)({},"".concat(_,"-disabled"),de));"value"in ke&&(ke.value=ke.value||"");var Pe=Object(j.a)(Object(j.a)(Object(j.a)({},ve.props.style),Le),Ie===ne.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return D.createElement(c,{onResize:ve.handleResize,disabled:!(H||q)},D.createElement("textarea",Object(ue.a)({},ke,{className:Oe,style:Pe,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:ne.NONE},ve}return Object(k.a)(Ce,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!U()(ve.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ve=this.textArea.selectionStart,W=this.textArea.selectionEnd;this.textArea.setSelectionRange(ve,W)}}catch(A){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ce}(D.Component),ge=fe,be=function(Te){Object(V.a)(Ce,Te);var De=Object(I.a)(Ce);function Ce(we){var ve;Object(Y.a)(this,Ce),ve=De.call(this,we),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(A){ve.resizableTextArea=A},ve.handleChange=function(A){var _=ve.props.onChange;ve.setValue(A.target.value,function(){ve.resizableTextArea.resizeTextarea()}),_&&_(A)},ve.handleKeyDown=function(A){var _=ve.props,H=_.onPressEnter,q=_.onKeyDown;A.keyCode===13&&H&&H(A),q&&q(A)};var W=typeof we.value=="undefined"||we.value===null?we.defaultValue:we.value;return ve.state={value:W},ve}return Object(k.a)(Ce,[{key:"setValue",value:function(ve,W){"value"in this.props||this.setState({value:ve},W)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return D.createElement(ge,Object(ue.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ve){return"value"in ve?{value:ve.value}:null}}]),Ce}(D.Component),Me=Ze.default=be},bT9E:function(ht,Ze,le){"use strict";le.d(Ze,"a",function(){return Y});var ue=le("VTBJ");function Y(k,V){var I=Object(ue.a)({},k);return Array.isArray(V)&&V.forEach(function(D){delete I[D]}),I}},c5Ni:function(ht,Ze,le){},dejd:function(ht,Ze,le){},dmUQ:function(ht,Ze,le){"use strict";var ue=le("Ff2n"),Y=le("rePB"),k=le("1OyB"),V=le("vuIU"),I=le("Ji7U"),D=le("md7G"),j=le("foSv"),F=le("q1tI"),P=le.n(F),O=le("TSYQ"),g=le.n(O),T=le("4IlW");function R(h,a){var y=Object.keys(h);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(h);a&&(m=m.filter(function(x){return Object.getOwnPropertyDescriptor(h,x).enumerable})),y.push.apply(y,m)}return y}function L(h){for(var a=1;a<arguments.length;a++){var y=arguments[a]!=null?arguments[a]:{};a%2?R(Object(y),!0).forEach(function(m){Object(Y.a)(h,m,y[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(y)):R(Object(y)).forEach(function(m){Object.defineProperty(h,m,Object.getOwnPropertyDescriptor(y,m))})}return h}function w(h){var a=E();return function(){var m=Object(j.a)(h),x;if(a){var M=Object(j.a)(this).constructor;x=Reflect.construct(m,arguments,M)}else x=m.apply(this,arguments);return Object(D.a)(this,x)}}function E(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(h){return!1}}function u(){}function o(h){h.preventDefault()}var s=function(a){return a.replace(/[^\w.-]+/g,"")},l=200,S=600,p=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,f=function(a){return a!=null},C=function(a,y){return y===a||typeof y=="number"&&typeof a=="number"&&isNaN(y)&&isNaN(a)},v=function(h){Object(I.a)(y,h);var a=w(y);function y(m){var x;Object(k.a)(this,y),x=a.call(this,m),x.onKeyDown=function($){var re=x.props,z=re.onKeyDown,U=re.onPressEnter;if($.keyCode===T.a.UP){var ne=x.getRatio($);x.up($,ne,null),x.stop()}else if($.keyCode===T.a.DOWN){var fe=x.getRatio($);x.down($,fe,null),x.stop()}else $.keyCode===T.a.ENTER&&U&&U($);if(x.recordCursorPosition(),x.lastKeyCode=$.keyCode,z){for(var ge=arguments.length,be=new Array(ge>1?ge-1:0),Me=1;Me<ge;Me++)be[Me-1]=arguments[Me];z.apply(void 0,[$].concat(be))}},x.onKeyUp=function($){var re=x.props.onKeyUp;if(x.stop(),x.recordCursorPosition(),re){for(var z=arguments.length,U=new Array(z>1?z-1:0),ne=1;ne<z;ne++)U[ne-1]=arguments[ne];re.apply(void 0,[$].concat(U))}},x.onChange=function($){var re=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent($)),x.setState({inputValue:x.rawInput}),re(x.toNumber(x.rawInput))},x.onMouseUp=function(){var $=x.props.onMouseUp;x.recordCursorPosition(),$&&$.apply(void 0,arguments)},x.onFocus=function(){var $;x.setState({focused:!0}),($=x.props).onFocus.apply($,arguments)},x.onBlur=function(){var $=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var re=x.getCurrentValidValue(x.state.inputValue),z=x.setValue(re,u);if($){var U=x.input.value,ne=x.getInputDisplayValue({focus:!1,value:z});x.input.value=ne&&Number(ne),$.apply(void 0,arguments),x.input.value=U}},x.getRatio=function($){var re=1;return $.metaKey||$.ctrlKey?re=.1:$.shiftKey&&(re=10),re},x.getFullNum=function($){return isNaN($)?$:/e/i.test(String($))?Number($).toFixed(18).replace(/\.?0+$/,""):$},x.getPrecision=function($){if(f(x.props.precision))return x.props.precision;var re=String($);if(re.indexOf("e-")>=0)return parseInt(re.slice(re.indexOf("e-")+2),10);var z=0;return re.indexOf(".")>=0&&(z=re.length-re.indexOf(".")-1),z},x.getInputDisplayValue=function($){var re=$||x.state,z=re.focused,U=re.inputValue,ne=re.value,fe;z?fe=U:fe=x.toPrecisionAsStep(ne),fe==null&&(fe="");var ge=x.formatWrapper(fe);return f(x.props.decimalSeparator)&&(ge=ge.toString().replace(".",x.props.decimalSeparator)),ge},x.recordCursorPosition=function(){try{x.cursorStart=x.input.selectionStart,x.cursorEnd=x.input.selectionEnd,x.currentValue=x.input.value,x.cursorBefore=x.input.value.substring(0,x.cursorStart),x.cursorAfter=x.input.value.substring(x.cursorEnd)}catch($){}},x.restoreByAfter=function($){if($===void 0)return!1;var re=x.input.value,z=re.lastIndexOf($);if(z===-1)return!1;var U=x.cursorBefore.length;return x.lastKeyCode===T.a.DELETE&&x.cursorBefore.charAt(U-1)===$[0]?(x.fixCaret(U,U),!0):z+$.length===re.length?(x.fixCaret(z,z),!0):!1},x.partRestoreByAfter=function($){return $===void 0?!1:Array.prototype.some.call($,function(re,z){var U=$.substring(z);return x.restoreByAfter(U)})},x.isNotCompleteNumber=function($){return isNaN($)||$===""||$===null||$&&$.toString().indexOf(".")===$.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function($,re,z){x.pressingUpOrDown=!0,x.step("down",$,re,z)},x.up=function($,re,z){x.pressingUpOrDown=!0,x.step("up",$,re,z)},x.saveInput=function($){x.input=$};var M=m.value;M===void 0&&(M=m.defaultValue),x.state={focused:m.autoFocus};var G=x.getValidValue(x.toNumber(M));return x.state=L(L({},x.state),{},{inputValue:x.toPrecisionAsStep(G),value:G}),x}return Object(V.a)(y,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var M=this.props,G=M.value,$=M.onChange,re=M.max,z=M.min,U=this.state.focused;if(x){if(!C(x.value,G)||!C(x.max,re)||!C(x.min,z)){var ne=U?G:this.getValidValue(G),fe;this.pressingUpOrDown?fe=ne:this.inputting?fe=this.rawInput:fe=this.toPrecisionAsStep(ne),this.setState({value:ne,inputValue:fe})}var ge="value"in this.props?G:this.state.value;"max"in this.props&&x.max!==re&&typeof ge=="number"&&ge>re&&$&&$(re),"min"in this.props&&x.min!==z&&typeof ge=="number"&&ge<z&&$&&$(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var be=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===T.a.BACKSPACE?be=this.cursorStart-1:this.lastKeyCode===T.a.DELETE&&(be=this.cursorStart):be=this.input.value.length,this.fixCaret(be,be)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case T.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case T.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Me){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(x){var M=x;return M===""?M="":this.isNotCompleteNumber(parseFloat(M))?M=this.state.value:M=this.getValidValue(M),this.toNumber(M)}},{key:"getValueFromEvent",value:function(x){var M=x.target.value.trim().replace(/。/g,".");return f(this.props.decimalSeparator)&&(M=M.replace(this.props.decimalSeparator,".")),M}},{key:"getValidValue",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,$=parseFloat(x);return isNaN($)?x:($<M&&($=M),$>G&&($=G),$)}},{key:"setValue",value:function(x,M){var G=this.props.precision,$=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),re=this.state.value,z=re===void 0?null:re,U=this.state.inputValue,ne=U===void 0?null:U,fe=typeof $=="number"?$.toFixed(G):"".concat($),ge=$!==z||fe!=="".concat(ne);return"value"in this.props?(ne=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ne},M)):this.setState({value:$,inputValue:this.toPrecisionAsStep(x)},M),ge&&this.props.onChange($),$}},{key:"getMaxPrecision",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,$=G.precision,re=G.step;if(f($))return $;var z=this.getPrecision(M),U=this.getPrecision(re),ne=this.getPrecision(x);return x?Math.max(ne,z+U):z+U}},{key:"getPrecisionFactor",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(x,M);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(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var M=Math.abs(this.getMaxPrecision(x));return isNaN(M)?x.toString():Number(x).toFixed(M)}},{key:"toNumber",value:function(x){var M=this.props.precision,G=this.state.focused,$=x&&x.length>16&&G;return this.isNotCompleteNumber(x)||$?x:f(M)?Math.round(x*Math.pow(10,M))/Math.pow(10,M):Number(x)}},{key:"upStep",value:function(x,M){var G=this.props.step,$=this.getPrecisionFactor(x,M),re=Math.abs(this.getMaxPrecision(x,M)),z=(($*x+$*G*M)/$).toFixed(re);return this.toNumber(z)}},{key:"downStep",value:function(x,M){var G=this.props.step,$=this.getPrecisionFactor(x,M),re=Math.abs(this.getMaxPrecision(x,M)),z=(($*x-$*G*M)/$).toFixed(re);return this.toNumber(z)}},{key:"step",value:function(x,M){var G=this,$=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,re=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var z=this.props;if(z.disabled)return;var U=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(U))return;var ne=this["".concat(x,"Step")](U,$),fe=ne>z.max||ne<z.min;if(ne>z.max?ne=z.max:ne<z.min&&(ne=z.min),this.setValue(ne,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),fe)return;this.autoStepTimer=setTimeout(function(){G[x](M,$,!0)},re?l:S)}},{key:"fixCaret",value:function(x,M){if(x===void 0||M===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,$=this.input.selectionEnd;(x!==G||M!==$)&&this.input.setSelectionRange(x,M)}catch(re){}}},{key:"render",value:function(){var x,M=this.props,G=M.prefixCls,$=M.disabled,re=M.readOnly,z=M.useTouch,U=M.autoComplete,ne=M.upHandler,fe=M.downHandler,ge=M.className,be=M.max,Me=M.min,Te=M.style,De=M.title,Ce=M.onMouseEnter,we=M.onMouseLeave,ve=M.onMouseOver,W=M.onMouseOut,A=M.required,_=M.onClick,H=M.tabIndex,q=M.type,B=M.placeholder,de=M.id,Ee=M.inputMode,Le=M.pattern,Ie=M.step,ke=M.maxLength,Oe=M.autoFocus,Pe=M.name,We=M.onPaste,He=M.onInput,Ve=Object(ue.a)(M,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),Xe=this.state,nt=Xe.value,Ke=Xe.focused,Ye=g()(G,(x={},Object(Y.a)(x,ge,!!ge),Object(Y.a)(x,"".concat(G,"-disabled"),$),Object(Y.a)(x,"".concat(G,"-focused"),Ke),x)),Ae={};Object.keys(Ve).forEach(function(he){(he.substr(0,5)==="data-"||he.substr(0,5)==="aria-"||he==="role")&&(Ae[he]=Ve[he])});var rt=!re&&!$,Qe=this.getInputDisplayValue(null),ae=(nt||nt===0)&&(isNaN(nt)||Number(nt)>=be),J=(nt||nt===0)&&(isNaN(nt)||Number(nt)<=Me),Z=ae||$||re,ie=J||$||re,oe=g()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(Y.a)({},"".concat(G,"-handler-up-disabled"),Z)),Q=g()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(Y.a)({},"".concat(G,"-handler-down-disabled"),ie)),te=z?{onTouchStart:Z?u:this.up,onTouchEnd:this.stop}:{onMouseDown:Z?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=z?{onTouchStart:ie?u:this.down,onTouchEnd:this.stop}:{onMouseDown:ie?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:Ye,style:Te,title:De,onMouseEnter:Ce,onMouseLeave:we,onMouseOver:ve,onMouseOut:W,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(G,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":Z,className:oe}),ne||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),P.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":ie,className:Q}),fe||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),P.a.createElement("div",{className:"".concat(G,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Me,"aria-valuemax":be,"aria-valuenow":nt,required:A,type:q,placeholder:B,onPaste:We,onClick:_,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:H,autoComplete:U,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:rt?this.onKeyDown:u,onKeyUp:rt?this.onKeyUp:u,autoFocus:Oe,maxLength:ke,readOnly:re,disabled:$,max:be,min:Me,step:Ie,name:Pe,title:De,id:de,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(Qe),pattern:Le,inputMode:Ee,onInput:He},Ae))))}}]),y}(P.a.Component);v.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:p,min:-p,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:s,required:!1,autoComplete:"off"};var d=v,c=Ze.a=d},fnXi:function(ht,Ze,le){"use strict";var ue=le("2qtc"),Y=le("kLXV"),k=le("q1tI"),V=le.n(k),I=le("Ty5D"),D=le("9kvl"),j=le("93VE"),F=le.n(j),P=function(g){var T=g.activeIndex,R=g.isEdit,L=R===void 0?!0:R,w=g.dispatch,E=g.practiceSetting,u=Object(I.i)(),o=u.id,s=u.challengesId,l=Object(k.useMemo)(function(){return[{name:"\u672C\u5173\u4EFB\u52A1",url:"/shixuns/".concat(o,"/edit/").concat(s,"/editcheckpoint")},{name:"\u8BC4\u6D4B\u8BBE\u7F6E",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=2")},{name:"\u53C2\u8003\u7B54\u6848",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=3")},{name:"\u5173\u5361\u6392\u884C\u699C",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=4")}]},[o,s]),S=function(f){var C,v=function(){D.d.push(f),w({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};E!=null&&(C=E.sideBar)!==null&&C!==void 0&&C.confirmLeave?Y.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){v()}}):v()};return V.a.createElement("ul",{className:"challenge-nav"},L?l.map(function(p,f){return T===f?V.a.createElement("li",{key:p.url}," ",V.a.createElement("a",{className:"active"},p.name)," "):V.a.createElement("li",{key:p.url}," ",V.a.createElement("a",{onClick:function(){return S(p.url)}},p.name)," ")}):V.a.createElement("li",{key:l[0].url}," ",V.a.createElement("a",{className:"active"},l[0].name)," "))};Ze.a=Object(D.a)(function(O){var g=O.globalSetting,T=O.practiceSetting;return{globalSetting:g,practiceSetting:T}})(P)},kSUc:function(ht,Ze,le){},lZu9:function(ht,Ze,le){(function(ue){ue(le("VrN/"),le("1eCo"),le("8EBN"))})(function(ue){"use strict";ue.defineMode("markdown",function(Y,k){var V=ue.getMode(Y,"text/html"),I=V.name=="null";function D(z){if(ue.findModeByName){var U=ue.findModeByName(z);U&&(z=U.mime||U.mimes[0])}var ne=ue.getMode(Y,z);return ne.name=="null"?null:ne}k.highlightFormatting===void 0&&(k.highlightFormatting=!1),k.maxBlockquoteDepth===void 0&&(k.maxBlockquoteDepth=0),k.taskLists===void 0&&(k.taskLists=!1),k.strikethrough===void 0&&(k.strikethrough=!1),k.emoji===void 0&&(k.emoji=!1),k.fencedCodeBlockHighlighting===void 0&&(k.fencedCodeBlockHighlighting=!0),k.fencedCodeBlockDefaultMode===void 0&&(k.fencedCodeBlockDefaultMode="text/plain"),k.xml===void 0&&(k.xml=!0),k.tokenTypeOverrides===void 0&&(k.tokenTypeOverrides={});var j={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 j)j.hasOwnProperty(F)&&k.tokenTypeOverrides[F]&&(j[F]=k.tokenTypeOverrides[F]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,g=/^\[(x| )\](?=\s)/i,T=k.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,w=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,E=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function s(z,U,ne){return U.f=U.inline=ne,ne(z,U)}function l(z,U,ne){return U.f=U.block=ne,ne(z,U)}function S(z){return!z||!/\S/.test(z.string)}function p(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==C){var U=I;if(!U){var ne=ue.innerMode(V,z.htmlState);U=ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText}U&&(z.f=h,z.block=f,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function f(z,U){var ne=z.column()===U.indentation,fe=S(U.prevLine.stream),ge=U.indentedCode,be=U.prevLine.hr,Me=U.list!==!1,Te=(U.listStack[U.listStack.length-1]||0)+3;U.indentedCode=!1;var De=U.indentation;if(U.indentationDiff===null&&(U.indentationDiff=U.indentation,Me)){for(U.list=null;De<U.listStack[U.listStack.length-1];)U.listStack.pop(),U.listStack.length?U.indentation=U.listStack[U.listStack.length-1]:U.list=!1;U.list!==!1&&(U.indentationDiff=De-U.listStack[U.listStack.length-1])}var Ce=!fe&&!be&&!U.prevLine.header&&(!Me||!ge)&&!U.prevLine.fencedCodeEnd,we=(U.list===!1||be||fe)&&U.indentation<=Te&&z.match(P),ve=null;if(U.indentationDiff>=4&&(ge||U.prevLine.fencedCodeEnd||U.prevLine.header||fe))return z.skipToEnd(),U.indentedCode=!0,j.code;if(z.eatSpace())return null;if(ne&&U.indentation<=Te&&(ve=z.match(T))&&ve[1].length<=6)return U.quote=0,U.header=ve[1].length,U.thisLine.header=!0,k.highlightFormatting&&(U.formatting="header"),U.f=U.inline,d(U);if(U.indentation<=Te&&z.eat(">"))return U.quote=ne?1:U.quote+1,k.highlightFormatting&&(U.formatting="quote"),z.eatSpace(),d(U);if(!we&&!U.setext&&ne&&U.indentation<=Te&&(ve=z.match(O))){var W=ve[1]?"ol":"ul";return U.indentation=De+z.current().length,U.list=!0,U.quote=0,U.listStack.push(U.indentation),U.em=!1,U.strong=!1,U.code=!1,U.strikethrough=!1,k.taskLists&&z.match(g,!1)&&(U.taskList=!0),U.f=U.inline,k.highlightFormatting&&(U.formatting=["list","list-"+W]),d(U)}else{if(ne&&U.indentation<=Te&&(ve=z.match(w,!0)))return U.quote=0,U.fencedEndRE=new RegExp(ve[1]+"+ *$"),U.localMode=k.fencedCodeBlockHighlighting&&D(ve[2]||k.fencedCodeBlockDefaultMode),U.localMode&&(U.localState=ue.startState(U.localMode)),U.f=U.block=v,k.highlightFormatting&&(U.formatting="code-block"),U.code=-1,d(U);if(U.setext||(!Ce||!Me)&&!U.quote&&U.list===!1&&!U.code&&!we&&!E.test(z.string)&&(ve=z.lookAhead(1))&&(ve=ve.match(R)))return U.setext?(U.header=U.setext,U.setext=0,z.skipToEnd(),k.highlightFormatting&&(U.formatting="header")):(U.header=ve[0].charAt(0)=="="?1:2,U.setext=U.header),U.thisLine.header=!0,U.f=U.inline,d(U);if(we)return z.skipToEnd(),U.hr=!0,U.thisLine.hr=!0,j.hr;if(z.peek()==="[")return s(z,U,M)}return s(z,U,U.inline)}function C(z,U){var ne=V.token(z,U.htmlState);if(!I){var fe=ue.innerMode(V,U.htmlState);(fe.mode.name=="xml"&&fe.state.tagStart===null&&!fe.state.context&&fe.state.tokenize.isInText||U.md_inside&&z.current().indexOf(">")>-1)&&(U.f=h,U.block=f,U.htmlState=null)}return ne}function v(z,U){var ne=U.listStack[U.listStack.length-1]||0,fe=U.indentation<ne,ge=ne+3;if(U.fencedEndRE&&U.indentation<=ge&&(fe||z.match(U.fencedEndRE))){k.highlightFormatting&&(U.formatting="code-block");var be;return fe||(be=d(U)),U.localMode=U.localState=null,U.block=f,U.f=h,U.fencedEndRE=null,U.code=0,U.thisLine.fencedCodeEnd=!0,fe?l(z,U,U.block):be}else return U.localMode?U.localMode.token(z,U.localState):(z.skipToEnd(),j.code)}function d(z){var U=[];if(z.formatting){U.push(j.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var ne=0;ne<z.formatting.length;ne++)U.push(j.formatting+"-"+z.formatting[ne]),z.formatting[ne]==="header"&&U.push(j.formatting+"-"+z.formatting[ne]+"-"+z.header),z.formatting[ne]==="quote"&&(!k.maxBlockquoteDepth||k.maxBlockquoteDepth>=z.quote?U.push(j.formatting+"-"+z.formatting[ne]+"-"+z.quote):U.push("error"))}if(z.taskOpen)return U.push("meta"),U.length?U.join(" "):null;if(z.taskClosed)return U.push("property"),U.length?U.join(" "):null;if(z.linkHref?U.push(j.linkHref,"url"):(z.strong&&U.push(j.strong),z.em&&U.push(j.em),z.strikethrough&&U.push(j.strikethrough),z.emoji&&U.push(j.emoji),z.linkText&&U.push(j.linkText),z.code&&U.push(j.code),z.image&&U.push(j.image),z.imageAltText&&U.push(j.imageAltText,"link"),z.imageMarker&&U.push(j.imageMarker)),z.header&&U.push(j.header,j.header+"-"+z.header),z.quote&&(U.push(j.quote),!k.maxBlockquoteDepth||k.maxBlockquoteDepth>=z.quote?U.push(j.quote+"-"+z.quote):U.push(j.quote+"-"+k.maxBlockquoteDepth)),z.list!==!1){var fe=(z.listStack.length-1)%3;fe?fe===1?U.push(j.list2):U.push(j.list3):U.push(j.list1)}return z.trailingSpaceNewLine?U.push("trailing-space-new-line"):z.trailingSpace&&U.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),U.length?U.join(" "):null}function c(z,U){return z.match(L,!0)?d(U):void 0}function h(z,U){var ne=U.text(z,U);if(typeof ne!="undefined")return ne;if(U.list)return U.list=null,d(U);if(U.taskList){var fe=z.match(g,!0)[1]===" ";return fe?U.taskOpen=!0:U.taskClosed=!0,k.highlightFormatting&&(U.formatting="task"),U.taskList=!1,d(U)}if(U.taskOpen=!1,U.taskClosed=!1,U.header&&z.match(/^#+$/,!0))return k.highlightFormatting&&(U.formatting="header"),d(U);var ge=z.next();if(U.linkTitle){U.linkTitle=!1;var be=ge;ge==="("&&(be=")"),be=(be+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Me="^\\s*(?:[^"+be+"\\\\]+|\\\\\\\\|\\\\.)"+be;if(z.match(new RegExp(Me),!0))return j.linkHref}if(ge==="`"){var Te=U.formatting;k.highlightFormatting&&(U.formatting="code"),z.eatWhile("`");var De=z.current().length;if(U.code==0&&(!U.quote||De==1))return U.code=De,d(U);if(De==U.code){var Ce=d(U);return U.code=0,Ce}else return U.formatting=Te,d(U)}else if(U.code)return d(U);if(ge==="\\"&&(z.next(),k.highlightFormatting)){var we=d(U),ve=j.formatting+"-escape";return we?we+" "+ve:ve}if(ge==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return U.imageMarker=!0,U.image=!0,k.highlightFormatting&&(U.formatting="image"),d(U);if(ge==="["&&U.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return U.imageMarker=!1,U.imageAltText=!0,k.highlightFormatting&&(U.formatting="image"),d(U);if(ge==="]"&&U.imageAltText){k.highlightFormatting&&(U.formatting="image");var we=d(U);return U.imageAltText=!1,U.image=!1,U.inline=U.f=y,we}if(ge==="["&&!U.image)return U.linkText&&z.match(/^.*?\]/)||(U.linkText=!0,k.highlightFormatting&&(U.formatting="link")),d(U);if(ge==="]"&&U.linkText){k.highlightFormatting&&(U.formatting="link");var we=d(U);return U.linkText=!1,U.inline=U.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?y:h,we}if(ge==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){U.f=U.inline=a,k.highlightFormatting&&(U.formatting="link");var we=d(U);return we?we+=" ":we="",we+j.linkInline}if(ge==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){U.f=U.inline=a,k.highlightFormatting&&(U.formatting="link");var we=d(U);return we?we+=" ":we="",we+j.linkEmail}if(k.xml&&ge==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var W=z.string.indexOf(">",z.pos);if(W!=-1){var A=z.string.substring(z.start,W);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(A)&&(U.md_inside=!0)}return z.backUp(1),U.htmlState=ue.startState(V),l(z,U,C)}if(k.xml&&ge==="<"&&z.match(/^\/\w*?>/))return U.md_inside=!1,"tag";if(ge==="*"||ge==="_"){for(var _=1,H=z.pos==1?" ":z.string.charAt(z.pos-2);_<3&&z.eat(ge);)_++;var q=z.peek()||" ",B=!/\s/.test(q)&&(!u.test(q)||/\s/.test(H)||u.test(H)),de=!/\s/.test(H)&&(!u.test(H)||/\s/.test(q)||u.test(q)),Ee=null,Le=null;if(_%2&&(!U.em&&B&&(ge==="*"||!de||u.test(H))?Ee=!0:U.em==ge&&de&&(ge==="*"||!B||u.test(q))&&(Ee=!1)),_>1&&(!U.strong&&B&&(ge==="*"||!de||u.test(H))?Le=!0:U.strong==ge&&de&&(ge==="*"||!B||u.test(q))&&(Le=!1)),Le!=null||Ee!=null){k.highlightFormatting&&(U.formatting=Ee==null?"strong":Le==null?"em":"strong em"),Ee===!0&&(U.em=ge),Le===!0&&(U.strong=ge);var Ce=d(U);return Ee===!1&&(U.em=!1),Le===!1&&(U.strong=!1),Ce}}else if(ge===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return d(U);z.backUp(1)}if(k.strikethrough){if(ge==="~"&&z.eatWhile(ge)){if(U.strikethrough){k.highlightFormatting&&(U.formatting="strikethrough");var Ce=d(U);return U.strikethrough=!1,Ce}else if(z.match(/^[^\s]/,!1))return U.strikethrough=!0,k.highlightFormatting&&(U.formatting="strikethrough"),d(U)}else if(ge===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return d(U);z.backUp(2)}}if(k.emoji&&ge===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){U.emoji=!0,k.highlightFormatting&&(U.formatting="emoji");var Ie=d(U);return U.emoji=!1,Ie}return ge===" "&&(z.match(/^ +$/,!1)?U.trailingSpace++:U.trailingSpace&&(U.trailingSpaceNewLine=!0)),d(U)}function a(z,U){var ne=z.next();if(ne===">"){U.f=U.inline=h,k.highlightFormatting&&(U.formatting="link");var fe=d(U);return fe?fe+=" ":fe="",fe+j.linkInline}return z.match(/^[^>]+/,!0),j.linkInline}function y(z,U){if(z.eatSpace())return null;var ne=z.next();return ne==="("||ne==="["?(U.f=U.inline=x(ne==="("?")":"]"),k.highlightFormatting&&(U.formatting="link-string"),U.linkHref=!0,d(U)):"error"}var m={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(z){return function(U,ne){var fe=U.next();if(fe===z){ne.f=ne.inline=h,k.highlightFormatting&&(ne.formatting="link-string");var ge=d(ne);return ne.linkHref=!1,ge}return U.match(m[z]),ne.linkHref=!0,d(ne)}}function M(z,U){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(U.f=G,z.next(),k.highlightFormatting&&(U.formatting="link"),U.linkText=!0,d(U)):s(z,U,h)}function G(z,U){if(z.match(/^\]:/,!0)){U.f=U.inline=$,k.highlightFormatting&&(U.formatting="link");var ne=d(U);return U.linkText=!1,ne}return z.match(/^([^\]\\]|\\.)+/,!0),j.linkText}function $(z,U){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?U.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),U.f=U.inline=h,j.linkHref+" url")}var re={startState:function(){return{f,prevLine:{stream:null},thisLine:{stream:null},block:f,htmlState:null,indentation:0,inline:h,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&&ue.copyState(V,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?ue.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,U){if(U.formatting=!1,z!=U.thisLine.stream){if(U.header=0,U.hr=!1,z.match(/^\s*$/,!0))return p(U),null;if(U.prevLine=U.thisLine,U.thisLine={stream:z},U.taskList=!1,U.trailingSpace=0,U.trailingSpaceNewLine=!1,!U.localState&&(U.f=U.block,U.f!=C)){var ne=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(U.indentation=ne,U.indentationDiff=null,ne>0)return null}}return U.f(z,U)},innerMode:function(z){return z.block==C?{state:z.htmlState,mode:V}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:re}},indent:function(z,U,ne){return z.block==C&&V.indent?V.indent(z.htmlState,U,ne):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,U,ne):ue.Pass},blankLine:p,getType:d,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return re},"xml"),ue.defineMIME("text/markdown","markdown"),ue.defineMIME("text/x-markdown","markdown")})},nuEh:function(ht,Ze,le){"use strict";var ue=le("T2oS"),Y=le("W9HT"),k=le("q1tI"),V=le.n(k),I=le("F8wB"),D=le.n(I),j=function(P){var O=P.loading;return O?V.a.createElement("div",{className:D.a.loading},V.a.createElement(Y.a,null)):V.a.createElement(V.a.Fragment,null)};Ze.a=j},osHv:function(ht,Ze,le){(function(ue){ue(le("VrN/"))})(function(ue){"use strict";var Y=ue.Pos;function k(u,o){return u.line-o.line||u.ch-o.ch}var V="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",I=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",D=new RegExp("<(/?)(["+V+"]["+I+"]*)","g");function j(u,o,s,l){this.line=o,this.ch=s,this.cm=u,this.text=u.getLine(o),this.min=l?Math.max(l.from,u.firstLine()):u.firstLine(),this.max=l?Math.min(l.to-1,u.lastLine()):u.lastLine()}function F(u,o){var s=u.cm.getTokenTypeAt(Y(u.line,o));return s&&/\btag\b/.test(s)}function P(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function O(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function g(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(P(u))continue;return}if(!F(u,o+1)){u.ch=o+1;continue}var s=u.text.lastIndexOf("/",o),l=s>-1&&!/\S/.test(u.text.slice(s+1,o));return u.ch=o+1,l?"selfClose":"regular"}}function T(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!F(u,o+1)){u.ch=o;continue}D.lastIndex=o,u.ch=o;var s=D.exec(u.text);if(s&&s.index==o)return s}}function R(u){for(;;){D.lastIndex=u.ch;var o=D.exec(u.text);if(!o){if(P(u))continue;return}if(!F(u,o.index+1)){u.ch=o.index+1;continue}return u.ch=o.index+o[0].length,o}}function L(u){for(;;){var o=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!F(u,o+1)){u.ch=o;continue}var s=u.text.lastIndexOf("/",o),l=s>-1&&!/\S/.test(u.text.slice(s+1,o));return u.ch=o+1,l?"selfClose":"regular"}}function w(u,o){for(var s=[];;){var l=R(u),S,p=u.line,f=u.ch-(l?l[0].length:0);if(!l||!(S=g(u)))return;if(S=="selfClose")continue;if(l[1]){for(var C=s.length-1;C>=0;--C)if(s[C]==l[2]){s.length=C;break}if(C<0&&(!o||o==l[2]))return{tag:l[2],from:Y(p,f),to:Y(u.line,u.ch)}}else s.push(l[2])}}function E(u,o){for(var s=[];;){var l=L(u);if(!l)return;if(l=="selfClose"){T(u);continue}var S=u.line,p=u.ch,f=T(u);if(!f)return;if(f[1])s.push(f[2]);else{for(var C=s.length-1;C>=0;--C)if(s[C]==f[2]){s.length=C;break}if(C<0&&(!o||o==f[2]))return{tag:f[2],from:Y(u.line,u.ch),to:Y(S,p)}}}}ue.registerHelper("fold","xml",function(u,o){for(var s=new j(u,o.line,0);;){var l=R(s);if(!l||s.line!=o.line)return;var S=g(s);if(!S)return;if(!l[1]&&S!="selfClose"){var p=Y(s.line,s.ch),f=w(s,l[2]);return f&&k(f.from,p)>0?{from:p,to:f.from}:null}}}),ue.findMatchingTag=function(u,o,s){var l=new j(u,o.line,o.ch,s);if(l.text.indexOf(">")==-1&&l.text.indexOf("<")==-1)return;var S=g(l),p=S&&Y(l.line,l.ch),f=S&&T(l);if(!S||!f||k(l,o)>0)return;var C={from:Y(l.line,l.ch),to:p,tag:f[2]};return S=="selfClose"?{open:C,close:null,at:"open"}:f[1]?{open:E(l,f[2]),close:C,at:"close"}:(l=new j(u,p.line,p.ch,s),{open:C,close:w(l,f[2]),at:"open"})},ue.findEnclosingTag=function(u,o,s,l){for(var S=new j(u,o.line,o.ch,s);;){var p=E(S,l);if(!p)break;var f=new j(u,o.line,o.ch,s),C=w(f,p.tag);if(C)return{open:p,close:C}}},ue.scanForClosingTag=function(u,o,s,l){var S=new j(u,o.line,o.ch,l?{from:0,to:l}:null);return w(S,s)}})},p5ED:function(ht,Ze,le){"use strict";var ue=le("+L6B"),Y=le("2/Rp"),k=le("5Dmo"),V=le("3S7+"),I=le("k1fw"),D=le("9og8"),j=le("tJVT"),F=le("WmNS"),P=le.n(F),O=le("q1tI"),g=le.n(O),T=le("vHTk"),R=le.n(T),L=le("yEEn"),w=le("ZW9T"),E=le("1vsH"),u=le("V0Rq"),o=le("m3rI");Ze.a=function(s){var l,S,p,f,C,v,d,c=s.editOffice,h=c===void 0?"view":c,a=s.data,y=s.theme,m=s.type,x=s.filename,M=s.monacoEditor,G=s.className,$=s.style,re=s.close,z=s.onClose,U=s.hasMask,ne=s.disabledDownload,fe=Object(O.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ge=Object(j.a)(fe,2),be=ge[0],Me=ge[1],Te=Object(O.useState)(""),De=Object(j.a)(Te,2),Ce=De[0],we=De[1],ve=Object(O.useState)(),W=Object(j.a)(ve,2),A=W[0],_=W[1],H=window.ENV==="build"?"/react/build":"",q=o.a.PROXY_SERVER||location.origin,B,de=1024*1024,Ee=10*de,Le=Object(O.useRef)();(l=a)!==null&&l!==void 0&&l.startsWith("/api")&&m!=="txt"&&(a=(o.a.API_SERVER||location.origin)+a),m==="office"&&(B=Object(E.T)(a).filesize,B>Ee&&(m="other")),x&&M&&(M.filename=x),Object(O.useEffect)(function(){var Pe,We,He=(Pe=document.cookie)===null||Pe===void 0||((We=Pe.replace(/\s/g,""))===null||We===void 0)?void 0:We.split(";");He==null||He.map(function(Ve){var Xe=Ve.split("=");Xe[0]==="_educoder_session"&&we(Xe[1])})},[]),Object(O.useEffect)(function(){m==="office"&&Ie()},[m,a]);var Ie=function(){var Pe=Object(D.a)(P.a.mark(function We(){var He,Ve,Xe;return P.a.wrap(function(Ke){for(;;)switch(Ke.prev=Ke.next){case 0:return console.log("data:",a),He=a,a.startsWith("http")||(He=location.origin+He),Ve=new URL(He).pathname.split("/").pop(),Ke.next=6,Object(u.V)({attachment_id:Ve});case 6:Xe=Ke.sent,_(Xe);case 8:case"end":return Ke.stop()}},We)}));return function(){return Pe.apply(this,arguments)}}(),ke=function(){if(a.startsWith("http")||a.startsWith("blob:")){Oe();return}Object(E.z)(x||"educoder",a,x)},Oe=function(){Object(E.x)(x||"educoder",decodeURIComponent(a))};return g.a.createElement("div",{style:Object(I.a)({},$||{}),className:"".concat(U&&R.a.bgBlack," ").concat(m?R.a.wrp:"hide")},re&&g.a.createElement("div",{className:R.a.close,ref:Le},!ne&&g.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Le.current}},g.a.createElement("span",{onClick:Oe},g.a.createElement("i",{className:"icon-quxiaozhiding"}))),g.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Le.current}},g.a.createElement("span",{className:"",onClick:z},g.a.createElement("i",{className:"icon-guanbi1"})))),g.a.createElement("div",{className:"".concat(R.a[G]," ").concat(G," ").concat(R.a.monaco," ").concat(m==="txt"?"show":"hide")},m==="txt"&&g.a.createElement(w.b,M)),m==="audio"&&g.a.createElement("audio",{src:"".concat(((S=a)===null||S===void 0?void 0:S.indexOf("http://"))>-1||((p=a)===null||p===void 0?void 0:p.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),m==="video"&&g.a.createElement(g.a.Fragment,null,((f=a)===null||f===void 0?void 0:f.indexOf("http"))>-1?g.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):g.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),m==="office"&&A&&g.a.createElement("iframe",{src:"".concat(H,"/office.html?key=").concat(A.key,"&url=").concat(q+A.url,"&callbackUrl=").concat(q+A.callbackUrl,"&fileType=").concat(A.fileType,"&title=").concat(A.title,"&model=").concat(h,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!ne)}),m==="html"&&g.a.createElement("iframe",{src:a+"&disposition=inline"}),m==="pdf"&&g.a.createElement("iframe",{src:"".concat(H,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!ne)}),m==="image"&&g.a.createElement("img",{src:"".concat(((C=a)===null||C===void 0?void 0:C.indexOf("http://"))>-1||((v=a)===null||v===void 0?void 0:v.indexOf("https://"))>-1||(d=a)!==null&&d!==void 0&&d.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),m==="other"&&g.a.createElement("div",null,g.a.createElement(Y.a,{type:"primary",size:"large",onClick:ke},g.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),m==="download"&&g.a.createElement(Y.a,{type:"primary",size:"large",onClick:ke},g.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(ht,Ze,le){},rUJ1:function(ht,Ze){const le=/[&<>"']/,ue=/[&<>"']/g,Y=/[<>"']|&(?!#?\w+;)/,k=/[<>"']|&(?!#?\w+;)/g,V={"&":"&","<":"<",">":">",'"':""","'":"'"},I=v=>V[v];function D(v,d){if(d){if(le.test(v))return v.replace(ue,I)}else if(Y.test(v))return v.replace(k,I);return v}const j=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(v){return v.replace(j,(d,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const P=/(^|[^\[])\^/g;function O(v,d){v=v.source||v,d=d||"";const c={replace:(h,a)=>(a=a.source||a,a=a.replace(P,"$1"),v=v.replace(h,a),c),getRegex:()=>new RegExp(v,d)};return c}const g=/[^\w:]/g,T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(v,d,c){if(v){let h;try{h=decodeURIComponent(F(c)).replace(g,"").toLowerCase()}catch(a){return null}if(h.indexOf("javascript:")===0||h.indexOf("vbscript:")===0||h.indexOf("data:")===0)return null}d&&!T.test(c)&&(c=o(d,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(h){return null}return c}const L={},w=/^[^:]+:\/*[^/]*$/,E=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(v,d){L[" "+v]||(w.test(v)?L[" "+v]=v+"/":L[" "+v]=p(v,"/",!0)),v=L[" "+v];const c=v.indexOf(":")===-1;return d.substring(0,2)==="//"?c?d:v.replace(E,"$1")+d:d.charAt(0)==="/"?c?d:v.replace(u,"$1")+d:v+d}const s={exec:function(){}};function l(v){let d=1,c,h;for(;d<arguments.length;d++){c=arguments[d];for(h in c)Object.prototype.hasOwnProperty.call(c,h)&&(v[h]=c[h])}return v}function S(v,d){const c=v.replace(/\|/g,(y,m,x)=>{let M=!1,G=m;for(;--G>=0&&x[G]==="\\";)M=!M;return M?"|":" |"}),h=c.split(/ \|/);let a=0;if(h.length>d)h.splice(d);else for(;h.length<d;)h.push("");for(;a<h.length;a++)h[a]=h[a].trim().replace(/\\\|/g,"|");return h}function p(v,d,c){const h=v.length;if(h===0)return"";let a=0;for(;a<h;){const y=v.charAt(h-a-1);if(y===d&&!c)a++;else if(y!==d&&c)a++;else break}return v.substr(0,h-a)}function f(v,d){if(v.indexOf(d[1])===-1)return-1;const c=v.length;let h=0,a=0;for(;a<c;a++)if(v[a]==="\\")a++;else if(v[a]===d[0])h++;else if(v[a]===d[1]&&(h--,h<0))return a;return-1}function C(v){v&&v.sanitize&&!v.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}ht.exports={escape:D,unescape:F,edit:O,cleanUrl:R,resolveUrl:o,noopTest:s,merge:l,splitCells:S,rtrim:p,findClosingBracket:f,checkSanitizeDeprecation:C}},ulZh:function(ht,Ze,le){typeof window!="undefined"&&function(Y,k){ht.exports=k()}(this,function(){return function(ue){var Y={};function k(V){if(Y[V])return Y[V].exports;var I=Y[V]={i:V,l:!1,exports:{}};return ue[V].call(I.exports,I,I.exports,k),I.l=!0,I.exports}return k.m=ue,k.c=Y,k.d=function(V,I,D){k.o(V,I)||Object.defineProperty(V,I,{enumerable:!0,get:D})},k.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},k.t=function(V,I){if(I&1&&(V=k(V)),I&8)return V;if(I&4&&typeof V=="object"&&V&&V.__esModule)return V;var D=Object.create(null);if(k.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:V}),I&2&&typeof V!="string")for(var j in V)k.d(D,j,function(F){return V[F]}.bind(null,j));return D},k.n=function(V){var I=V&&V.__esModule?function(){return V.default}:function(){return V};return k.d(I,"a",I),I},k.o=function(V,I){return Object.prototype.hasOwnProperty.call(V,I)},k.p="/dist/",k(k.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ue,Y,k){"use strict";var V=Object.prototype.hasOwnProperty,I="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(I=!1));function j(g,T,R){this.fn=g,this.context=T,this.once=R||!1}function F(g,T,R,L,w){if(typeof R!="function")throw new TypeError("The listener must be a function");var E=new j(R,L||g,w),u=I?I+T:T;return g._events[u]?g._events[u].fn?g._events[u]=[g._events[u],E]:g._events[u].push(E):(g._events[u]=E,g._eventsCount++),g}function P(g,T){--g._eventsCount===0?g._events=new D:delete g._events[T]}function O(){this._events=new D,this._eventsCount=0}O.prototype.eventNames=function(){var T=[],R,L;if(this._eventsCount===0)return T;for(L in R=this._events)V.call(R,L)&&T.push(I?L.slice(1):L);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(R)):T},O.prototype.listeners=function(T){var R=I?I+T:T,L=this._events[R];if(!L)return[];if(L.fn)return[L.fn];for(var w=0,E=L.length,u=new Array(E);w<E;w++)u[w]=L[w].fn;return u},O.prototype.listenerCount=function(T){var R=I?I+T:T,L=this._events[R];return L?L.fn?1:L.length:0},O.prototype.emit=function(T,R,L,w,E,u){var o=I?I+T:T;if(!this._events[o])return!1;var s=this._events[o],l=arguments.length,S,p;if(s.fn){s.once&&this.removeListener(T,s.fn,void 0,!0);switch(l){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,R),!0;case 3:return s.fn.call(s.context,R,L),!0;case 4:return s.fn.call(s.context,R,L,w),!0;case 5:return s.fn.call(s.context,R,L,w,E),!0;case 6:return s.fn.call(s.context,R,L,w,E,u),!0}for(p=1,S=new Array(l-1);p<l;p++)S[p-1]=arguments[p];s.fn.apply(s.context,S)}else{var f=s.length,C;for(p=0;p<f;p++){s[p].once&&this.removeListener(T,s[p].fn,void 0,!0);switch(l){case 1:s[p].fn.call(s[p].context);break;case 2:s[p].fn.call(s[p].context,R);break;case 3:s[p].fn.call(s[p].context,R,L);break;case 4:s[p].fn.call(s[p].context,R,L,w);break;default:if(!S)for(C=1,S=new Array(l-1);C<l;C++)S[C-1]=arguments[C];s[p].fn.apply(s[p].context,S)}}}return!0},O.prototype.on=function(T,R,L){return F(this,T,R,L,!1)},O.prototype.once=function(T,R,L){return F(this,T,R,L,!0)},O.prototype.removeListener=function(T,R,L,w){var E=I?I+T:T;if(!this._events[E])return this;if(!R)return P(this,E),this;var u=this._events[E];if(u.fn)u.fn===R&&(!w||u.once)&&(!L||u.context===L)&&P(this,E);else{for(var o=0,s=[],l=u.length;o<l;o++)(u[o].fn!==R||w&&!u[o].once||L&&u[o].context!==L)&&s.push(u[o]);s.length?this._events[E]=s.length===1?s[0]:s:P(this,E)}return this},O.prototype.removeAllListeners=function(T){var R;return T?(R=I?I+T:T,this._events[R]&&P(this,R)):(this._events=new D,this._eventsCount=0),this},O.prototype.off=O.prototype.removeListener,O.prototype.addListener=O.prototype.on,O.prefixed=I,O.EventEmitter=O,ue.exports=O},"./node_modules/url-toolkit/src/url-toolkit.js":function(ue,Y,k){(function(V){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,D=/^([^\/?#]*)([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,F=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(O,g,T){if(T=T||{},O=O.trim(),g=g.trim(),!g){if(!T.alwaysNormalize)return O;var R=P.parseURL(O);if(!R)throw new Error("Error trying to parse base URL.");return R.path=P.normalizePath(R.path),P.buildURLFromParts(R)}var L=P.parseURL(g);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return T.alwaysNormalize?(L.path=P.normalizePath(L.path),P.buildURLFromParts(L)):g;var w=P.parseURL(O);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var E=D.exec(w.path);w.netLoc=E[1],w.path=E[2]}w.netLoc&&!w.path&&(w.path="/");var u={scheme:w.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(u.netLoc=w.netLoc,L.path[0]!=="/"))if(!L.path)u.path=w.path,L.params||(u.params=w.params,L.query||(u.query=w.query));else{var o=w.path,s=o.substring(0,o.lastIndexOf("/")+1)+L.path;u.path=P.normalizePath(s)}return u.path===null&&(u.path=T.alwaysNormalize?P.normalizePath(L.path):L.path),P.buildURLFromParts(u)},parseURL:function(O){var g=I.exec(O);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(j,"");O.length!==(O=O.replace(F,"")).length;);return O.split("").reverse().join("")},buildURLFromParts:function(O){return O.scheme+O.netLoc+O.path+O.params+O.query+O.fragment}};ue.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(ue,Y,k){function V(T){var R={};function L(E){if(R[E])return R[E].exports;var u=R[E]={i:E,l:!1,exports:{}};return T[E].call(u.exports,u,u.exports,L),u.l=!0,u.exports}L.m=T,L.c=R,L.i=function(E){return E},L.d=function(E,u,o){L.o(E,u)||Object.defineProperty(E,u,{configurable:!1,enumerable:!0,get:o})},L.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},L.n=function(E){var u=E&&E.__esModule?function(){return E.default}:function(){return E};return L.d(u,"a",u),u},L.o=function(E,u){return Object.prototype.hasOwnProperty.call(E,u)},L.p="/",L.oe=function(E){throw console.error(E),E};var w=L(L.s=ENTRY_MODULE);return w.default||w}var I="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function j(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function F(T){return!isNaN(1*T)}function P(T,R,L){var w={};w[L]=[];var E=R.toString(),u=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return w;for(var o=u[1],s=new RegExp("(\\\\n|\\W)"+j(o)+D,"g"),l;l=s.exec(E);){if(l[3]==="dll-reference")continue;w[L].push(l[3])}for(s=new RegExp("\\("+j(o)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+D,"g");l=s.exec(E);)T[l[2]]||(w[L].push(l[1]),T[l[2]]=k(l[1]).m),w[l[2]]=w[l[2]]||[],w[l[2]].push(l[4]);for(var S=Object.keys(w),p=0;p<S.length;p++)for(var f=0;f<w[S[p]].length;f++)F(w[S[p]][f])&&(w[S[p]][f]=1*w[S[p]][f]);return w}function O(T){var R=Object.keys(T);return R.reduce(function(L,w){return L||T[w].length>0},!1)}function g(T,R){for(var L={main:[R]},w={main:[]},E={main:{}};O(L);)for(var u=Object.keys(L),o=0;o<u.length;o++){var s=u[o],l=L[s],S=l.pop();if(E[s]=E[s]||{},E[s][S]||!T[s][S])continue;E[s][S]=!0,w[s]=w[s]||[],w[s].push(S);for(var p=P(T,T[s][S],s),f=Object.keys(p),C=0;C<f.length;C++)L[f[C]]=L[f[C]]||[],L[f[C]]=L[f[C]].concat(p[f[C]])}return w}ue.exports=function(T,R){R=R||{};var L={main:k.m},w=R.all?{main:Object.keys(L.main)}:g(L,T),E="";Object.keys(w).filter(function(S){return S!=="main"}).forEach(function(S){for(var p=0;w[S][p];)p++;w[S].push(p),L[S][p]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+S+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(p))+")({"+w[S].map(function(f){return""+JSON.stringify(f)+": "+L[S][f].toString()}).join(",")+`});
|
|
`}),E=E+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+w.main.map(function(S){return""+JSON.stringify(S)+": "+L.main[S].toString()}).join(",")+"}))(self);";var u=new window.Blob([E],{type:"text/javascript"});if(R.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,s=o.createObjectURL(u),l=new window.Worker(s);return l.objectURL=s,l}},"./src/config.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"hlsDefaultConfig",function(){return C}),k.d(Y,"mergeConfig",function(){return d}),k.d(Y,"enableStreamingMode",function(){return c});var V=k("./src/controller/abr-controller.ts"),I=k("./src/controller/audio-stream-controller.ts"),D=k("./src/controller/audio-track-controller.ts"),j=k("./src/controller/subtitle-stream-controller.ts"),F=k("./src/controller/subtitle-track-controller.ts"),P=k("./src/controller/buffer-controller.ts"),O=k("./src/controller/timeline-controller.ts"),g=k("./src/controller/cap-level-controller.ts"),T=k("./src/controller/fps-controller.ts"),R=k("./src/controller/eme-controller.ts"),L=k("./src/controller/cmcd-controller.ts"),w=k("./src/utils/xhr-loader.ts"),E=k("./src/utils/fetch-loader.ts"),u=k("./src/utils/cues.ts"),o=k("./src/utils/mediakeys-helper.ts"),s=k("./src/utils/logger.ts");function l(){return l=Object.assign||function(h){for(var a=1;a<arguments.length;a++){var y=arguments[a];for(var m in y)Object.prototype.hasOwnProperty.call(y,m)&&(h[m]=y[m])}return h},l.apply(this,arguments)}function S(h,a){var y=Object.keys(h);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(h);a&&(m=m.filter(function(x){return Object.getOwnPropertyDescriptor(h,x).enumerable})),y.push.apply(y,m)}return y}function p(h){for(var a=1;a<arguments.length;a++){var y=arguments[a]!=null?arguments[a]:{};a%2?S(Object(y),!0).forEach(function(m){f(h,m,y[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(y)):S(Object(y)).forEach(function(m){Object.defineProperty(h,m,Object.getOwnPropertyDescriptor(y,m))})}return h}function f(h,a,y){return a in h?Object.defineProperty(h,a,{value:y,enumerable:!0,configurable:!0,writable:!0}):h[a]=y,h}var C=p(p({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:w.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:P.default,capLevelController:g.default,fpsController:T.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},v()),{},{subtitleStreamController:j.SubtitleStreamController,subtitleTrackController:F.default,timelineController:O.TimelineController,audioStreamController:I.default,audioTrackController:D.default,emeController:R.default,cmcdController:L.default});function v(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function d(h,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return l({},h,a)}function c(h){var a=h.loader;if(a!==E.default&&a!==w.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),h.progressive=!1;else{var y=Object(E.fetchSupported)();y&&(h.loader=E.default,h.progressive=!0,h.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/polyfills/number.ts"),I=k("./src/utils/ewma-bandwidth-estimator.ts"),D=k("./src/events.ts"),j=k("./src/utils/buffer-helper.ts"),F=k("./src/errors.ts"),P=k("./src/types/loader.ts"),O=k("./src/utils/logger.ts");function g(L,w){for(var E=0;E<w.length;E++){var u=w[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function T(L,w,E){return w&&g(L.prototype,w),E&&g(L,E),L}var R=function(){function L(E){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=E;var u=E.config;this.bwEstimator=new I.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(D.Events.FRAG_LOADING,this.onFragLoading,this),u.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(D.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(D.Events.FRAG_LOADING,this.onFragLoading,this),u.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(D.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},w.onFragLoading=function(u,o){var s=o.frag;if(s.type===P.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=s,this.partCurrent=(l=o.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},w.onLevelLoaded=function(u,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},w._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.autoLevelEnabled,S=s.config,p=s.media;if(!u||!p)return;var f=o?o.stats:u.stats,C=o?o.duration:u.duration;if(f.aborted){O.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!l||p.paused||!p.playbackRate||!p.readyState)return;var v=performance.now()-f.loading.start,d=Math.abs(p.playbackRate);if(v<=500*C/d)return;var c=s.levels,h=s.minAutoLevel,a=c[u.level],y=f.total||Math.max(f.loaded,Math.round(C*a.maxBitrate/8)),m=Math.max(1,f.bwEstimate?f.bwEstimate/8:f.loaded*1e3/v),x=(y-f.loaded)/m,M=p.currentTime,G=(j.BufferHelper.bufferInfo(p,M,S.maxBufferHole).end-M)/d;if(G>=2*C/d||x<=G)return;var $=Number.POSITIVE_INFINITY,re;for(re=u.level-1;re>h;re--){var z=c[re].maxBitrate;if($=C*z/(8*.8*m),$<G)break}if($>=x)return;var U=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+u.sn+(o?" part "+o.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+re+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+$.toFixed(3)+` s
|
|
Time to underbuffer: `+G.toFixed(3)+" s"),s.nextLoadLevel=re,this.bwEstimator.sample(v,f.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:o,stats:f})},w.onFragLoaded=function(u,o){var s=o.frag,l=o.part;if(s.type===P.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(s.sn)){var S=l?l.stats:s.stats,p=l?l.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var f=this.hls.levels[s.level],C=(f.loaded?f.loaded.bytes:0)+S.loaded,v=(f.loaded?f.loaded.duration:0)+p;f.loaded={bytes:C,duration:v},f.realBitrate=Math.round(8*C/v)}if(s.bitrateTest){var d={stats:S,frag:s,part:l,id:s.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,d),s.bitrateTest=!1}}},w.onFragBuffered=function(u,o){var s=o.frag,l=o.part,S=l?l.stats:s.stats;if(S.aborted)return;if(s.type!==P.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var p=S.parsing.end-S.loading.start;this.bwEstimator.sample(p,S.loaded),S.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=p/1e3:this.bitrateTestDelay=0},w.onError=function(u,o){switch(o.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},w.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},w.getNextABRAutoLevel=function(){var u=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.maxAutoLevel,S=s.config,p=s.minAutoLevel,f=s.media,C=o?o.duration:u?u.duration:0,v=f?f.currentTime:0,d=f&&f.playbackRate!==0?Math.abs(f.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():S.abrEwmaDefaultEstimate,h=(j.BufferHelper.bufferInfo(f,v,S.maxBufferHole).end-v)/d,a=this.findBestLevel(c,p,l,h,S.abrBandWidthFactor,S.abrBandWidthUpFactor);if(a>=0)return a;O.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=C?Math.min(C,S.maxStarvationDelay):S.maxStarvationDelay,m=S.abrBandWidthFactor,x=S.abrBandWidthUpFactor;if(!h){var M=this.bitrateTestDelay;if(M){var G=C?Math.min(C,S.maxLoadingDelay):S.maxLoadingDelay;y=G-M,O.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),m=x=1}}return a=this.findBestLevel(c,p,l,h+y,m,x),Math.max(a,0)},w.findBestLevel=function(u,o,s,l,S,p){for(var f,C=this.fragCurrent,v=this.partCurrent,d=this.lastLoadedFragLevel,c=this.hls.levels,h=c[d],a=!!(h!=null&&(f=h.details)!==null&&f!==void 0&&f.live),y=h==null?void 0:h.codecSet,m=v?v.duration:C?C.duration:0,x=s;x>=o;x--){var M=c[x];if(!M||y&&M.codecSet!==y)continue;var G=M.details,$=(v?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||m,re=void 0;x<=d?re=S*u:re=p*u;var z=c[x].maxBitrate,U=z*$/re;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(re)+"/"+z+"/"+$+"/"+l+"/"+U),re>z&&(!U||a&&!this.bitrateTestDelay||U<l))return x}return-1},T(L,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,o=this.bwEstimator;if(u!==-1&&(!o||!o.canEstimate()))return u;var s=this.getNextABRAutoLevel();return u!==-1&&(s=Math.min(u,s)),s},set:function(u){this._nextAutoLevel=u}}]),L}();Y.default=R},"./src/controller/audio-stream-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/polyfills/number.ts"),I=k("./src/controller/base-stream-controller.ts"),D=k("./src/events.ts"),j=k("./src/utils/buffer-helper.ts"),F=k("./src/controller/fragment-tracker.ts"),P=k("./src/types/level.ts"),O=k("./src/types/loader.ts"),g=k("./src/loader/fragment.ts"),T=k("./src/demux/chunk-cache.ts"),R=k("./src/demux/transmuxer-interface.ts"),L=k("./src/types/transmuxer.ts"),w=k("./src/controller/fragment-finders.ts"),E=k("./src/utils/discontinuities.ts"),u=k("./src/errors.ts"),o=k("./src/utils/logger.ts");function s(){return s=Object.assign||function(C){for(var v=1;v<arguments.length;v++){var d=arguments[v];for(var c in d)Object.prototype.hasOwnProperty.call(d,c)&&(C[c]=d[c])}return C},s.apply(this,arguments)}function l(C,v){C.prototype=Object.create(v.prototype),C.prototype.constructor=C,S(C,v)}function S(C,v){return S=Object.setPrototypeOf||function(c,h){return c.__proto__=h,c},S(C,v)}var p=100,f=function(C){l(v,C);function v(c,h){var a;return a=C.call(this,c,h,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var d=v.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var h=this.hls;h.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(D.Events.ERROR,this.onError,this),h.on(D.Events.BUFFER_RESET,this.onBufferReset,this),h.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var h=this.hls;h.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(D.Events.ERROR,this.onError,this),h.off(D.Events.BUFFER_RESET,this.onBufferReset,this),h.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(h,a){var y=a.frag,m=a.id,x=a.initPTS;if(m==="main"){var M=y.cc;this.initPTS[y.cc]=x,this.log("InitPTS for cc: "+M+" found from main: "+x),this.videoTrackCC=M,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=I.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(p),this.fragLoadError=0,a>0&&h===-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=h,this.tick()},d.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var h,a=this.levels,y=this.trackId,m=a==null||((h=a[y])===null||h===void 0)?void 0:h.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var x,M=performance.now(),G=this.retryDate;(!G||M>=G||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var $=this.waitingData;if($){var re=$.frag,z=$.part,U=$.cache,ne=$.complete;if(this.initPTS[re.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var fe=U.flush(),ge={frag:re,part:z,payload:fe,networkDetails:null};this._handleFragmentLoadProgress(ge),ne&&C.prototype._handleFragmentLoadComplete.call(this,ge)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+re.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var be=this.getLoadPosition(),Me=j.BufferHelper.bufferInfo(this.mediaBuffer,be,this.config.maxBufferHole),Te=Object(w.fragmentWithinToleranceTest)(Me.end,this.config.maxFragLookUpTolerance,re);Te<0&&(o.logger.log("Waiting fragment cc ("+re.cc+") @ "+re.start+" cancelled because another fragment at "+Me.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},d.onTickEnd=function(){var h=this.media;if(!h||!h.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:h,y=a.buffered;!this.loadedmetadata&&y.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime},d.doTickIdle=function(){var h,a,y=this.hls,m=this.levels,x=this.media,M=this.trackId,G=y.config;if(!m||!m[M])return;if(!x&&(this.startFragRequested||!G.startFragPrefetch))return;var $=m[M],re=$.details;if(!re||re.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(re)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var U=z.len,ne=this.getMaxBufferLength(),fe=this.audioSwitch;if(U>=ne&&!fe)return;if(!fe&&this._streamEnded(z,re)){y.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var ge=re.fragments,be=ge[0].start,Me=z.end;if(fe){var Te=this.getLoadPosition();Me=Te,re.PTSKnown&&Te<be&&((z.end>be||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=be+.05))}var De=this.getNextFragment(Me,re);if(!De){this.bufferFlushed=!0;return}((h=De.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((a=De.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(De,re):this.loadFragment(De,re,Me)},d.getMaxBufferLength=function(){var h=C.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return a===null?h:Math.max(h,a.len)},d.onMediaDetaching=function(){this.videoBuffer=null,C.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(h,a){var y=a.audioTracks;this.resetTransmuxer(),this.levels=y.map(function(m){return new P.Level(m)})},d.onAudioTrackSwitching=function(h,a){var y=!!a.url;this.trackId=a.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),y?this.setInterval(p):this.resetTransmuxer(),y?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(h,a){this.mainDetails=a.details},d.onAudioTrackLoaded=function(h,a){var y,m=this.levels,x=a.details,M=a.id;if(!m){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var G=m[M],$=0;if(x.live||(y=G.details)!==null&&y!==void 0&&y.live){var re=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!re)return;!G.details&&x.hasProgramDateTime&&re.hasProgramDateTime?(Object(E.alignMediaPlaylistByPDT)(x,re),$=x.fragments[0].start):$=this.alignPlaylists(x,G.details)}G.details=x,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(G.details,$),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=I.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(h){var a,y=h.frag,m=h.part,x=h.payload,M=this.config,G=this.trackId,$=this.levels;if(!$){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+y.sn+" of level "+y.level+" will not be buffered");return}var re=$[G];console.assert(re,"Audio track is defined on fragment load progress");var z=re.details;console.assert(z,"Audio track details are defined on fragment load progress");var U=M.defaultAudioCodec||re.audioCodec||"mp4a.40.2",ne=this.transmuxer;ne||(ne=this.transmuxer=new R.default(this.hls,O.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var fe=this.initPTS[y.cc],ge=(a=y.initSegment)===null||a===void 0?void 0:a.data;if(fe!==void 0){var be=!1,Me=m?m.index:-1,Te=Me!==-1,De=new L.ChunkMetadata(y.level,y.sn,y.stats.chunkCount,x.byteLength,Me,Te);ne.push(x,ge,U,"",y,m,z.totalduration,be,De,fe)}else{o.logger.log("Unknown video PTS for cc "+y.cc+", waiting for video PTS before demuxing audio frag "+y.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Ce=this.waitingData=this.waitingData||{frag:y,part:m,cache:new T.default,complete:!1},we=Ce.cache;we.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}C.prototype._handleFragmentLoadComplete.call(this,h)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(h,a){var y=a.tracks.audio;y&&(this.mediaBuffer=y.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},d.onFragBuffered=function(h,a){var y=a.frag,m=a.part;if(y.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(y)){this.warn("Fragment "+y.sn+(m?" p: "+m.index:"")+" of level "+y.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}y.sn!=="initSegment"&&(this.fragPrevious=y,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(y,m)},d.onError=function(h,a){switch(a.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==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 u.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var y=!0,m=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);m&&m.len>.5&&(y=!this.reduceMaxBufferLength(m.len)),y&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,C.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},d.onBufferFlushed=function(h,a){var y=a.type;y===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(h){var a,y="audio",m=this.hls,x=h.remuxResult,M=h.chunkMeta,G=this.getCurrentContext(M);if(!G){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(M.level);return}var $=G.frag,re=G.part,z=x.audio,U=x.text,ne=x.id3,fe=x.initSegment;if(this.fragContextChanged($))return;if(this.state=I.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),fe!=null&&fe.tracks&&(this._bufferInitSegment(fe.tracks,$,M),m.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:$,id:y,tracks:fe.tracks})),z){var ge=z.startPTS,be=z.endPTS,Me=z.startDTS,Te=z.endDTS;re&&(re.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:ge,endPTS:be,startDTS:Me,endDTS:Te}),$.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,ge,be,Me,Te),this.bufferFragmentData(z,$,re,M)}if(ne!=null&&(a=ne.samples)!==null&&a!==void 0&&a.length){var De=s({frag:$,id:y},ne);m.trigger(D.Events.FRAG_PARSING_METADATA,De)}if(U){var Ce=s({frag:$,id:y},U);m.trigger(D.Events.FRAG_PARSING_USERDATA,Ce)}},d._bufferInitSegment=function(h,a,y){if(this.state!==I.State.PARSING)return;h.video&&delete h.video;var m=h.audio;if(!m)return;m.levelCodec=m.codec,m.id="audio",this.log("Init audio buffer, container:"+m.container+", codecs[parsed]=["+m.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,h);var x=m.initSegment;if(x!=null&&x.byteLength){var M={type:"audio",frag:a,part:null,chunkMeta:y,parent:a.type,data:x};this.hls.trigger(D.Events.BUFFER_APPENDING,M)}this.tick()},d.loadFragment=function(h,a,y){var m=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||m===F.FragmentState.NOT_LOADED||m===F.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):a.live&&!Object(V.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,C.prototype.loadFragment.call(this,h,a,y)))},d.completeAudioSwitch=function(){var h=this.hls,a=this.media,y=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),C.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:y})},v}(I.default);Y.default=f},"./src/controller/audio-track-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts"),I=k("./src/errors.ts"),D=k("./src/controller/base-playlist-controller.ts"),j=k("./src/types/loader.ts");function F(R,L){for(var w=0;w<L.length;w++){var E=L[w];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(R,E.key,E)}}function P(R,L,w){return L&&F(R.prototype,L),w&&F(R,w),R}function O(R,L){R.prototype=Object.create(L.prototype),R.prototype.constructor=R,g(R,L)}function g(R,L){return g=Object.setPrototypeOf||function(E,u){return E.__proto__=u,E},g(R,L)}var T=function(R){O(L,R);function L(E){var u;return u=R.call(this,E,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(V.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(V.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},w.onManifestParsed=function(u,o){this.tracks=o.audioTracks||[]},w.onAudioTrackLoaded=function(u,o){var s=o.id,l=o.details,S=this.tracksInGroup[s];if(!S){this.warn("Invalid audio track id "+s);return}var p=S.details;S.details=o.details,this.log("audioTrack "+s+" loaded ["+l.startSN+"-"+l.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,o,p))},w.onLevelLoading=function(u,o){this.switchLevel(o.level)},w.onLevelSwitching=function(u,o){this.switchLevel(o.level)},w.switchLevel=function(u){var o=this.hls.levels[u];if(!(o!=null&&o.audioGroupIds))return;var s=o.audioGroupIds[o.urlId];if(this.groupId!==s){this.groupId=s;var l=this.tracks.filter(function(p){return!s||p.groupId===s});this.selectDefaultTrack&&!l.some(function(p){return p.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var S={audioTracks:l};this.log("Updating audio tracks, "+l.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,S),this.selectInitialTrack()}},w.onError=function(u,o){if(R.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===j.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},w.setAudioTrack=function(u){var o=this.tracksInGroup;if(u<0||u>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=o[this.trackId];this.log("Now switching to audio-track index "+u);var l=o[u],S=l.id,p=l.groupId,f=p===void 0?"":p,C=l.name,v=l.type,d=l.url;if(this.trackId=u,this.trackName=C,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:S,groupId:f,name:C,type:v,url:d}),l.details&&!l.details.live)return;var c=this.switchParams(l.url,s==null?void 0:s.details);this.loadPlaylist(c)},w.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,s=this.findTrackId(o)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},w.findTrackId=function(u){for(var o=this.tracksInGroup,s=0;s<o.length;s++){var l=o[s];if((!this.selectDefaultTrack||l.default)&&(!u||u===l.name))return l.id}return-1},w.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var s=o.id,l=o.groupId,S=o.url;if(u)try{S=u.addDirectives(S)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:S,id:s,groupId:l,deliveryDirectives:u||null})}},P(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),L}(D.default);Y.default=T},"./src/controller/base-playlist-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return P});var V=k("./src/polyfills/number.ts"),I=k("./src/types/level.ts"),D=k("./src/controller/level-helper.ts"),j=k("./src/utils/logger.ts"),F=k("./src/errors.ts"),P=function(){function O(T,R){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=j.logger.log.bind(j.logger,R+":"),this.warn=j.logger.warn.bind(j.logger,R+":"),this.hls=T}var g=O.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(R,L){L.fatal&&L.type===F.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(R,L){var w=L==null?void 0:L.renditionReports;if(w)for(var E=0;E<w.length;E++){var u=w[E],o=""+u.URI;if(o===R.substr(-o.length)){var s=parseInt(u["LAST-MSN"]),l=parseInt(u["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var S=Math.min(L.age-L.partTarget,L.targetduration);l!==void 0&&S>L.partTarget&&(l+=1)}if(Object(V.isFiniteNumber)(s))return new I.HlsUrlParameters(s,Object(V.isFiniteNumber)(l)?l:void 0,I.HlsSkip.No)}}},g.loadPlaylist=function(R){},g.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},g.playlistLoaded=function(R,L,w){var E=this,u=L.details,o=L.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||w!=null&&w.live){if(u.reloaded(w),w&&this.log("live playlist "+R+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),w&&u.fragments.length>0&&Object(D.mergeDetails)(w,u),!this.canLoad||!u.live)return;var l,S=void 0,p=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var f=this.hls.config.lowLatencyMode,C=u.lastPartSn,v=u.endSN,d=u.lastPartIndex,c=d!==-1,h=C===v,a=f?0:d;c?(S=h?v+1:C,p=h?a:d+1):S=v+1;var y=u.age,m=y+u.ageHeader,x=Math.min(m-u.partTarget,u.targetduration*1.5);if(x>0){if(w&&x>w.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+w.tuneInGoal+" to: "+x+" with playlist age: "+u.age),x=0;else{var M=Math.floor(x/u.targetduration);if(S+=M,p!==void 0){var G=Math.round(x%u.targetduration/u.partTarget);p+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+x+" skip sn "+M+" to part "+p)}u.tuneInGoal=x}if(l=this.getDeliveryDirectives(u,L.deliveryDirectives,S,p),f||!h){this.loadPlaylist(l);return}}else l=this.getDeliveryDirectives(u,L.deliveryDirectives,S,p);var $=Object(D.computeReloadInterval)(u,o);S!==void 0&&u.canBlockReload&&($-=u.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round($)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(l)},$)}else this.clearTimer()},g.getDeliveryDirectives=function(R,L,w,E){var u=Object(I.getSkipValue)(R,w);return L!=null&&L.skip&&R.deltaUpdateFailed&&(w=L.msn,E=L.part,u=I.HlsSkip.No),new I.HlsUrlParameters(w,E,u)},g.retryLoadingOrFail=function(R){var L=this,w=this.hls.config,E=this.retryCount<w.levelLoadingMaxRetry;if(E){var u;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(u=R.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*w.levelLoadingRetryDelay,w.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+R.details+'"')}}else this.warn('cannot recover from error "'+R.details+'"'),this.clearTimer(),R.fatal=!0;return E},O}()},"./src/controller/base-stream-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"State",function(){return v}),k.d(Y,"default",function(){return d});var V=k("./src/polyfills/number.ts"),I=k("./src/task-loop.ts"),D=k("./src/controller/fragment-tracker.ts"),j=k("./src/utils/buffer-helper.ts"),F=k("./src/utils/logger.ts"),P=k("./src/events.ts"),O=k("./src/errors.ts"),g=k("./src/types/transmuxer.ts"),T=k("./src/utils/mp4-tools.ts"),R=k("./src/utils/discontinuities.ts"),L=k("./src/controller/fragment-finders.ts"),w=k("./src/controller/level-helper.ts"),E=k("./src/loader/fragment-loader.ts"),u=k("./src/crypt/decrypter.ts"),o=k("./src/utils/time-ranges.ts"),s=k("./src/types/loader.ts");function l(c,h){for(var a=0;a<h.length;a++){var y=h[a];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(c,y.key,y)}}function S(c,h,a){return h&&l(c.prototype,h),a&&l(c,a),c}function p(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function f(c,h){c.prototype=Object.create(h.prototype),c.prototype.constructor=c,C(c,h)}function C(c,h){return C=Object.setPrototypeOf||function(y,m){return y.__proto__=m,y},C(c,h)}var v={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},d=function(c){f(h,c);function h(y,m,x){var M;return M=c.call(this)||this,M.hls=void 0,M.fragPrevious=null,M.fragCurrent=null,M.fragmentTracker=void 0,M.transmuxer=null,M._state=v.STOPPED,M.media=void 0,M.mediaBuffer=void 0,M.config=void 0,M.bitrateTest=!1,M.lastCurrentTime=0,M.nextLoadPosition=0,M.startPosition=0,M.loadedmetadata=!1,M.fragLoadError=0,M.retryDate=0,M.levels=null,M.fragmentLoader=void 0,M.levelLastLoaded=null,M.startFragRequested=!1,M.decrypter=void 0,M.initPTS=[],M.onvseeking=null,M.onvended=null,M.logPrefix="",M.log=void 0,M.warn=void 0,M.logPrefix=x,M.log=F.logger.log.bind(F.logger,x+":"),M.warn=F.logger.warn.bind(F.logger,x+":"),M.hls=y,M.fragmentLoader=new E.default(y.config),M.fragmentTracker=m,M.config=y.config,M.decrypter=new u.default(y,y.config),y.on(P.Events.KEY_LOADED,M.onKeyLoaded,p(M)),M}var a=h.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(m){},a.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=v.STOPPED},a._streamEnded=function(m,x){var M=this.fragCurrent,G=this.fragmentTracker;if(!x.live&&M&&M.sn===x.endSN&&!m.nextStart){var $=G.getState(M);return $===D.FragmentState.PARTIAL||$===D.FragmentState.OK}return!1},a.onMediaAttached=function(m,x){var M=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),M.addEventListener("seeking",this.onvseeking),M.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===v.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var m=this.config,x=this.fragCurrent,M=this.media,G=this.mediaBuffer,$=this.state,re=M?M.currentTime:0,z=j.BufferHelper.bufferInfo(G||M,re,m.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(re)?re.toFixed(3):re)+", state: "+$),$===v.ENDED)this.resetLoadingState();else if(x&&!z.len){var U=m.maxFragLookUpTolerance,ne=x.start-U,fe=x.start+x.duration+U,ge=re>fe;(re<ne||ge)&&(ge&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}M&&(this.lastCurrentTime=re),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=re),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(m,x){if(this.state!==v.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=v.IDLE;var M=this.levels[x.frag.level].details;M&&this.loadFragment(x.frag,M,x.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=v.STOPPED,this.hls.off(P.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(m,x){this.log("Loading key for "+m.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=v.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(P.Events.KEY_LOADING,{frag:m})},a.loadFragment=function(m,x,M){this._loadFragForPlayback(m,x,M)},a._loadFragForPlayback=function(m,x,M){var G=this,$=function(z){if(G.fragContextChanged(m)){G.warn("Fragment "+m.sn+(z.part?" p: "+z.part.index:"")+" of level "+m.level+" was dropped during download."),G.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(m,x,M,$).then(function(re){if(!re)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(m)){(z===v.FRAG_LOADING||z===v.BACKTRACKING||!G.fragCurrent&&z===v.PARSING)&&(G.fragmentTracker.removeFragment(m),G.state=v.IDLE);return}if("payload"in re&&(G.log("Loaded fragment "+m.sn+" of level "+m.level),G.hls.trigger(P.Events.FRAG_LOADED,re),G.state===v.BACKTRACKING)){G.fragmentTracker.backtrack(m,re),G.resetFragmentLoading(m);return}G._handleFragmentLoadComplete(re)}).catch(function(re){G.warn(re),G.resetFragmentLoading(m)})},a.flushMainBuffer=function(m,x,M){if(M===void 0&&(M=null),!(m-x))return;var G={startOffset:m,endOffset:x,type:M};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(m){var x=this;this._doFragLoad(m).then(function(M){if(!M||x.fragContextChanged(m)||!x.levels)throw new Error("init load aborted");return M}).then(function(M){var G=x.hls,$=M.payload,re=m.decryptdata;if($&&$.byteLength>0&&re&&re.key&&re.iv&&re.method==="AES-128"){var z=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array($),re.key.buffer,re.iv.buffer).then(function(U){var ne=self.performance.now();return G.trigger(P.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:z,tdecrypt:ne}}),M.payload=U,M})}return M}).then(function(M){var G=x.fragCurrent,$=x.hls,re=x.levels;if(!re)throw new Error("init load aborted, missing levels");var z=re[m.level].details;console.assert(z,"Level details are defined when init segment is loaded");var U=m.stats;x.state=v.IDLE,x.fragLoadError=0,m.data=new Uint8Array(M.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),M.frag===G&&$.trigger(P.Events.FRAG_BUFFERED,{stats:U,frag:G,part:null,id:m.type}),x.tick()}).catch(function(M){x.warn(M),x.resetFragmentLoading(m)})},a.fragContextChanged=function(m){var x=this.fragCurrent;return!m||!x||m.level!==x.level||m.sn!==x.sn||m.urlId!==x.urlId},a.fragBufferedComplete=function(m,x){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+o.default.toString(j.BufferHelper.getBuffered(M))),this.state=v.IDLE,this.tick()},a._handleFragmentLoadComplete=function(m){var x=this.transmuxer;if(!x)return;var M=m.frag,G=m.part,$=m.partsLoaded,re=!$||$.length===0||$.some(function(U){return!U}),z=new g.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,G?G.index:-1,!re);x.flush(z)},a._handleFragmentLoadProgress=function(m){},a._doFragLoad=function(m,x,M,G){var $=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(m.start,M||0),this.config.lowLatencyMode&&x){var re=x.partList;if(re&&G){M>m.end&&x.fragmentHint&&(m=x.fragmentHint);var z=this.getNextPart(re,m,M);if(z>-1){var U=re[z];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+z+"-"+(re.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=v.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:m,part:re[z],targetBufferTime:M}),this.doFragPartsLoad(m,re,z,G).catch(function(ne){return $.handleFragLoadError(ne)})}else if(!m.url||this.loadedEndOfParts(re,M))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(M.toFixed(3))),Object(V.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=v.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:m,targetBufferTime:M}),this.fragmentLoader.load(m,G).catch(function(ne){return $.handleFragLoadError(ne)})},a.doFragPartsLoad=function(m,x,M,G){var $=this;return new Promise(function(re,z){var U=[],ne=function fe(ge){var be=x[ge];$.fragmentLoader.loadPart(m,be,G).then(function(Me){U[be.index]=Me;var Te=Me.part;$.hls.trigger(P.Events.FRAG_LOADED,Me);var De=x[ge+1];if(De&&De.fragment===m)fe(ge+1);else return re({frag:m,part:Te,partsLoaded:U})}).catch(z)};ne(M)})},a.handleFragLoadError=function(m){var x=m.data;return x&&x.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(P.Events.ERROR,x),null},a._handleTransmuxerFlush=function(m){var x=this.getCurrentContext(m);if(!x||this.state!==v.PARSING){this.fragCurrent||(this.state=v.IDLE);return}var M=x.frag,G=x.part,$=x.level,re=self.performance.now();M.stats.parsing.end=re,G&&(G.stats.parsing.end=re),this.updateLevelTiming(M,G,$,m.partial)},a.getCurrentContext=function(m){var x=this.levels,M=m.level,G=m.sn,$=m.part;if(!x||!x[M])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+M+". The current chunk will not be buffered."),null;var re=x[M],z=$>-1?Object(w.getPartWith)(re,G,$):null,U=z?z.fragment:Object(w.getFragmentWithSN)(re,G,this.fragCurrent);return U?{frag:U,part:z,level:re}:null},a.bufferFragmentData=function(m,x,M,G){if(!m||this.state!==v.PARSING)return;var $=m.data1,re=m.data2,z=$;if($&&re&&(z=Object(T.appendUint8Array)($,re)),!z||!z.length)return;var U={type:m.type,frag:x,part:M,chunkMeta:G,parent:x.type,data:z};this.hls.trigger(P.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!M&&this.flushBufferGap(x)},a.flushBufferGap=function(m){var x=this.media;if(!x)return;if(!j.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,m.start);return}var M=x.currentTime,G=j.BufferHelper.bufferInfo(x,M,0),$=m.duration,re=Math.min(this.config.maxFragLookUpTolerance*2,$*.25),z=Math.max(Math.min(m.start-re,G.end-re),M+re);m.start-z>re&&this.flushMainBuffer(z,m.start)},a.getFwdBufferInfo=function(m,x){var M=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var $=j.BufferHelper.bufferInfo(m,G,M.maxBufferHole);if($.len===0&&$.nextStart!==void 0){var re=this.fragmentTracker.getBufferedFrag(G,x);if(re&&$.nextStart<re.end)return j.BufferHelper.bufferInfo(m,G,Math.max($.nextStart,M.maxBufferHole))}return $},a.getMaxBufferLength=function(m){var x=this.config,M;return m?M=Math.max(8*x.maxBufferSize/m,x.maxBufferLength):M=x.maxBufferLength,Math.min(M,x.maxMaxBufferLength)},a.reduceMaxBufferLength=function(m){var x=this.config,M=m||x.maxBufferLength;return x.maxMaxBufferLength>=M?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(m,x){var M,G,$=x.fragments,re=$.length;if(!re)return null;var z=this.config,U=$[0].start,ne;if(x.live){var fe=z.initialLiveManifestSize;if(re<fe)return this.warn("Not enough fragments to start playback (have: "+re+", need: "+fe+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ne=this.getInitialLiveFragment(x,$),this.startPosition=ne?this.hls.liveSyncPosition||ne.start:m)}else m<=U&&(ne=$[0]);if(!ne){var ge=z.lowLatencyMode?x.partEnd:x.fragmentEnd;ne=this.getFragmentAtPosition(m,ge,x)}return(M=ne)!==null&&M!==void 0&&M.initSegment&&!((G=ne)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(ne=ne.initSegment),ne},a.getNextPart=function(m,x,M){for(var G=-1,$=!1,re=!0,z=0,U=m.length;z<U;z++){var ne=m[z];if(re=re&&!ne.independent,G>-1&&M<ne.start)break;var fe=ne.loaded;!fe&&($||ne.independent||re)&&ne.fragment===x&&(G=z),$=fe}return G},a.loadedEndOfParts=function(m,x){var M=m[m.length-1];return M&&x>M.start&&M.loaded},a.getInitialLiveFragment=function(m,x){var M=this.fragPrevious,G=null;if(M){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),G=Object(L.findFragmentByPDT)(x,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var $=M.sn+1;if($>=m.startSN&&$<=m.endSN){var re=x[$-m.startSN];M.cc===re.cc&&(G=re,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(L.findFragWithCC)(x,M.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?m.fragmentEnd:m.edge,m))}return G},a.getFragmentAtPosition=function(m,x,M){var G=this.config,$=this.fragPrevious,re=M.fragments,z=M.endSN,U=M.fragmentHint,ne=G.maxFragLookUpTolerance,fe=!!(G.lowLatencyMode&&M.partList&&U);fe&&U&&!this.bitrateTest&&(re=re.concat(U),z=U.sn);var ge;if(m<x){var be=m>x-ne?0:ne;ge=Object(L.findFragmentByPTS)($,re,m,be)}else ge=re[re.length-1];if(ge){var Me=ge.sn-M.startSN,Te=$&&ge.level===$.level,De=re[Me+1],Ce=this.fragmentTracker.getState(ge);if(Ce===D.FragmentState.BACKTRACKED){ge=null;for(var we=Me;re[we]&&this.fragmentTracker.getState(re[we])===D.FragmentState.BACKTRACKED;)$?ge=re[we--]:ge=re[--we];ge||(ge=De)}else $&&ge.sn===$.sn&&!fe&&(Te&&(ge.sn<z&&this.fragmentTracker.getState(De)!==D.FragmentState.OK?(this.log("SN "+ge.sn+" just loaded, load next one: "+De.sn),ge=De):ge=null))}return ge},a.synchronizeToLiveEdge=function(m){var x=this.config,M=this.media;if(!M)return;var G=this.hls.liveSyncPosition,$=M.currentTime,re=m.fragments[0].start,z=m.edge,U=$>=re-x.maxFragLookUpTolerance&&$<=z;if(G!==null&&M.duration>G&&($<G||!U)){var ne=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*m.targetduration;(!U&&M.readyState<4||$<z-ne)&&(this.loadedmetadata||(this.nextLoadPosition=G),M.readyState&&(this.warn("Playback: "+$.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),M.currentTime=G))}},a.alignPlaylists=function(m,x){var M=this.levels,G=this.levelLastLoaded,$=this.fragPrevious,re=G!==null?M[G]:null,z=m.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,ne=!x,fe=m.alignedSliding&&Object(V.isFiniteNumber)(U);if(ne||!fe&&!U){Object(R.alignStream)($,re,m);var ge=m.fragments[0].start;return this.log("Live playlist sliding: "+ge.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+m.startSN+" prev-sn: "+($?$.sn:"na")+" fragments: "+z),ge}return U},a.waitForCdnTuneIn=function(m){var x=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*x)},a.setStartPosition=function(m,x){var M=this.startPosition;if(M<x&&(M=-1),M===-1||this.lastCurrentTime===-1){var G=m.startTimeOffset;Object(V.isFiniteNumber)(G)?(M=x+G,G<0&&(M+=m.totalduration),M=Math.min(Math.max(x,M),x+m.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+M),this.startPosition=M):m.live?M=this.hls.liveSyncPosition||x:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},a.getLoadPosition=function(){var m=this.media,x=0;return this.loadedmetadata&&m?x=m.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},a.handleFragLoadAborted=function(m,x){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(x?" part"+x.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},a.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=v.IDLE)},a.onFragmentOrKeyLoadError=function(m,x){if(x.fatal)return;var M=x.frag;if(!M||M.type!==m)return;var G=this.fragCurrent;console.assert(G&&M.sn===G.sn&&M.level===G.level&&M.urlId===G.urlId,"Frag load error must match current frag to retry");var $=this.config;if(this.fragLoadError+1<=$.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(M.level))return;var re=Math.min(Math.pow(2,this.fragLoadError)*$.fragLoadingRetryDelay,$.fragLoadingMaxRetryTimeout);this.warn("Fragment "+M.sn+" of "+m+" "+M.level+" failed to load, retrying in "+re+"ms"),this.retryDate=self.performance.now()+re,this.fragLoadError++,this.state=v.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(m===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=v.IDLE):(F.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=v.ERROR)},a.afterBufferFlushed=function(m,x,M){if(!m)return;var G=j.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(x,G,M),this.state===v.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=v.IDLE},a.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[m].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(m,x,M,G){var $=this,re=M.details;console.assert(!!re,"level.details must be defined");var z=Object.keys(m.elementaryStreams).reduce(function(U,ne){var fe=m.elementaryStreams[ne];if(fe){var ge=fe.endPTS-fe.startPTS;if(ge<=0)return $.warn("Could not parse fragment "+m.sn+" "+ne+" duration reliably ("+ge+") resetting transmuxer to fallback to playlist timing"),$.resetTransmuxer(),U||!1;var be=G?0:Object(w.updateFragPTSDTS)(re,m,fe.startPTS,fe.endPTS,fe.startDTS,fe.endDTS);return $.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:re,level:M,drift:be,type:ne,frag:m,start:fe.startPTS,end:fe.endPTS}),!0}return U},!1);z?(this.state=v.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:m,part:x})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S(h,[{key:"state",get:function(){return this._state},set:function(m){var x=this._state;x!==m&&(this._state=m,this.log(x+"->"+m))}}]),h}(I.default)},"./src/controller/buffer-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return L});var V=k("./src/polyfills/number.ts"),I=k("./src/events.ts"),D=k("./src/utils/logger.ts"),j=k("./src/errors.ts"),F=k("./src/utils/buffer-helper.ts"),P=k("./src/utils/mediasource-helper.ts"),O=k("./src/loader/fragment.ts"),g=k("./src/controller/buffer-operation-queue.ts"),T=Object(P.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function w(u){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=o.hls,l=o.media,S=o.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),l&&(o.updateMediaElementDuration(),s.trigger(I.Events.MEDIA_ATTACHED,{media:l})),S&&S.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=u,this._initSourceBuffer(),this.registerListeners()}var E=w.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var o=this.hls;o.on(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)},E.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)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(o,s){var l=2;(s.audio&&!s.video||!s.altAudio)&&(l=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=l,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(o,s){var l=this.media=s.media;if(l&&T){var S=this.mediaSource=new T;S.addEventListener("sourceopen",this._onMediaSourceOpen),S.addEventListener("sourceended",this._onMediaSourceEnded),S.addEventListener("sourceclose",this._onMediaSourceClose),l.src=self.URL.createObjectURL(S),this._objectUrl=l.src}},E.onMediaDetaching=function(){var o=this.media,s=this.mediaSource,l=this._objectUrl;if(s){if(D.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(S){D.logger.warn("[buffer-controller]: onMediaDetaching: "+S.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(l&&self.URL.revokeObjectURL(l),o.src===l?(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)},E.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(s){var l=o.sourceBuffer[s];try{l&&(o.removeBufferListeners(s),o.mediaSource&&o.mediaSource.removeSourceBuffer(l),o.sourceBuffer[s]=void 0)}catch(S){D.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",S)}}),this._initSourceBuffer()},E.onBufferCodecs=function(o,s){var l=this,S=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(p){if(S){var f=l.tracks[p];if(f&&typeof f.buffer.changeType=="function"){var C=s[p],v=C.codec,d=C.levelCodec,c=C.container,h=(f.levelCodec||f.codec).replace(R,"$1"),a=(d||v).replace(R,"$1");if(h!==a){var y=c+";codecs="+(d||v);l.appendChangeType(p,y)}}}else l.pendingTracks[p]=s[p]}),S)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},E.appendChangeType=function(o,s){var l=this,S=this.operationQueue,p={execute:function(){var C=l.sourceBuffer[o];C&&(D.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+s),C.changeType(s)),S.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(C){D.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",C)}};S.append(p,o)},E.onBufferAppending=function(o,s){var l=this,S=this.hls,p=this.operationQueue,f=this.tracks,C=s.data,v=s.type,d=s.frag,c=s.part,h=s.chunkMeta,a=h.buffering[v],y=self.performance.now();a.start=y;var m=d.stats.buffering,x=c?c.stats.buffering:null;m.start===0&&(m.start=y),x&&x.start===0&&(x.start=y);var M=f.audio,G=v==="audio"&&h.id===1&&(M==null?void 0:M.container)==="audio/mpeg",$={execute:function(){if(a.executeStart=self.performance.now(),G){var z=l.sourceBuffer[v];if(z){var U=d.start-z.timestampOffset;Math.abs(U)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+d.start+" (delta: "+U+") sn: "+d.sn+")"),z.timestampOffset=d.start)}}l.appendExecutor(C,v)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,m.first===0&&(m.first=z),x&&x.first===0&&(x.first=z);var U=l.sourceBuffer,ne={};for(var fe in U)ne[fe]=F.BufferHelper.getBuffered(U[fe]);l.appendError=0,l.hls.trigger(I.Events.BUFFER_APPENDED,{type:v,frag:d,part:c,chunkMeta:h,parent:d.type,timeRanges:ne})},onError:function(z){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+v+" SourceBuffer",z);var U={type:j.ErrorTypes.MEDIA_ERROR,parent:d.type,details:j.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=j.ErrorDetails.BUFFER_FULL_ERROR:(l.appendError++,U.details=j.ErrorDetails.BUFFER_APPEND_ERROR,l.appendError>S.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+S.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),S.trigger(I.Events.ERROR,U)}};p.append($,v)},E.onBufferFlushing=function(o,s){var l=this,S=this.operationQueue,p=function(C){return{execute:l.removeExecutor.bind(l,C,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){l.hls.trigger(I.Events.BUFFER_FLUSHED,{type:C})},onError:function(d){D.logger.warn("[buffer-controller]: Failed to remove from "+C+" SourceBuffer",d)}}};s.type?S.append(p(s.type),s.type):this.getSourceBufferTypes().forEach(function(f){S.append(p(f),f)})},E.onFragParsed=function(o,s){var l=this,S=s.frag,p=s.part,f=[],C=p?p.elementaryStreams:S.elementaryStreams;C[O.ElementaryStreamTypes.AUDIOVIDEO]?f.push("audiovideo"):(C[O.ElementaryStreamTypes.AUDIO]&&f.push("audio"),C[O.ElementaryStreamTypes.VIDEO]&&f.push("video"));var v=function(){var c=self.performance.now();S.stats.buffering.end=c,p&&(p.stats.buffering.end=c);var h=p?p.stats:S.stats;l.hls.trigger(I.Events.FRAG_BUFFERED,{frag:S,part:p,stats:h,id:S.type})};f.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+S.type+" level: "+S.level+" sn: "+S.sn),this.blockBuffers(v,f)},E.onFragChanged=function(o,s){this.flushBackBuffer()},E.onBufferEos=function(o,s){var l=this,S=this.getSourceBufferTypes().reduce(function(p,f){var C=l.sourceBuffer[f];return(!s.type||s.type===f)&&(C&&!C.ended&&(C.ended=!0,D.logger.log("[buffer-controller]: "+f+" sourceBuffer now EOS"))),p&&!!(!C||C.ended)},!0);S&&this.blockBuffers(function(){var p=l.mediaSource;if(!p||p.readyState!=="open")return;p.endOfStream()})},E.onLevelUpdated=function(o,s){var l=s.details;if(!l.fragments.length)return;this.details=l,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},E.flushBackBuffer=function(){var o=this.hls,s=this.details,l=this.media,S=this.sourceBuffer;if(!l||s===null)return;var p=this.getSourceBufferTypes();if(!p.length)return;var f=s.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(V.isFiniteNumber)(f)||f<0)return;var C=l.currentTime,v=s.levelTargetDuration,d=Math.max(f,v),c=Math.floor(C/v)*v-d;p.forEach(function(h){var a=S[h];if(a){var y=F.BufferHelper.getBuffered(a);y.length>0&&c>y.start(0)&&(o.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),s.live&&o.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:h}))}})},E.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,s=this.hls,l=this.media,S=this.mediaSource,p=o.fragments[0].start+o.totalduration,f=l.duration,C=Object(V.isFiniteNumber)(S.duration)?S.duration:0;o.live&&s.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),S.duration=Infinity,this.updateSeekableRange(o)):(p>C&&p>f||!Object(V.isFiniteNumber)(f))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+p.toFixed(3)),S.duration=p)},E.updateSeekableRange=function(o){var s=this.mediaSource,l=o.fragments,S=l.length;if(S&&o.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var p=Math.max(0,l[0].start),f=Math.max(p,p+o.totalduration);s.setLiveSeekableRange(p,f)}},E.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,s=this.operationQueue,l=this.pendingTracks,S=Object.keys(l).length;if(S&&!o||S===2){this.createSourceBuffers(l),this.pendingTracks={};var p=this.getSourceBufferTypes();if(p.length===0){this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}p.forEach(function(f){s.executeNext(f)})}},E.createSourceBuffers=function(o){var s=this.sourceBuffer,l=this.mediaSource;if(!l)throw Error("createSourceBuffers called when mediaSource was null");var S=0;for(var p in o)if(!s[p]){var f=o[p];if(!f)throw Error("source buffer exists for track "+p+", however track does not");var C=f.levelCodec||f.codec,v=f.container+";codecs="+C;D.logger.log("[buffer-controller]: creating sourceBuffer("+v+")");try{var d=s[p]=l.addSourceBuffer(v),c=p;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[p]={buffer:d,codec:C,container:f.container,levelCodec:f.levelCodec,id:f.id},S++}catch(h){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+h.message),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,mimeType:v})}}S&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(o){var s=this.operationQueue,l=s.current(o);l.onStart()},E._onSBUpdateEnd=function(o){var s=this.operationQueue,l=s.current(o);l.onComplete(),s.shiftAndExecuteNext(o)},E._onSBUpdateError=function(o,s){D.logger.error("[buffer-controller]: "+o+" SourceBuffer error",s),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var l=this.operationQueue.current(o);l&&l.onError(s)},E.removeExecutor=function(o,s,l){var S=this.media,p=this.mediaSource,f=this.operationQueue,C=this.sourceBuffer,v=C[o];if(!S||!p||!v){D.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}var d=Object(V.isFiniteNumber)(S.duration)?S.duration:Infinity,c=Object(V.isFiniteNumber)(p.duration)?p.duration:Infinity,h=Math.max(0,s),a=Math.min(l,d,c);a>h?(D.logger.log("[buffer-controller]: Removing ["+h+","+a+"] from the "+o+" SourceBuffer"),console.assert(!v.updating,o+" sourceBuffer must not be updating"),v.remove(h,a)):f.shiftAndExecuteNext(o)},E.appendExecutor=function(o,s){var l=this.operationQueue,S=this.sourceBuffer,p=S[s];if(!p){D.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(s);return}p.ended=!1,console.assert(!p.updating,s+" sourceBuffer must not be updating"),p.appendBuffer(o)},E.blockBuffers=function(o,s){var l=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var S=this.operationQueue,p=s.map(function(f){return S.appendBlocker(f)});Promise.all(p).then(function(){o(),s.forEach(function(f){var C=l.sourceBuffer[f];(!C||!C.updating)&&S.shiftAndExecuteNext(f)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(o,s,l){var S=this.sourceBuffer[o];if(!S)return;var p=l.bind(this,o);this.listeners[o].push({event:s,listener:p}),S.addEventListener(s,p)},E.removeBufferListeners=function(o){var s=this.sourceBuffer[o];if(!s)return;this.listeners[o].forEach(function(l){s.removeEventListener(l.event,l.listener)})},w}()},"./src/controller/buffer-operation-queue.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return I});var V=k("./src/utils/logger.ts"),I=function(){function D(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var j=D.prototype;return j.append=function(P,O){var g=this.queues[O];g.push(P),g.length===1&&this.buffers[O]&&this.executeNext(O)},j.insertAbort=function(P,O){var g=this.queues[O];g.unshift(P),this.executeNext(O)},j.appendBlocker=function(P){var O,g=new Promise(function(R){O=R}),T={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,P),g},j.executeNext=function(P){var O=this.buffers,g=this.queues,T=O[P],R=g[P];if(R.length){var L=R[0];try{L.execute()}catch(w){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(w),(!T||!T.updating)&&(R.shift(),this.executeNext(P))}}},j.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},j.current=function(P){return this.queues[P][0]},D}()},"./src/controller/cap-level-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts");function I(F,P){for(var O=0;O<P.length;O++){var g=P[O];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(F,g.key,g)}}function D(F,P,O){return P&&I(F.prototype,P),O&&I(F,O),F}var j=function(){function F(O){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=O,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=F.prototype;return P.setStreamController=function(g){this.streamController=g},P.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},P.registerListeners=function(){var g=this.hls;g.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var g=this.hls;g.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(g,T){F.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},P.onMediaAttaching=function(g,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},P.onManifestParsed=function(g,T){var R=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,R.config.capLevelToPlayerSize&&T.video&&this.startCapping()},P.onBufferCodecs=function(g,T){var R=this.hls;R.config.capLevelToPlayerSize&&T.video&&this.startCapping()},P.onMediaDetaching=function(){this.stopCapping()},P.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(g.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},P.getMaxLevel=function(g){var T=this,R=this.hls.levels;if(!R.length)return-1;var L=R.filter(function(w,E){return F.isLevelAllowed(E,T.restrictedLevels)&&E<=g});return this.clientRect=null,F.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},P.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},P.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},P.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,T={width:0,height:0};if(g){var R=g.getBoundingClientRect();T.width=R.width,T.height=R.height,!T.width&&!T.height&&(T.width=R.right-R.left||g.width||0,T.height=R.bottom-R.top||g.height||0)}return this.clientRect=T,T},F.isLevelAllowed=function(g,T){return T===void 0&&(T=[]),T.indexOf(g)===-1},F.getMaxLevelByMediaSize=function(g,T,R){if(!g||!g.length)return-1;for(var L=function(s,l){return l?s.width!==l.width||s.height!==l.height:!0},w=g.length-1,E=0;E<g.length;E+=1){var u=g[E];if((u.width>=T||u.height>=R)&&L(u,g[E+1])){w=E;break}}return w},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 g=1;try{g=self.devicePixelRatio}catch(T){}return g}}]),F}();Y.default=j},"./src/controller/cmcd-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return L});var V=k("./src/events.ts"),I=k("./src/types/cmcd.ts"),D=k("./src/utils/buffer-helper.ts"),j=k("./src/utils/logger.ts");function F(w,E){for(var u=0;u<E.length;u++){var o=E[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(w,o.key,o)}}function P(w,E,u){return E&&F(w.prototype,E),u&&F(w,u),w}function O(w,E){var u=typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(u)return(u=u.call(w)).next.bind(u);if(Array.isArray(w)||(u=g(w))||E&&w&&typeof w.length=="number"){u&&(w=u);var o=0;return function(){return o>=w.length?{done:!0}:{done:!1,value:w[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 g(w,E){if(!w)return;if(typeof w=="string")return T(w,E);var u=Object.prototype.toString.call(w).slice(8,-1);if(u==="Object"&&w.constructor&&(u=w.constructor.name),u==="Map"||u==="Set")return Array.from(w);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(w,E)}function T(w,E){(E==null||E>w.length)&&(E=w.length);for(var u=0,o=new Array(E);u<E;u++)o[u]=w[u];return o}function R(){return R=Object.assign||function(w){for(var E=1;E<arguments.length;E++){var u=arguments[E];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(w[o]=u[o])}return w},R.apply(this,arguments)}var L=function(){function w(u){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(S){try{o.apply(S,{ot:I.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(p){j.logger.warn("Could not generate manifest CMCD data.",p)}},this.applyFragmentData=function(S){try{var p=S.frag,f=o.hls.levels[p.level],C=o.getObjectType(p),v={d:p.duration*1e3,ot:C};(C===I.CMCDObjectType.VIDEO||C===I.CMCDObjectType.AUDIO||C==I.CMCDObjectType.MUXED)&&(v.br=f.bitrate/1e3,v.tb=o.getTopBandwidth(C),v.bl=o.getBufferLength(C)),o.apply(S,v)}catch(d){j.logger.warn("Could not generate segment CMCD data.",d)}},this.hls=u;var s=this.config=u.config,l=s.cmcd;l!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||w.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var E=w.prototype;return E.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},E.onBufferCreated=function(o,s){var l,S;this.audioBuffer=(l=s.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(S=s.tracks.video)===null||S===void 0?void 0:S.buffer},E.createData=function(){var o;return{v:I.CMCDVersion,sf:I.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(o,s){s===void 0&&(s={}),R(s,this.createData());var l=s.ot===I.CMCDObjectType.INIT||s.ot===I.CMCDObjectType.VIDEO||s.ot===I.CMCDObjectType.MUXED;if(this.starved&&l&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var S=w.toHeaders(s);if(!Object.keys(S).length)return;o.headers||(o.headers={}),R(o.headers,S)}else{var p=w.toQuery(s);if(!p)return;o.url=w.appendQueryToUri(o.url,p)}},E.getObjectType=function(o){var s=o.type;return s==="subtitle"?I.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?I.CMCDObjectType.INIT:s==="audio"?I.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},E.getTopBandwidth=function(o){for(var s=0,l=o===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,S=O(l),p;!(p=S()).done;){var f=p.value;f.bitrate>s&&(s=f.bitrate)}return s>0?s:NaN},E.getBufferLength=function(o){var s=this.hls.media,l=o===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!s)return NaN;var S=D.BufferHelper.bufferInfo(l,s.currentTime,this.config.maxBufferHole);return S.len*1e3},E.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,l=o||this.config.loader;return function(){function S(f){this.loader=void 0,this.loader=new l(f)}var p=S.prototype;return p.destroy=function(){this.loader.destroy()},p.abort=function(){this.loader.abort()},p.load=function(C,v,d){s(C),this.loader.load(C,v,d)},P(S,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),S}()},E.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,l=o||this.config.loader;return function(){function S(f){this.loader=void 0,this.loader=new l(f)}var p=S.prototype;return p.destroy=function(){this.loader.destroy()},p.abort=function(){this.loader.abort()},p.load=function(C,v,d){s(C),this.loader.load(C,v,d)},P(S,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),S}()},w.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.substr(s.lastIndexOf("/")+1)},w.serialize=function(o){for(var s=[],l=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},S=function(G){return Math.round(G)},p=function(G){return S(G/100)*100},f=function(G){return encodeURIComponent(G)},C={br:S,d:S,bl:p,dl:p,mtp:p,nor:f,rtp:p,tb:S},v=Object.keys(o||{}).sort(),d=O(v),c;!(c=d()).done;){var h=c.value,a=o[h];if(!l(a))continue;if(h==="v"&&a===1)continue;if(h=="pr"&&a===1)continue;var y=C[h];y&&(a=y(a));var m=typeof a,x=void 0;h==="ot"||h==="sf"||h==="st"?x=h+"="+a:m==="boolean"?x=h:m==="number"?x=h+"="+a:x=h+"="+JSON.stringify(a),s.push(x)}return s.join(",")},w.toHeaders=function(o){for(var s=Object.keys(o),l={},S=["Object","Request","Session","Status"],p=[{},{},{},{}],f={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},C=0,v=s;C<v.length;C++){var d=v[C],c=f[d]!=null?f[d]:1;p[c][d]=o[d]}for(var h=0;h<p.length;h++){var a=w.serialize(p[h]);a&&(l["CMCD-"+S[h]]=a)}return l},w.toQuery=function(o){return"CMCD="+encodeURIComponent(w.serialize(o))},w.appendQueryToUri=function(o,s){if(!s)return o;var l=o.includes("?")?"&":"?";return""+o+l+s},w}()},"./src/controller/eme-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts"),I=k("./src/errors.ts"),D=k("./src/utils/logger.ts"),j=k("./src/utils/mediakeys-helper.ts");function F(L,w){for(var E=0;E<w.length;E++){var u=w[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,E){return w&&F(L.prototype,w),E&&F(L,E),L}var O=3,g=function(w,E,u){var o={audioCapabilities:[],videoCapabilities:[]};return w.forEach(function(s){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),E.forEach(function(s){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[o]},T=function(w,E,u,o){switch(w){case j.KeySystems.WIDEVINE:return g(E,u,o);default:throw new Error("Unknown key-system: "+w)}},R=function(){function L(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var w=L.prototype;return w.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},w._registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w._unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w.getLicenseServerUrl=function(u){switch(u){case j.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},w._attemptKeySystemAccess=function(u,o,s){var l=this,S=T(u,o,s,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var p=this.requestMediaKeySystemAccess(u,S);this.mediaKeysPromise=p.then(function(f){return l._onMediaKeySystemAccessObtained(u,f)}),p.catch(function(f){D.logger.error('Failed to obtain key-system "'+u+'" access:',f)})},w._onMediaKeySystemAccessObtained=function(u,o){var s=this;D.logger.log('Access for key-system "'+u+'" obtained');var l={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:u};this._mediaKeysList.push(l);var S=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(p){return l.mediaKeys=p,D.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),p});return S.catch(function(p){D.logger.error("Failed to create media-keys:",p)}),S},w._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},w._onNewMediaKeySession=function(u){var o=this;D.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){o._onKeySessionMessage(u,s.message)},!1)},w._onKeySessionMessage=function(u,o){D.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(s){D.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s)})},w.onMediaEncrypted=function(u){var o=this;if(D.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(S){if(!o._media)return;o._attemptSetMediaKeys(S),o._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(s).catch(s)},w._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},w._generateRequestWithPreferredKeySession=function(u,o){var s=this,l=this._mediaKeysList[0];if(!l){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(l.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var S=l.mediaKeysSession;if(!S){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){D.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+u+'" init data type'),l.mediaKeysSessionInitialized=!0,S.generateRequest(u,o).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(p){D.logger.error("Error generating key-session request:",p),s.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},w._createLicenseXhr=function(u,o,s){var l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,l,u,o,s);var S=this._licenseXhrSetup;if(S)try{S.call(this.hls,l,u),S=void 0}catch(p){D.logger.error(p)}try{l.readyState||l.open("POST",u,!0),S&&S.call(this.hls,l,u)}catch(p){throw new Error("issue setting up KeySystem license XHR "+p)}return l},w._onLicenseRequestReadyStageChange=function(u,o,s,l){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var S=u.response,p=this._licenseResponseCallback;if(p)try{S=p.call(this.hls,u,o)}catch(C){D.logger.error(C)}l(S)}else{if(D.logger.error("License Request XHR failed ("+o+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>O){this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var f=O-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+f+" attempts left"),this._requestLicense(s,l)}break}},w._generateLicenseRequestChallenge=function(u,o){switch(u.mediaKeySystemDomain){case j.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},w._requestLicense=function(u,o){D.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var l=this.getLicenseServerUrl(s.mediaKeySystemDomain),S=this._createLicenseXhr(l,u,o);D.logger.log("Sending license request to URL: "+l);var p=this._generateLicenseRequestChallenge(s,u);S.send(p)}catch(f){D.logger.error("Failure requesting DRM license: "+f),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},w.onMediaAttached=function(u,o){if(!this._emeEnabled)return;var s=o.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},w.onMediaDetached=function(){var u=this._media,o=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},w.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var s=o.levels.map(function(S){return S.audioCodec}).filter(function(S){return!!S}),l=o.levels.map(function(S){return S.videoCodec}).filter(function(S){return!!S});this._attemptKeySystemAccess(j.KeySystems.WIDEVINE,s,l)},P(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();Y.default=R},"./src/controller/fps-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts"),I=k("./src/utils/logger.ts"),D=function(){function j(P){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=P,this.registerListeners()}var F=j.prototype;return F.setStreamController=function(O){this.streamController=O},F.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(O,g){var T=this.hls.config;if(T.capLevelOnFPSDrop){var R=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=R,R&&typeof R.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},F.checkFPS=function(O,g,T){var R=performance.now();if(g){if(this.lastTime){var L=R-this.lastTime,w=T-this.lastDroppedFrames,E=g-this.lastDecodedFrames,u=1e3*w/L,o=this.hls;if(o.trigger(V.Events.FPS_DROP,{currentDropped:w,currentDecoded:E,totalDroppedFrames:T}),u>0&&w>o.config.fpsDroppedMonitoringThreshold*E){var s=o.currentLevel;I.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=s)&&(s=s-1,o.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:o.currentLevel}),o.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=R,this.lastDroppedFrames=T,this.lastDecodedFrames=g}},F.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var g=O.getVideoPlaybackQuality();this.checkFPS(O,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},j}();Y.default=D},"./src/controller/fragment-finders.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"findFragmentByPDT",function(){return D}),k.d(Y,"findFragmentByPTS",function(){return j}),k.d(Y,"fragmentWithinToleranceTest",function(){return F}),k.d(Y,"pdtWithinToleranceTest",function(){return P}),k.d(Y,"findFragWithCC",function(){return O});var V=k("./src/polyfills/number.ts"),I=k("./src/utils/binary-search.ts");function D(g,T,R){if(T===null||!Array.isArray(g)||!g.length||!Object(V.isFiniteNumber)(T))return null;var L=g[0].programDateTime;if(T<(L||0))return null;var w=g[g.length-1].endProgramDateTime;if(T>=(w||0))return null;R=R||0;for(var E=0;E<g.length;++E){var u=g[E];if(P(T,R,u))return u}return null}function j(g,T,R,L){R===void 0&&(R=0),L===void 0&&(L=0);var w=null;if(g?w=T[g.sn-T[0].sn+1]||null:R===0&&T[0].start===0&&(w=T[0]),w&&F(R,L,w)===0)return w;var E=I.default.search(T,F.bind(null,R,L));return E||w}function F(g,T,R){g===void 0&&(g=0),T===void 0&&(T=0);var L=Math.min(T,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-L<=g?1:R.start-L>g&&R.start?-1:0}function P(g,T,R){var L=Math.min(T,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,w=R.endProgramDateTime||0;return w-L>g}function O(g,T){return I.default.search(g,function(R){return R.cc<T?1:R.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"FragmentState",function(){return D}),k.d(Y,"FragmentTracker",function(){return j});var V=k("./src/events.ts"),I=k("./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 j=function(){function O(T){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=T,this._registerListeners()}var g=O.prototype;return g._registerListeners=function(){var R=this.hls;R.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var R=this.hls;R.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(R,L){if(L===I.PlaylistLevelType.MAIN){var w=this.activeFragment,E=this.activeParts;if(!w)return null;if(E)for(var u=E.length;u--;){var o=E[u],s=o?o.end:w.appendedPTS;if(o.start<=R&&s!==void 0&&R<=s)return u>9&&(this.activeParts=E.slice(u-9)),o}else if(w.start<=R&&w.appendedPTS!==void 0&&R<=w.appendedPTS)return w}return this.getBufferedFrag(R,L)},g.getBufferedFrag=function(R,L){for(var w=this.fragments,E=Object.keys(w),u=E.length;u--;){var o=w[E[u]];if((o==null?void 0:o.body.type)===L&&o.buffered){var s=o.body;if(s.start<=R&&R<=s.end)return s}}return null},g.detectEvictedFragments=function(R,L,w){var E=this;Object.keys(this.fragments).forEach(function(u){var o=E.fragments[u];if(!o)return;if(!o.buffered){o.body.type===w&&E.removeFragment(o.body);return}var s=o.range[R];if(!s)return;s.time.some(function(l){var S=!E.isTimeBuffered(l.startPTS,l.endPTS,L);return S&&E.removeFragment(o.body),S})})},g.detectPartialFragments=function(R){var L=this,w=this.timeRanges,E=R.frag,u=R.part;if(!w||E.sn==="initSegment")return;var o=P(E),s=this.fragments[o];if(!s)return;Object.keys(w).forEach(function(l){var S=E.elementaryStreams[l];if(!S)return;var p=w[l],f=u!==null||S.partial===!0;s.range[l]=L.getBufferedTimes(E,u,f,p)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},g.fragBuffered=function(R){var L=P(R),w=this.fragments[L];w&&(w.backtrack=w.loaded=null,w.buffered=!0)},g.getBufferedTimes=function(R,L,w,E){for(var u={time:[],partial:w},o=L?L.start:R.start,s=L?L.end:R.end,l=R.minEndPTS||s,S=R.maxStartPTS||o,p=0;p<E.length;p++){var f=E.start(p)-this.bufferPadding,C=E.end(p)+this.bufferPadding;if(S>=f&&l<=C){u.time.push({startPTS:Math.max(o,E.start(p)),endPTS:Math.min(s,E.end(p))});break}else if(o<C&&s>f)u.partial=!0,u.time.push({startPTS:Math.max(o,E.start(p)),endPTS:Math.min(s,E.end(p))});else if(s<=f)break}return u},g.getPartialFragment=function(R){var L=null,w,E,u,o=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(S){var p=l[S];if(!p)return;F(p)&&(E=p.body.start-s,u=p.body.end+s,R>=E&&R<=u&&(w=Math.min(R-E,u-R),o<=w&&(L=p.body,o=w)))}),L},g.getState=function(R){var L=P(R),w=this.fragments[L];return w?w.buffered?F(w)?D.PARTIAL:D.OK:w.backtrack?D.BACKTRACKED:D.APPENDING:D.NOT_LOADED},g.backtrack=function(R,L){var w=P(R),E=this.fragments[w];if(!E||E.backtrack)return null;var u=E.backtrack=L||E.loaded;return E.loaded=null,u},g.getBacktrackData=function(R){var L=P(R),w=this.fragments[L];if(w){var E,u=w.backtrack;if(u!=null&&(E=u.payload)!==null&&E!==void 0&&E.byteLength)return u;this.removeFragment(R)}return null},g.isTimeBuffered=function(R,L,w){for(var E,u,o=0;o<w.length;o++){if(E=w.start(o)-this.bufferPadding,u=w.end(o)+this.bufferPadding,R>=E&&L<=u)return!0;if(L<=E)return!1}return!1},g.onFragLoaded=function(R,L){var w=L.frag,E=L.part;if(w.sn==="initSegment"||w.bitrateTest||E)return;var u=P(w);this.fragments[u]={body:w,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},g.onBufferAppended=function(R,L){var w=this,E=L.frag,u=L.part,o=L.timeRanges;if(E.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=E,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(l){var S=o[l];if(w.detectEvictedFragments(l,S),!u)for(var p=0;p<S.length;p++)E.appendedPTS=Math.max(S.end(p),E.appendedPTS||0)})},g.onFragBuffered=function(R,L){this.detectPartialFragments(L)},g.hasFragment=function(R){var L=P(R);return!!this.fragments[L]},g.removeFragmentsInRange=function(R,L,w){var E=this;Object.keys(this.fragments).forEach(function(u){var o=E.fragments[u];if(!o)return;if(o.buffered){var s=o.body;s.type===w&&s.start<L&&s.end>R&&E.removeFragment(s)}})},g.removeFragment=function(R){var L=P(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[L]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function F(O){var g,T;return O.buffered&&(((g=O.range.video)===null||g===void 0?void 0:g.partial)||((T=O.range.audio)===null||T===void 0?void 0:T.partial))}function P(O){return O.type+"_"+O.level+"_"+O.urlId+"_"+O.sn}},"./src/controller/gap-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"STALL_MINIMUM_DURATION_MS",function(){return F}),k.d(Y,"MAX_START_GAP_JUMP",function(){return P}),k.d(Y,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),k.d(Y,"SKIP_BUFFER_RANGE_START",function(){return g}),k.d(Y,"default",function(){return T});var V=k("./src/utils/buffer-helper.ts"),I=k("./src/errors.ts"),D=k("./src/events.ts"),j=k("./src/utils/logger.ts"),F=250,P=2,O=.1,g=.05,T=function(){function R(w,E,u,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=w,this.media=E,this.fragmentTracker=u,this.hls=o}var L=R.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(E){var u=this.config,o=this.media,s=this.stalled,l=o.currentTime,S=o.seeking,p=this.seeking&&!S,f=!this.seeking&&S;if(this.seeking=S,l!==E){if(this.moved=!0,s!==null){if(this.stallReported){var C=self.performance.now()-s;j.logger.warn("playback not stuck anymore @"+l+", after "+Math.round(C)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((f||p)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!V.BufferHelper.getBuffered(o).length)return;var v=V.BufferHelper.bufferInfo(o,l,0),d=v.len>0,c=v.nextStart||0;if(!d&&!c)return;if(S){var h=v.len>P,a=!c||c-l>P&&!this.fragmentTracker.getPartialFragment(l);if(h||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var y,m=Math.max(c,v.start||0)-l,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=x==null||((y=x.details)===null||y===void 0)?void 0:y.live,G=M?x.details.targetduration*2:P;if(m>0&&m<=G){this._trySkipBufferHole(null);return}}var $=self.performance.now();if(s===null){this.stalled=$;return}var re=$-s;!S&&re>=F&&this._reportStall(v.len);var z=V.BufferHelper.bufferInfo(o,l,u.maxBufferHole);this._tryFixBufferStall(z,re)},L._tryFixBufferStall=function(E,u){var o=this.config,s=this.fragmentTracker,l=this.media,S=l.currentTime,p=s.getPartialFragment(S);if(p){var f=this._trySkipBufferHole(p);if(f)return}E.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(j.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(E){var u=this.hls,o=this.media,s=this.stallReported;s||(this.stallReported=!0,j.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+E+")"),u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E}))},L._trySkipBufferHole=function(E){for(var u=this.config,o=this.hls,s=this.media,l=s.currentTime,S=0,p=V.BufferHelper.getBuffered(s),f=0;f<p.length;f++){var C=p.start(f);if(l+u.maxBufferHole>=S&&l<C){var v=Math.max(C+g,s.currentTime+O);return j.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+v),this.moved=!0,this.stalled=null,s.currentTime=v,E&&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 "+l+" to "+v,frag:E}),v}S=p.end(f)}return 0},L._tryNudgeBuffer=function(){var E=this.config,u=this.hls,o=this.media,s=o.currentTime,l=(this.nudgeRetry||0)+1;if(this.nudgeRetry=l,l<E.nudgeMaxRetry){var S=s+l*E.nudgeOffset;j.logger.warn("Nudging 'currentTime' from "+s+" to "+S),o.currentTime=S,u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else j.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+E.nudgeMaxRetry+" nudges"),u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts"),I=k("./src/utils/texttrack-utils.ts"),D=k("./src/demux/id3.ts"),j=.25,F=function(){function P(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var O=P.prototype;return O.destroy=function(){this._unregisterListeners()},O._registerListeners=function(){var T=this.hls;T.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O._unregisterListeners=function(){var T=this.hls;T.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O.onMediaAttached=function(T,R){this.media=R.media},O.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},O.getID3Track=function(T){if(!this.media)return;for(var R=0;R<T.length;R++){var L=T[R];if(L.kind==="metadata"&&L.label==="id3")return Object(I.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},O.onFragParsingMetadata=function(T,R){if(!this.media)return;var L=R.frag,w=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var E=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<w.length;u++){var o=D.getID3Frames(w[u].data);if(o){var s=w[u].pts,l=u<w.length-1?w[u+1].pts:L.end,S=l-s;S<=0&&(l=s+j);for(var p=0;p<o.length;p++){var f=o[p];if(!D.isTimeStampFrame(f)){var C=new E(s,l,"");C.value=f,this.id3Track.addCue(C)}}}}},O.onBufferFlushing=function(T,R){var L=R.startOffset,w=R.endOffset,E=R.type;if(!E||E==="audio"){var u=this.id3Track;u&&Object(I.removeCuesInRange)(u,L,w)}},P}();Y.default=F},"./src/controller/latency-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return P});var V=k("./src/errors.ts"),I=k("./src/events.ts"),D=k("./src/utils/logger.ts");function j(O,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function F(O,g,T){return g&&j(O.prototype,g),T&&j(O,T),O}var P=function(){function O(T){var R=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return R.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var g=O.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(I.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(I.Events.ERROR,this.onError)},g.onMediaAttached=function(R,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(R,L){var w=L.details;this.levelDetails=w,w.advanced&&this.timeupdate(),!w.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(R,L){if(L.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},g.timeupdate=function(){var R=this.media,L=this.levelDetails;if(!R||!L)return;this.currentTime=R.currentTime;var w=this.computeLatency();if(w===null)return;this._latency=w;var E=this.config,u=E.lowLatencyMode,o=E.maxLiveSyncPlaybackRate;if(!u||o===1)return;var s=this.targetLatency;if(s===null)return;var l=w-s,S=Math.min(this.maxLatency,s+L.targetduration),p=l<S;if(L.live&&p&&l>.05&&this.forwardBufferLength>1){var f=Math.min(2,Math.max(1,o)),C=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;R.playbackRate=Math.min(f,Math.max(1,C))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},g.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},g.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},F(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,L=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:L?R.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var L=R.holdBack,w=R.partHoldBack,E=R.targetduration,u=this.config,o=u.liveSyncDuration,s=u.liveSyncDurationCount,l=u.lowLatencyMode,S=this.hls.userConfig,p=l&&w||L;(S.liveSyncDuration||S.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:s*E);var f=E,C=1;return p+Math.min(this.stallCount*C,f)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),L=this.targetLatency,w=this.levelDetails;if(R===null||L===null||w===null)return null;var E=w.edge,u=R-L-this.edgeStalled,o=E-w.totalduration,s=E-(this.config.lowLatencyMode&&w.partTarget||w.targetduration);return Math.min(Math.max(o,u),s)}},{key:"drift",get:function(){var R=this.levelDetails;return R===null?1:R.drift}},{key:"edgeStalled",get:function(){var R=this.levelDetails;if(R===null)return 0;var L=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-L,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,L=this.levelDetails;if(!R||!L)return 0;var w=R.buffered.length;return w?R.buffered.end(w-1):L.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return u});var V=k("./src/types/level.ts"),I=k("./src/events.ts"),D=k("./src/errors.ts"),j=k("./src/utils/codecs.ts"),F=k("./src/controller/level-helper.ts"),P=k("./src/controller/base-playlist-controller.ts"),O=k("./src/types/loader.ts");function g(){return g=Object.assign||function(o){for(var s=1;s<arguments.length;s++){var l=arguments[s];for(var S in l)Object.prototype.hasOwnProperty.call(l,S)&&(o[S]=l[S])}return o},g.apply(this,arguments)}function T(o,s){for(var l=0;l<s.length;l++){var S=s[l];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(o,S.key,S)}}function R(o,s,l){return s&&T(o.prototype,s),l&&T(o,l),o}function L(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,w(o,s)}function w(o,s){return w=Object.setPrototypeOf||function(S,p){return S.__proto__=p,S},w(o,s)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){L(s,o);function s(S){var p;return p=o.call(this,S,"[level-controller]")||this,p._levels=[],p._firstLevel=-1,p._startLevel=void 0,p.currentLevelIndex=-1,p.manualLevelIndex=-1,p.onParsedComplete=void 0,p._registerListeners(),p}var l=s.prototype;return l._registerListeners=function(){var p=this.hls;p.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),p.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),p.on(I.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var p=this.hls;p.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),p.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),p.off(I.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},l.startLoad=function(){var p=this._levels;p.forEach(function(f){f.loadError=0}),o.prototype.startLoad.call(this)},l.onManifestLoaded=function(p,f){var C=[],v=[],d=[],c,h={},a,y=!1,m=!1,x=!1;if(f.levels.forEach(function(re){var z=re.attrs;y=y||!!(re.width&&re.height),m=m||!!re.videoCodec,x=x||!!re.audioCodec,E&&re.audioCodec&&re.audioCodec.indexOf("mp4a.40.34")!==-1&&(re.audioCodec=void 0);var U=re.bitrate+"-"+re.attrs.RESOLUTION+"-"+re.attrs.CODECS;a=h[U],a?a.url.push(re.url):(a=new V.Level(re),h[U]=a,C.push(a)),z&&(z.AUDIO&&Object(F.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(F.addGroupId)(a,"text",z.SUBTITLES))}),(y||m)&&x&&(C=C.filter(function(re){var z=re.videoCodec,U=re.width,ne=re.height;return!!z||!!(U&&ne)})),C=C.filter(function(re){var z=re.audioCodec,U=re.videoCodec;return(!z||Object(j.isCodecSupportedInMp4)(z,"audio"))&&(!U||Object(j.isCodecSupportedInMp4)(U,"video"))}),f.audioTracks&&(v=f.audioTracks.filter(function(re){return!re.audioCodec||Object(j.isCodecSupportedInMp4)(re.audioCodec,"audio")}),Object(F.assignTrackIdsByGroup)(v)),f.subtitles&&(d=f.subtitles,Object(F.assignTrackIdsByGroup)(d)),C.length>0){c=C[0].bitrate,C.sort(function(re,z){return re.bitrate-z.bitrate}),this._levels=C;for(var M=0;M<C.length;M++)if(C[M].bitrate===c){this._firstLevel=M,this.log("manifest loaded, "+C.length+" level(s) found, first bitrate: "+c);break}var G=x&&!m,$={levels:C,audioTracks:v,subtitleTracks:d,firstLevel:this._firstLevel,stats:f.stats,audio:x,video:m,altAudio:!G&&v.some(function(re){return!!re.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,$),(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:f.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(p,f){if(o.prototype.onError.call(this,p,f),f.fatal)return;var C=f.context,v=this._levels[this.currentLevelIndex];if(C&&(C.type===O.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&C.groupId===v.audioGroupIds[v.urlId]||C.type===O.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&C.groupId===v.textGroupIds[v.urlId])){this.redundantFailover(this.currentLevelIndex);return}var d=!1,c=!0,h;switch(f.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(f.frag){var a=this._levels[f.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(h=f.frag.level)):h=f.frag.level}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:C&&(C.deliveryDirectives&&(c=!1),h=C.level),d=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:h=f.level,d=!0;break}h!==void 0&&this.recoverLevel(f,h,d,c)},l.recoverLevel=function(p,f,C,v){var d=p.details,c=this._levels[f];if(c.loadError++,C){var h=this.retryLoadingOrFail(p);if(h)p.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(v){var a=c.url.length;if(a>1&&c.loadError<a)p.levelRetry=!0,this.redundantFailover(f);else if(this.manualLevelIndex===-1){var y=f===0?this._levels.length-1:f-1;this.currentLevelIndex!==y&&this._levels[y].loadError===0&&(this.warn(d+": switch to "+y),p.levelRetry=!0,this.hls.nextAutoLevel=y)}}},l.redundantFailover=function(p){var f=this._levels[p],C=f.url.length;if(C>1){var v=(f.urlId+1)%C;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(d){d.urlId=v}),this.level=p}},l.onFragLoaded=function(p,f){var C=f.frag;if(C!==void 0&&C.type===O.PlaylistLevelType.MAIN){var v=this._levels[C.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},l.onLevelLoaded=function(p,f){var C,v=f.level,d=f.details,c=this._levels[v];if(!c){var h;this.warn("Invalid level index "+v),(h=f.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(d.deltaUpdateFailed=!0);return}v===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(v,f,c.details)):(C=f.deliveryDirectives)!==null&&C!==void 0&&C.skip&&(d.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(p,f){var C=this.hls.levels[this.currentLevelIndex];if(!C)return;if(C.audioGroupIds){for(var v=-1,d=this.hls.audioTracks[f.id].groupId,c=0;c<C.audioGroupIds.length;c++)if(C.audioGroupIds[c]===d){v=c;break}v!==C.urlId&&(C.urlId=v,this.startLoad())}},l.loadPlaylist=function(p){var f=this.currentLevelIndex,C=this._levels[f];if(this.canLoad&&C&&C.url.length>0){var v=C.urlId,d=C.url[v];if(p)try{d=p.addDirectives(d)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+f+(p?" at sn "+p.msn+" part "+p.part:"")+" with URL-id "+v+" "+d),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:d,level:f,id:v,deliveryDirectives:p||null})}},l.removeLevel=function(p,f){var C=function(c,h){return h!==f},v=this._levels.filter(function(d,c){return c!==p?!0:d.url.length>1&&f!==void 0?(d.url=d.url.filter(C),d.audioGroupIds&&(d.audioGroupIds=d.audioGroupIds.filter(C)),d.textGroupIds&&(d.textGroupIds=d.textGroupIds.filter(C)),d.urlId=0,!0):!1}).map(function(d,c){var h=d.details;return h!=null&&h.fragments&&h.fragments.forEach(function(a){a.level=c}),d});this._levels=v,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:v})},R(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(p){var f,C=this._levels;if(C.length===0)return;if(this.currentLevelIndex===p&&(f=C[p])!==null&&f!==void 0&&f.details)return;if(p<0||p>=C.length){var v=p<0;if(this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:p,fatal:v,reason:"invalid level idx"}),v)return;p=Math.min(p,C.length-1)}this.clearTimer();var d=this.currentLevelIndex,c=C[d],h=C[p];this.log("switching to level "+p+" from "+d),this.currentLevelIndex=p;var a=g({},h,{level:p,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete a._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,a);var y=h.details;if(!y||y.live){var m=this.switchParams(h.uri,c==null?void 0:c.details);this.loadPlaylist(m)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(p){this.manualLevelIndex=p,this._startLevel===void 0&&(this._startLevel=p),p!==-1&&(this.level=p)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(p){this._firstLevel=p}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var p=this.hls.config.startLevel;return p!==void 0?p:this._firstLevel}else return this._startLevel},set:function(p){this._startLevel=p}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(p){this.level=p,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=p)}}]),s}(P.default)},"./src/controller/level-helper.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"addGroupId",function(){return D}),k.d(Y,"assignTrackIdsByGroup",function(){return j}),k.d(Y,"updatePTS",function(){return F}),k.d(Y,"updateFragPTSDTS",function(){return O}),k.d(Y,"mergeDetails",function(){return g}),k.d(Y,"mapPartIntersection",function(){return T}),k.d(Y,"mapFragmentIntersection",function(){return R}),k.d(Y,"adjustSliding",function(){return L}),k.d(Y,"addSliding",function(){return w}),k.d(Y,"computeReloadInterval",function(){return E}),k.d(Y,"getFragmentWithSN",function(){return u}),k.d(Y,"getPartWith",function(){return o});var V=k("./src/polyfills/number.ts"),I=k("./src/utils/logger.ts");function D(s,l,S){switch(l){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(S);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(S);break}}function j(s){var l={};s.forEach(function(S){var p=S.groupId||"";S.id=l[p]=l[p]||0,l[p]++})}function F(s,l,S){var p=s[l],f=s[S];P(p,f)}function P(s,l){var S=l.startPTS;if(Object(V.isFiniteNumber)(S)){var p=0,f;l.sn>s.sn?(p=S-s.start,f=s):(p=s.start-S,f=l),f.duration!==p&&(f.duration=p)}else if(l.sn>s.sn){var C=s.cc===l.cc;C&&s.minEndPTS?l.start=s.start+(s.minEndPTS-s.start):l.start=s.start+s.duration}else l.start=Math.max(s.start-l.duration,0)}function O(s,l,S,p,f,C){var v=p-S;v<=0&&(I.logger.warn("Fragment should have a positive duration",l),p=S+l.duration,C=f+l.duration);var d=S,c=p,h=l.startPTS,a=l.endPTS;if(Object(V.isFiniteNumber)(h)){var y=Math.abs(h-S);Object(V.isFiniteNumber)(l.deltaPTS)?l.deltaPTS=Math.max(y,l.deltaPTS):l.deltaPTS=y,d=Math.max(S,h),S=Math.min(S,h),f=Math.min(f,l.startDTS),c=Math.min(p,a),p=Math.max(p,a),C=Math.max(C,l.endDTS)}l.duration=p-S;var m=S-l.start;l.appendedPTS=p,l.start=l.startPTS=S,l.maxStartPTS=d,l.startDTS=f,l.endPTS=p,l.minEndPTS=c,l.endDTS=C;var x=l.sn;if(!s||x<s.startSN||x>s.endSN)return 0;var M,G=x-s.startSN,$=s.fragments;for($[G]=l,M=G;M>0;M--)P($[M],$[M-1]);for(M=G;M<$.length-1;M++)P($[M],$[M+1]);return s.fragmentHint&&P($[$.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,m}function g(s,l){for(var S=null,p=s.fragments,f=p.length-1;f>=0;f--){var C=p[f].initSegment;if(C){S=C;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var v=0,d;if(R(s,l,function(M,G){M.relurl&&(v=M.cc-G.cc),Object(V.isFiniteNumber)(M.startPTS)&&Object(V.isFiniteNumber)(M.endPTS)&&(G.start=G.startPTS=M.startPTS,G.startDTS=M.startDTS,G.appendedPTS=M.appendedPTS,G.maxStartPTS=M.maxStartPTS,G.endPTS=M.endPTS,G.endDTS=M.endDTS,G.minEndPTS=M.minEndPTS,G.duration=M.endPTS-M.startPTS,G.duration&&(d=G),l.PTSKnown=l.alignedSliding=!0),G.elementaryStreams=M.elementaryStreams,G.loader=M.loader,G.stats=M.stats,G.urlId=M.urlId,M.initSegment&&(G.initSegment=M.initSegment,S=M.initSegment)}),S){var c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;c.forEach(function(M){var G;(!M.initSegment||M.initSegment.relurl===((G=S)===null||G===void 0?void 0:G.relurl))&&(M.initSegment=S)})}if(l.skippedSegments&&(l.deltaUpdateFailed=l.fragments.some(function(M){return!M}),l.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=l.skippedSegments;h--;)l.fragments.shift();l.startSN=l.fragments[0].sn,l.startCC=l.fragments[0].cc}var a=l.fragments;if(v){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var y=0;y<a.length;y++)a[y].cc+=v}l.skippedSegments&&(l.startCC=l.fragments[0].cc),T(s.partList,l.partList,function(M,G){G.elementaryStreams=M.elementaryStreams,G.stats=M.stats}),d?O(l,d,d.startPTS,d.endPTS,d.startDTS,d.endDTS):L(s,l),a.length&&(l.totalduration=l.edge-a[0].start),l.driftStartTime=s.driftStartTime,l.driftStart=s.driftStart;var m=l.advancedDateTime;if(l.advanced&&m){var x=l.edge;l.driftStart||(l.driftStartTime=m,l.driftStart=x),l.driftEndTime=m,l.driftEnd=x}else l.driftEndTime=s.driftEndTime,l.driftEnd=s.driftEnd,l.advancedDateTime=s.advancedDateTime}function T(s,l,S){if(s&&l)for(var p=0,f=0,C=s.length;f<=C;f++){var v=s[f],d=l[f+p];v&&d&&v.index===d.index&&v.fragment.sn===d.fragment.sn?S(v,d):p--}}function R(s,l,S){for(var p=l.skippedSegments,f=Math.max(s.startSN,l.startSN)-l.startSN,C=(s.fragmentHint?1:0)+(p?l.endSN:Math.min(s.endSN,l.endSN))-l.startSN,v=l.startSN-s.startSN,d=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,c=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,h=f;h<=C;h++){var a=c[v+h],y=d[h];p&&!y&&h<p&&(y=l.fragments[h]=a),a&&y&&S(a,y)}}function L(s,l){var S=l.startSN+l.skippedSegments-s.startSN,p=s.fragments;if(S<0||S>=p.length)return;w(l,p[S].start)}function w(s,l){if(l){for(var S=s.fragments,p=s.skippedSegments;p<S.length;p++)S[p].start+=l;s.fragmentHint&&(s.fragmentHint.start+=l)}}function E(s,l){var S=1e3*s.levelTargetDuration,p=S/2,f=s.age,C=f>0&&f<S*3,v=l.loading.end-l.loading.start,d,c=s.availabilityDelay;if(s.updated===!1)if(C){var h=333*s.misses;d=Math.max(Math.min(p,v*2),h),s.availabilityDelay=(s.availabilityDelay||0)+d}else d=p;else C?(c=Math.min(c||S/2,f),s.availabilityDelay=c,d=c+S-f):d=S-v;return Math.round(d)}function u(s,l,S){if(!s||!s.details)return null;var p=s.details,f=p.fragments[l-p.startSN];return f||(f=p.fragmentHint,f&&f.sn===l?f:l<p.startSN&&S&&S.sn===l?S:null)}function o(s,l,S){if(!s||!s.details)return null;var p=s.details.partList;if(p)for(var f=p.length;f--;){var C=p[f];if(C.index===S&&C.fragment.sn===l)return C}return null}},"./src/controller/stream-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return p});var V=k("./src/polyfills/number.ts"),I=k("./src/controller/base-stream-controller.ts"),D=k("./src/is-supported.ts"),j=k("./src/events.ts"),F=k("./src/utils/buffer-helper.ts"),P=k("./src/controller/fragment-tracker.ts"),O=k("./src/types/loader.ts"),g=k("./src/loader/fragment.ts"),T=k("./src/demux/transmuxer-interface.ts"),R=k("./src/types/transmuxer.ts"),L=k("./src/controller/gap-controller.ts"),w=k("./src/errors.ts"),E=k("./src/utils/logger.ts");function u(f,C){for(var v=0;v<C.length;v++){var d=C[v];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,d.key,d)}}function o(f,C,v){return C&&u(f.prototype,C),v&&u(f,v),f}function s(f,C){f.prototype=Object.create(C.prototype),f.prototype.constructor=f,l(f,C)}function l(f,C){return l=Object.setPrototypeOf||function(d,c){return d.__proto__=c,d},l(f,C)}var S=100,p=function(f){s(C,f);function C(d,c){var h;return h=f.call(this,d,c,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.stalled=!1,h.couldBacktrack=!1,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var v=C.prototype;return v._registerListeners=function(){var c=this.hls;c.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(j.Events.ERROR,this.onError,this),c.on(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(j.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var c=this.hls;c.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(j.Events.ERROR,this.onError,this),c.off(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(j.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},v.startLoad=function(c){if(this.levels){var h=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(S),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var y=a.startLevel;y===-1&&(a.config.testBandwidth?(y=0,this.bitrateTest=!0):y=a.nextAutoLevel),this.level=a.nextLoadLevel=y,this.loadedmetadata=!1}h>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),c=h),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,f.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var c,h=this.levels,a=this.level,y=h==null||((c=h[a])===null||c===void 0)?void 0:c.details;if(y&&(!y.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(y))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var m,x=self.performance.now(),M=this.retryDate;(!M||x>=M||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},v.onTickEnd=function(){f.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var c,h,a=this.hls,y=this.levelLastLoaded,m=this.levels,x=this.media,M=a.config,G=a.nextLoadLevel;if(y===null||!x&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!m||!m[G])return;var $=m[G];this.level=a.nextLoadLevel=G;var re=$.details;if(!re||this.state===I.State.WAITING_LEVEL||re.live&&this.levelLastLoaded!==G){this.state=I.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,O.PlaylistLevelType.MAIN);if(z===null)return;var U=z.len,ne=this.getMaxBufferLength($.maxBitrate);if(U>=ne)return;if(this._streamEnded(z,re)){var fe={};this.altAudio&&(fe.type="video"),this.hls.trigger(j.Events.BUFFER_EOS,fe),this.state=I.State.ENDED;return}var ge=z.end,be=this.getNextFragment(ge,re);if(this.couldBacktrack&&!this.fragPrevious&&be&&be.sn!=="initSegment"){var Me=be.sn-re.startSN;Me>1&&(be=re.fragments[Me-1],this.fragmentTracker.removeFragment(be))}if(be&&this.fragmentTracker.getState(be)===P.FragmentState.OK&&this.nextLoadPosition>ge){var Te=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,Te,O.PlaylistLevelType.MAIN),be=this.getNextFragment(this.nextLoadPosition,re)}if(!be)return;be.initSegment&&!be.initSegment.data&&!this.bitrateTest&&(be=be.initSegment),((c=be.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((h=be.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(be,re):this.loadFragment(be,re,ge)},v.loadFragment=function(c,h,a){var y,m=this.fragmentTracker.getState(c);if(this.fragCurrent=c,m===P.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(c);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else m=P.FragmentState.NOT_LOADED}m===P.FragmentState.NOT_LOADED||m===P.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,f.prototype.loadFragment.call(this,c,h,a)):m===P.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((y=this.media)===null||y===void 0?void 0:y.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(c){var h=this.fragmentTracker.getAppendedFrag(c,O.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},v.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,O.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var c=this.levels,h=this.media;if(h!=null&&h.readyState){var a,y=this.getAppendedFrag(h.currentTime);if(y&&y.start>1&&this.flushMainBuffer(0,y.start-1),!h.paused&&c){var m=this.hls.nextLoadLevel,x=c[m],M=this.fragLastKbps;M&&this.fragCurrent?a=this.fragCurrent.duration*x.maxBitrate/(1e3*M)+1:a=0}else a=0;var G=this.getBufferedFrag(h.currentTime+a);if(G){var $=this.followingBufferedFrag(G);if($){this.abortCurrentFrag();var re=$.maxStartPTS?$.maxStartPTS:$.start,z=$.duration,U=Math.max(G.end,re+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},v.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()},v.flushMainBuffer=function(c,h){f.prototype.flushMainBuffer.call(this,c,h,this.altAudio?"video":null)},v.onMediaAttached=function(c,h){f.prototype.onMediaAttached.call(this,c,h);var a=h.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,a,this.fragmentTracker,this.hls)},v.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),f.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var c=this.media,h=c?c.currentTime:null;Object(V.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(j.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(c,h){var a=!1,y=!1,m;h.levels.forEach(function(x){m=x.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(a=!0),m.indexOf("mp4a.40.5")!==-1&&(y=!0))}),this.audioCodecSwitch=a&&y&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},v.onLevelLoading=function(c,h){var a=this.levels;if(!a||this.state!==I.State.IDLE)return;var y=a[h.level];(!y.details||y.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(y.details))&&(this.state=I.State.WAITING_LEVEL)},v.onLevelLoaded=function(c,h){var a,y=this.levels,m=h.level,x=h.details,M=x.totalduration;if(!y){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+M);var G=this.fragCurrent;G&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==h.level&&G.loader&&(this.state=I.State.IDLE,G.loader.abort()));var $=y[m],re=0;if(x.live||(a=$.details)!==null&&a!==void 0&&a.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;re=this.alignPlaylists(x,$.details)}if($.details=x,this.levelLastLoaded=m,this.hls.trigger(j.Events.LEVEL_UPDATED,{details:x,level:m}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=I.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,re),this.tick()},v._handleFragmentLoadProgress=function(c){var h,a=c.frag,y=c.part,m=c.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var M=x[a.level],G=M.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var $=M.videoCodec,re=G.PTSKnown||!G.live,z=(h=a.initSegment)===null||h===void 0?void 0:h.data,U=this._getAudioCodec(M),ne=this.transmuxer=this.transmuxer||new T.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),fe=y?y.index:-1,ge=fe!==-1,be=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,m.byteLength,fe,ge),Me=this.initPTS[a.cc];ne.push(m,z,U,$,a,y,G.totalduration,re,be,Me)},v.onAudioTrackSwitching=function(c,h){var a=this.altAudio,y=!!h.url,m=h.id;if(!y){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;a&&M.trigger(j.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(j.Events.AUDIO_TRACK_SWITCHED,{id:m})}},v.onAudioTrackSwitched=function(c,h){var a=h.id,y=!!this.hls.audioTracks[a].url;if(y){var m=this.videoBuffer;m&&this.mediaBuffer!==m&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=m)}this.altAudio=y,this.tick()},v.onBufferCreated=function(c,h){var a=h.tracks,y,m,x=!1;for(var M in a){var G=a[M];if(G.id==="main"){if(m=M,y=G,M==="video"){var $=a[M];$&&(this.videoBuffer=$.buffer)}}else x=!0}x&&y?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=y.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(c,h){var a=h.frag,y=h.part;if(a&&a.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(y?" p: "+y.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 m=y?y.stats:a.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,y)},v.onError=function(c,h){switch(h.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.MAIN,h);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=I.State.ERROR):!h.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var a=!0,y=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);y&&y.len>.5&&(a=!this.reduceMaxBufferLength(y.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},v.checkBuffer=function(){var c=this.media,h=this.gapController;if(!c||!h||!c.readyState)return;var a=F.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):h.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},v.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(c,h){var a=h.type;if(a!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var y=(a===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(y,a,O.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(c,h){this.levels=h.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var c=this.media,h=c.currentTime,a=this.startPosition;if(a>=0&&h<a){if(c.seeking){E.logger.log("could not seek to "+a+", already seeking at "+h);return}var y=F.BufferHelper.getBuffered(c),m=y.length?y.start(0):0,x=m-a;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(E.logger.log("adjusting start position by "+x+" to match buffer start"),a+=x,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+h),c.currentTime=a}},v._getAudioCodec=function(c){var h=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},v._loadBitrateTestFrag=function(c){var h=this;this._doFragLoad(c).then(function(a){var y=h.hls;if(!a||y.nextLoadLevel||h.fragContextChanged(c))return;h.fragLoadError=0,h.state=I.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var m=c.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),y.trigger(j.Events.FRAG_LOADED,a)})},v._handleTransmuxComplete=function(c){var h,a="main",y=this.hls,m=c.remuxResult,x=c.chunkMeta,M=this.getCurrentContext(x);if(!M){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var G=M.frag,$=M.part,re=M.level,z=m.video,U=m.text,ne=m.id3,fe=m.initSegment,ge=this.altAudio?void 0:m.audio;if(this.fragContextChanged(G))return;if(this.state=I.State.PARSING,fe){fe.tracks&&(this._bufferInitSegment(re,fe.tracks,G,x),y.trigger(j.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:fe.tracks}));var be=fe.initPTS,Me=fe.timescale;Object(V.isFiniteNumber)(be)&&(this.initPTS[G.cc]=be,y.trigger(j.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:be,timescale:Me}))}if(z&&m.independent!==!1){if(re.details){var Te=z.startPTS,De=z.endPTS,Ce=z.startDTS,we=z.endDTS;if($)$.elementaryStreams[z.type]={startPTS:Te,endPTS:De,startDTS:Ce,endDTS:we};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var ve=this.getLoadPosition()+this.config.maxBufferHole;if(ve<Te){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,De,G.start,we,!0)}G.setElementaryStreamInfo(z.type,Te,De,Ce,we),this.bufferFragmentData(z,G,$,x)}}else if(m.independent===!1){this.backtrack(G);return}if(ge){var W=ge.startPTS,A=ge.endPTS,_=ge.startDTS,H=ge.endDTS;$&&($.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:A,startDTS:_,endDTS:H}),G.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,W,A,_,H),this.bufferFragmentData(ge,G,$,x)}if(ne!=null&&(h=ne.samples)!==null&&h!==void 0&&h.length){var q={frag:G,id:a,samples:ne.samples};y.trigger(j.Events.FRAG_PARSING_METADATA,q)}if(U){var B={frag:G,id:a,samples:U.samples};y.trigger(j.Events.FRAG_PARSING_USERDATA,B)}},v._bufferInitSegment=function(c,h,a,y){var m=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var x=h.audio,M=h.video,G=h.audiovideo;if(x){var $=c.audioCodec,re=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&($&&($.indexOf("mp4a.40.5")!==-1?$="mp4a.40.2":$="mp4a.40.5"),x.metadata.channelCount!==1&&re.indexOf("firefox")===-1&&($="mp4a.40.5")),re.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&($="mp4a.40.2",this.log("Android: force audio codec to "+$)),c.audioCodec&&c.audioCodec!==$&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+$+'"'),x.levelCodec=$,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+($||"")+"/"+(c.audioCodec||"")+"/"+x.codec+"]")}M&&(M.levelCodec=c.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+M.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(j.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(z){var U=h[z],ne=U.initSegment;ne!=null&&ne.byteLength&&m.hls.trigger(j.Events.BUFFER_APPENDING,{type:z,data:ne,frag:a,part:null,chunkMeta:y,parent:a.type})}),this.tick()},v.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var h=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,h?this.resetFragmentLoading(c):this.state=I.State.BACKTRACKING},v.checkFragmentChanged=function(){var c=this.media,h=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(F.BufferHelper.isBuffered(c,a)?h=this.getAppendedFrag(a):F.BufferHelper.isBuffered(c,a+.1)&&(h=this.getAppendedFrag(a+.1)),h){var y=this.fragPlaying,m=h.level;(!y||h.sn!==y.sn||y.level!==m||h.urlId!==y.urlId)&&(this.hls.trigger(j.Events.FRAG_CHANGED,{frag:h}),(!y||y.level!==m)&&this.hls.trigger(j.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=h)}}},o(C,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var h=this.getAppendedFrag(c.currentTime);if(h)return h.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var h=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(h)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),C}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"SubtitleStreamController",function(){return s});var V=k("./src/events.ts"),I=k("./src/utils/logger.ts"),D=k("./src/utils/buffer-helper.ts"),j=k("./src/controller/fragment-finders.ts"),F=k("./src/utils/discontinuities.ts"),P=k("./src/controller/level-helper.ts"),O=k("./src/controller/fragment-tracker.ts"),g=k("./src/controller/base-stream-controller.ts"),T=k("./src/types/loader.ts"),R=k("./src/types/level.ts");function L(l,S){for(var p=0;p<S.length;p++){var f=S[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(l,f.key,f)}}function w(l,S,p){return S&&L(l.prototype,S),p&&L(l,p),l}function E(l,S){l.prototype=Object.create(S.prototype),l.prototype.constructor=l,u(l,S)}function u(l,S){return u=Object.setPrototypeOf||function(f,C){return f.__proto__=C,f},u(l,S)}var o=500,s=function(l){E(S,l);function S(f,C){var v;return v=l.call(this,f,C,"[subtitle-stream-controller]")||this,v.levels=[],v.currentTrackId=-1,v.tracksBuffered=[],v.mainDetails=null,v._registerListeners(),v}var p=S.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var C=this.hls;C.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),C.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),C.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),C.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),C.on(V.Events.ERROR,this.onError,this),C.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),C.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),C.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),C.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),C.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},p._unregisterListeners=function(){var C=this.hls;C.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),C.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),C.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),C.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),C.off(V.Events.ERROR,this.onError,this),C.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),C.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),C.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),C.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),C.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},p.startLoad=function(){this.stopLoad(),this.state=g.State.IDLE,this.setInterval(o),this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},p.onLevelLoaded=function(C,v){this.mainDetails=v.details},p.onSubtitleFragProcessed=function(C,v){var d=v.frag,c=v.success;if(this.fragPrevious=d,this.state=g.State.IDLE,!c)return;var h=this.tracksBuffered[this.currentTrackId];if(!h)return;for(var a,y=d.start,m=0;m<h.length;m++)if(y>=h[m].start&&y<=h[m].end){a=h[m];break}var x=d.start+d.duration;a?a.end=x:(a={start:y,end:x},h.push(a)),this.fragmentTracker.fragBuffered(d)},p.onBufferFlushing=function(C,v){var d=v.startOffset,c=v.endOffset;if(d===0&&c!==Number.POSITIVE_INFINITY){var h=this.currentTrackId,a=this.levels;if(!a.length||!a[h]||!a[h].details)return;var y=a[h].details,m=y.targetduration,x=c-m;if(x<=0)return;v.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(M){for(var G=0;G<M.length;){if(M[G].end<=x){M.shift();continue}else if(M[G].start<x)M[G].start=x;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(d,x,T.PlaylistLevelType.SUBTITLE)}},p.onError=function(C,v){var d,c=v.frag;if(!c||c.type!==T.PlaylistLevelType.SUBTITLE)return;(d=this.fragCurrent)!==null&&d!==void 0&&d.loader&&this.fragCurrent.loader.abort(),this.state=g.State.IDLE},p.onSubtitleTracksUpdated=function(C,v){var d=this,c=v.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(h){return new R.Level(h)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(h){d.tracksBuffered[h.id]=[]}),this.mediaBuffer=null},p.onSubtitleTrackSwitch=function(C,v){if(this.currentTrackId=v.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var d=this.levels[this.currentTrackId];d!=null&&d.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,d&&this.setInterval(o)},p.onSubtitleTrackLoaded=function(C,v){var d,c=v.details,h=v.id,a=this.currentTrackId,y=this.levels;if(!y.length)return;var m=y[a];if(h>=y.length||h!==a||!m)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(d=m.details)!==null&&d!==void 0&&d.live){var x=this.mainDetails;if(c.deltaUpdateFailed||!x)return;var M=x.fragments[0];if(!m.details)c.hasProgramDateTime&&x.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(c,x):M&&Object(P.addSliding)(c,M.start);else{var G=this.alignPlaylists(c,m.details);G===0&&M&&Object(P.addSliding)(c,M.start)}}if(m.details=c,this.levelLastLoaded=h,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===g.State.IDLE){var $=Object(j.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);$||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}},p._handleFragmentLoadComplete=function(C){var v=C.frag,d=C.payload,c=v.decryptdata,h=this.hls;if(this.fragContextChanged(v))return;if(d&&d.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(d),c.key.buffer,c.iv.buffer).then(function(y){var m=performance.now();h.trigger(V.Events.FRAG_DECRYPTED,{frag:v,payload:y,stats:{tstart:a,tdecrypt:m}})})}},p.doTick=function(){if(!this.media){this.state=g.State.IDLE;return}if(this.state===g.State.IDLE){var C,v=this.currentTrackId,d=this.levels;if(!d.length||!d[v]||!d[v].details)return;var c=d[v].details,h=c.targetduration,a=this.config,y=this.media,m=D.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,y.currentTime-h,a.maxBufferHole),x=m.end,M=m.len,G=this.getMaxBufferLength()+h;if(M>G)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var $=c.fragments,re=$.length,z=c.edge,U,ne=this.fragPrevious;if(x<z){var fe=a.maxFragLookUpTolerance;ne&&c.hasProgramDateTime&&(U=Object(j.findFragmentByPDT)($,ne.endProgramDateTime,fe)),U||(U=Object(j.findFragmentByPTS)(ne,$,x,fe),!U&&ne&&ne.start<$[0].start&&(U=$[0]))}else U=$[re-1];(C=U)!==null&&C!==void 0&&C.encrypted?(I.logger.log("Loading key for "+U.sn),this.state=g.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:U})):U&&this.fragmentTracker.getState(U)===O.FragmentState.NOT_LOADED&&this.loadFragment(U,c,x)}},p.loadFragment=function(C,v,d){this.fragCurrent=C,l.prototype.loadFragment.call(this,C,v,d)},w(S,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),S}(g.default)},"./src/controller/subtitle-track-controller.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/events.ts"),I=k("./src/utils/texttrack-utils.ts"),D=k("./src/controller/base-playlist-controller.ts"),j=k("./src/types/loader.ts");function F(L,w){for(var E=0;E<w.length;E++){var u=w[E];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,E){return w&&F(L.prototype,w),E&&F(L,E),L}function O(L,w){L.prototype=Object.create(w.prototype),L.prototype.constructor=L,g(L,w)}function g(L,w){return g=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},g(L,w)}var T=function(L){O(w,L);function w(u){var o;return o=L.call(this,u,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var E=w.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},E.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(V.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(V.Events.ERROR,this.onError,this)},E.onMediaAttached=function(o,s){if(this.media=s.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},E.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},E.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=R(this.media.textTracks);o.forEach(function(s){Object(I.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(o,s){this.tracks=s.subtitleTracks},E.onSubtitleTrackLoaded=function(o,s){var l=s.id,S=s.details,p=this.trackId,f=this.tracksInGroup[p];if(!f){this.warn("Invalid subtitle track id "+l);return}var C=f.details;f.details=s.details,this.log("subtitle track "+l+" loaded ["+S.startSN+"-"+S.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,C))},E.onLevelLoading=function(o,s){this.switchLevel(s.level)},E.onLevelSwitching=function(o,s){this.switchLevel(s.level)},E.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.textGroupIds))return;var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var S=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,p=this.tracks.filter(function(v){return!l||v.groupId===l});this.tracksInGroup=p;var f=this.findTrackId(S==null?void 0:S.name)||this.findTrackId();this.groupId=l;var C={subtitleTracks:p};this.log("Updating subtitle tracks, "+p.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,C),f!==-1&&this.setSubtitleTrack(f,S)}},E.findTrackId=function(o){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var S=s[l];if((!this.selectDefaultTrack||S.default)&&(!o||o===S.name))return S.id}return-1},E.onError=function(o,s){if(L.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===j.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},E.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,S=s.groupId,p=s.url;if(o)try{p=o.addDirectives(p)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:p,id:l,groupId:S,deliveryDirectives:o||null})}},E.toggleTrackModes=function(o){var s=this,l=this.media,S=this.subtitleDisplay,p=this.trackId;if(!l)return;var f=R(l.textTracks),C=f.filter(function(c){return c.groupId===s.groupId});if(o===-1)[].slice.call(f).forEach(function(c){c.mode="disabled"});else{var v=C[p];v&&(v.mode="disabled")}var d=C[o];d&&(d.mode=S?"showing":"hidden")},E.setSubtitleTrack=function(o,s){var l,S=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(l=S[o])!==null&&l!==void 0&&l.details)||o<-1||o>=S.length)return;this.clearTimer();var p=S[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,p){var f=p.id,C=p.groupId,v=C===void 0?"":C,d=p.name,c=p.type,h=p.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:f,groupId:v,name:d,type:c,url:h});var a=this.switchParams(p.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:o})},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,s=R(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")o=l;else if(s[l].mode==="showing"){o=l;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},P(w,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,s)}}]),w}(D.default);function R(L){for(var w=[],E=0;E<L.length;E++){var u=L[E];u.kind==="subtitles"&&u.label&&w.push(L[E])}return w}Y.default=T},"./src/controller/timeline-controller.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"TimelineController",function(){return R});var V=k("./src/polyfills/number.ts"),I=k("./src/events.ts"),D=k("./src/utils/cea-608-parser.ts"),j=k("./src/utils/output-filter.ts"),F=k("./src/utils/webvtt-parser.ts"),P=k("./src/utils/texttrack-utils.ts"),O=k("./src/utils/imsc1-ttml-parser.ts"),g=k("./src/types/loader.ts"),T=k("./src/utils/logger.ts"),R=function(){function u(s){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=E(),this.captionsProperties=void 0,this.hls=s,this.config=s.config,this.Cues=s.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var l=new j.default(this,"textTrack1"),S=new j.default(this,"textTrack2"),p=new j.default(this,"textTrack3"),f=new j.default(this,"textTrack4");this.cea608Parser1=new D.default(1,l,S),this.cea608Parser2=new D.default(3,p,f)}s.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(I.Events.FRAG_LOADING,this.onFragLoading,this),s.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=u.prototype;return o.destroy=function(){var l=this.hls;l.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(I.Events.FRAG_LOADING,this.onFragLoading,this),l.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(l,S,p,f,C){for(var v=!1,d=C.length;d--;){var c=C[d],h=w(c[0],c[1],S,p);if(h>=0&&(c[0]=Math.min(c[0],S),c[1]=Math.max(c[1],p),v=!0,h/(p-S)>.5))return}if(v||C.push([S,p]),this.config.renderTextTracksNatively){var a=this.captionsTracks[l];this.Cues.newCue(a,S,p,f)}else{var y=this.Cues.newCue(null,S,p,f);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:y,track:l})}},o.onInitPtsFound=function(l,S){var p=this,f=S.frag,C=S.id,v=S.initPTS,d=S.timescale,c=this.unparsedVttFrags;C==="main"&&(this.initPTS[f.cc]=v,this.timescale[f.cc]=d),c.length&&(this.unparsedVttFrags=[],c.forEach(function(h){p.onFragLoaded(I.Events.FRAG_LOADED,h)}))},o.getExistingTrack=function(l){var S=this.media;if(S)for(var p=0;p<S.textTracks.length;p++){var f=S.textTracks[p];if(f[l])return f}return null},o.createCaptionsTrack=function(l){this.config.renderTextTracksNatively?this.createNativeTrack(l):this.createNonNativeTrack(l)},o.createNativeTrack=function(l){if(this.captionsTracks[l])return;var S=this.captionsProperties,p=this.captionsTracks,f=this.media,C=S[l],v=C.label,d=C.languageCode,c=this.getExistingTrack(l);if(c)p[l]=c,Object(P.clearCurrentCues)(p[l]),Object(P.sendAddTrackEvent)(p[l],f);else{var h=this.createTextTrack("captions",v,d);h&&(h[l]=!0,p[l]=h)}},o.createNonNativeTrack=function(l){if(this.nonNativeCaptionsTracks[l])return;var S=this.captionsProperties[l];if(!S)return;var p=S.label,f={_id:l,label:p,kind:"captions",default:S.media?!!S.media.default:!1,closedCaptions:S.media};this.nonNativeCaptionsTracks[l]=f,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[f]})},o.createTextTrack=function(l,S,p){var f=this.media;return f?f.addTextTrack(l,S,p):void 0},o.onMediaAttaching=function(l,S){this.media=S.media,this._cleanTracks()},o.onMediaDetaching=function(){var l=this.captionsTracks;Object.keys(l).forEach(function(S){Object(P.clearCurrentCues)(l[S]),delete l[S]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=E(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var l=this.media;if(!l)return;var S=l.textTracks;if(S)for(var p=0;p<S.length;p++)Object(P.clearCurrentCues)(S[p])},o.onSubtitleTracksUpdated=function(l,S){var p=this;this.textTracks=[];var f=S.subtitleTracks||[],C=f.some(function(h){return h.textCodec===O.IMSC1_CODEC});if(this.config.enableWebVTT||C&&this.config.enableIMSC1){var v=this.tracks&&f&&this.tracks.length===f.length;if(this.tracks=f||[],this.config.renderTextTracksNatively){var d=this.media?this.media.textTracks:[];this.tracks.forEach(function(h,a){var y;if(a<d.length){for(var m=null,x=0;x<d.length;x++)if(L(d[x],h)){m=d[x];break}m&&(y=m)}y?Object(P.clearCurrentCues)(y):(y=p.createTextTrack("subtitles",h.name,h.lang),y&&(y.mode="disabled")),y&&(y.groupId=h.groupId,p.textTracks.push(y))})}else if(!v&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(h){return{label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(l,S){var p=this;this.config.enableCEA708Captions&&S.captions&&S.captions.forEach(function(f){var C=/(?:CC|SERVICE)([1-4])/.exec(f.instreamId);if(!C)return;var v="textTrack"+C[1],d=p.captionsProperties[v];if(!d)return;d.label=f.name,f.lang&&(d.languageCode=f.lang),d.media=f})},o.onFragLoading=function(l,S){var p=this.cea608Parser1,f=this.cea608Parser2,C=this.lastSn,v=this.lastPartIndex;if(!this.enabled||!(p&&f))return;if(S.frag.type===g.PlaylistLevelType.MAIN){var d,c,h=S.frag.sn,a=(d=S==null||((c=S.part)===null||c===void 0)?void 0:c.index)!=null?d:-1;h===C+1||h===C&&a===v+1||(p.reset(),f.reset()),this.lastSn=h,this.lastPartIndex=a}},o.onFragLoaded=function(l,S){var p=S.frag,f=S.payload,C=this.initPTS,v=this.unparsedVttFrags;if(p.type===g.PlaylistLevelType.SUBTITLE)if(f.byteLength){if(!Object(V.isFiniteNumber)(C[p.cc])){v.push(S),C.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:p,error:new Error("Missing initial subtitle PTS")});return}var d=p.decryptdata;if(d==null||d.key==null||d.method!=="AES-128"){var c=this.tracks[p.level],h=this.vttCCs;h[p.cc]||(h[p.cc]={start:p.start,prevCC:this.prevCC,new:!0},this.prevCC=p.cc),c&&c.textCodec===O.IMSC1_CODEC?this._parseIMSC1(p,f):this._parseVTTs(p,f,h)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:p,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(l,S){var p=this,f=this.hls;Object(O.parseIMSC1)(S,this.initPTS[l.cc],this.timescale[l.cc],function(C){p._appendCues(C,l.level),f.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:l})},function(C){T.logger.log("Failed to parse IMSC1: "+C),f.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:C})})},o._parseVTTs=function(l,S,p){var f=this,C=this.hls;Object(F.parseWebVTT)(S,this.initPTS[l.cc],this.timescale[l.cc],p,l.cc,l.start,function(v){f._appendCues(v,l.level),C.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:l})},function(v){f._fallbackToIMSC1(l,S),T.logger.log("Failed to parse VTT cue: "+v),C.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:v})})},o._fallbackToIMSC1=function(l,S){var p=this,f=this.tracks[l.level];f.textCodec||Object(O.parseIMSC1)(S,this.initPTS[l.cc],this.timescale[l.cc],function(){f.textCodec=O.IMSC1_CODEC,p._parseIMSC1(l,S)},function(){f.textCodec="wvtt"})},o._appendCues=function(l,S){var p=this.hls;if(this.config.renderTextTracksNatively){var f=this.textTracks[S];if(f.mode==="disabled")return;l.forEach(function(d){return Object(P.addCueToTrack)(f,d)})}else{var C=this.tracks[S],v=C.default?"default":"subtitles"+S;p.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:l,track:v})}},o.onFragDecrypted=function(l,S){var p=S.frag;if(p.type===g.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[p.cc])){this.unparsedVttFrags.push(S);return}this.onFragLoaded(I.Events.FRAG_LOADED,S)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(l,S){var p=this.cea608Parser1,f=this.cea608Parser2;if(!this.enabled||!(p&&f))return;for(var C=0;C<S.samples.length;C++){var v=S.samples[C].bytes;if(v){var d=this.extractCea608Data(v);p.addData(S.samples[C].pts,d[0]),f.addData(S.samples[C].pts,d[1])}}},o.onBufferFlushing=function(l,S){var p=S.startOffset,f=S.endOffset,C=S.endOffsetSubtitles,v=S.type,d=this.media;if(!d||d.currentTime<f)return;if(!v||v==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(P.removeCuesInRange)(c[a],p,f)})}if(this.config.renderTextTracksNatively&&(p===0&&C!==void 0)){var h=this.textTracks;Object.keys(h).forEach(function(a){return Object(P.removeCuesInRange)(h[a],p,C)})}},o.extractCea608Data=function(l){for(var S=l[0]&31,p=2,f=[[],[]],C=0;C<S;C++){var v=l[p++],d=127&l[p++],c=127&l[p++],h=(4&v)!==0,a=3&v;if(d===0&&c===0)continue;h&&((a===0||a===1)&&(f[a].push(d),f[a].push(c)))}return f},u}();function L(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function w(u,o,s,l){return Math.min(o,l)-Math.max(u,s)}function E(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return V});var V=function(){function I(j,F){this.subtle=void 0,this.aesIV=void 0,this.subtle=j,this.aesIV=F}var D=I.prototype;return D.decrypt=function(F,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,F)},I}()},"./src/crypt/aes-decryptor.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"removePadding",function(){return I}),k.d(Y,"default",function(){return D});var V=k("./src/utils/typed-array.ts");function I(j){var F=j.byteLength,P=F&&new DataView(j.buffer).getUint8(F-1);return P?Object(V.sliceUint8)(j,0,F-P):j}var D=function(){function j(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var F=j.prototype;return F.uint8ArrayToUint32Array_=function(O){for(var g=new DataView(O),T=new Uint32Array(4),R=0;R<4;R++)T[R]=g.getUint32(R*4);return T},F.initTable=function(){var O=this.sBox,g=this.invSBox,T=this.subMix,R=T[0],L=T[1],w=T[2],E=T[3],u=this.invSubMix,o=u[0],s=u[1],l=u[2],S=u[3],p=new Uint32Array(256),f=0,C=0,v=0;for(v=0;v<256;v++)v<128?p[v]=v<<1:p[v]=v<<1^283;for(v=0;v<256;v++){var d=C^C<<1^C<<2^C<<3^C<<4;d=d>>>8^d&255^99,O[f]=d,g[d]=f;var c=p[f],h=p[c],a=p[h],y=p[d]*257^d*16843008;R[f]=y<<24|y>>>8,L[f]=y<<16|y>>>16,w[f]=y<<8|y>>>24,E[f]=y,y=a*16843009^h*65537^c*257^f*16843008,o[d]=y<<24|y>>>8,s[d]=y<<16|y>>>16,l[d]=y<<8|y>>>24,S[d]=y,f?(f=c^p[p[p[a^c]]],C^=p[p[C]]):f=C=1}},F.expandKey=function(O){for(var g=this.uint8ArrayToUint32Array_(O),T=!0,R=0;R<g.length&&T;)T=g[R]===this.key[R],R++;if(T)return;this.key=g;var L=this.keySize=g.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var w=this.ksRows=(L+6+1)*4,E,u,o=this.keySchedule=new Uint32Array(w),s=this.invKeySchedule=new Uint32Array(w),l=this.sBox,S=this.rcon,p=this.invSubMix,f=p[0],C=p[1],v=p[2],d=p[3],c,h;for(E=0;E<w;E++){if(E<L){c=o[E]=g[E];continue}h=c,E%L===0?(h=h<<8|h>>>24,h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[h&255],h^=S[E/L|0]<<24):L>6&&E%L===4&&(h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[h&255]),o[E]=c=(o[E-L]^h)>>>0}for(u=0;u<w;u++)E=w-u,u&3?h=o[E]:h=o[E-4],u<4||E<=4?s[u]=h:s[u]=f[l[h>>>24]]^C[l[h>>>16&255]]^v[l[h>>>8&255]]^d[l[h&255]],s[u]=s[u]>>>0},F.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},F.decrypt=function(O,g,T){for(var R=this.keySize+6,L=this.invKeySchedule,w=this.invSBox,E=this.invSubMix,u=E[0],o=E[1],s=E[2],l=E[3],S=this.uint8ArrayToUint32Array_(T),p=S[0],f=S[1],C=S[2],v=S[3],d=new Int32Array(O),c=new Int32Array(d.length),h,a,y,m,x,M,G,$,re,z,U,ne,fe,ge,be=this.networkToHostOrderSwap;g<d.length;){for(re=be(d[g]),z=be(d[g+1]),U=be(d[g+2]),ne=be(d[g+3]),x=re^L[0],M=ne^L[1],G=U^L[2],$=z^L[3],fe=4,ge=1;ge<R;ge++)h=u[x>>>24]^o[M>>16&255]^s[G>>8&255]^l[$&255]^L[fe],a=u[M>>>24]^o[G>>16&255]^s[$>>8&255]^l[x&255]^L[fe+1],y=u[G>>>24]^o[$>>16&255]^s[x>>8&255]^l[M&255]^L[fe+2],m=u[$>>>24]^o[x>>16&255]^s[M>>8&255]^l[G&255]^L[fe+3],x=h,M=a,G=y,$=m,fe=fe+4;h=w[x>>>24]<<24^w[M>>16&255]<<16^w[G>>8&255]<<8^w[$&255]^L[fe],a=w[M>>>24]<<24^w[G>>16&255]<<16^w[$>>8&255]<<8^w[x&255]^L[fe+1],y=w[G>>>24]<<24^w[$>>16&255]<<16^w[x>>8&255]<<8^w[M&255]^L[fe+2],m=w[$>>>24]<<24^w[x>>16&255]<<16^w[M>>8&255]<<8^w[G&255]^L[fe+3],c[g]=be(h^p),c[g+1]=be(m^f),c[g+2]=be(y^C),c[g+3]=be(a^v),p=re,f=z,C=U,v=ne,g=g+4}return c.buffer},j}()},"./src/crypt/decrypter.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return g});var V=k("./src/crypt/aes-crypto.ts"),I=k("./src/crypt/fast-aes-key.ts"),D=k("./src/crypt/aes-decryptor.ts"),j=k("./src/utils/logger.ts"),F=k("./src/utils/mp4-tools.ts"),P=k("./src/utils/typed-array.ts"),O=16,g=function(){function T(L,w,E){var u=E===void 0?{}:E,o=u.removePKCS7Padding,s=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=w,this.removePKCS7Padding=s,s)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch(S){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=T.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var w=this.currentResult;if(!w){this.reset();return}var E=new Uint8Array(w);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(E):E},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(w,E,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(w),E,u);var s=this.flush();s&&o(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(w),E,u).then(o)},R.softwareDecrypt=function(w,E,u){var o=this.currentIV,s=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(w=Object(F.appendUint8Array)(l,w),this.remainderData=null);var S=this.getValidChunk(w);if(!S.length)return null;o&&(u=o);var p=this.softwareDecrypter;p||(p=this.softwareDecrypter=new D.default),p.expandKey(E);var f=s;return this.currentResult=p.decrypt(S.buffer,0,u),this.currentIV=Object(P.sliceUint8)(S,-16).buffer,f||null},R.webCryptoDecrypt=function(w,E,u){var o=this,s=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new I.default(s,E)),this.fastAesKey.expandKey().then(function(l){if(!s)return Promise.reject(new Error("web crypto not initialized"));var S=new V.default(s,u);return S.decrypt(w.buffer,l)}).catch(function(l){return o.onWebCryptoError(l,w,E,u)})},R.onWebCryptoError=function(w,E,u,o){return j.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",w),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,u,o)},R.getValidChunk=function(w){var E=w,u=w.length-w.length%O;return u!==w.length&&(E=Object(P.sliceUint8)(w,0,u),this.remainderData=Object(P.sliceUint8)(w,u)),E},R.logOnce=function(w){if(!this.logEnabled)return;j.logger.log("[decrypter.ts]: "+w),this.logEnabled=!1},T}()},"./src/crypt/fast-aes-key.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return V});var V=function(){function I(j,F){this.subtle=void 0,this.key=void 0,this.subtle=j,this.key=F}var D=I.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/demux/base-audio-demuxer.ts"),I=k("./src/demux/adts.ts"),D=k("./src/utils/logger.ts"),j=k("./src/demux/id3.ts");function F(g,T){g.prototype=Object.create(T.prototype),g.prototype.constructor=g,P(g,T)}function P(g,T){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(g,T)}var O=function(g){F(T,g);function T(L,w){var E;return E=g.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=L,E.config=w,E}var R=T.prototype;return R.resetInitSegment=function(w,E,u){g.prototype.resetInitSegment.call(this,w,E,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(w){if(!w)return!1;for(var E=j.getID3Data(w,0)||[],u=E.length,o=w.length;u<o;u++)if(I.probe(w,u))return D.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(w,E){return I.canParse(w,E)},R.appendFrame=function(w,E,u){I.initTrackConfig(w,this.observer,E,u,w.manifestCodec);var o=I.appendFrame(w,E,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},T}(V.default);O.minProbeByteLength=9,Y.default=O},"./src/demux/adts.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"getAudioConfig",function(){return j}),k.d(Y,"isHeaderPattern",function(){return F}),k.d(Y,"getHeaderLength",function(){return P}),k.d(Y,"getFullFrameLength",function(){return O}),k.d(Y,"canGetFrameLength",function(){return g}),k.d(Y,"isHeader",function(){return T}),k.d(Y,"canParse",function(){return R}),k.d(Y,"probe",function(){return L}),k.d(Y,"initTrackConfig",function(){return w}),k.d(Y,"getFrameDuration",function(){return E}),k.d(Y,"parseFrameHeader",function(){return u}),k.d(Y,"appendFrame",function(){return o});var V=k("./src/utils/logger.ts"),I=k("./src/errors.ts"),D=k("./src/events.ts");function j(s,l,S,p){var f,C,v,d,c=navigator.userAgent.toLowerCase(),h=p,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];f=((l[S+2]&192)>>>6)+1;var y=(l[S+2]&60)>>>2;if(y>a.length-1){s.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+y});return}return v=(l[S+2]&1)<<2,v|=(l[S+3]&192)>>>6,V.logger.log("manifest codec:"+p+", ADTS type:"+f+", samplingIndex:"+y),/firefox/i.test(c)?y>=6?(f=5,d=new Array(4),C=y-3):(f=2,d=new Array(2),C=y):c.indexOf("android")!==-1?(f=2,d=new Array(2),C=y):(f=5,d=new Array(4),p&&(p.indexOf("mp4a.40.29")!==-1||p.indexOf("mp4a.40.5")!==-1)||!p&&y>=6?C=y-3:((p&&p.indexOf("mp4a.40.2")!==-1&&(y>=6&&v===1||/vivaldi/i.test(c))||!p&&v===1)&&(f=2,d=new Array(2)),C=y)),d[0]=f<<3,d[0]|=(y&14)>>1,d[1]|=(y&1)<<7,d[1]|=v<<3,f===5&&(d[1]|=(C&14)>>1,d[2]=(C&1)<<7,d[2]|=2<<2,d[3]=0),{config:d,samplerate:a[y],channelCount:v,codec:"mp4a.40."+f,manifestCodec:h}}function F(s,l){return s[l]===255&&(s[l+1]&246)===240}function P(s,l){return s[l+1]&1?7:9}function O(s,l){return(s[l+3]&3)<<11|s[l+4]<<3|(s[l+5]&224)>>>5}function g(s,l){return l+5<s.length}function T(s,l){return l+1<s.length&&F(s,l)}function R(s,l){return g(s,l)&&F(s,l)&&O(s,l)<=s.length-l}function L(s,l){if(T(s,l)){var S=P(s,l);if(l+S>=s.length)return!1;var p=O(s,l);if(p<=S)return!1;var f=l+p;return f===s.length||T(s,f)}return!1}function w(s,l,S,p,f){if(!s.samplerate){var C=j(l,S,p,f);if(!C)return;s.config=C.config,s.samplerate=C.samplerate,s.channelCount=C.channelCount,s.codec=C.codec,s.manifestCodec=C.manifestCodec,V.logger.log("parsed codec:"+s.codec+", rate:"+C.samplerate+", channels:"+C.channelCount)}}function E(s){return 1024*9e4/s}function u(s,l,S,p,f){var C=P(s,l),v=O(s,l);if(v-=C,v>0){var d=S+p*f;return{headerLength:C,frameLength:v,stamp:d}}}function o(s,l,S,p,f){var C=E(s.samplerate),v=u(l,S,p,f,C);if(v){var d=v.frameLength,c=v.headerLength,h=v.stamp,a=c+d,y=Math.max(0,S+a-l.length),m;y?(m=new Uint8Array(a-c),m.set(l.subarray(S+c,l.length),0)):m=l.subarray(S+c,S+a);var x={unit:m,pts:h};return y||s.samples.push(x),{sample:x,length:a,missing:y}}}},"./src/demux/base-audio-demuxer.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"initPTSFn",function(){return O});var V=k("./src/polyfills/number.ts"),I=k("./src/demux/id3.ts"),D=k("./src/demux/dummy-demuxed-track.ts"),j=k("./src/utils/mp4-tools.ts"),F=k("./src/utils/typed-array.ts"),P=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var T=g.prototype;return T.resetInitSegment=function(L,w,E){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},T.resetTimeStamp=function(){},T.resetContiguity=function(){},T.canParse=function(L,w){return!1},T.appendFrame=function(L,w,E){},T.demux=function(L,w){this.cachedData&&(L=Object(j.appendUint8Array)(this.cachedData,L),this.cachedData=null);var E=I.getID3Data(L,0),u=E?E.length:0,o,s,l=this._audioTrack,S=this._id3Track,p=E?I.getTimeStamp(E):void 0,f=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(p,w)),E&&E.length>0&&S.samples.push({pts:this.initPTS,dts:this.initPTS,data:E}),s=this.initPTS;u<f;){if(this.canParse(L,u)){var C=this.appendFrame(l,L,u);C?(this.frameIndex++,s=C.sample.pts,u+=C.length,o=u):u=f}else I.canParse(L,u)?(E=I.getID3Data(L,u),S.samples.push({pts:s,dts:s,data:E}),u+=E.length,o=u):u++;if(u===f&&o!==f){var v=Object(F.sliceUint8)(L,o);this.cachedData?this.cachedData=Object(j.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:l,avcTrack:Object(D.dummyTrack)(),id3Track:S,textTrack:Object(D.dummyTrack)()}},T.demuxSampleAes=function(L,w,E){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},T.flush=function(L){var w=this.cachedData;return w&&(this.cachedData=null,this.demux(w,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(D.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(D.dummyTrack)()}},T.destroy=function(){},g}(),O=function(T,R){return Object(V.isFiniteNumber)(T)?T*90:R*9e4};Y.default=P},"./src/demux/chunk-cache.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return V});var V=function(){function D(){this.chunks=[],this.dataLength=0}var j=D.prototype;return j.push=function(P){this.chunks.push(P),this.dataLength+=P.length},j.flush=function(){var P=this.chunks,O=this.dataLength,g;if(P.length)P.length===1?g=P[0]:g=I(P,O);else return new Uint8Array(0);return this.reset(),g},j.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function I(D,j){for(var F=new Uint8Array(j),P=0,O=0;O<D.length;O++){var g=D[O];F.set(g,P),P+=g.length}return F}},"./src/demux/dummy-demuxed-track.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/utils/logger.ts"),I=function(){function D(F){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=F,this.bytesAvailable=F.byteLength,this.word=0,this.bitsAvailable=0}var j=D.prototype;return j.loadWord=function(){var P=this.data,O=this.bytesAvailable,g=P.byteLength-O,T=new Uint8Array(4),R=Math.min(4,O);if(R===0)throw new Error("no bytes available");T.set(P.subarray(g,g+R)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},j.skipBits=function(P){var O;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,O=P>>3,P-=O>>3,this.bytesAvailable-=O,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},j.readBits=function(P){var O=Math.min(this.bitsAvailable,P),g=this.word>>>32-O;return P>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0?this.word<<=O:this.bytesAvailable>0&&this.loadWord(),O=P-O,O>0&&this.bitsAvailable?g<<O|this.readBits(O):g},j.skipLZ=function(){var P;for(P=0;P<this.bitsAvailable;++P)if((this.word&2147483648>>>P)!==0)return this.word<<=P,this.bitsAvailable-=P,P;return this.loadWord(),P+this.skipLZ()},j.skipUEG=function(){this.skipBits(1+this.skipLZ())},j.skipEG=function(){this.skipBits(1+this.skipLZ())},j.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},j.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},j.readBoolean=function(){return this.readBits(1)===1},j.readUByte=function(){return this.readBits(8)},j.readUShort=function(){return this.readBits(16)},j.readUInt=function(){return this.readBits(32)},j.skipScalingList=function(P){for(var O=8,g=8,T,R=0;R<P;R++)g!==0&&(T=this.readEG(),g=(O+T+256)%256),O=g===0?O:g},j.readSPS=function(){var P=0,O=0,g=0,T=0,R,L,w,E=this.readUByte.bind(this),u=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),l=this.skipBits.bind(this),S=this.skipEG.bind(this),p=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);E();var C=E();if(u(5),l(3),E(),p(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){var v=o();if(v===3&&l(1),p(),p(),l(1),s())for(L=v!==3?8:12,w=0;w<L;w++)s()&&(w<6?f(16):f(64))}p();var d=o();if(d===0)o();else if(d===1)for(l(1),S(),S(),R=o(),w=0;w<R;w++)S();p(),l(1);var c=o(),h=o(),a=u(1);a===0&&l(1),l(1),s()&&(P=o(),O=o(),g=o(),T=o());var y=[1,1];if(s()&&s()){var m=E();switch(m){case 1:y=[1,1];break;case 2:y=[12,11];break;case 3:y=[10,11];break;case 4:y=[16,11];break;case 5:y=[40,33];break;case 6:y=[24,11];break;case 7:y=[20,11];break;case 8:y=[32,11];break;case 9:y=[80,33];break;case 10:y=[18,11];break;case 11:y=[15,11];break;case 12:y=[64,33];break;case 13:y=[160,99];break;case 14:y=[4,3];break;case 15:y=[3,2];break;case 16:y=[2,1];break;case 255:{y=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((c+1)*16-P*2-O*2),height:(2-a)*(h+1)*16-(a?2:4)*(g+T),pixelRatio:y}},j.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();Y.default=I},"./src/demux/id3.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"isHeader",function(){return V}),k.d(Y,"isFooter",function(){return I}),k.d(Y,"getID3Data",function(){return D}),k.d(Y,"canParse",function(){return F}),k.d(Y,"getTimeStamp",function(){return P}),k.d(Y,"isTimeStampFrame",function(){return O}),k.d(Y,"getID3Frames",function(){return T}),k.d(Y,"decodeFrame",function(){return R}),k.d(Y,"utf8ArrayToStr",function(){return o}),k.d(Y,"testables",function(){return s});var V=function(f,C){return C+10<=f.length&&(f[C]===73&&f[C+1]===68&&f[C+2]===51&&(f[C+3]<255&&f[C+4]<255&&(f[C+6]<128&&f[C+7]<128&&f[C+8]<128&&f[C+9]<128)))},I=function(f,C){return C+10<=f.length&&(f[C]===51&&f[C+1]===68&&f[C+2]===73&&(f[C+3]<255&&f[C+4]<255&&(f[C+6]<128&&f[C+7]<128&&f[C+8]<128&&f[C+9]<128)))},D=function(f,C){for(var v=C,d=0;V(f,C);){d+=10;var c=j(f,C+6);d+=c,I(f,C+10)&&(d+=10),C+=d}return d>0?f.subarray(v,v+d):void 0},j=function(f,C){var v=0;return v=(f[C]&127)<<21,v|=(f[C+1]&127)<<14,v|=(f[C+2]&127)<<7,v|=f[C+3]&127,v},F=function(f,C){return V(f,C)&&j(f,C+6)+10<=f.length-C},P=function(f){for(var C=T(f),v=0;v<C.length;v++){var d=C[v];if(O(d))return u(d)}return},O=function(f){return f&&f.key==="PRIV"&&f.info==="com.apple.streaming.transportStreamTimestamp"},g=function(f){var C=String.fromCharCode(f[0],f[1],f[2],f[3]),v=j(f,4),d=10;return{type:C,size:v,data:f.subarray(d,d+v)}},T=function(f){for(var C=0,v=[];V(f,C);){var d=j(f,C+6);C+=10;for(var c=C+d;C+8<c;){var h=g(f.subarray(C)),a=R(h);a&&v.push(a),C+=h.size+10}I(f,C)&&(C+=10)}return v},R=function(f){return f.type==="PRIV"?L(f):f.type[0]==="W"?E(f):w(f)},L=function(f){if(f.size<2)return;var C=o(f.data,!0),v=new Uint8Array(f.data.subarray(C.length+1));return{key:f.type,info:C,data:v.buffer}},w=function(f){if(f.size<2)return;if(f.type==="TXXX"){var C=1,v=o(f.data.subarray(C),!0);C+=v.length+1;var d=o(f.data.subarray(C));return{key:f.type,info:v,data:d}}var c=o(f.data.subarray(1));return{key:f.type,data:c}},E=function(f){if(f.type==="WXXX"){if(f.size<2)return;var C=1,v=o(f.data.subarray(C),!0);C+=v.length+1;var d=o(f.data.subarray(C));return{key:f.type,info:v,data:d}}var c=o(f.data);return{key:f.type,data:c}},u=function(f){if(f.data.byteLength===8){var C=new Uint8Array(f.data),v=C[3]&1,d=(C[4]<<23)+(C[5]<<15)+(C[6]<<7)+C[7];return d/=45,v&&(d+=4772185884e-2),Math.round(d)}return},o=function(f,C){C===void 0&&(C=!1);var v=S();if(v){var d=v.decode(f);if(C){var c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}for(var h=f.length,a,y,m,x="",M=0;M<h;){if(a=f[M++],a===0&&C)return x;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(a);break;case 12:case 13:y=f[M++],x+=String.fromCharCode((a&31)<<6|y&63);break;case 14:y=f[M++],m=f[M++],x+=String.fromCharCode((a&15)<<12|(y&63)<<6|(m&63)<<0);break;default:}}return x},s={decodeTextFrame:w},l;function S(){return!l&&typeof self.TextDecoder!="undefined"&&(l=new self.TextDecoder("utf-8")),l}},"./src/demux/mp3demuxer.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/demux/base-audio-demuxer.ts"),I=k("./src/demux/id3.ts"),D=k("./src/utils/logger.ts"),j=k("./src/demux/mpegaudio.ts");function F(g,T){g.prototype=Object.create(T.prototype),g.prototype.constructor=g,P(g,T)}function P(g,T){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(g,T)}var O=function(g){F(T,g);function T(){return g.apply(this,arguments)||this}var R=T.prototype;return R.resetInitSegment=function(w,E,u){g.prototype.resetInitSegment.call(this,w,E,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(w){if(!w)return!1;for(var E=I.getID3Data(w,0)||[],u=E.length,o=w.length;u<o;u++)if(j.probe(w,u))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(w,E){return j.canParse(w,E)},R.appendFrame=function(w,E,u){return this.initPTS===null?void 0:j.appendFrame(w,E,u,this.initPTS,this.frameIndex)},T}(V.default);O.minProbeByteLength=4,Y.default=O},"./src/demux/mp4demuxer.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/utils/mp4-tools.ts"),I=k("./src/demux/dummy-demuxed-track.ts"),D=function(){function j(P,O){this.remainderData=null,this.config=void 0,this.config=O}var F=j.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(){},F.resetContiguity=function(){},j.probe=function(O){return Object(V.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},F.demux=function(O){var g=O,T=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(V.appendUint8Array)(this.remainderData,O));var R=Object(V.segmentValidRange)(g);this.remainderData=R.remainder,T.samples=R.valid||new Uint8Array}else T.samples=g;return{audioTrack:Object(I.dummyTrack)(),avcTrack:T,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,g,T){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},j}();D.minProbeByteLength=1024,Y.default=D},"./src/demux/mpegaudio.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"appendFrame",function(){return P}),k.d(Y,"parseHeader",function(){return O}),k.d(Y,"isHeaderPattern",function(){return g}),k.d(Y,"isHeader",function(){return T}),k.d(Y,"canParse",function(){return R}),k.d(Y,"probe",function(){return L});var V=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],j=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function P(w,E,u,o,s){if(u+24>E.length)return;var l=O(E,u);if(l&&u+l.frameLength<=E.length){var S=l.samplesPerFrame*9e4/l.sampleRate,p=o+s*S,f={unit:E.subarray(u,u+l.frameLength),pts:p,dts:p};return w.config=[],w.channelCount=l.channelCount,w.samplerate=l.sampleRate,w.samples.push(f),{sample:f,length:l.frameLength,missing:0}}}function O(w,E){var u=w[E+1]>>3&3,o=w[E+1]>>1&3,s=w[E+2]>>4&15,l=w[E+2]>>2&3;if(u!==1&&s!==0&&s!==15&&l!==3){var S=w[E+2]>>1&1,p=w[E+3]>>6,f=u===3?3-o:o===3?3:4,C=I[f*14+s-1]*1e3,v=u===3?0:u===2?1:2,d=D[v*3+l],c=p===3?1:2,h=j[u][o],a=F[o],y=h*8*a,m=Math.floor(h*C/d+S)*a;if(V===null){var x=navigator.userAgent||"",M=x.match(/Chrome\/(\d+)/i);V=M?parseInt(M[1]):0}var G=!!V&&V<=87;return G&&o===2&&C>=224e3&&p===0&&(w[E+3]=w[E+3]|128),{sampleRate:d,channelCount:c,frameLength:m,samplesPerFrame:y}}}function g(w,E){return w[E]===255&&(w[E+1]&224)===224&&(w[E+1]&6)!==0}function T(w,E){return E+1<w.length&&g(w,E)}function R(w,E){var u=4;return g(w,E)&&u<=w.length-E}function L(w,E){if(E+1<w.length&&g(w,E)){var u=4,o=O(w,E),s=u;o!=null&&o.frameLength&&(s=o.frameLength);var l=E+s;return l===w.length||T(w,l)}return!1}},"./src/demux/sample-aes.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/crypt/decrypter.ts"),I=k("./src/demux/tsdemuxer.ts"),D=function(){function j(P,O,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new V.default(P,O,{removePKCS7Padding:!1})}var F=j.prototype;return F.decryptBuffer=function(O,g){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,g)},F.decryptAacSample=function(O,g,T,R){var L=O[g].unit,w=L.subarray(16,L.length-L.length%16),E=w.buffer.slice(w.byteOffset,w.byteOffset+w.length),u=this;this.decryptBuffer(E,function(o){var s=new Uint8Array(o);L.set(s,16),R||u.decryptAacSamples(O,g+1,T)})},F.decryptAacSamples=function(O,g,T){for(;;g++){if(g>=O.length){T();return}if(O[g].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(O,g,T,R),!R)return}},F.getAvcEncryptedData=function(O){for(var g=Math.floor((O.length-48)/160)*16+16,T=new Int8Array(g),R=0,L=32;L<=O.length-16;L+=160,R+=16)T.set(O.subarray(L,L+16),R);return T},F.getAvcDecryptedUnit=function(O,g){for(var T=new Uint8Array(g),R=0,L=32;L<=O.length-16;L+=160,R+=16)O.set(T.subarray(R,R+16),L);return O},F.decryptAvcSample=function(O,g,T,R,L,w){var E=Object(I.discardEPB)(L.data),u=this.getAvcEncryptedData(E),o=this;this.decryptBuffer(u.buffer,function(s){L.data=o.getAvcDecryptedUnit(E,s),w||o.decryptAvcSamples(O,g,T+1,R)})},F.decryptAvcSamples=function(O,g,T,R){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,T=0){if(g>=O.length){R();return}for(var L=O[g].units;!(T>=L.length);T++){var w=L[T];if(w.data.length<=48||w.type!==1&&w.type!==5)continue;var E=this.decrypter.isSync();if(this.decryptAvcSample(O,g,T,R,w,E),!E)return}}},j}();Y.default=D},"./src/demux/transmuxer-interface.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return L});var V=k("./node_modules/webworkify-webpack/index.js"),I=k.n(V),D=k("./src/events.ts"),j=k("./src/demux/transmuxer.ts"),F=k("./src/utils/logger.ts"),P=k("./src/errors.ts"),O=k("./src/utils/mediasource-helper.ts"),g=k("./node_modules/eventemitter3/index.js"),T=k.n(g),R=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function w(u,o,s,l){var S=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=u,this.id=o,this.onTransmuxComplete=s,this.onFlush=l;var p=u.config,f=function(h,a){a=a||{},a.frag=S.frag,a.id=S.id,u.trigger(h,a)};this.observer=new g.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,f),this.observer.on(D.Events.ERROR,f);var C={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},v=navigator.vendor;if(p.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var d;try{d=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),d.addEventListener("message",this.onwmsg),d.onerror=function(c){u.trigger(D.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},d.postMessage({cmd:"init",typeSupported:C,vendor:v,id:o,config:JSON.stringify(p)})}catch(c){F.logger.warn("Error in worker:",c),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),d&&self.URL.revokeObjectURL(d.objectURL),this.transmuxer=new j.default(this.observer,C,p,v,o),this.worker=null}}else this.transmuxer=new j.default(this.observer,C,p,v,o)}var E=w.prototype;return E.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var l=this.observer;l&&l.removeAllListeners(),this.observer=null},E.push=function(o,s,l,S,p,f,C,v,d,c){var h=this;d.transmuxing.start=self.performance.now();var a=this.transmuxer,y=this.worker,m=f?f.start:p.start,x=p.decryptdata,M=this.frag,G=!(M&&p.cc===M.cc),$=!(M&&d.level===M.level),re=M?d.sn-M.sn:-1,z=this.part?d.part-this.part.index:1,U=!$&&(re===1||re===0&&z===1),ne=self.performance.now();($||re||p.stats.parsing.start===0)&&(p.stats.parsing.start=ne),f&&(z||!U)&&(f.stats.parsing.start=ne);var fe=new j.TransmuxState(G,U,v,$,m);if(!U||G){F.logger.log("[transmuxer-interface, "+p.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
|
|
discontinuity: `+G+`
|
|
trackSwitch: `+$+`
|
|
contiguous: `+U+`
|
|
accurateTimeOffset: `+v+`
|
|
timeOffset: `+m);var ge=new j.TransmuxConfig(l,S,s,C,c);this.configureTransmuxer(ge)}if(this.frag=p,this.part=f,y)y.postMessage({cmd:"demux",data:o,decryptdata:x,chunkMeta:d,state:fe},o instanceof ArrayBuffer?[o]:[]);else if(a){var be=a.push(o,x,d,fe);Object(j.isPromise)(be)?be.then(function(Me){h.handleTransmuxComplete(Me)}):this.handleTransmuxComplete(be)}},E.flush=function(o){var s=this;o.transmuxing.start=self.performance.now();var l=this.transmuxer,S=this.worker;if(S)S.postMessage({cmd:"flush",chunkMeta:o});else if(l){var p=l.flush(o);Object(j.isPromise)(p)?p.then(function(f){s.handleFlushResult(f,o)}):this.handleFlushResult(p,o)}},E.handleFlushResult=function(o,s){var l=this;o.forEach(function(S){l.handleTransmuxComplete(S)}),this.onFlush(s)},E.onWorkerMessage=function(o){var s=o.data,l=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,l.trigger(s.event,s.data);break}}},E.configureTransmuxer=function(o){var s=this.worker,l=this.transmuxer;s?s.postMessage({cmd:"configure",config:o}):l&&l.configure(o)},E.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},w}()},"./src/demux/transmuxer-worker.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return P});var V=k("./src/demux/transmuxer.ts"),I=k("./src/events.ts"),D=k("./src/utils/logger.ts"),j=k("./node_modules/eventemitter3/index.js"),F=k.n(j);function P(L){var w=new j.EventEmitter,E=function(o,s){L.postMessage({event:o,data:s})};w.on(I.Events.FRAG_DECRYPTED,E),w.on(I.Events.ERROR,E),L.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);L.transmuxer=new V.default(w,o.typeSupported,s,o.vendor,o.id),Object(D.enableLogs)(s.debug),E("init",null);break}case"configure":{L.transmuxer.configure(o.config);break}case"demux":{var l=L.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(V.isPromise)(l)?l.then(function(f){O(L,f)}):O(L,l);break}case"flush":{var S=o.chunkMeta,p=L.transmuxer.flush(S);Object(V.isPromise)(p)?p.then(function(f){T(L,f,S)}):T(L,p,S);break}default:break}})}function O(L,w){if(R(w.remuxResult))return;var E=[],u=w.remuxResult,o=u.audio,s=u.video;o&&g(E,o),s&&g(E,s),L.postMessage({event:"transmuxComplete",data:w},E)}function g(L,w){w.data1&&L.push(w.data1.buffer),w.data2&&L.push(w.data2.buffer)}function T(L,w,E){w.forEach(function(u){O(L,u)}),L.postMessage({event:"flush",data:E})}function R(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return s}),k.d(Y,"isPromise",function(){return p}),k.d(Y,"TransmuxConfig",function(){return f}),k.d(Y,"TransmuxState",function(){return C});var V=k("./src/events.ts"),I=k("./src/errors.ts"),D=k("./src/crypt/decrypter.ts"),j=k("./src/demux/aacdemuxer.ts"),F=k("./src/demux/mp4demuxer.ts"),P=k("./src/demux/tsdemuxer.ts"),O=k("./src/demux/mp3demuxer.ts"),g=k("./src/remux/mp4-remuxer.ts"),T=k("./src/remux/passthrough-remuxer.ts"),R=k("./src/demux/chunk-cache.ts"),L=k("./src/utils/mp4-tools.ts"),w=k("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch(v){w.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var u=[{demux:P.default,remux:g.default},{demux:F.default,remux:T.default},{demux:j.default,remux:g.default},{demux:O.default,remux:g.default}],o=1024;u.forEach(function(v){var d=v.demux;o=Math.max(o,d.minProbeByteLength)});var s=function(){function v(c,h,a,y,m){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new R.default,this.observer=c,this.typeSupported=h,this.config=a,this.vendor=y,this.id=m}var d=v.prototype;return d.configure=function(h){this.transmuxConfig=h,this.decrypter&&this.decrypter.reset()},d.push=function(h,a,y,m){var x=this,M=y.transmuxing;M.executeStart=E();var G=new Uint8Array(h),$=this.cache,re=this.config,z=this.currentTransmuxState,U=this.transmuxConfig;m&&(this.currentTransmuxState=m);var ne=l(G,a);if(ne&&ne.method==="AES-128"){var fe=this.getDecrypter();if(re.enableSoftwareAES){var ge=fe.softwareDecrypt(G,ne.key.buffer,ne.iv.buffer);if(!ge)return M.executeEnd=E(),S(y);G=new Uint8Array(ge)}else return this.decryptionPromise=fe.webCryptoDecrypt(G,ne.key.buffer,ne.iv.buffer).then(function(Ee){var Le=x.push(Ee,null,y);return x.decryptionPromise=null,Le}),this.decryptionPromise}var be=m||z,Me=be.contiguous,Te=be.discontinuity,De=be.trackSwitch,Ce=be.accurateTimeOffset,we=be.timeOffset,ve=U.audioCodec,W=U.videoCodec,A=U.defaultInitPts,_=U.duration,H=U.initSegmentData;if((Te||De)&&this.resetInitSegment(H,ve,W,_),Te&&this.resetInitialTimestamp(A),Me||this.resetContiguity(),this.needsProbing(G,Te,De)){if($.dataLength){var q=$.flush();G=Object(L.appendUint8Array)(q,G)}this.configureTransmuxer(G,U)}var B=this.transmux(G,ne,we,Ce,y),de=this.currentTransmuxState;return de.contiguous=!0,de.discontinuity=!1,de.trackSwitch=!1,M.executeEnd=E(),B},d.flush=function(h){var a=this,y=h.transmuxing;y.executeStart=E();var m=this.decrypter,x=this.cache,M=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(h)});var $=[],re=M.timeOffset;if(m){var z=m.flush();z&&$.push(this.push(z,null,h))}var U=x.dataLength;x.reset();var ne=this.demuxer,fe=this.remuxer;if(!ne||!fe)return U>=o&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),y.executeEnd=E(),[S(h)];var ge=ne.flush(re);return p(ge)?ge.then(function(be){return a.flushRemux($,be,h),$}):(this.flushRemux($,ge,h),$)},d.flushRemux=function(h,a,y){var m=a.audioTrack,x=a.avcTrack,M=a.id3Track,G=a.textTrack,$=this.currentTransmuxState,re=$.accurateTimeOffset,z=$.timeOffset;w.logger.log("[transmuxer.ts]: Flushed fragment "+y.sn+(y.part>-1?" p: "+y.part:"")+" of level "+y.level);var U=this.remuxer.remux(m,x,M,G,z,re,!0,this.id);h.push({remuxResult:U,chunkMeta:y}),y.transmuxing.executeEnd=E()},d.resetInitialTimestamp=function(h){var a=this.demuxer,y=this.remuxer;if(!a||!y)return;a.resetTimeStamp(h),y.resetTimeStamp(h)},d.resetContiguity=function(){var h=this.demuxer,a=this.remuxer;if(!h||!a)return;h.resetContiguity(),a.resetNextTimestamp()},d.resetInitSegment=function(h,a,y,m){var x=this.demuxer,M=this.remuxer;if(!x||!M)return;x.resetInitSegment(a,y,m),M.resetInitSegment(h,a,y)},d.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},d.transmux=function(h,a,y,m,x){var M;return a&&a.method==="SAMPLE-AES"?M=this.transmuxSampleAes(h,a,y,m,x):M=this.transmuxUnencrypted(h,y,m,x),M},d.transmuxUnencrypted=function(h,a,y,m){var x=this.demuxer.demux(h,a,!1,!this.config.progressive),M=x.audioTrack,G=x.avcTrack,$=x.id3Track,re=x.textTrack,z=this.remuxer.remux(M,G,$,re,a,y,!1,this.id);return{remuxResult:z,chunkMeta:m}},d.transmuxSampleAes=function(h,a,y,m,x){var M=this;return this.demuxer.demuxSampleAes(h,a,y).then(function(G){var $=M.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,y,m,!1,M.id);return{remuxResult:$,chunkMeta:x}})},d.configureTransmuxer=function(h,a){for(var y=this.config,m=this.observer,x=this.typeSupported,M=this.vendor,G=a.audioCodec,$=a.defaultInitPts,re=a.duration,z=a.initSegmentData,U=a.videoCodec,ne,fe=0,ge=u.length;fe<ge;fe++)if(u[fe].demux.probe(h)){ne=u[fe];break}ne||(w.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ne={demux:F.default,remux:T.default});var be=this.demuxer,Me=this.remuxer,Te=ne.remux,De=ne.demux;(!Me||!(Me instanceof Te))&&(this.remuxer=new Te(m,y,x,M)),(!be||!(be instanceof De))&&(this.demuxer=new De(m,y,x),this.probe=De.probe),this.resetInitSegment(z,G,U,re),this.resetInitialTimestamp($)},d.needsProbing=function(h,a,y){return!this.demuxer||!this.remuxer||a||y},d.getDecrypter=function(){var h=this.decrypter;return h||(h=this.decrypter=new D.default(this.observer,this.config)),h},v}();function l(v,d){var c=null;return v.byteLength>0&&d!=null&&d.key!=null&&d.iv!==null&&d.method!=null&&(c=d),c}var S=function(d){return{remuxResult:{},chunkMeta:d}};function p(v){return"then"in v&&v.then instanceof Function}var f=function(d,c,h,a,y){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=d,this.videoCodec=c,this.initSegmentData=h,this.duration=a,this.defaultInitPts=y},C=function(d,c,h,a,y){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=d,this.contiguous=c,this.accurateTimeOffset=h,this.trackSwitch=a,this.timeOffset=y}},"./src/demux/tsdemuxer.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"discardEPB",function(){return S});var V=k("./src/demux/adts.ts"),I=k("./src/demux/mpegaudio.ts"),D=k("./src/demux/exp-golomb.ts"),j=k("./src/demux/id3.ts"),F=k("./src/demux/sample-aes.ts"),P=k("./src/events.ts"),O=k("./src/utils/mp4-tools.ts"),g=k("./src/utils/logger.ts"),T=k("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},L=function(){function p(C,v,d){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=C,this.config=v,this.typeSupported=d}p.probe=function(v){var d=p.syncOffset(v);return d<0?!1:(d&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+d+", junk ahead ?"),!0)},p.syncOffset=function(v){for(var d=Math.min(1e3,v.length-3*188),c=0;c<d;){if(v[c]===71&&v[c+188]===71&&v[c+2*188]===71)return c;c++}return-1},p.createTrack=function(v,d){return{container:v==="video"||v==="audio"?"video/mp2t":void 0,type:v,id:R[v],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:v==="audio"?d:void 0}};var f=p.prototype;return f.resetInitSegment=function(v,d,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=p.createTrack("video",c),this._audioTrack=p.createTrack("audio",c),this._id3Track=p.createTrack("id3",c),this._txtTrack=p.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=v,this.videoCodec=d,this._duration=c},f.resetTimeStamp=function(){},f.resetContiguity=function(){var v=this._audioTrack,d=this._avcTrack,c=this._id3Track;v&&(v.pesData=null),d&&(d.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},f.demux=function(v,d,c,h){c===void 0&&(c=!1),h===void 0&&(h=!1),c||(this.sampleAes=null);var a,y=this._avcTrack,m=this._audioTrack,x=this._id3Track,M=y.pid,G=y.pesData,$=m.pid,re=x.pid,z=m.pesData,U=x.pesData,ne=!1,fe=this.pmtParsed,ge=this._pmtId,be=v.length;if(this.remainderData&&(v=Object(O.appendUint8Array)(this.remainderData,v),be=v.length,this.remainderData=null),be<188&&!h)return this.remainderData=v,{audioTrack:m,avcTrack:y,id3Track:x,textTrack:this._txtTrack};var Me=Math.max(0,p.syncOffset(v));be-=(be+Me)%188,be<v.byteLength&&!h&&(this.remainderData=new Uint8Array(v.buffer,be,v.buffer.byteLength-be));for(var Te=Me;Te<be;Te+=188)if(v[Te]===71){var De=!!(v[Te+1]&64),Ce=((v[Te+1]&31)<<8)+v[Te+2],we=(v[Te+3]&48)>>4,ve=void 0;if(we>1){if(ve=Te+5+v[Te+4],ve===Te+188)continue}else ve=Te+4;switch(Ce){case M:De&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(v.subarray(ve,Te+188)),G.size+=Te+188-ve);break;case $:De&&(z&&(a=o(z))&&(m.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(v.subarray(ve,Te+188)),z.size+=Te+188-ve);break;case re:De&&(U&&(a=o(U))&&this.parseID3PES(a),U={data:[],size:0}),U&&(U.data.push(v.subarray(ve,Te+188)),U.size+=Te+188-ve);break;case 0:De&&(ve+=v[ve]+1),ge=this._pmtId=E(v,ve);break;case ge:{De&&(ve+=v[ve]+1);var W=u(v,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);M=W.avc,M>0&&(y.pid=M),$=W.audio,$>0&&(m.pid=$,m.isAAC=W.isAAC),re=W.id3,re>0&&(x.pid=re),ne&&!fe&&(g.logger.log("reparse from beginning"),ne=!1,Te=Me-188),fe=this.pmtParsed=!0;break}case 17:case 8191:break;default:ne=!0;break}}else this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});y.pesData=G,m.pesData=z,x.pesData=U;var A={audioTrack:m,avcTrack:y,id3Track:x,textTrack:this._txtTrack};return h&&this.extractRemainingSamples(A),A},f.flush=function(){var v=this.remainderData;this.remainderData=null;var d;return v?d=this.demux(v,-1,!1,!0):d={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},f.extractRemainingSamples=function(v){var d=v.audioTrack,c=v.avcTrack,h=v.id3Track,a=c.pesData,y=d.pesData,m=h.pesData,x;a&&(x=o(a))?(this.parseAVCPES(x,!0),c.pesData=null):c.pesData=a,y&&(x=o(y))?(d.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),d.pesData=null):(y!=null&&y.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=y),m&&(x=o(m))?(this.parseID3PES(x),h.pesData=null):h.pesData=m},f.demuxSampleAes=function(v,d,c){var h=this.demux(v,c,!0,!this.config.progressive),a=this.sampleAes=new F.default(this.observer,this.config,d);return this.decrypt(h,a)},f.decrypt=function(v,d){return new Promise(function(c){var h=v.audioTrack,a=v.avcTrack;h.samples&&h.isAAC?d.decryptAacSamples(h.samples,0,function(){a.samples?d.decryptAvcSamples(a.samples,0,0,function(){c(v)}):c(v)}):a.samples&&d.decryptAvcSamples(a.samples,0,0,function(){c(v)})})},f.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},f.parseAVCPES=function(v,d){var c=this,h=this._avcTrack,a=this.parseAVCNALu(v.data),y=!1,m=this.avcSample,x,M=!1;v.data=null,m&&a.length&&!h.audFound&&(s(m,h),m=this.avcSample=w(!1,v.pts,v.dts,"")),a.forEach(function(G){switch(G.type){case 1:{x=!0,m||(m=c.avcSample=w(!0,v.pts,v.dts,"")),y&&(m.debug+="NDR "),m.frame=!0;var $=G.data;if(M&&$.length>4){var re=new D.default($).readSliceType();(re===2||re===4||re===7||re===9)&&(m.key=!0)}break}case 5:x=!0,m||(m=c.avcSample=w(!0,v.pts,v.dts,"")),y&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{x=!0,y&&m&&(m.debug+="SEI ");var z=new D.default(S(G.data));z.readUByte();for(var U=0,ne=0,fe=!1,ge=0;!fe&&z.bytesAvailable>1;){U=0;do ge=z.readUByte(),U+=ge;while(ge===255);ne=0;do ge=z.readUByte(),ne+=ge;while(ge===255);if(U===4&&z.bytesAvailable!==0){fe=!0;var be=z.readUByte();if(be===181){var Me=z.readUShort();if(Me===49){var Te=z.readUInt();if(Te===1195456820){var De=z.readUByte();if(De===3){for(var Ce=z.readUByte(),we=z.readUByte(),ve=31&Ce,W=[Ce,we],A=0;A<ve;A++)W.push(z.readUByte()),W.push(z.readUByte()),W.push(z.readUByte());l(c._txtTrack.samples,{type:3,pts:v.pts,bytes:W})}}}}}else if(U===5&&z.bytesAvailable!==0){if(fe=!0,ne>16){for(var _=[],H=0;H<16;H++)_.push(z.readUByte().toString(16)),(H===3||H===5||H===7||H===9)&&_.push("-");for(var q=ne-16,B=new Uint8Array(q),de=0;de<q;de++)B[de]=z.readUByte();l(c._txtTrack.samples,{pts:v.pts,payloadType:U,uuid:_.join(""),userData:Object(j.utf8ArrayToStr)(B),userDataBytes:B})}}else if(ne<z.bytesAvailable)for(var Ee=0;Ee<ne;Ee++)z.readUByte()}break}case 7:if(x=!0,M=!0,y&&m&&(m.debug+="SPS "),!h.sps){var Le=new D.default(G.data),Ie=Le.readSPS();h.width=Ie.width,h.height=Ie.height,h.pixelRatio=Ie.pixelRatio,h.sps=[G.data],h.duration=c._duration;for(var ke=G.data.subarray(1,4),Oe="avc1.",Pe=0;Pe<3;Pe++){var We=ke[Pe].toString(16);We.length<2&&(We="0"+We),Oe+=We}h.codec=Oe}break;case 8:x=!0,y&&m&&(m.debug+="PPS "),h.pps||(h.pps=[G.data]);break;case 9:x=!1,h.audFound=!0,m&&s(m,h),m=c.avcSample=w(!1,v.pts,v.dts,y?"AUD ":"");break;case 12:x=!1;break;default:x=!1,m&&(m.debug+="unknown NAL "+G.type+" ");break}if(m&&x){var He=m.units;He.push(G)}}),d&&m&&(s(m,h),this.avcSample=null)},f.getLastNalUnit=function(){var v,d=this.avcSample,c;if(!d||d.units.length===0){var h=this._avcTrack.samples;d=h[h.length-1]}if((v=d)!==null&&v!==void 0&&v.units){var a=d.units;c=a[a.length-1]}return c},f.parseAVCNALu=function(v){var d=v.byteLength,c=this._avcTrack,h=c.naluState||0,a=h,y=[],m=0,x,M,G,$=-1,re=0;for(h===-1&&($=0,re=v[0]&31,h=0,m=1);m<d;){if(x=v[m++],!h){h=x?0:1;continue}if(h===1){h=x?0:2;continue}if(!x)h=3;else if(x===1){if($>=0){var z={data:v.subarray($,m-h-1),type:re};y.push(z)}else{var U=this.getLastNalUnit();if(U&&(a&&m<=4-a&&(U.state&&(U.data=U.data.subarray(0,U.data.byteLength-a))),M=m-h-1,M>0)){var ne=new Uint8Array(U.data.byteLength+M);ne.set(U.data,0),ne.set(v.subarray(0,M),U.data.byteLength),U.data=ne,U.state=0}}m<d?(G=v[m]&31,$=m,re=G,h=0):h=-1}else h=0}if($>=0&&h>=0){var fe={data:v.subarray($,d),type:re,state:h};y.push(fe)}if(y.length===0){var ge=this.getLastNalUnit();if(ge){var be=new Uint8Array(ge.data.byteLength+v.byteLength);be.set(ge.data,0),be.set(v,ge.data.byteLength),ge.data=be}}return c.naluState=h,y},f.parseAACPES=function(v){var d=0,c=this._audioTrack,h=this.aacOverFlow,a=v.data;if(h){this.aacOverFlow=null;var y=h.sample.unit.byteLength,m=Math.min(h.missing,y),x=y-m;h.sample.unit.set(a.subarray(0,m),x),c.samples.push(h.sample),d=h.missing}var M,G;for(M=d,G=a.length;M<G-1&&!V.isHeader(a,M);M++);if(M!==d){var $,re;if(M<G-1?($="AAC PES did not start with ADTS header,offset:"+M,re=!1):($="no ADTS header found in AAC PES",re=!0),g.logger.warn("parsing error:"+$),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:re,reason:$}),re)return}V.initTrackConfig(c,this.observer,a,M,this.audioCodec);var z;if(v.pts!==void 0)z=v.pts;else if(h){var U=V.getFrameDuration(c.samplerate);z=h.sample.pts+U}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ne=0;M<G;)if(V.isHeader(a,M)){if(M+5<G){var fe=V.appendFrame(c,a,M,z,ne);if(fe)if(fe.missing)this.aacOverFlow=fe;else{M+=fe.length,ne++;continue}}break}else M++},f.parseMPEGPES=function(v){var d=v.data,c=d.length,h=0,a=0,y=v.pts;if(y===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(I.isHeader(d,a)){var m=I.appendFrame(this._audioTrack,d,a,y,h);if(m)a+=m.length,h++;else break}else a++},f.parseID3PES=function(v){if(v.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(v)},p}();L.minProbeByteLength=188;function w(p,f,C,v){return{key:p,frame:!1,pts:f,dts:C,units:[],debug:v,length:0}}function E(p,f){return(p[f+10]&31)<<8|p[f+11]}function u(p,f,C,v){var d={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(p[f+1]&15)<<8|p[f+2],h=f+3+c-4,a=(p[f+10]&15)<<8|p[f+11];for(f+=12+a;f<h;){var y=(p[f+1]&31)<<8|p[f+2];switch(p[f]){case 207:if(!v){g.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=y);break;case 21:d.id3===-1&&(d.id3=y);break;case 219:if(!v){g.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=y);break;case 3:case 4:C?d.audio===-1&&(d.audio=y,d.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser");break;case 36:g.logger.warn("Unsupported HEVC stream type found");break;default:break}f+=((p[f+3]&15)<<8|p[f+4])+5}return d}function o(p){var f=0,C,v,d,c,h,a=p.data;if(!p||p.size===0)return null;for(;a[0].length<19&&a.length>1;){var y=new Uint8Array(a[0].length+a[1].length);y.set(a[0]),y.set(a[1],a[0].length),a[0]=y,a.splice(1,1)}C=a[0];var m=(C[0]<<16)+(C[1]<<8)+C[2];if(m===1){if(v=(C[4]<<8)+C[5],v&&v>p.size-6)return null;var x=C[7];x&192&&(c=(C[9]&14)*536870912+(C[10]&255)*4194304+(C[11]&254)*16384+(C[12]&255)*128+(C[13]&254)/2,x&64?(h=(C[14]&14)*536870912+(C[15]&255)*4194304+(C[16]&254)*16384+(C[17]&255)*128+(C[18]&254)/2,c-h>60*9e4&&(g.logger.warn(Math.round((c-h)/9e4)+"s delta between PTS and DTS, align them"),c=h)):h=c),d=C[8];var M=d+9;if(p.size<=M)return null;p.size-=M;for(var G=new Uint8Array(p.size),$=0,re=a.length;$<re;$++){C=a[$];var z=C.byteLength;if(M)if(M>z){M-=z;continue}else C=C.subarray(M),z-=M,M=0;G.set(C,f),f+=z}return v&&(v-=d+3),{data:G,pts:c,dts:h,len:v}}return null}function s(p,f){if(p.units.length&&p.frame){if(p.pts===void 0){var C=f.samples,v=C.length;if(v){var d=C[v-1];p.pts=d.pts,p.dts=d.dts}else{f.dropped++;return}}f.samples.push(p)}p.debug.length&&g.logger.log(p.pts+"/"+p.dts+":"+p.debug)}function l(p,f){var C=p.length;if(C>0){if(f.pts>=p[C-1].pts)p.push(f);else for(var v=C-1;v>=0;v--)if(f.pts<p[v].pts){p.splice(v,0,f);break}}else p.push(f)}function S(p){for(var f=p.byteLength,C=[],v=1;v<f-2;)p[v]===0&&p[v+1]===0&&p[v+2]===3?(C.push(v+2),v+=2):v++;if(C.length===0)return p;var d=f-C.length,c=new Uint8Array(d),h=0;for(v=0;v<d;h++,v++)h===C[0]&&(h++,C.shift()),c[v]=p[h];return c}Y.default=L},"./src/errors.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"ErrorTypes",function(){return V}),k.d(Y,"ErrorDetails",function(){return I});var V;(function(D){D.NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError"})(V||(V={}));var I;(function(D){D.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"Events",function(){return V});var V;(function(I){I.MEDIA_ATTACHING="hlsMediaAttaching",I.MEDIA_ATTACHED="hlsMediaAttached",I.MEDIA_DETACHING="hlsMediaDetaching",I.MEDIA_DETACHED="hlsMediaDetached",I.BUFFER_RESET="hlsBufferReset",I.BUFFER_CODECS="hlsBufferCodecs",I.BUFFER_CREATED="hlsBufferCreated",I.BUFFER_APPENDING="hlsBufferAppending",I.BUFFER_APPENDED="hlsBufferAppended",I.BUFFER_EOS="hlsBufferEos",I.BUFFER_FLUSHING="hlsBufferFlushing",I.BUFFER_FLUSHED="hlsBufferFlushed",I.MANIFEST_LOADING="hlsManifestLoading",I.MANIFEST_LOADED="hlsManifestLoaded",I.MANIFEST_PARSED="hlsManifestParsed",I.LEVEL_SWITCHING="hlsLevelSwitching",I.LEVEL_SWITCHED="hlsLevelSwitched",I.LEVEL_LOADING="hlsLevelLoading",I.LEVEL_LOADED="hlsLevelLoaded",I.LEVEL_UPDATED="hlsLevelUpdated",I.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",I.LEVELS_UPDATED="hlsLevelsUpdated",I.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",I.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",I.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",I.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",I.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",I.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",I.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",I.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",I.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",I.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",I.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",I.CUES_PARSED="hlsCuesParsed",I.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",I.INIT_PTS_FOUND="hlsInitPtsFound",I.FRAG_LOADING="hlsFragLoading",I.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",I.FRAG_LOADED="hlsFragLoaded",I.FRAG_DECRYPTED="hlsFragDecrypted",I.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",I.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",I.FRAG_PARSING_METADATA="hlsFragParsingMetadata",I.FRAG_PARSED="hlsFragParsed",I.FRAG_BUFFERED="hlsFragBuffered",I.FRAG_CHANGED="hlsFragChanged",I.FPS_DROP="hlsFpsDrop",I.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",I.ERROR="hlsError",I.DESTROYING="hlsDestroying",I.KEY_LOADING="hlsKeyLoading",I.KEY_LOADED="hlsKeyLoaded",I.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",I.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return p});var V=k("./node_modules/url-toolkit/src/url-toolkit.js"),I=k.n(V),D=k("./src/loader/playlist-loader.ts"),j=k("./src/loader/key-loader.ts"),F=k("./src/controller/id3-track-controller.ts"),P=k("./src/controller/latency-controller.ts"),O=k("./src/controller/level-controller.ts"),g=k("./src/controller/fragment-tracker.ts"),T=k("./src/controller/stream-controller.ts"),R=k("./src/is-supported.ts"),L=k("./src/utils/logger.ts"),w=k("./src/config.ts"),E=k("./node_modules/eventemitter3/index.js"),u=k.n(E),o=k("./src/events.ts"),s=k("./src/errors.ts");function l(f,C){for(var v=0;v<C.length;v++){var d=C[v];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,d.key,d)}}function S(f,C,v){return C&&l(f.prototype,C),v&&l(f,v),f}var p=function(){f.isSupported=function(){return Object(R.isSupported)()};function f(v){v===void 0&&(v={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var d=this.config=Object(w.mergeConfig)(f.DefaultConfig,v);this.userConfig=v,Object(L.enableLogs)(d.debug),this._autoLevelCapping=-1,d.progressive&&Object(w.enableStreamingMode)(d);var c=d.abrController,h=d.bufferController,a=d.capLevelController,y=d.fpsController,m=this.abrController=new c(this),x=this.bufferController=new h(this),M=this.capLevelController=new a(this),G=new y(this),$=new D.default(this),re=new j.default(this),z=new F.default(this),U=this.levelController=new O.default(this),ne=new g.FragmentTracker(this),fe=this.streamController=new T.default(this,ne);M.setStreamController(fe),G.setStreamController(fe);var ge=[U,fe];this.networkControllers=ge;var be=[$,re,m,x,M,G,z,ne];this.audioTrackController=this.createController(d.audioTrackController,null,ge),this.createController(d.audioStreamController,ne,ge),this.subtitleTrackController=this.createController(d.subtitleTrackController,null,ge),this.createController(d.subtitleStreamController,ne,ge),this.createController(d.timelineController,null,be),this.emeController=this.createController(d.emeController,null,be),this.cmcdController=this.createController(d.cmcdController,null,be),this.latencyController=this.createController(P.default,null,be),this.coreComponents=be}var C=f.prototype;return C.createController=function(d,c,h){if(d){var a=c?new d(this,c):new d(this);return h&&h.push(a),a}return null},C.on=function(d,c,h){h===void 0&&(h=this),this._emitter.on(d,c,h)},C.once=function(d,c,h){h===void 0&&(h=this),this._emitter.once(d,c,h)},C.removeAllListeners=function(d){this._emitter.removeAllListeners(d)},C.off=function(d,c,h,a){h===void 0&&(h=this),this._emitter.off(d,c,h,a)},C.listeners=function(d){return this._emitter.listeners(d)},C.emit=function(d,c,h){return this._emitter.emit(d,c,h)},C.trigger=function(d,c){if(this.config.debug)return this.emit(d,d,c);try{return this.emit(d,d,c)}catch(h){L.logger.error("An internal error happened while handling event "+d+'. Error message: "'+h.message+'". Here is a stacktrace:',h),this.trigger(o.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:d,error:h})}return!1},C.listenerCount=function(d){return this._emitter.listenerCount(d)},C.destroy=function(){L.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(d){return d.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(d){return d.destroy()}),this.coreComponents.length=0},C.attachMedia=function(d){L.logger.log("attachMedia"),this._media=d,this.trigger(o.Events.MEDIA_ATTACHING,{media:d})},C.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},C.loadSource=function(d){this.stopLoad();var c=this.media,h=this.url,a=this.url=V.buildAbsoluteURL(self.location.href,d,{alwaysNormalize:!0});L.logger.log("loadSource:"+a),c&&h&&h!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:d})},C.startLoad=function(d){d===void 0&&(d=-1),L.logger.log("startLoad("+d+")"),this.networkControllers.forEach(function(c){c.startLoad(d)})},C.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(d){d.stopLoad()})},C.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},C.recoverMediaError=function(){L.logger.log("recoverMediaError");var d=this._media;this.detachMedia(),d&&this.attachMedia(d)},C.removeLevel=function(d,c){c===void 0&&(c=0),this.levelController.removeLevel(d,c)},S(f,[{key:"levels",get:function(){var d=this.levelController.levels;return d||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(d){L.logger.log("set currentLevel:"+d),this.loadLevel=d,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(d){L.logger.log("set nextLevel:"+d),this.levelController.manualLevel=d,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(d){L.logger.log("set loadLevel:"+d),this.levelController.manualLevel=d}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(d){this.levelController.nextLoadLevel=d}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(d){L.logger.log("set firstLevel:"+d),this.levelController.firstLevel=d}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(d){L.logger.log("set startLevel:"+d),d!==-1&&(d=Math.max(d,this.minAutoLevel)),this.levelController.startLevel=d}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(d){var c=!!d;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(d){this._autoLevelCapping!==d&&(L.logger.log("set autoLevelCapping:"+d),this._autoLevelCapping=d)}},{key:"bandwidthEstimate",get:function(){var d=this.abrController.bwEstimator;return d?d.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var d=this.levels,c=this.config.minAutoBitrate;if(!d)return 0;for(var h=d.length,a=0;a<h;a++)if(d[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var d=this.levels,c=this.autoLevelCapping,h;return c===-1&&d&&d.length?h=d.length-1:h=c,h}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(d){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,d)}},{key:"audioTracks",get:function(){var d=this.audioTrackController;return d?d.audioTracks:[]}},{key:"audioTrack",get:function(){var d=this.audioTrackController;return d?d.audioTrack:-1},set:function(d){var c=this.audioTrackController;c&&(c.audioTrack=d)}},{key:"subtitleTracks",get:function(){var d=this.subtitleTrackController;return d?d.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var d=this.subtitleTrackController;return d?d.subtitleTrack:-1},set:function(d){var c=this.subtitleTrackController;c&&(c.subtitleTrack=d)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var d=this.subtitleTrackController;return d?d.subtitleDisplay:!1},set:function(d){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=d)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(d){this.config.lowLatencyMode=d}},{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 s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return f.defaultConfig?f.defaultConfig:w.hlsDefaultConfig},set:function(d){f.defaultConfig=d}}]),f}();p.defaultConfig=void 0},"./src/is-supported.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"isSupported",function(){return D}),k.d(Y,"changeTypeSupported",function(){return j});var V=k("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var F=Object(V.getMediaSource)();if(!F)return!1;var P=I(),O=F&&typeof F.isTypeSupported=="function"&&F.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!O&&!!g}function j(){var F,P=I();return typeof(P==null||((F=P.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return L}),k.d(Y,"LoadError",function(){return E});var V=k("./src/polyfills/number.ts"),I=k("./src/errors.ts");function D(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,g(u,o)}function j(u){var o=typeof Map=="function"?new Map:void 0;return j=function(l){if(l===null||!O(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(l))return o.get(l);o.set(l,S)}function S(){return F(l,arguments,T(this).constructor)}return S.prototype=Object.create(l.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),g(S,l)},j(u)}function F(u,o,s){return P()?F=Reflect.construct:F=function(S,p,f){var C=[null];C.push.apply(C,p);var v=Function.bind.apply(S,C),d=new v;return f&&g(d,f.prototype),d},F.apply(null,arguments)}function P(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(u){return!1}}function O(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function g(u,o){return g=Object.setPrototypeOf||function(l,S){return l.__proto__=S,l},g(u,o)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},T(u)}var R=Math.pow(2,17),L=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var o=u.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(l,S){var p=this,f=l.url;if(!f)return Promise.reject(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,networkDetails:null},"Fragment does not have a "+(f?"part list":"url")));this.abort();var C=this.config,v=C.fLoader,d=C.loader;return new Promise(function(c,h){p.loader&&p.loader.destroy();var a=p.loader=l.loader=v?new v(C):new d(C),y=w(l),m={timeout:C.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:C.fragLoadingMaxRetryTimeout,highWaterMark:R};l.stats=a.stats,a.load(y,m,{onSuccess:function(M,G,$,re){p.resetLoader(l,a),c({frag:l,part:null,payload:M.data,networkDetails:re})},onError:function(M,G,$){p.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,response:M,networkDetails:$}))},onAbort:function(M,G,$){p.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,networkDetails:$}))},onTimeout:function(M,G,$){p.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,networkDetails:$}))},onProgress:function(M,G,$,re){S&&S({frag:l,part:null,payload:$,networkDetails:re})}})})},o.loadPart=function(l,S,p){var f=this;this.abort();var C=this.config,v=C.fLoader,d=C.loader;return new Promise(function(c,h){f.loader&&f.loader.destroy();var a=f.loader=l.loader=v?new v(C):new d(C),y=w(l,S),m={timeout:C.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:C.fragLoadingMaxRetryTimeout,highWaterMark:R};S.stats=a.stats,a.load(y,m,{onSuccess:function(M,G,$,re){f.resetLoader(l,a),f.updateStatsFromPart(l,S);var z={frag:l,part:S,payload:M.data,networkDetails:re};p(z),c(z)},onError:function(M,G,$){f.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:S,response:M,networkDetails:$}))},onAbort:function(M,G,$){l.stats.aborted=S.stats.aborted,f.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,part:S,networkDetails:$}))},onTimeout:function(M,G,$){f.resetLoader(l,a),h(new E({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:S,networkDetails:$}))}})})},o.updateStatsFromPart=function(l,S){var p=l.stats,f=S.stats,C=f.total;if(p.loaded+=f.loaded,C){var v=Math.round(l.duration/S.duration),d=Math.min(Math.round(p.loaded/C),v),c=v-d,h=c*Math.round(p.loaded/d);p.total=p.loaded+h}else p.total=Math.max(p.loaded,p.total);var a=p.loading,y=f.loading;a.start?a.first+=y.first-y.start:(a.start=y.start,a.first=y.first),a.end=y.end},o.resetLoader=function(l,S){l.loader=null,this.loader===S&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),S.destroy()},u}();function w(u,o){o===void 0&&(o=null);var s=o||u,l={frag:u,part:o,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},S=s.byteRangeStartOffset,p=s.byteRangeEndOffset;return Object(V.isFiniteNumber)(S)&&Object(V.isFiniteNumber)(p)&&(l.rangeStart=S,l.rangeEnd=p),l}var E=function(u){D(o,u);function o(s){for(var l,S=arguments.length,p=new Array(S>1?S-1:0),f=1;f<S;f++)p[f-1]=arguments[f];return l=u.call.apply(u,[this].concat(p))||this,l.data=void 0,l.data=s,l}return o}(j(Error))},"./src/loader/fragment.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"ElementaryStreamTypes",function(){return L}),k.d(Y,"BaseSegment",function(){return w}),k.d(Y,"Fragment",function(){return E}),k.d(Y,"Part",function(){return u});var V=k("./src/polyfills/number.ts"),I=k("./node_modules/url-toolkit/src/url-toolkit.js"),D=k.n(I),j=k("./src/utils/logger.ts"),F=k("./src/loader/level-key.ts"),P=k("./src/loader/load-stats.ts");function O(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,g(o,s)}function g(o,s){return g=Object.setPrototypeOf||function(S,p){return S.__proto__=p,S},g(o,s)}function T(o,s){for(var l=0;l<s.length;l++){var S=s[l];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(o,S.key,S)}}function R(o,s,l){return s&&T(o.prototype,s),l&&T(o,l),o}var L;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(L||(L={}));var w=function(){function o(l){var S;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(S={},S[L.AUDIO]=null,S[L.VIDEO]=null,S[L.AUDIOVIDEO]=null,S),this.baseurl=l}var s=o.prototype;return s.setByteRange=function(S,p){var f=S.split("@",2),C=[];f.length===1?C[0]=p?p.byteRangeEndOffset:0:C[0]=parseInt(f[1]),C[1]=parseInt(f[0])+C[0],this._byteRange=C},R(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(I.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(S){this._url=S}}]),o}(),E=function(o){O(s,o);function s(S,p){var f;return f=o.call(this,p)||this,f._decryptdata=null,f.rawProgramDateTime=null,f.programDateTime=null,f.tagList=[],f.duration=0,f.sn=0,f.levelkey=void 0,f.type=void 0,f.loader=null,f.level=-1,f.cc=0,f.startPTS=void 0,f.endPTS=void 0,f.appendedPTS=void 0,f.startDTS=void 0,f.endDTS=void 0,f.start=0,f.deltaPTS=void 0,f.maxStartPTS=void 0,f.minEndPTS=void 0,f.stats=new P.LoadStats,f.urlId=0,f.data=void 0,f.bitrateTest=!1,f.title=null,f.initSegment=null,f.type=S,f}var l=s.prototype;return l.createInitializationVector=function(p){for(var f=new Uint8Array(16),C=12;C<16;C++)f[C]=p>>8*(15-C)&255;return f},l.setDecryptDataFromLevelKey=function(p,f){var C=p;return(p==null?void 0:p.method)==="AES-128"&&p.uri&&!p.iv&&(C=F.LevelKey.fromURI(p.uri),C.method=p.method,C.iv=this.createInitializationVector(f),C.keyFormat="identity"),C},l.setElementaryStreamInfo=function(p,f,C,v,d,c){c===void 0&&(c=!1);var h=this.elementaryStreams,a=h[p];if(!a){h[p]={startPTS:f,endPTS:C,startDTS:v,endDTS:d,partial:c};return}a.startPTS=Math.min(a.startPTS,f),a.endPTS=Math.max(a.endPTS,C),a.startDTS=Math.min(a.startDTS,v),a.endDTS=Math.max(a.endDTS,d)},l.clearElementaryStreamInfo=function(){var p=this.elementaryStreams;p[L.AUDIO]=null,p[L.VIDEO]=null,p[L.AUDIOVIDEO]=null},R(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var p=this.sn;typeof p!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&j.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),p=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,p)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(V.isFiniteNumber)(this.programDateTime))return null;var p=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+p*1e3}},{key:"encrypted",get:function(){var p;return!!((p=this.decryptdata)!==null&&p!==void 0&&p.keyFormat&&this.decryptdata.uri)}}]),s}(w),u=function(o){O(s,o);function s(l,S,p,f,C){var v;v=o.call(this,p)||this,v.fragOffset=0,v.duration=0,v.gap=!1,v.independent=!1,v.relurl=void 0,v.fragment=void 0,v.index=void 0,v.stats=new P.LoadStats,v.duration=l.decimalFloatingPoint("DURATION"),v.gap=l.bool("GAP"),v.independent=l.bool("INDEPENDENT"),v.relurl=l.enumeratedString("URI"),v.fragment=S,v.index=f;var d=l.enumeratedString("BYTERANGE");return d&&v.setByteRange(d,C),C&&(v.fragOffset=C.fragOffset+C.duration),v}return R(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var S=this.elementaryStreams;return!!(S.audio||S.video||S.audiovideo)}}]),s}(w)},"./src/loader/key-loader.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return j});var V=k("./src/events.ts"),I=k("./src/errors.ts"),D=k("./src/utils/logger.ts"),j=function(){function F(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var P=F.prototype;return P._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},P.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var T=this.loaders[g];T&&T.destroy()}this.loaders={}},P.onKeyLoading=function(g,T){var R=T.frag,L=R.type,w=this.loaders[L];if(!R.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=R.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(w&&(D.logger.warn("abort previous key loader for type:"+L),w.abort()),!E){D.logger.warn("key uri is falsy");return}var o=u.loader,s=R.loader=this.loaders[L]=new o(u);this.decrypturl=E,this.decryptkey=null;var l={url:E,frag:R,responseType:"arraybuffer"},S={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(l,S,p)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:R}))},P.loadsuccess=function(g,T,R){var L=R.frag;if(!L.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(g.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:L})},P.loaderror=function(g,T){var R=T.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:g})},P.loadtimeout=function(g,T){var R=T.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},F}()},"./src/loader/level-details.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"LevelDetails",function(){return F});var V=k("./src/polyfills/number.ts");function I(P,O){for(var g=0;g<O.length;g++){var T=O[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(P,T.key,T)}}function D(P,O,g){return O&&I(P.prototype,O),g&&I(P,g),P}var j=10,F=function(){function P(g){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=g}var O=P.prototype;return O.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-T.lastPartSn,L=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!L||!!R,this.advanced=this.endSN>T.endSN||R>0||R===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},D(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(V.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||j}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var R=this.driftEnd-this.driftStart;return R*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.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 T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),P}()},"./src/loader/level-key.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"LevelKey",function(){return F});var V=k("./node_modules/url-toolkit/src/url-toolkit.js"),I=k.n(V);function D(P,O){for(var g=0;g<O.length;g++){var T=O[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(P,T.key,T)}}function j(P,O,g){return O&&D(P.prototype,O),g&&D(P,g),P}var F=function(){P.fromURL=function(g,T){return new P(g,T)},P.fromURI=function(g){return new P(g)};function P(O,g){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,g?this._uri=Object(V.buildAbsoluteURL)(O,g,{alwaysNormalize:!0}):this._uri=O}return j(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"LoadStats",function(){return V});var V=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return s});var V=k("./src/polyfills/number.ts"),I=k("./node_modules/url-toolkit/src/url-toolkit.js"),D=k.n(I),j=k("./src/loader/fragment.ts"),F=k("./src/loader/level-details.ts"),P=k("./src/loader/level-key.ts"),O=k("./src/utils/attr-list.ts"),g=k("./src/utils/logger.ts"),T=k("./src/utils/codecs.ts"),R=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,w=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),E=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(C){var v,d;return u.test((v=(d=I.parseURL(C))===null||d===void 0?void 0:d.path)!=null?v:"")}var s=function(){function C(){}return C.findGroup=function(d,c){for(var h=0;h<d.length;h++){var a=d[h];if(a.id===c)return a}},C.convertAVC1ToAVCOTI=function(d){var c=d.split(".");if(c.length>2){var h=c.shift()+".";return h+=parseInt(c.shift()).toString(16),h+=("000"+parseInt(c.shift()).toString(16)).substr(-4),h}return d},C.resolve=function(d,c){return I.buildAbsoluteURL(c,d,{alwaysNormalize:!0})},C.parseMasterPlaylist=function(d,c){var h=[],a={},y=!1;R.lastIndex=0;for(var m;(m=R.exec(d))!=null;)if(m[1]){var x=new O.AttrList(m[1]),M={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:C.resolve(m[2],c)},G=x.decimalResolution("RESOLUTION");G&&(M.width=G.width,M.height=G.height),l((x.CODECS||"").split(/[ ,]+/).filter(function(re){return re}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=C.convertAVC1ToAVCOTI(M.videoCodec)),h.push(M)}else if(m[3]){var $=new O.AttrList(m[3]);$["DATA-ID"]&&(y=!0,a[$["DATA-ID"]]=$)}return{levels:h,sessionData:y?a:null}},C.parseMasterPlaylistMedia=function(d,c,h,a){a===void 0&&(a=[]);var y,m=[],x=0;for(L.lastIndex=0;(y=L.exec(d))!==null;){var M=new O.AttrList(y[1]);if(M.TYPE===h){var G={attrs:M,bitrate:0,id:x++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:h,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?C.resolve(M.URI,c):""};if(a.length){var $=C.findGroup(a,G.groupId)||a[0];S(G,$,"audioCodec"),S(G,$,"textCodec")}m.push(G)}}return m},C.parseLevelPlaylist=function(d,c,h,a,y){var m=new F.LevelDetails(c),x=m.fragments,M=null,G=0,$=0,re=0,z=0,U=null,ne=new j.Fragment(a,c),fe,ge,be,Me=-1,Te=!1;for(w.lastIndex=0,m.m3u8=d;(fe=w.exec(d))!==null;){Te&&(Te=!1,ne=new j.Fragment(a,c),ne.start=re,ne.sn=G,ne.cc=z,ne.level=h,M&&(ne.initSegment=M,ne.rawProgramDateTime=M.rawProgramDateTime));var De=fe[1];if(De){ne.duration=parseFloat(De);var Ce=(" "+fe[2]).slice(1);ne.title=Ce||null,ne.tagList.push(Ce?["INF",De,Ce]:["INF",De])}else if(fe[3])Object(V.isFiniteNumber)(ne.duration)&&(ne.start=re,be&&(ne.levelkey=be),ne.sn=G,ne.level=h,ne.cc=z,ne.urlId=y,x.push(ne),ne.relurl=(" "+fe[3]).slice(1),f(ne,U),U=ne,re+=ne.duration,G++,$=0,Te=!0);else if(fe[4]){var we=(" "+fe[4]).slice(1);U?ne.setByteRange(we,U):ne.setByteRange(we)}else if(fe[5])ne.rawProgramDateTime=(" "+fe[5]).slice(1),ne.tagList.push(["PROGRAM-DATE-TIME",ne.rawProgramDateTime]),Me===-1&&(Me=x.length);else{if(fe=fe[0].match(E),!fe){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(ge=1;ge<fe.length&&!(typeof fe[ge]!="undefined");ge++);var ve=(" "+fe[ge]).slice(1),W=(" "+fe[ge+1]).slice(1),A=fe[ge+2]?(" "+fe[ge+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":m.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":G=m.startSN=parseInt(W);break;case"SKIP":{var _=new O.AttrList(W),H=_.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(H)){m.skippedSegments=H;for(var q=H;q--;)x.unshift(null);G+=H}var B=_.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(m.recentlyRemovedDateranges=B.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(W);break;case"VERSION":m.version=parseInt(W);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(W||A)&&ne.tagList.push(A?[W,A]:[W]);break;case"DIS":z++;case"GAP":ne.tagList.push([ve]);break;case"BITRATE":ne.tagList.push([ve,W]);break;case"DISCONTINUITY-SEQ":z=parseInt(W);break;case"KEY":{var de,Ee=new O.AttrList(W),Le=Ee.enumeratedString("METHOD"),Ie=Ee.URI,ke=Ee.hexadecimalInteger("IV"),Oe=Ee.enumeratedString("KEYFORMATVERSIONS"),Pe=Ee.enumeratedString("KEYID"),We=(de=Ee.enumeratedString("KEYFORMAT"))!=null?de:"identity",He=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(He.indexOf(We)>-1){g.logger.warn("Keyformat "+We+" is not supported from the manifest");continue}else if(We!=="identity")continue;Le&&(be=P.LevelKey.fromURL(c,Ie),Ie&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Le)>=0&&(be.method=Le,be.keyFormat=We,Pe&&(be.keyID=Pe),Oe&&(be.keyFormatVersions=Oe),be.iv=ke));break}case"START":{var Ve=new O.AttrList(W),Xe=Ve.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(Xe)&&(m.startTimeOffset=Xe);break}case"MAP":{var nt=new O.AttrList(W);ne.relurl=nt.URI,nt.BYTERANGE&&ne.setByteRange(nt.BYTERANGE),ne.level=h,ne.sn="initSegment",be&&(ne.levelkey=be),ne.initSegment=null,M=ne,Te=!0;break}case"SERVER-CONTROL":{var Ke=new O.AttrList(W);m.canBlockReload=Ke.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=Ke.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&Ke.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=Ke.optionalFloat("PART-HOLD-BACK",0),m.holdBack=Ke.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Ye=new O.AttrList(W);m.partTarget=Ye.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ae=m.partList;Ae||(Ae=m.partList=[]);var rt=$>0?Ae[Ae.length-1]:void 0,Qe=$++,ae=new j.Part(new O.AttrList(W),ne,c,Qe,rt);Ae.push(ae),ne.duration+=ae.duration;break}case"PRELOAD-HINT":{var J=new O.AttrList(W);m.preloadHint=J;break}case"RENDITION-REPORT":{var Z=new O.AttrList(W);m.renditionReports=m.renditionReports||[],m.renditionReports.push(Z);break}default:g.logger.warn("line parsed but not handled: "+fe);break}}}U&&!U.relurl?(x.pop(),re-=U.duration,m.partList&&(m.fragmentHint=U)):m.partList&&(f(ne,U),ne.cc=z,m.fragmentHint=ne);var ie=x.length,oe=x[0],Q=x[ie-1];if(re+=m.skippedSegments*m.targetduration,re>0&&ie&&Q){m.averagetargetduration=re/ie;var te=Q.sn;m.endSN=te!=="initSegment"?te:0,oe&&(m.startCC=oe.cc,oe.initSegment||m.fragments.every(function(se){return se.relurl&&o(se.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ne=new j.Fragment(a,c),ne.relurl=Q.relurl,ne.level=h,ne.sn="initSegment",oe.initSegment=ne,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(re+=m.fragmentHint.duration),m.totalduration=re,m.endCC=z,Me>0&&p(x,Me),m},C}();function l(C,v){["video","audio","text"].forEach(function(d){var c=C.filter(function(a){return Object(T.isCodecType)(a,d)});if(c.length){var h=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});v[d+"Codec"]=h.length>0?h[0]:c[0],C=C.filter(function(a){return c.indexOf(a)===-1})}}),v.unknownCodecs=C}function S(C,v,d){var c=v[d];c&&(C[d]=c)}function p(C,v){for(var d=C[v],c=v;c--;){var h=C[c];if(!h)return;h.programDateTime=d.programDateTime-h.duration*1e3,d=h}}function f(C,v){C.rawProgramDateTime?C.programDateTime=Date.parse(C.rawProgramDateTime):v!=null&&v.programDateTime&&(C.programDateTime=v.endProgramDateTime),Object(V.isFiniteNumber)(C.programDateTime)||(C.programDateTime=null,C.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/polyfills/number.ts"),I=k("./src/events.ts"),D=k("./src/errors.ts"),j=k("./src/utils/logger.ts"),F=k("./src/utils/mp4-tools.ts"),P=k("./src/loader/m3u8-parser.ts"),O=k("./src/types/loader.ts"),g=k("./src/utils/attr-list.ts");function T(w){var E=w.type;switch(E){case O.PlaylistContextType.AUDIO_TRACK:return O.PlaylistLevelType.AUDIO;case O.PlaylistContextType.SUBTITLE_TRACK:return O.PlaylistLevelType.SUBTITLE;default:return O.PlaylistLevelType.MAIN}}function R(w,E){var u=w.url;return(u===void 0||u.indexOf("data:")===0)&&(u=E.url),u}var L=function(){function w(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var E=w.prototype;return E.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)},E.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)},E.createInternalLoader=function(o){var s=this.hls.config,l=s.pLoader,S=s.loader,p=l||S,f=new p(s);return o.loader=f,this.loaders[o.type]=f,f},E.getInternalLoader=function(o){return this.loaders[o.type]},E.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},E.destroyInternalLoaders=function(){for(var o in this.loaders){var s=this.loaders[o];s&&s.destroy(),this.resetInternalLoader(o)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(o,s){var l=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:l,deliveryDirectives:null})},E.onLevelLoading=function(o,s){var l=s.id,S=s.level,p=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:null,level:S,responseType:"text",type:O.PlaylistContextType.LEVEL,url:p,deliveryDirectives:f})},E.onAudioTrackLoading=function(o,s){var l=s.id,S=s.groupId,p=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:S,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:p,deliveryDirectives:f})},E.onSubtitleTrackLoading=function(o,s){var l=s.id,S=s.groupId,p=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:S,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:p,deliveryDirectives:f})},E.load=function(o){var s,l=this.hls.config,S=this.getInternalLoader(o);if(S){var p=S.context;if(p&&p.url===o.url){j.logger.trace("[playlist-loader]: playlist request ongoing");return}j.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),S.abort()}var f,C,v,d;switch(o.type){case O.PlaylistContextType.MANIFEST:f=l.manifestLoadingMaxRetry,C=l.manifestLoadingTimeOut,v=l.manifestLoadingRetryDelay,d=l.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:f=0,C=l.levelLoadingTimeOut;break;default:f=l.levelLoadingMaxRetry,C=l.levelLoadingTimeOut,v=l.levelLoadingRetryDelay,d=l.levelLoadingMaxRetryTimeout;break}if(S=this.createInternalLoader(o),(s=o.deliveryDirectives)!==null&&s!==void 0&&s.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 h=c.partTarget,a=c.targetduration;h&&a&&(C=Math.min(Math.max(h*3,a*.8)*1e3,C))}}var y={timeout:C,maxRetry:f,retryDelay:v,maxRetryDelay:d,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};S.load(o,y,m)},E.loadsuccess=function(o,s,l,S){if(S===void 0&&(S=null),l.isSidxRequest){this.handleSidxRequest(o,l),this.handlePlaylistLoaded(o,s,l,S);return}this.resetInternalLoader(l.type);var p=o.data;if(p.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,l,"no EXTM3U delimiter",S);return}s.parsing.start=performance.now(),p.indexOf("#EXTINF:")>0||p.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,s,l,S):this.handleMasterPlaylist(o,s,l,S)},E.loaderror=function(o,s,l){l===void 0&&(l=null),this.handleNetworkError(s,l,!1,o)},E.loadtimeout=function(o,s,l){l===void 0&&(l=null),this.handleNetworkError(s,l,!0)},E.handleMasterPlaylist=function(o,s,l,S){var p=this.hls,f=o.data,C=R(o,l),v=P.default.parseMasterPlaylist(f,C),d=v.levels,c=v.sessionData;if(!d.length){this.handleManifestParsingError(o,l,"no level found in manifest",S);return}var h=d.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=d.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),y=P.default.parseMasterPlaylistMedia(f,C,"AUDIO",h),m=P.default.parseMasterPlaylistMedia(f,C,"SUBTITLES",a),x=P.default.parseMasterPlaylistMedia(f,C,"CLOSED-CAPTIONS");if(y.length){var M=y.some(function(G){return!G.url});!M&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(j.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new g.AttrList({}),bitrate:0,url:""}))}p.trigger(I.Events.MANIFEST_LOADED,{levels:d,audioTracks:y,subtitles:m,captions:x,url:C,stats:s,networkDetails:S,sessionData:c})},E.handleTrackOrLevelPlaylist=function(o,s,l,S){var p=this.hls,f=l.id,C=l.level,v=l.type,d=R(o,l),c=Object(V.isFiniteNumber)(f)?f:0,h=Object(V.isFiniteNumber)(C)?C:c,a=T(l),y=P.default.parseLevelPlaylist(o.data,d,h,a,c);if(!y.fragments.length){p.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:d,reason:"no fragments found in level",level:typeof l.level=="number"?l.level:void 0});return}if(v===O.PlaylistContextType.MANIFEST){var m={attrs:new g.AttrList({}),bitrate:0,details:y,name:"",url:d};p.trigger(I.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:d,stats:s,networkDetails:S,sessionData:null})}if(s.parsing.end=performance.now(),y.needSidxRanges){var x,M=(x=y.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:M,isSidxRequest:!0,type:v,level:C,levelDetails:y,id:f,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}l.levelDetails=y,this.handlePlaylistLoaded(o,s,l,S)},E.handleSidxRequest=function(o,s){var l=Object(F.parseSegmentIndex)(new Uint8Array(o.data));if(!l)return;var S=l.references,p=s.levelDetails;S.forEach(function(f,C){var v=f.info,d=p.fragments[C];d.byteRange.length===0&&d.setByteRange(String(1+v.end-v.start)+"@"+String(v.start)),d.initSegment&&d.initSegment.setByteRange(String(l.moovEndOffset)+"@0")})},E.handleManifestParsingError=function(o,s,l,S){this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===O.PlaylistContextType.MANIFEST,url:o.url,reason:l,response:o,context:s,networkDetails:S})},E.handleNetworkError=function(o,s,l,S){l===void 0&&(l=!1),j.logger.warn("[playlist-loader]: A network "+(l?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var p=D.ErrorDetails.UNKNOWN,f=!1,C=this.getInternalLoader(o);switch(o.type){case O.PlaylistContextType.MANIFEST:p=l?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,f=!0;break;case O.PlaylistContextType.LEVEL:p=l?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,f=!1;break;case O.PlaylistContextType.AUDIO_TRACK:p=l?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:p=l?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,f=!1;break}C&&this.resetInternalLoader(o.type);var v={type:D.ErrorTypes.NETWORK_ERROR,details:p,fatal:f,url:o.url,loader:C,context:o,networkDetails:s};S&&(v.response=S),this.hls.trigger(I.Events.ERROR,v)},E.handlePlaylistLoaded=function(o,s,l,S){var p=l.type,f=l.level,C=l.id,v=l.groupId,d=l.loader,c=l.levelDetails,h=l.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,l,"invalid target duration",S);return}if(!d)return;c.live&&(d.getCacheAge&&(c.ageHeader=d.getCacheAge()||0),(!d.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(p){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:c,level:f||0,id:C||0,stats:s,networkDetails:S,deliveryDirectives:h});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:c,id:C||0,groupId:v||"",stats:s,networkDetails:S,deliveryDirectives:h});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:c,id:C||0,groupId:v||"",stats:s,networkDetails:S,deliveryDirectives:h});break}},w}();Y.default=L},"./src/polyfills/number.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"isFiniteNumber",function(){return V}),k.d(Y,"MAX_SAFE_INTEGER",function(){return I});var V=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ue,Y,k){"use strict";k.r(Y);var V=function(){function I(){}return I.getSilentFrame=function(j,F){switch(j){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}();Y.default=V},"./src/remux/mp4-generator.ts":function(ue,Y,k){"use strict";k.r(Y);var V=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 P=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),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:P,audio:O};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=T,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 R=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),w=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,R,w,R,L),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,g))},D.box=function(F){for(var P=8,O=arguments.length,g=new Array(O>1?O-1:0),T=1;T<O;T++)g[T-1]=arguments[T];for(var R=g.length,L=R;R--;)P+=g[R].byteLength;var w=new Uint8Array(P);for(w[0]=P>>24&255,w[1]=P>>16&255,w[2]=P>>8&255,w[3]=P&255,w.set(F,4),R=0,P=8;R<L;R++)w.set(g[R],P),P+=g[R].byteLength;return w},D.hdlr=function(F){return D.box(D.types.hdlr,D.HDLR_TYPES[F])},D.mdat=function(F){return D.box(D.types.mdat,F)},D.mdhd=function(F,P){P*=F;var O=Math.floor(P/(V+1)),g=Math.floor(P%(V+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,g>>24,g>>16&255,g>>8&255,g&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,P,O){return D.box(D.types.moof,D.mfhd(F),D.traf(O,P))},D.moov=function(F){for(var P=F.length,O=[];P--;)O[P]=D.trak(F[P]);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 P=F.length,O=[];P--;)O[P]=D.trex(F[P]);return D.box.apply(null,[D.types.mvex].concat(O))},D.mvhd=function(F,P){P*=F;var O=Math.floor(P/(V+1)),g=Math.floor(P%(V+1)),T=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,g>>24,g>>16&255,g>>8&255,g&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,T)},D.sdtp=function(F){var P=F.samples||[],O=new Uint8Array(4+P.length),g,T;for(g=0;g<P.length;g++)T=P[g].flags,O[g+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return D.box(D.types.sdtp,O)},D.stbl=function(F){return D.box(D.types.stbl,D.stsd(F),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(F){var P=[],O=[],g,T,R;for(g=0;g<F.sps.length;g++)T=F.sps[g],R=T.byteLength,P.push(R>>>8&255),P.push(R&255),P=P.concat(Array.prototype.slice.call(T));for(g=0;g<F.pps.length;g++)T=F.pps[g],R=T.byteLength,O.push(R>>>8&255),O.push(R&255),O=O.concat(Array.prototype.slice.call(T));var L=D.box(D.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|F.sps.length].concat(P).concat([F.pps.length]).concat(O))),w=F.width,E=F.height,u=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,w>>8&255,w&255,E>>8&255,E&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),L,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([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])))},D.esds=function(F){var P=F.config.length;return new Uint8Array([0,0,0,0,3,23+P,0,1,0,4,15+P,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([P]).concat(F.config).concat([6,1,2]))},D.mp4a=function(F){var P=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,P>>8&255,P&255,0,0]),D.box(D.types.esds,D.esds(F)))},D.mp3=function(F){var P=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,P>>8&255,P&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 P=F.id,O=F.duration*F.timescale,g=F.width,T=F.height,R=Math.floor(O/(V+1)),L=Math.floor(O%(V+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,g>>8&255,g&255,0,0,T>>8&255,T&255,0,0]))},D.traf=function(F,P){var O=D.sdtp(F),g=F.id,T=Math.floor(P/(V+1)),R=Math.floor(P%(V+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,R>>24,R>>16&255,R>>8&255,R&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 P=F.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(F,P){var O=F.samples||[],g=O.length,T=12+16*g,R=new Uint8Array(T),L,w,E,u,o,s;for(P+=8+T,R.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255],0),L=0;L<g;L++)w=O[L],E=w.duration,u=w.size,o=w.flags,s=w.cts,R.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*L);return D.box(D.types.trun,R)},D.initSegment=function(F){D.types||D.init();var P=D.moov(F),O=new Uint8Array(D.FTYP.byteLength+P.byteLength);return O.set(D.FTYP),O.set(P,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,Y.default=I},"./src/remux/mp4-remuxer.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return s}),k.d(Y,"normalizePts",function(){return l});var V=k("./src/polyfills/number.ts"),I=k("./src/remux/aac-helper.ts"),D=k("./src/remux/mp4-generator.ts"),j=k("./src/events.ts"),F=k("./src/errors.ts"),P=k("./src/utils/logger.ts"),O=k("./src/types/loader.ts"),g=k("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign||function(C){for(var v=1;v<arguments.length;v++){var d=arguments[v];for(var c in d)Object.prototype.hasOwnProperty.call(d,c)&&(C[c]=d[c])}return C},T.apply(this,arguments)}var R=10*1e3,L=1024,w=1152,E=null,u=null,o=!1,s=function(){function C(d,c,h,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=d,this.config=c,this.typeSupported=h,this.ISGenerated=!1,E===null){var y=navigator.userAgent||"",m=y.match(/Chrome\/(\d+)/i);E=m?parseInt(m[1]):0}if(u===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);u=x?parseInt(x[1]):0}o=!!E&&E<75||!!u&&u<600}var v=C.prototype;return v.destroy=function(){},v.resetTimeStamp=function(c){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},v.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},v.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},v.getVideoStartPts=function(c){var h=!1,a=c.reduce(function(y,m){var x=m.pts-y;return x<-4294967296?(h=!0,l(y,m.pts)):x>0?y:m.pts},c[0].pts);return h&&P.logger.debug("PTS rollover detected"),a},v.remux=function(c,h,a,y,m,x,M,G){var $,re,z,U,ne,fe,ge=m,be=m,Me=c.pid>-1,Te=h.pid>-1,De=h.samples.length,Ce=c.samples.length>0,we=De>1,ve=(!Me||Ce)&&(!Te||we)||this.ISGenerated||M;if(ve){this.ISGenerated||(z=this.generateIS(c,h,m));var W=this.isVideoContiguous,A=-1;if(we&&(A=S(h.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(fe=!0,A>0){P.logger.warn("[mp4-remuxer]: Dropped "+A+" out of "+De+" video samples due to a missing keyframe");var _=this.getVideoStartPts(h.samples);h.samples=h.samples.slice(A),h.dropped+=A,be+=(h.samples[0].pts-_)/(h.timescale||9e4)}else A===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+De+" video samples"),fe=!1);if(this.ISGenerated){if(Ce&&we){var H=this.getVideoStartPts(h.samples),q=l(c.samples[0].pts,H)-H,B=q/h.inputTimeScale;ge+=Math.max(0,B),be+=Math.max(0,-B)}if(Ce){if(c.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(c,h,m)),re=this.remuxAudio(c,ge,this.isAudioContiguous,x,Te||we||G===O.PlaylistLevelType.AUDIO?be:void 0),we){var de=re?re.endPTS-re.startPTS:0;h.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(c,h,m)),$=this.remuxVideo(h,be,W,de)}}else we&&($=this.remuxVideo(h,be,W,0));$&&($.firstKeyFrame=A,$.independent=A!==-1)}}return this.ISGenerated&&(a.samples.length&&(ne=this.remuxID3(a,m)),y.samples.length&&(U=this.remuxText(y,m))),{audio:re,video:$,initSegment:z,independent:fe,text:U,id3:ne}},v.generateIS=function(c,h,a){var y=c.samples,m=h.samples,x=this.typeSupported,M={},G=!Object(V.isFiniteNumber)(this._initPTS),$="audio/mp4",re,z,U;if(G&&(re=z=Infinity),c.config&&y.length&&(c.timescale=c.samplerate,c.isAAC||(x.mpeg?($="audio/mpeg",c.codec=""):x.mp3&&(c.codec="mp3")),M.audio={id:"audio",container:$,codec:c.codec,initSegment:!c.isAAC&&x.mpeg?new Uint8Array(0):D.default.initSegment([c]),metadata:{channelCount:c.channelCount}},G&&(U=c.inputTimeScale,re=z=y[0].pts-Math.round(U*a))),h.sps&&h.pps&&m.length&&(h.timescale=h.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:h.codec,initSegment:D.default.initSegment([h]),metadata:{width:h.width,height:h.height}},G)){U=h.inputTimeScale;var ne=this.getVideoStartPts(m),fe=Math.round(U*a);z=Math.min(z,l(m[0].dts,ne)-fe),re=Math.min(re,ne-fe)}if(Object.keys(M).length)return this.ISGenerated=!0,G&&(this._initPTS=re,this._initDTS=z),{tracks:M,initPTS:re,timescale:U}},v.remuxVideo=function(c,h,a,y){var m=c.inputTimeScale,x=c.samples,M=[],G=x.length,$=this._initPTS,re=this.nextAvcDts,z=8,U,ne,fe,ge=Number.POSITIVE_INFINITY,be=Number.NEGATIVE_INFINITY,Me=0,Te=!1;if(!a||re===null){var De=h*m,Ce=x[0].pts-l(x[0].dts,x[0].pts);re=De-Ce}for(var we=0;we<G;we++){var ve=x[we];if(ve.pts=l(ve.pts-$,re),ve.dts=l(ve.dts-$,re),ve.dts>ve.pts){var W=9e4*.2;Me=Math.max(Math.min(Me,ve.pts-ve.dts),-1*W)}ve.dts<x[we>0?we-1:we].dts&&(Te=!0)}Te&&x.sort(function(xt,ot){var it=xt.dts-ot.dts,Lt=xt.pts-ot.pts;return it||Lt}),ne=x[0].dts,fe=x[x.length-1].dts;var A=Math.round((fe-ne)/(G-1));if(Me<0){if(Me<A*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-A,!0)+" ms");for(var _=Me,H=0;H<G;H++)x[H].dts=_=Math.max(_,x[H].pts-A),x[H].pts=Math.max(_,x[H].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(Me,!0)+" ms to overcome this issue");for(var q=0;q<G;q++)x[q].dts=x[q].dts+Me}ne=x[0].dts}if(a){var B=ne-re,de=B>A,Ee=B<-1;if(de||Ee){de?P.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(B,!0)+" ms ("+B+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-B,!0)+" ms ("+B+"dts) overlapping between fragments detected"),ne=re;var Le=x[0].pts-B;x[0].dts=ne,x[0].pts=Le,P.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(Le,!0)+"/"+Object(g.toMsFromMpegTsClock)(ne,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(B,!0)+" ms")}}o&&(ne=Math.max(0,ne));for(var Ie=0,ke=0,Oe=0;Oe<G;Oe++){for(var Pe=x[Oe],We=Pe.units,He=We.length,Ve=0,Xe=0;Xe<He;Xe++)Ve+=We[Xe].data.length;ke+=Ve,Ie+=He,Pe.length=Ve,Pe.dts=Math.max(Pe.dts,ne),Pe.pts=Math.max(Pe.pts,Pe.dts,0),ge=Math.min(Pe.pts,ge),be=Math.max(Pe.pts,be)}fe=x[G-1].dts;var nt=ke+4*Ie+8,Ke;try{Ke=new Uint8Array(nt)}catch(xt){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:nt,reason:"fail allocating video mdat "+nt});return}var Ye=new DataView(Ke.buffer);Ye.setUint32(0,nt),Ke.set(D.default.types.mdat,4);for(var Ae=0;Ae<G;Ae++){for(var rt=x[Ae],Qe=rt.units,ae=0,J=0,Z=Qe.length;J<Z;J++){var ie=Qe[J],oe=ie.data,Q=ie.data.byteLength;Ye.setUint32(z,Q),z+=4,Ke.set(oe,z),z+=Q,ae+=4+Q}if(Ae<G-1)U=x[Ae+1].dts-rt.dts;else{var te=this.config,se=rt.dts-x[Ae>0?Ae-1:Ae].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var he=Math.floor(te.maxBufferHole*m),me=(y?ge+y*m:this.nextAudioPts)-rt.pts;me>he?(U=me-se,U<0&&(U=se),P.logger.log("[mp4-remuxer]: It is approximately "+me/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=se}else U=se}var ye=Math.round(rt.pts-rt.dts);M.push(new p(rt.key,U,ae,ye))}if(M.length&&E&&E<70){var _e=M[0].flags;_e.dependsOn=2,_e.isNonSync=0}console.assert(U!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=re=fe+U,this.isVideoContiguous=!0;var Fe=D.default.moof(c.sequenceNumber++,ne,T({},c,{samples:M})),qe="video",et={data1:Fe,data2:Ke,startPTS:ge/m,endPTS:(be+U)/m,startDTS:ne/m,endDTS:re/m,type:qe,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(Ke.length,"MDAT length must not be zero"),et},v.remuxAudio=function(c,h,a,y,m){var x=c.inputTimeScale,M=c.samplerate?c.samplerate:x,G=x/M,$=c.isAAC?L:w,re=$*G,z=this._initPTS,U=!c.isAAC&&this.typeSupported.mpeg,ne=[],fe=c.samples,ge=U?0:8,be=this.nextAudioPts||-1,Me=h*x;if(this.isAudioContiguous=a=a||fe.length&&be>0&&(y&&Math.abs(Me-be)<9e3||Math.abs(l(fe[0].pts-z,Me)-be)<20*re),fe.forEach(function(oe){oe.pts=l(oe.pts-z,Me)}),!a||be<0){if(fe=fe.filter(function(oe){return oe.pts>=0}),!fe.length)return;m===0?be=0:y?be=Math.max(0,Me):be=fe[0].pts}if(c.isAAC)for(var Te=m!==void 0,De=this.config.maxAudioFramesDrift,Ce=0,we=be;Ce<fe.length;Ce++){var ve=fe[Ce],W=ve.pts,A=W-we,_=Math.abs(1e3*A/x);if(A<=-De*re&&Te)Ce===0&&(P.logger.warn("Audio frame @ "+(W/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*A/x)+" ms."),this.nextAudioPts=be=we=W);else if(A>=De*re&&_<R&&Te){var H=Math.round(A/re);we=W-H*re,we<0&&(H--,we+=re),Ce===0&&(this.nextAudioPts=be=we),P.logger.warn("[mp4-remuxer]: Injecting "+H+" audio frame @ "+(we/x).toFixed(3)+"s due to "+Math.round(1e3*A/x)+" ms gap.");for(var q=0;q<H;q++){var B=Math.max(we,0),de=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);de||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),de=ve.unit.subarray()),fe.splice(Ce,0,{unit:de,pts:B}),we+=re,Ce++}}ve.pts=we,we+=re}for(var Ee=null,Le=null,Ie,ke=0,Oe=fe.length;Oe--;)ke+=fe[Oe].unit.byteLength;for(var Pe=0,We=fe.length;Pe<We;Pe++){var He=fe[Pe],Ve=He.unit,Xe=He.pts;if(Le!==null){var nt=ne[Pe-1];nt.duration=Math.round((Xe-Le)/G)}else if(a&&c.isAAC&&(Xe=be),Ee=Xe,ke>0){ke+=ge;try{Ie=new Uint8Array(ke)}catch(oe){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ke,reason:"fail allocating audio mdat "+ke});return}if(!U){var Ke=new DataView(Ie.buffer);Ke.setUint32(0,ke),Ie.set(D.default.types.mdat,4)}}else return;Ie.set(Ve,ge);var Ye=Ve.byteLength;ge+=Ye,ne.push(new p(!0,$,Ye,0)),Le=Xe}var Ae=ne.length;if(!Ae)return;var rt=ne[ne.length-1];this.nextAudioPts=be=Le+G*rt.duration;var Qe=U?new Uint8Array(0):D.default.moof(c.sequenceNumber++,Ee/G,T({},c,{samples:ne}));c.samples=[];var ae=Ee/x,J=be/x,Z="audio",ie={data1:Qe,data2:Ie,startPTS:ae,endPTS:J,startDTS:ae,endDTS:J,type:Z,hasAudio:!0,hasVideo:!1,nb:Ae};return this.isAudioContiguous=!0,console.assert(Ie.length,"MDAT length must not be zero"),ie},v.remuxEmptyAudio=function(c,h,a,y){var m=c.inputTimeScale,x=c.samplerate?c.samplerate:m,M=m/x,G=this.nextAudioPts,$=(G!==null?G:y.startDTS*m)+this._initDTS,re=y.endDTS*m+this._initDTS,z=M*L,U=Math.ceil((re-$)/z),ne=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!ne){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var fe=[],ge=0;ge<U;ge++){var be=$+ge*z;fe.push({unit:ne,pts:be,dts:be})}return c.samples=fe,this.remuxAudio(c,h,a,!1)},v.remuxID3=function(c,h){var a=c.samples.length;if(!a)return;for(var y=c.inputTimeScale,m=this._initPTS,x=this._initDTS,M=0;M<a;M++){var G=c.samples[M];G.pts=l(G.pts-m,h*y)/y,G.dts=l(G.dts-x,h*y)/y}var $=c.samples;return c.samples=[],{samples:$}},v.remuxText=function(c,h){var a=c.samples.length;if(!a)return;for(var y=c.inputTimeScale,m=this._initPTS,x=0;x<a;x++){var M=c.samples[x];M.pts=l(M.pts-m,h*y)/y}c.samples.sort(function($,re){return $.pts-re.pts});var G=c.samples;return c.samples=[],{samples:G}},C}();function l(C,v){var d;if(v===null)return C;for(v<C?d=-8589934592:d=8589934592;Math.abs(C-v)>4294967296;)C+=d;return C}function S(C){for(var v=0;v<C.length;v++)if(C[v].key)return v;return-1}var p=function(v,d,c,h){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=d,this.size=c,this.cts=h,this.flags=new f(v)},f=function(v){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=v?2:1,this.isNonSync=v?0:1}},"./src/remux/passthrough-remuxer.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/polyfills/number.ts"),I=k("./src/utils/mp4-tools.ts"),D=k("./src/loader/fragment.ts"),j=k("./src/utils/logger.ts"),F=function(){function g(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var T=g.prototype;return T.destroy=function(){},T.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},T.resetNextTimestamp=function(){this.lastEndDTS=null},T.resetInitSegment=function(L,w,E){this.audioCodec=w,this.videoCodec=E,this.generateInitSegment(L),this.emitInitSegment=!0},T.generateInitSegment=function(L){var w=this.audioCodec,E=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(I.parseInitSegment)(L);w||(w=O(u.audio,D.ElementaryStreamTypes.AUDIO)),E||(E=O(u.video,D.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:w+","+E,initSegment:L,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:w,initSegment:L,id:"audio"}:u.video?o.video={container:"video/mp4",codec:E,initSegment:L,id:"main"}:j.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},T.remux=function(L,w,E,u,o){var s=this.initPTS,l=this.lastEndDTS,S={audio:void 0,video:void 0,text:u,id3:E,initSegment:void 0};Object(V.isFiniteNumber)(l)||(l=this.lastEndDTS=o||0);var p=w.samples;if(!p||!p.length)return S;var f={initPTS:void 0,timescale:1},C=this.initData;if((!C||!C.length)&&(this.generateInitSegment(p),C=this.initData),!C||!C.length)return j.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),S;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(s)||(this.initPTS=f.initPTS=s=P(C,p,l));var v=Object(I.getDuration)(p,C),d=l,c=v+d;Object(I.offsetStartDTS)(C,p,s),v>0?this.lastEndDTS=c:(j.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var h=!!C.audio,a=!!C.video,y="";h&&(y+="audio"),a&&(y+="video");var m={data1:p,startPTS:d,startDTS:d,endPTS:c,endDTS:c,type:y,hasAudio:h,hasVideo:a,nb:1,dropped:0};return S.audio=m.type==="audio"?m:void 0,S.video=m.type!=="audio"?m:void 0,S.text=u,S.id3=E,S.initSegment=f,S},g}(),P=function(T,R,L){return Object(I.getStartDTS)(T,R)-L};function O(g,T){var R=g==null?void 0:g.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||T===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Y.default=F},"./src/task-loop.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return V});var V=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(ue,Y,k){"use strict";k.r(Y),k.d(Y,"CMCDVersion",function(){return V}),k.d(Y,"CMCDObjectType",function(){return I}),k.d(Y,"CMCDStreamingFormat",function(){return D}),k.d(Y,"CMCDStreamType",function(){return j});var V=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 j;(function(F){F.VOD="v",F.LIVE="l"})(j||(j={}))},"./src/types/level.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"HlsSkip",function(){return D}),k.d(Y,"getSkipValue",function(){return j}),k.d(Y,"HlsUrlParameters",function(){return F}),k.d(Y,"Level",function(){return P});function V(O,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function I(O,g,T){return g&&V(O.prototype,g),T&&V(O,T),O}var D;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(D||(D={}));function j(O,g){var T=O.canSkipUntil,R=O.canSkipDateRanges,L=O.endSN,w=g!==void 0?g-L:0;return T&&w<T?R?D.v2:D.Yes:D.No}var F=function(){function O(T,R,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=R,this.skip=L}var g=O.prototype;return g.addDirectives=function(R){var L=new self.URL(R);return this.msn!==void 0&&L.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&L.searchParams.set("_HLS_part",this.part.toString()),this.skip&&L.searchParams.set("_HLS_skip",this.skip),L.toString()},O}(),P=function(){function O(g){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return I(O,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(T){var R=T%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),O}()},"./src/types/loader.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"PlaylistContextType",function(){return V}),k.d(Y,"PlaylistLevelType",function(){return I});var V;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var I;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"ChunkMetadata",function(){return V});var V=function(j,F,P,O,g,T){O===void 0&&(O=0),g===void 0&&(g=-1),T===void 0&&(T=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=I(),this.buffering={audio:I(),video:I(),audiovideo:I()},this.level=j,this.sn=F,this.id=P,this.size=O,this.part=g,this.partial=T};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"AttrList",function(){return D});var V=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function j(P){typeof P=="string"&&(P=j.parseAttrList(P));for(var O in P)P.hasOwnProperty(O)&&(this[O]=P[O])}var F=j.prototype;return F.decimalInteger=function(O){var g=parseInt(this[O],10);return g>Number.MAX_SAFE_INTEGER?Infinity:g},F.hexadecimalInteger=function(O){if(this[O]){var g=(this[O]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var T=new Uint8Array(g.length/2),R=0;R<g.length/2;R++)T[R]=parseInt(g.slice(R*2,R*2+2),16);return T}else return null},F.hexadecimalIntegerAsNumber=function(O){var g=parseInt(this[O],16);return g>Number.MAX_SAFE_INTEGER?Infinity:g},F.decimalFloatingPoint=function(O){return parseFloat(this[O])},F.optionalFloat=function(O,g){var T=this[O];return T?parseFloat(T):g},F.enumeratedString=function(O){return this[O]},F.bool=function(O){return this[O]==="YES"},F.decimalResolution=function(O){var g=V.exec(this[O]);return g===null?void 0:{width:parseInt(g[1],10),height:parseInt(g[2],10)}},j.parseAttrList=function(O){var g,T={},R='"';for(I.lastIndex=0;(g=I.exec(O))!==null;){var L=g[2];L.indexOf(R)===0&&L.lastIndexOf(R)===L.length-1&&(L=L.slice(1,-1)),T[g[1]]=L}return T},j}()},"./src/utils/binary-search.ts":function(ue,Y,k){"use strict";k.r(Y);var V={search:function(D,j){for(var F=0,P=D.length-1,O=null,g=null;F<=P;){O=(F+P)/2|0,g=D[O];var T=j(g);if(T>0)F=O+1;else if(T<0)P=O-1;else return g}return null}};Y.default=V},"./src/utils/buffer-helper.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"BufferHelper",function(){return D});var V=k("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function j(){}return j.isBuffered=function(P,O){try{if(P){for(var g=j.getBuffered(P),T=0;T<g.length;T++)if(O>=g.start(T)&&O<=g.end(T))return!0}}catch(R){}return!1},j.bufferInfo=function(P,O,g){try{if(P){var T=j.getBuffered(P),R=[],L;for(L=0;L<T.length;L++)R.push({start:T.start(L),end:T.end(L)});return this.bufferedInfo(R,O,g)}}catch(w){}return{len:0,start:O,end:O,nextStart:void 0}},j.bufferedInfo=function(P,O,g){O=Math.max(0,O),P.sort(function(f,C){var v=f.start-C.start;return v||C.end-f.end});var T=[];if(g)for(var R=0;R<P.length;R++){var L=T.length;if(L){var w=T[L-1].end;P[R].start-w<g?P[R].end>w&&(T[L-1].end=P[R].end):T.push(P[R])}else T.push(P[R])}else T=P;for(var E=0,u,o=O,s=O,l=0;l<T.length;l++){var S=T[l].start,p=T[l].end;if(O+g>=S&&O<p)o=S,s=p,E=s-O;else if(O+g<S){u=S;break}}return{len:E,start:o||0,end:s||0,nextStart:u}},j.getBuffered=function(P){try{return P.buffered}catch(O){return V.logger.log("failed to get media.buffered",O),I}},j}()},"./src/utils/cea-608-parser.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"Row",function(){return s}),k.d(Y,"CaptionScreen",function(){return l});var V=k("./src/utils/logger.ts"),I={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},D=function(c){var h=c;return I.hasOwnProperty(c)&&(h=I[c]),String.fromCharCode(h)},j=15,F=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(L||(L={}));var w=function(){function d(){this.time=null,this.verboseLevel=L.ERROR}var c=d.prototype;return c.log=function(a,y){this.verboseLevel>=a&&V.logger.log(this.time+" ["+a+"] "+y)},d}(),E=function(c){for(var h=[],a=0;a<c.length;a++)h.push(c[a].toString(16));return h},u=function(){function d(h,a,y,m,x){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=h||"white",this.underline=a||!1,this.italics=y||!1,this.background=m||"black",this.flash=x||!1}var c=d.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var y=["foreground","underline","italics","background","flash"],m=0;m<y.length;m++){var x=y[m];a.hasOwnProperty(x)&&(this[x]=a[x])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),o=function(){function d(h,a,y,m,x,M){this.uchar=void 0,this.penState=void 0,this.uchar=h||" ",this.penState=new u(a,y,m,x,M)}var c=d.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,y){this.uchar=a,this.penState.copy(y)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),s=function(){function d(h){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<F;a++)this.chars.push(new o);this.logger=h,this.pos=0,this.currPenState=new u}var c=d.prototype;return c.equals=function(a){for(var y=!0,m=0;m<F;m++)if(!this.chars[m].equals(a.chars[m])){y=!1;break}return y},c.copy=function(a){for(var y=0;y<F;y++)this.chars[y].copy(a.chars[y])},c.isEmpty=function(){for(var a=!0,y=0;y<F;y++)if(!this.chars[y].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>F&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},c.moveCursor=function(a){var y=this.pos+a;if(a>1)for(var m=this.pos+1;m<y+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(y)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var y=D(a);if(this.pos>=F){this.logger.log(L.ERROR,"Cannot insert "+a.toString(16)+" ("+y+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var y;for(y=a;y<F;y++)this.chars[y].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],y=!0,m=0;m<F;m++){var x=this.chars[m].uchar;x!==" "&&(y=!1),a.push(x)}return y?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var y=this.chars[this.pos];y.setPenState(this.currPenState)},d}(),l=function(){function d(h){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<j;a++)this.rows.push(new s(h));this.logger=h,this.currRow=j-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=d.prototype;return c.reset=function(){for(var a=0;a<j;a++)this.rows[a].clear();this.currRow=j-1},c.equals=function(a){for(var y=!0,m=0;m<j;m++)if(!this.rows[m].equals(a.rows[m])){y=!1;break}return y},c.copy=function(a){for(var y=0;y<j;y++)this.rows[y].copy(a.rows[y])},c.isEmpty=function(){for(var a=!0,y=0;y<j;y++)if(!this.rows[y].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var y=this.rows[this.currRow];y.insertChar(a)},c.setPen=function(a){var y=this.rows[this.currRow];y.setPenStyles(a)},c.moveCursor=function(a){var y=this.rows[this.currRow];y.moveCursor(a)},c.setCursor=function(a){this.logger.log(L.INFO,"setCursor: "+a);var y=this.rows[this.currRow];y.setCursor(a)},c.setPAC=function(a){this.logger.log(L.INFO,"pacData = "+JSON.stringify(a));var y=a.row-1;if(this.nrRollUpRows&&y<this.nrRollUpRows-1&&(y=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==y){for(var m=0;m<j;m++)this.rows[m].clear();var x=this.currRow+1-this.nrRollUpRows,M=this.lastOutputScreen;if(M){var G=M.rows[x].cueStartTime,$=this.logger.time;if(G&&$!==null&&G<$)for(var re=0;re<this.nrRollUpRows;re++)this.rows[y-this.nrRollUpRows+re+1].copy(M.rows[x+re])}}this.currRow=y;var z=this.rows[this.currRow];if(a.indent!==null){var U=a.indent,ne=Math.max(U-1,0);z.setCursor(a.indent),a.color=z.chars[ne].penState.foreground}var fe={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(fe)},c.setBkgData=function(a){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(a,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(L.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var y=[],m="",x=-1,M=0;M<j;M++){var G=this.rows[M].getTextString();G&&(x=M+1,a?y.push("Row "+x+": '"+G+"'"):y.push(G.trim()))}return y.length>0&&(a?m="["+y.join(" | ")+"]":m=y.join(`
|
|
`)),m},c.getTextAndFormat=function(){return this.rows},d}(),S=function(){function d(h,a,y){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=h,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new l(y),this.nonDisplayedMemory=new l(y),this.lastOutputScreen=new l(y),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=y}var c=d.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[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(L.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},c.insertChars=function(a){for(var y=0;y<a.length;y++)this.writeScreen.insertChar(a[y]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(L.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(L.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(a){this.logger.log(L.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},c.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(L.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(L.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var y={flash:!1};if(y.underline=a%2===1,y.italics=a>=46,y.italics)y.foreground="white";else{var m=Math.floor(a/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];y.foreground=x[m]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(y)),this.writeScreen.setPen(y)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var y=this.logger.time;if(y===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=y:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,y,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:y),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))},d}(),p=function(){function d(h,a,y){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new w;this.channels=[null,new S(h,a,m),new S(h+1,y,m)],this.cmdHistory=v(),this.logger=m}var c=d.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,y){this.channels[a].setHandler(y)},c.addData=function(a,y){var m,x,M,G=!1;this.logger.time=a;for(var $=0;$<y.length;$+=2){if(x=y[$]&127,M=y[$+1]&127,x===0&&M===0)continue;if(this.logger.log(L.DATA,"["+E([y[$],y[$+1]])+"] -> ("+E([x,M])+")"),m=this.parseCmd(x,M),m||(m=this.parseMidrow(x,M)),m||(m=this.parsePAC(x,M)),m||(m=this.parseBackgroundAttributes(x,M)),!m&&(G=this.parseChars(x,M),G)){var re=this.currentChannel;if(re&&re>0){var z=this.channels[re];z.insertChars(G)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!G&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+E([x,M])+" orig: "+E([y[$],y[$+1]]))}},c.parseCmd=function(a,y){var m=this.cmdHistory,x=(a===20||a===28||a===21||a===29)&&y>=32&&y<=47,M=(a===23||a===31)&&y>=33&&y<=35;if(!(x||M))return!1;if(C(a,y,m))return f(null,null,m),this.logger.log(L.DEBUG,"Repeated command ("+E([a,y])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,$=this.channels[G];return a===20||a===21||a===28||a===29?y===32?$.ccRCL():y===33?$.ccBS():y===34?$.ccAOF():y===35?$.ccAON():y===36?$.ccDER():y===37?$.ccRU(2):y===38?$.ccRU(3):y===39?$.ccRU(4):y===40?$.ccFON():y===41?$.ccRDC():y===42?$.ccTR():y===43?$.ccRTD():y===44?$.ccEDM():y===45?$.ccCR():y===46?$.ccENM():y===47&&$.ccEOC():$.ccTO(y-32),f(a,y,m),this.currentChannel=G,!0},c.parseMidrow=function(a,y){var m=0;if((a===17||a===25)&&y>=32&&y<=47){if(a===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[m];return x?(x.ccMIDROW(y),this.logger.log(L.DEBUG,"MIDROW ("+E([a,y])+")"),!0):!1}return!1},c.parsePAC=function(a,y){var m,x=this.cmdHistory,M=(a>=17&&a<=23||a>=25&&a<=31)&&y>=64&&y<=127,G=(a===16||a===24)&&y>=64&&y<=95;if(!(M||G))return!1;if(C(a,y,x))return f(null,null,x),!0;var $=a<=23?1:2;y>=64&&y<=95?m=$===1?P[a]:g[a]:m=$===1?O[a]:T[a];var re=this.channels[$];return re?(re.setPAC(this.interpretPAC(m,y)),f(a,y,x),this.currentChannel=$,!0):!1},c.interpretPAC=function(a,y){var m,x={color:null,italics:!1,indent:null,underline:!1,row:a};return y>95?m=y-96:m=y-64,x.underline=(m&1)===1,m<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((m-16)/2)*4,x},c.parseChars=function(a,y){var m,x=null,M=null;if(a>=25?(m=2,M=a-8):(m=1,M=a),M>=17&&M<=19){var G;M===17?G=y+80:M===18?G=y+112:G=y+144,this.logger.log(L.INFO,"Special char '"+D(G)+"' in channel "+m),x=[G]}else a>=32&&a<=127&&(x=y===0?[a]:[a,y]);if(x){var $=E(x);this.logger.log(L.DEBUG,"Char codes = "+$.join(",")),f(a,y,this.cmdHistory)}return x},c.parseBackgroundAttributes=function(a,y){var m=(a===16||a===24)&&y>=32&&y<=47,x=(a===23||a===31)&&y>=45&&y<=47;if(!(m||x))return!1;var M,G={};a===16||a===24?(M=Math.floor((y-32)/2),G.background=R[M],y%2===1&&(G.background=G.background+"_semi")):y===45?G.background="transparent":(G.foreground="black",y===47&&(G.underline=!0));var $=a<=23?1:2,re=this.channels[$];return re.setBkgData(G),f(a,y,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var y=this.channels[a];y&&y.reset()}this.cmdHistory=v()},c.cueSplitAtTime=function(a){for(var y=0;y<this.channels.length;y++){var m=this.channels[y];m&&m.cueSplitAtTime(a)}},d}();function f(d,c,h){h.a=d,h.b=c}function C(d,c,h){return h.a===d&&h.b===c}function v(){return{a:null,b:null}}Y.default=p},"./src/utils/codecs.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"isCodecType",function(){return I}),k.d(Y,"isCodecSupportedInMp4",function(){return D});var V={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function I(j,F){var P=V[F];return!!P&&P[j.slice(0,4)]===!0}function D(j,F){return MediaSource.isTypeSupported((F||"video")+'/mp4;codecs="'+j+'"')}},"./src/utils/cues.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/utils/vttparser.ts"),I=k("./src/utils/webvtt-parser.ts"),D=k("./src/utils/texttrack-utils.ts"),j=/\s/,F={newCue:function(O,g,T,R){for(var L=[],w,E,u,o,s,l=self.VTTCue||self.TextTrackCue,S=0;S<R.rows.length;S++)if(w=R.rows[S],u=!0,o=0,s="",!w.isEmpty()){for(var p=0;p<w.chars.length;p++)j.test(w.chars[p].uchar)&&u?o++:(s+=w.chars[p].uchar,u=!1);w.cueStartTime=g,g===T&&(T+=1e-4),o>=16?o--:o++;var f=Object(V.fixLineBreaks)(s.trim()),C=Object(I.generateCueId)(g,T,f);(!O||!O.cues||!O.cues.getCueById(C))&&(E=new l(g,T,f),E.id=C,E.line=S+1,E.align="left",E.position=10+Math.min(80,Math.floor(o*8/32)*10),L.push(E))}return O&&L.length&&(L.sort(function(v,d){return v.line==="auto"||d.line==="auto"?0:v.line>8&&d.line>8?d.line-v.line:v.line-d.line}),L.forEach(function(v){return Object(D.addCueToTrack)(O,v)})),L}};Y.default=F},"./src/utils/discontinuities.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"findFirstFragWithCC",function(){return j}),k.d(Y,"shouldAlignOnDiscontinuities",function(){return F}),k.d(Y,"findDiscontinuousReferenceFrag",function(){return P}),k.d(Y,"adjustSlidingStart",function(){return g}),k.d(Y,"alignStream",function(){return T}),k.d(Y,"alignPDT",function(){return L}),k.d(Y,"alignFragmentByPDTDelta",function(){return w}),k.d(Y,"alignMediaPlaylistByPDT",function(){return E});var V=k("./src/polyfills/number.ts"),I=k("./src/utils/logger.ts"),D=k("./src/controller/level-helper.ts");function j(u,o){for(var s=null,l=0,S=u.length;l<S;l++){var p=u[l];if(p&&p.cc===o){s=p;break}}return s}function F(u,o,s){return!!(o.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function P(u,o){var s=u.fragments,l=o.fragments;if(!l.length||!s.length){I.logger.log("No fragments to align");return}var S=j(s,l[0].cc);if(!S||S&&!S.startPTS){I.logger.log("No frag in previous level to align on");return}return S}function O(u,o){if(u){var s=u.start+o;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function g(u,o){for(var s=o.fragments,l=0,S=s.length;l<S;l++)O(s[l],u);o.fragmentHint&&O(o.fragmentHint,u),o.alignedSliding=!0}function T(u,o,s){if(!o)return;R(u,s,o),!s.alignedSliding&&o.details&&L(s,o.details),!s.alignedSliding&&o.details&&!s.skippedSegments&&Object(D.adjustSliding)(o.details,s)}function R(u,o,s){if(F(u,s,o)){var l=P(s.details,o);l&&Object(V.isFiniteNumber)(l.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),g(l.start,o))}}function L(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,l=u.fragments[0].programDateTime,S=(l-s)/1e3+o.fragments[0].start;S&&Object(V.isFiniteNumber)(S)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(l-s)+"ms, sliding:"+S.toFixed(3)+" "+u.url+" "),g(S,u))}function w(u,o){var s=u.programDateTime;if(!s)return;var l=(s-o)/1e3;u.start=u.startPTS=l,u.endPTS=l+u.duration}function E(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,l=o.fragments[0].start,S=s-l*1e3;u.fragments.forEach(function(p){w(p,S)}),u.fragmentHint&&w(u.fragmentHint,S),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/utils/ewma.ts"),I=function(){function D(F,P,O){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=O,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(F),this.fast_=new V.default(P)}var j=D.prototype;return j.update=function(P,O){var g=this.slow_,T=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new V.default(P,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==O&&(this.fast_=new V.default(O,T.getEstimate(),T.getTotalWeight()))},j.sample=function(P,O){P=Math.max(P,this.minDelayMs_);var g=8*O,T=P/1e3,R=g/T;this.fast_.sample(T,R),this.slow_.sample(T,R)},j.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},j.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},j.destroy=function(){},D}();Y.default=I},"./src/utils/ewma.ts":function(ue,Y,k){"use strict";k.r(Y);var V=function(){function I(j,F,P){F===void 0&&(F=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=j,this.alpha_=j?Math.exp(Math.log(.5)/j):0,this.estimate_=F,this.totalWeight_=P}var D=I.prototype;return D.sample=function(F,P){var O=Math.pow(this.alpha_,F);this.estimate_=P*(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}();Y.default=V},"./src/utils/fetch-loader.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"fetchSupported",function(){return w});var V=k("./src/polyfills/number.ts"),I=k("./src/loader/load-stats.ts"),D=k("./src/demux/chunk-cache.ts");function j(l,S){l.prototype=Object.create(S.prototype),l.prototype.constructor=l,T(l,S)}function F(l){var S=typeof Map=="function"?new Map:void 0;return F=function(f){if(f===null||!g(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof S!="undefined"){if(S.has(f))return S.get(f);S.set(f,C)}function C(){return P(f,arguments,R(this).constructor)}return C.prototype=Object.create(f.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),T(C,f)},F(l)}function P(l,S,p){return O()?P=Reflect.construct:P=function(C,v,d){var c=[null];c.push.apply(c,v);var h=Function.bind.apply(C,c),a=new h;return d&&T(a,d.prototype),a},P.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(l){return!1}}function g(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function T(l,S){return T=Object.setPrototypeOf||function(f,C){return f.__proto__=C,f},T(l,S)}function R(l){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},R(l)}function L(){return L=Object.assign||function(l){for(var S=1;S<arguments.length;S++){var p=arguments[S];for(var f in p)Object.prototype.hasOwnProperty.call(p,f)&&(l[f]=p[f])}return l},L.apply(this,arguments)}function w(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(l){}return!1}var E=function(){function l(p){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=p.fetchSetup||o,this.controller=new self.AbortController,this.stats=new I.LoadStats}var S=l.prototype;return S.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},S.abortInternal=function(){var f=this.response;(!f||!f.ok)&&(this.stats.aborted=!0,this.controller.abort())},S.abort=function(){var f;this.abortInternal(),(f=this.callbacks)!==null&&f!==void 0&&f.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},S.load=function(f,C,v){var d=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var h=u(f,this.controller.signal),a=v.onProgress,y=f.responseType==="arraybuffer",m=y?"byteLength":"length";this.context=f,this.config=C,this.callbacks=v,this.request=this.fetchSetup(f,h),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){d.abortInternal(),v.onTimeout(c,f,d.response)},C.timeout),self.fetch(this.request).then(function(x){if(d.response=d.loader=x,!x.ok){var M=x.status,G=x.statusText;throw new s(G||"fetch, bad network response",M,x)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(x.headers.get("Content-Length")||"0"),a&&Object(V.isFiniteNumber)(C.highWaterMark)?d.loadProgressively(x,c,f,C.highWaterMark,a):y?x.arrayBuffer():x.text()}).then(function(x){var M=d.response;self.clearTimeout(d.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=x[m];var G={url:M.url,data:x};a&&!Object(V.isFiniteNumber)(C.highWaterMark)&&a(c,f,x,M),v.onSuccess(G,c,f,M)}).catch(function(x){if(self.clearTimeout(d.requestTimeout),c.aborted)return;var M=x.code||0;v.onError({code:M,text:x.message},f,x.details)})},S.getCacheAge=function(){var f=null;if(this.response){var C=this.response.headers.get("age");f=C?parseFloat(C):null}return f},S.loadProgressively=function(f,C,v,d,c){d===void 0&&(d=0);var h=new D.default,a=f.body.getReader(),y=function m(){return a.read().then(function(x){if(x.done)return h.dataLength&&c(C,v,h.flush(),f),Promise.resolve(new ArrayBuffer(0));var M=x.value,G=M.length;return C.loaded+=G,G<d||h.dataLength?(h.push(M),h.dataLength>=d&&c(C,v,h.flush(),f)):c(C,v,M,f),m()}).catch(function(){return Promise.reject()})};return y()},l}();function u(l,S){var p={method:"GET",mode:"cors",credentials:"same-origin",signal:S,headers:new self.Headers(L({},l.headers))};return l.rangeEnd&&p.headers.set("Range","bytes="+l.rangeStart+"-"+String(l.rangeEnd-1)),p}function o(l,S){return new self.Request(l.url,S)}var s=function(l){j(S,l);function S(p,f,C){var v;return v=l.call(this,p)||this,v.code=void 0,v.details=void 0,v.code=f,v.details=C,v}return S}(F(Error));Y.default=E},"./src/utils/imsc1-ttml-parser.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"IMSC1_CODEC",function(){return g}),k.d(Y,"parseIMSC1",function(){return w});var V=k("./src/utils/mp4-tools.ts"),I=k("./src/utils/vttparser.ts"),D=k("./src/utils/vttcue.ts"),j=k("./src/demux/id3.ts"),F=k("./src/utils/timescale-conversion.ts"),P=k("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(d){for(var c=1;c<arguments.length;c++){var h=arguments[c];for(var a in h)Object.prototype.hasOwnProperty.call(h,a)&&(d[a]=h[a])}return d},O.apply(this,arguments)}var g="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function w(d,c,h,a,y){var m=Object(V.findBox)(new Uint8Array(d),["mdat"]);if(m.length===0){y(new Error("Could not parse IMSC1 mdat"));return}var x=m[0],M=Object(j.utf8ArrayToStr)(new Uint8Array(d,x.start,x.end-x.start)),G=Object(F.toTimescaleFromScale)(c,1,h);try{a(E(M,G))}catch($){y($)}}function E(d,c){var h=new DOMParser,a=h.parseFromString(d,"text/xml"),y=a.getElementsByTagName("tt")[0];if(!y)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(m).reduce(function(z,U){return z[U]=y.getAttribute("ttp:"+U)||m[U],z},{}),M=y.getAttribute("xml:space")!=="preserve",G=o(u(y,"styling","style")),$=o(u(y,"layout","region")),re=u(y,"body","[begin]");return[].map.call(re,function(z){var U=s(z,M);if(!U||!z.hasAttribute("begin"))return null;var ne=f(z.getAttribute("begin"),x),fe=f(z.getAttribute("dur"),x),ge=f(z.getAttribute("end"),x);if(ne===null)throw p(z);if(ge===null){if(fe===null)throw p(z);ge=ne+fe}var be=new D.default(ne-c,ge-c,U);be.id=Object(P.generateCueId)(be.startTime,be.endTime,be.text);var Me=$[z.getAttribute("region")],Te=G[z.getAttribute("style")];be.position=10,be.size=80;var De=l(Me,Te),Ce=De.textAlign;if(Ce){var we=L[Ce];we&&(be.lineAlign=we),be.align=Ce}return O(be,De),be}).filter(function(z){return z!==null})}function u(d,c,h){var a=d.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(h)):[]}function o(d){return d.reduce(function(c,h){var a=h.getAttribute("xml:id");return a&&(c[a]=h),c},{})}function s(d,c){return[].slice.call(d.childNodes).reduce(function(h,a,y){var m;return a.nodeName==="br"&&y?h+`
|
|
`:(m=a.childNodes)!==null&&m!==void 0&&m.length?s(a,c):c?h+a.textContent.trim().replace(/\s+/g," "):h+a.textContent},"")}function l(d,c){var h="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(y,m){var x=S(c,h,m)||S(d,h,m);return x&&(y[m]=x),y},{})}function S(d,c,h){return d.hasAttributeNS(c,h)?d.getAttributeNS(c,h):null}function p(d){return new Error("Could not parse ttml timestamp "+d)}function f(d,c){if(!d)return null;var h=Object(I.parseTimeStamp)(d);return h===null&&(T.test(d)?h=C(d,c):R.test(d)&&(h=v(d,c))),h}function C(d,c){var h=T.exec(d),a=(h[4]|0)+(h[5]|0)/c.subFrameRate;return(h[1]|0)*3600+(h[2]|0)*60+(h[3]|0)+a/c.frameRate}function v(d,c){var h=R.exec(d),a=Number(h[1]),y=h[2];switch(y){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"enableLogs",function(){return P}),k.d(Y,"logger",function(){return O});var V=function(){},I={trace:V,debug:V,log:V,warn:V,info:V,error:V},D=I;function j(g){var T=self.console[g];return T?T.bind(self.console,"["+g+"] >"):V}function F(g){for(var T=arguments.length,R=new Array(T>1?T-1:0),L=1;L<T;L++)R[L-1]=arguments[L];R.forEach(function(w){D[w]=g[w]?g[w].bind(g):j(w)})}function P(g){if(self.console&&g===!0||typeof g=="object"){F(g,"debug","log","info","warn","error");try{D.log()}catch(T){D=I}}else D=I}var O=D},"./src/utils/mediakeys-helper.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"KeySystems",function(){return V}),k.d(Y,"requestMediaKeySystemAccess",function(){return I});var V;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})(V||(V={}));var I=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"bin2str",function(){return F}),k.d(Y,"readUint16",function(){return P}),k.d(Y,"readUint32",function(){return O}),k.d(Y,"writeUint32",function(){return g}),k.d(Y,"findBox",function(){return T}),k.d(Y,"parseSegmentIndex",function(){return R}),k.d(Y,"parseInitSegment",function(){return L}),k.d(Y,"getStartDTS",function(){return w}),k.d(Y,"getDuration",function(){return E}),k.d(Y,"computeRawDurationFromSamples",function(){return u}),k.d(Y,"offsetStartDTS",function(){return o}),k.d(Y,"segmentValidRange",function(){return s}),k.d(Y,"appendUint8Array",function(){return l});var V=k("./src/utils/typed-array.ts"),I=k("./src/loader/fragment.ts"),D=Math.pow(2,32)-1,j=[].push;function F(S){return String.fromCharCode.apply(null,S)}function P(S,p){"data"in S&&(p+=S.start,S=S.data);var f=S[p]<<8|S[p+1];return f<0?65536+f:f}function O(S,p){"data"in S&&(p+=S.start,S=S.data);var f=S[p]<<24|S[p+1]<<16|S[p+2]<<8|S[p+3];return f<0?4294967296+f:f}function g(S,p,f){"data"in S&&(p+=S.start,S=S.data),S[p]=f>>24,S[p+1]=f>>16&255,S[p+2]=f>>8&255,S[p+3]=f&255}function T(S,p){var f=[];if(!p.length)return f;var C,v,d;"data"in S?(C=S.data,v=S.start,d=S.end):(C=S,v=0,d=C.byteLength);for(var c=v;c<d;){var h=O(C,c),a=F(C.subarray(c+4,c+8)),y=h>1?c+h:d;if(a===p[0])if(p.length===1)f.push({data:C,start:c+8,end:y});else{var m=T({data:C,start:c+8,end:y},p.slice(1));m.length&&j.apply(f,m)}c=y}return f}function R(S){var p=T(S,["moov"]),f=p[0],C=f?f.end:null,v=T(S,["sidx"]);if(!v||!v[0])return null;var d=[],c=v[0],h=c.data[0],a=h===0?8:16,y=O(c,a);a+=4;var m=0,x=0;h===0?a+=8:a+=16,a+=2;var M=c.end+x,G=P(c,a);a+=2;for(var $=0;$<G;$++){var re=a,z=O(c,re);re+=4;var U=z&2147483647,ne=(z&2147483648)>>>31;if(ne===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var fe=O(c,re);re+=4,d.push({referenceSize:U,subsegmentDuration:fe,info:{duration:fe/y,start:M,end:M+U-1}}),M+=U,re+=4,a=re}return{earliestPresentationTime:m,timescale:y,version:h,referencesCount:G,references:d,moovEndOffset:C}}function L(S){for(var p=[],f=T(S,["moov","trak"]),C=0;C<f.length;C++){var v=f[C],d=T(v,["tkhd"])[0];if(d){var c=d.data[d.start],h=c===0?12:20,a=O(d,h),y=T(v,["mdia","mdhd"])[0];if(y){c=y.data[y.start],h=c===0?12:20;var m=O(y,h),x=T(v,["mdia","hdlr"])[0];if(x){var M=F(x.data.subarray(x.start+8,x.start+12)),G={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[M];if(G){var $=T(v,["mdia","minf","stbl","stsd"])[0],re=void 0;$&&(re=F($.data.subarray($.start+12,$.start+16))),p[a]={timescale:m,type:G},p[G]={timescale:m,id:a,codec:re}}}}}}var z=T(S,["moov","mvex","trex"]);return z.forEach(function(U){var ne=O(U,4),fe=p[ne];fe&&(fe.default={duration:O(U,12),flags:O(U,20)})}),p}function w(S,p){return T(p,["moof","traf"]).reduce(function(f,C){var v=T(C,["tfdt"])[0],d=v.data[v.start],c=T(C,["tfhd"]).reduce(function(h,a){var y=O(a,4),m=S[y];if(m){var x=O(v,4);d===1&&(x*=Math.pow(2,32),x+=O(v,8));var M=m.timescale||9e4,G=x/M;if(isFinite(G)&&(h===null||G<h))return G}return h},null);return c!==null&&isFinite(c)&&(f===null||c<f)?c:f},null)||0}function E(S,p){for(var f=0,C=0,v=0,d=T(S,["moof","traf"]),c=0;c<d.length;c++){var h=d[c],a=T(h,["tfhd"])[0],y=O(a,4),m=p[y];if(!m)continue;var x=m.default,M=O(a,0)|(x==null?void 0:x.flags),G=x==null?void 0:x.duration;M&8&&(M&2?G=O(a,12):G=O(a,8));for(var $=m.timescale||9e4,re=T(h,["trun"]),z=0;z<re.length;z++){if(G){var U=O(re[z],4);f=G*U}else f=u(re[z]);m.type===I.ElementaryStreamTypes.VIDEO?C+=f/$:m.type===I.ElementaryStreamTypes.AUDIO&&(v+=f/$)}}if(C===0&&v===0){var ne=R(S);if(ne!=null&&ne.references)return ne.references.reduce(function(fe,ge){return fe+ge.info.duration||0},0)}return C||v}function u(S){var p=O(S,0),f=8;p&1&&(f+=4),p&4&&(f+=4);for(var C=0,v=O(S,4),d=0;d<v;d++){if(p&256){var c=O(S,f);C+=c,f+=4}p&512&&(f+=4),p&1024&&(f+=4),p&2048&&(f+=4)}return C}function o(S,p,f){T(p,["moof","traf"]).forEach(function(C){T(C,["tfhd"]).forEach(function(v){var d=O(v,4),c=S[d];if(!c)return;var h=c.timescale||9e4;T(C,["tfdt"]).forEach(function(a){var y=a.data[a.start],m=O(a,4);if(y===0)g(a,4,m-f*h);else{m*=Math.pow(2,32),m+=O(a,8),m-=f*h,m=Math.max(m,0);var x=Math.floor(m/(D+1)),M=Math.floor(m%(D+1));g(a,4,x),g(a,8,M)}})})})}function s(S){var p={valid:null,remainder:null},f=T(S,["moof"]);if(f){if(f.length<2)return p.remainder=S,p}else return p;var C=f[f.length-1];return p.valid=Object(V.sliceUint8)(S,0,C.start-8),p.remainder=Object(V.sliceUint8)(S,C.start-8),p}function l(S,p){var f=new Uint8Array(S.length+p.length);return f.set(S),f.set(p,S.length),f}},"./src/utils/output-filter.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"default",function(){return V});var V=function(){function I(j,F){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=j,this.trackName=F}var D=I.prototype;return D.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},D.newCue=function(F,P,O){(this.startTime===null||this.startTime>F)&&(this.startTime=F),this.endTime=P,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"sendAddTrackEvent",function(){return I}),k.d(Y,"addCueToTrack",function(){return D}),k.d(Y,"clearCurrentCues",function(){return j}),k.d(Y,"removeCuesInRange",function(){return F}),k.d(Y,"getCuesInRange",function(){return O});var V=k("./src/utils/logger.ts");function I(g,T){var R;try{R=new Event("addtrack")}catch(L){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=g,T.dispatchEvent(R)}function D(g,T){var R=g.mode;if(R==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(T.id))try{if(g.addCue(T),!g.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(w){V.logger.debug("[texttrack-utils]: "+w);var L=new self.TextTrackCue(T.startTime,T.endTime,T.text);L.id=T.id,g.addCue(L)}R==="disabled"&&(g.mode=R)}function j(g){var T=g.mode;if(T==="disabled"&&(g.mode="hidden"),g.cues)for(var R=g.cues.length;R--;)g.removeCue(g.cues[R]);T==="disabled"&&(g.mode=T)}function F(g,T,R){var L=g.mode;if(L==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var w=O(g.cues,T,R),E=0;E<w.length;E++)g.removeCue(w[E]);L==="disabled"&&(g.mode=L)}function P(g,T){if(T<g[0].startTime)return 0;var R=g.length-1;if(T>g[R].endTime)return-1;for(var L=0,w=R;L<=w;){var E=Math.floor((w+L)/2);if(T<g[E].startTime)w=E-1;else if(T>g[E].startTime&&L<R)L=E+1;else return E}return g[L].startTime-T<T-g[w].startTime?L:w}function O(g,T,R){var L=[],w=P(g,T);if(w>-1)for(var E=w,u=g.length;E<u;E++){var o=g[E];if(o.startTime>=T&&o.endTime<=R)L.push(o);else if(o.startTime>R)return L}return L}},"./src/utils/time-ranges.ts":function(ue,Y,k){"use strict";k.r(Y);var V={toString:function(D){for(var j="",F=D.length,P=0;P<F;P++)j+="["+D.start(P).toFixed(3)+","+D.end(P).toFixed(3)+"]";return j}};Y.default=V},"./src/utils/timescale-conversion.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"toTimescaleFromBase",function(){return I}),k.d(Y,"toTimescaleFromScale",function(){return D}),k.d(Y,"toMsFromMpegTsClock",function(){return j}),k.d(Y,"toMpegTsClockFromTimescale",function(){return F});var V=9e4;function I(P,O,g,T){g===void 0&&(g=1),T===void 0&&(T=!1);var R=P*O*g;return T?Math.round(R):R}function D(P,O,g,T){return g===void 0&&(g=1),T===void 0&&(T=!1),I(P,O,1/g,T)}function j(P,O){return O===void 0&&(O=!1),I(P,1e3,1/V,O)}function F(P,O){return O===void 0&&(O=1),I(P,V,1/O)}},"./src/utils/typed-array.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"sliceUint8",function(){return V});function V(I,D,j){return Uint8Array.prototype.slice?I.slice(D,j):new Uint8Array(Array.prototype.slice.call(I,D,j))}},"./src/utils/vttcue.ts":function(ue,Y,k){"use strict";k.r(Y),Y.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],I=["start","middle","end","left","right"];function D(g,T){if(typeof T!="string")return!1;if(!Array.isArray(g))return!1;var R=T.toLowerCase();return~g.indexOf(R)?R:!1}function j(g){return D(V,g)}function F(g){return D(I,g)}function P(g){for(var T=arguments.length,R=new Array(T>1?T-1:0),L=1;L<T;L++)R[L-1]=arguments[L];for(var w=1;w<arguments.length;w++){var E=arguments[w];for(var u in E)g[u]=E[u]}return g}function O(g,T,R){var L=this,w={enumerable:!0};L.hasBeenReset=!1;var E="",u=!1,o=g,s=T,l=R,S=null,p="",f=!0,C="auto",v="start",d=50,c="middle",h=50,a="middle";Object.defineProperty(L,"id",P({},w,{get:function(){return E},set:function(m){E=""+m}})),Object.defineProperty(L,"pauseOnExit",P({},w,{get:function(){return u},set:function(m){u=!!m}})),Object.defineProperty(L,"startTime",P({},w,{get:function(){return o},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");o=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",P({},w,{get:function(){return s},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");s=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",P({},w,{get:function(){return l},set:function(m){l=""+m,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",P({},w,{get:function(){return S},set:function(m){S=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",P({},w,{get:function(){return p},set:function(m){var x=j(m);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");p=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",P({},w,{get:function(){return f},set:function(m){f=!!m,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",P({},w,{get:function(){return C},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");C=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",P({},w,{get:function(){return v},set:function(m){var x=F(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");v=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",P({},w,{get:function(){return d},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");d=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",P({},w,{get:function(){return c},set:function(m){var x=F(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");c=x,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",P({},w,{get:function(){return h},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");h=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",P({},w,{get:function(){return a},set:function(m){var x=F(m);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");a=x,this.hasBeenReset=!0}})),L.displayState=void 0}return O.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"parseTimeStamp",function(){return D}),k.d(Y,"fixLineBreaks",function(){return T}),k.d(Y,"VTTParser",function(){return R});var V=k("./src/utils/vttcue.ts"),I=function(){function L(){}var w=L.prototype;return w.decode=function(u,o){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},L}();function D(L){function w(u,o,s,l){return(u|0)*3600+(o|0)*60+(s|0)+parseFloat(l||0)}var E=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?w(E[2],E[3],0,E[4]):w(E[1],E[2],E[3],E[4]):null}var j=function(){function L(){this.values=Object.create(null)}var w=L.prototype;return w.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},w.get=function(u,o,s){return s?this.has(u)?this.values[u]:o[s]:this.has(u)?this.values[u]:o},w.has=function(u){return u in this.values},w.alt=function(u,o,s){for(var l=0;l<s.length;++l)if(o===s[l]){this.set(u,o);break}},w.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},w.percent=function(u,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var s=parseFloat(o);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},L}();function F(L,w,E,u){var o=u?L.split(u):[L];for(var s in o){if(typeof o[s]!="string")continue;var l=o[s].split(E);if(l.length!==2)continue;var S=l[0],p=l[1];w(S,p)}}var P=new V.default(0,0,""),O=P.align==="middle"?"middle":"center";function g(L,w,E){var u=L;function o(){var S=D(L);if(S===null)throw new Error("Malformed timestamp: "+u);return L=L.replace(/^[^\sa-zA-Z-]+/,""),S}function s(S,p){var f=new j;F(S,function(d,c){var h;switch(d){case"region":for(var a=E.length-1;a>=0;a--)if(E[a].id===c){f.set(d,E[a].region);break}break;case"vertical":f.alt(d,c,["rl","lr"]);break;case"line":h=c.split(","),f.integer(d,h[0]),f.percent(d,h[0])&&f.set("snapToLines",!1),f.alt(d,h[0],["auto"]),h.length===2&&f.alt("lineAlign",h[1],["start",O,"end"]);break;case"position":h=c.split(","),f.percent(d,h[0]),h.length===2&&f.alt("positionAlign",h[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":f.percent(d,c);break;case"align":f.alt(d,c,["start",O,"end","left","right"]);break}},/:/,/\s/),p.region=f.get("region",null),p.vertical=f.get("vertical","");var C=f.get("line","auto");C==="auto"&&P.line===-1&&(C=-1),p.line=C,p.lineAlign=f.get("lineAlign","start"),p.snapToLines=f.get("snapToLines",!0),p.size=f.get("size",100),p.align=f.get("align",O);var v=f.get("position","auto");v==="auto"&&P.position===50&&(v=p.align==="start"||p.align==="left"?0:p.align==="end"||p.align==="right"?100:50),p.position=v}function l(){L=L.replace(/^\s+/,"")}if(l(),w.startTime=o(),l(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);L=L.substr(3),l(),w.endTime=o(),l(),s(L,w)}function T(L){return L.replace(/<br(?: \/)?>/gi,`
|
|
`)}var R=function(){function L(){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 w=L.prototype;return w.parse=function(u){var o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function s(){var v=o.buffer,d=0;for(v=T(v);d<v.length&&v[d]!=="\r"&&v[d]!==`
|
|
`;)++d;var c=v.substr(0,d);return v[d]==="\r"&&++d,v[d]===`
|
|
`&&++d,o.buffer=v.substr(d),c}function l(v){F(v,function(d,c){},/:/)}try{var S="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;S=s();var p=S.match(/^()?WEBVTT([ \t].*)?$/);if(!p||!p[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var f=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;f?f=!1:S=s();switch(o.state){case"HEADER":/:/.test(S)?l(S):S||(o.state="ID");continue;case"NOTE":S||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(S)){o.state="NOTE";break}if(!S)continue;if(o.cue=new V.default(0,0,""),o.state="CUE",S.indexOf("-->")===-1){o.cue.id=S;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{g(S,o.cue,o.regionList)}catch(v){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var C=S.indexOf("-->")!==-1;if(!S||C&&(f=!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+=S}continue;case"BADCUE":S||(o.state="ID")}}}catch(v){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},w.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
|
|
|
|
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){u.onparsingerror&&u.onparsingerror(o)}return u.onflush&&u.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(ue,Y,k){"use strict";k.r(Y),k.d(Y,"generateCueId",function(){return R}),k.d(Y,"parseWebVTT",function(){return w});var V=k("./src/polyfills/number.ts"),I=k("./src/utils/vttparser.ts"),D=k("./src/demux/id3.ts"),j=k("./src/utils/timescale-conversion.ts"),F=k("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,O=function(u,o,s){return s===void 0&&(s=0),u.substr(s,o.length)===o},g=function(u){var o=parseInt(u.substr(-3)),s=parseInt(u.substr(-6,2)),l=parseInt(u.substr(-9,2)),S=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(o)||!Object(V.isFiniteNumber)(s)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(S))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*s,o+=60*1e3*l,o+=60*60*1e3*S,o},T=function(u){for(var o=5381,s=u.length;s;)o=o*33^u.charCodeAt(--s);return(o>>>0).toString()};function R(E,u,o){return T(E.toString())+T(u.toString())+T(o)}var L=function(u,o,s){var l=u[o],S=u[l.prevCC];if(!S||!S.new&&l.new){u.ccOffset=u.presentationOffset=l.start,l.new=!1;return}for(;(p=S)!==null&&p!==void 0&&p.new;){var p;u.ccOffset+=l.start-S.start,l.new=!1,l=S,S=u[l.prevCC]}u.presentationOffset=s};function w(E,u,o,s,l,S,p,f){var C=new I.VTTParser,v=Object(D.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(P,`
|
|
`).split(`
|
|
`),d=[],c=Object(j.toMpegTsClockFromTimescale)(u,o),h="00:00.000",a=0,y=0,m,x=!0,M=!1;C.oncue=function(G){var $=s[l],re=s.ccOffset,z=(a-c)/9e4;if($!=null&&$.new&&(y!==void 0?re=s.ccOffset=$.start:L(s,l,z)),z&&(re=z-s.presentationOffset),M){var U=G.endTime-G.startTime,ne=Object(F.normalizePts)((G.startTime+re-y)*9e4,S*9e4)/9e4;G.startTime=ne,G.endTime=ne+U}var fe=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(fe)),G.id||(G.id=R(G.startTime,G.endTime,fe)),G.endTime>0&&d.push(G)},C.onparsingerror=function(G){m=G},C.onflush=function(){if(m){f(m);return}p(d)},v.forEach(function(G){if(x)if(O(G,"X-TIMESTAMP-MAP=")){x=!1,M=!0,G.substr(16).split(",").forEach(function($){O($,"LOCAL:")?h=$.substr(6):O($,"MPEGTS:")&&(a=parseInt($.substr(7)))});try{y=g(h)/1e3}catch($){M=!1,m=$}return}else G===""&&(x=!1);C.parse(G+`
|
|
`)}),C.flush()}},"./src/utils/xhr-loader.ts":function(ue,Y,k){"use strict";k.r(Y);var V=k("./src/utils/logger.ts"),I=k("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,j=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 P=F.prototype;return P.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},P.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},P.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},P.load=function(g,T,R){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=T,this.callbacks=R,this.retryDelay=T.retryDelay,this.loadInternal()},P.loadInternal=function(){var g=this.config,T=this.context;if(!g)return;var R=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var w=this.xhrSetup;try{if(w)try{w(R,T.url)}catch(o){R.open("GET",T.url,!0),w(R,T.url)}R.readyState||R.open("GET",T.url,!0);var E=this.context.headers;if(E)for(var u in E)R.setRequestHeader(u,E[u])}catch(o){this.callbacks.onError({code:R.status,text:o.message},T,R);return}T.rangeEnd&&R.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),R.send()},P.readystatechange=function(){var g=this.context,T=this.loader,R=this.stats;if(!g||!T)return;var L=T.readyState,w=this.config;if(R.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),L===4){T.onreadystatechange=null,T.onprogress=null;var E=T.status;if(E>=200&&E<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var u,o;if(g.responseType==="arraybuffer"?(u=T.response,o=u.byteLength):(u=T.responseText,o=u.length),R.loaded=R.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(R,g,u,T),!this.callbacks)return;var l={url:T.responseURL,data:u};this.callbacks.onSuccess(l,R,g,T)}else R.retry>=w.maxRetry||E>=400&&E<499?(V.logger.error(E+" while loading "+g.url),this.callbacks.onError({code:E,text:T.statusText},g,T)):(V.logger.warn(E+" while loading "+g.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,w.maxRetryDelay),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),w.timeout)},P.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},P.loadprogress=function(g){var T=this.stats;T.loaded=g.loaded,g.lengthComputable&&(T.total=g.total)},P.getCacheAge=function(){var g=null;if(this.loader&&D.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");g=T?parseFloat(T):null}return g},F}();Y.default=j}}).default})},vHTk:function(ht,Ze,le){ht.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|