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

361 lines
910 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[203,7,8],{"+NIl":function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";fe.defineMode("stex",function($,_){"use strict";function V(w,b){w.cmdState.push(b)}function M(w){return w.cmdState.length>0?w.cmdState[w.cmdState.length-1]:null}function D(w){var b=w.cmdState.pop();b&&b.closeBracket()}function j(w){for(var b=w.cmdState,x=b.length-1;x>=0;x--){var l=b[x];if(l.name=="DEFAULT")continue;return l}return{styleIdentifier:function(){return null}}}function U(w,b,x){return function(){this.name=w,this.bracketNo=0,this.style=b,this.styles=x,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var I={};I.importmodule=U("importmodule","tag",["string","builtin"]),I.documentclass=U("documentclass","tag",["","atom"]),I.usepackage=U("usepackage","tag",["atom"]),I.begin=U("begin","tag",["atom"]),I.end=U("end","tag",["atom"]),I.label=U("label","tag",["atom"]),I.ref=U("ref","tag",["atom"]),I.eqref=U("eqref","tag",["atom"]),I.cite=U("cite","tag",["atom"]),I.bibitem=U("bibitem","tag",["atom"]),I.Bibitem=U("Bibitem","tag",["atom"]),I.RBibitem=U("RBibitem","tag",["atom"]),I.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(w,b){w.f=b}function v(w,b){var x;if(w.match(/^\\[a-zA-Z@]+/)){var l=w.current().slice(1);return x=I.hasOwnProperty(l)?I[l]:I.DEFAULT,x=new x,V(b,x),O(b,R),x.style}if(w.match(/^\\[$&%#{}_]/))return"tag";if(w.match(/^\\[,;!\/\\]/))return"tag";if(w.match("\\["))return O(b,function(s,h){return g(s,h,"\\]")}),"keyword";if(w.match("\\("))return O(b,function(s,h){return g(s,h,"\\)")}),"keyword";if(w.match("$$"))return O(b,function(s,h){return g(s,h,"$$")}),"keyword";if(w.match("$"))return O(b,function(s,h){return g(s,h,"$")}),"keyword";var o=w.next();if(o=="%")return w.skipToEnd(),"comment";if(o=="}"||o=="]"){if(x=M(b),x)x.closeBracket(o),O(b,R);else return"error";return"bracket"}else return o=="{"||o=="["?(x=I.DEFAULT,x=new x,V(b,x),"bracket"):/\d/.test(o)?(w.eatWhile(/[\w.%]/),"atom"):(w.eatWhile(/[\w\-_]/),x=j(b),x.name=="begin"&&(x.argument=w.current()),x.styleIdentifier())}function g(w,b,x){if(w.eatSpace())return null;if(x&&w.match(x))return O(b,v),"keyword";if(w.match(/^\\[a-zA-Z@]+/))return"tag";if(w.match(/^[a-zA-Z]+/))return"variable-2";if(w.match(/^\\[$&%#{}_]/))return"tag";if(w.match(/^\\[,;!\/]/))return"tag";if(w.match(/^[\^_&]/))return"tag";if(w.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(w.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var l=w.next();return l=="{"||l=="}"||l=="["||l=="]"||l=="("||l==")"?"bracket":l=="%"?(w.skipToEnd(),"comment"):"error"}function R(w,b){var x=w.peek(),l;return x=="{"||x=="["?(l=M(b),l.openBracket(x),w.eat(x),O(b,v),"bracket"):/[ \t\r]/.test(x)?(w.eat(x),null):(O(b,v),D(b),v(w,b))}return{startState:function(){var w=_.inMathMode?function(b,x){return g(b,x)}:v;return{cmdState:[],f:w}},copyState:function(w){return{cmdState:w.cmdState.slice(),f:w.f}},token:function(w,b){return b.f(w,b)},blankLine:function(w){w.f=v,w.cmdState.length=0},lineComment:"%"}}),fe.defineMIME("text/x-stex","stex"),fe.defineMIME("text/x-latex","stex")})},"19Vz":function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){fe.defineOption("placeholder","",function(U,I,O){var v=O&&O!=fe.Init;if(I&&!v)U.on("blur",M),U.on("change",D),U.on("swapDoc",D),fe.on(U.getInputField(),"compositionupdate",U.state.placeholderCompose=function(){V(U)}),D(U);else if(!I&&v){U.off("blur",M),U.off("change",D),U.off("swapDoc",D),fe.off(U.getInputField(),"compositionupdate",U.state.placeholderCompose),$(U);var g=U.getWrapperElement();g.className=g.className.replace(" CodeMirror-empty","")}I&&!U.hasFocus()&&M(U)});function $(U){U.state.placeholder&&(U.state.placeholder.parentNode.removeChild(U.state.placeholder),U.state.placeholder=null)}function _(U){$(U);var I=U.state.placeholder=document.createElement("pre");I.style.cssText="height: 0; overflow: visible",I.style.direction=U.getOption("direction"),I.className="CodeMirror-placeholder CodeMirror-line-like";var O=U.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),I.appendChild(O),U.display.lineSpace.insertBefore(I,U.display.lineSpace.firstChild)}function V(U){setTimeout(function(){var I=!1,O=U.getInputField();O.nodeName=="TEXTAREA"?I=!O.value:U.lineCount()==1&&(I=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),I?_(U):$(U)},20)}function M(U){j(U)&&_(U)}function D(U){var I=U.getWrapperElement(),O=j(U);I.className=I.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?_(U):$(U)}function j(U){return U.lineCount()===1&&U.getLine(0)===""}})},"1eCo":function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";var $={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},_={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};fe.defineMode("xml",function(V,M){var D=V.indentUnit,j={},U=M.htmlMode?$:_;for(var I in U)j[I]=U[I];for(var I in M)j[I]=M[I];var O,v;function g(a,y){function c(G){return y.tokenize=G,G(a,y)}var S=a.next();if(S=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?c(b("atom","]]>")):null:a.match("--")?c(b("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),c(x(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),y.tokenize=b("meta","?>"),"meta"):(O=a.eat("/")?"closeTag":"openTag",y.tokenize=R,"tag bracket");if(S=="&"){var P;return a.eat("#")?a.eat("x")?P=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):P=a.eatWhile(/[\d]/)&&a.eat(";"):P=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),P?"atom":"error"}else return a.eatWhile(/[^&<]/),null}g.isInText=!0;function R(a,y){var c=a.next();if(c==">"||c=="/"&&a.eat(">"))return y.tokenize=g,O=c==">"?"endTag":"selfcloseTag","tag bracket";if(c=="=")return O="equals",null;if(c=="<"){y.tokenize=g,y.state=h,y.tagName=y.tagStart=null;var S=y.tokenize(a,y);return S?S+" tag error":"tag error"}else return/[\'\"]/.test(c)?(y.tokenize=w(c),y.stringStartCol=a.column(),y.tokenize(a,y)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function w(a){var y=function(c,S){for(;!c.eol();)if(c.next()==a){S.tokenize=R;break}return"string"};return y.isInAttribute=!0,y}function b(a,y){return function(c,S){for(;!c.eol();){if(c.match(y)){S.tokenize=g;break}c.next()}return a}}function x(a){return function(y,c){for(var S;(S=y.next())!=null;){if(S=="<")return c.tokenize=x(a+1),c.tokenize(y,c);if(S==">")if(a==1){c.tokenize=g;break}else return c.tokenize=x(a-1),c.tokenize(y,c)}return"meta"}}function l(a,y,c){this.prev=a.context,this.tagName=y,this.indent=a.indented,this.startOfLine=c,(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 c;;){if(!a.context)return;if(c=a.context.tagName,!j.contextGrabbers.hasOwnProperty(c)||!j.contextGrabbers[c].hasOwnProperty(y))return;o(a)}}function h(a,y,c){return a=="openTag"?(c.tagStart=y.column(),C):a=="closeTag"?m:h}function C(a,y,c){return a=="word"?(c.tagName=y.current(),v="tag",E):j.allowMissingTagName&&a=="endTag"?(v="tag bracket",E(a,y,c)):(v="error",C)}function m(a,y,c){if(a=="word"){var S=y.current();return c.context&&c.context.tagName!=S&&j.implicitlyClosed.hasOwnProperty(c.context.tagName)&&o(c),c.context&&c.context.tagName==S||j.matchClosing===!1?(v="tag",p):(v="tag error",A)}else return j.allowMissingTagName&&a=="endTag"?(v="tag bracket",p(a,y,c)):(v="error",A)}function p(a,y,c){return a!="endTag"?(v="error",p):(o(c),h)}function A(a,y,c){return v="error",p(a,y,c)}function E(a,y,c){if(a=="word")return v="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var S=c.tagName,P=c.tagStart;return c.tagName=c.tagStart=null,a=="selfcloseTag"||j.autoSelfClosers.hasOwnProperty(S)?s(c,S):(s(c,S),c.context=new l(c,S,P==c.indented)),h}return v="error",E}function f(a,y,c){return a=="equals"?d:(j.allowMissing||(v="error"),E(a,y,c))}function d(a,y,c){return a=="string"?u:a=="word"&&j.allowUnquoted?(v="string",E):(v="error",E(a,y,c))}function u(a,y,c){return a=="string"?u:E(a,y,c)}return{startState:function(a){var y={tokenize:g,state:h,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 c=y.tokenize(a,y);return(c||O)&&c!="comment"&&(v=null,y.state=y.state(O||c,a,y),v&&(c=v=="error"?c+" error":v)),c},indent:function(a,y,c){var S=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+D;if(S&&S.noIndent)return fe.Pass;if(a.tokenize!=R&&a.tokenize!=g)return c?c.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 P=y&&/^<(\/)?([\w_:\.-]*)/.exec(y);if(P&&P[1])for(;S;)if(S.tagName==P[2]){S=S.prev;break}else if(j.implicitlyClosed.hasOwnProperty(S.tagName))S=S.prev;else break;else if(P)for(;S;){var G=j.contextGrabbers[S.tagName];if(G&&G.hasOwnProperty(P[2]))S=S.prev;else break}for(;S&&S.prev&&!S.startOfLine;)S=S.prev;return S?S.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==d&&(a.state=E)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var y=[],c=a.context;c;c=c.prev)c.tagName&&y.push(c.tagName);return y.reverse()}}}),fe.defineMIME("text/xml","xml"),fe.defineMIME("application/xml","xml"),fe.mimeModes.hasOwnProperty("text/html")||fe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"30zm":function(ct,rt,le){"use strict";var fe=le("jCWc"),$=le("kPKH"),_=le("k1fw"),V=le("tJVT"),M=le("PpiC"),D=le("B9cy"),j=le("Ol7k"),U=le("lUTK"),I=le("BvKs"),O=le("q1tI"),v=le.n(O),g=le("Ty5D"),R=le("55Ip"),w=le("9kvl"),b=le("m3rI"),x=le("kzJb"),l=le.n(x),o=I.a.SubMenu,s=j.a.Sider,h=j.a.Content,C=function(p){var A=p.messages,E=p.globalSetting,f=p.loading,d=p.user,u=p.dispatch,a=Object(M.a)(p,["messages","globalSetting","loading","user","dispatch"]),y=Object(g.i)(),c=d.userInfo,S=Object(g.h)(),P=A.tidingsList,G=A.privateMessage,X=A.unreadInfo,te=Object(O.useState)({per_page:10,page:1}),z=Object(V.a)(te,2),F=z[0],ne=z[1];Object(O.useEffect)(function(){ce()},[y.userId]);var ce=function(){u({type:"messages/unreadMessageInfo",payload:Object(_.a)(Object(_.a)({},F),y)})};return v.a.createElement($.a,{flex:"264px"},v.a.createElement("aside",{className:l.a.userInfo},v.a.createElement("img",{className:"mt40",src:b.a.IMG_SERVER+"/images/"+(c==null?void 0:c.image_url)}),v.a.createElement("p",{className:"font24 mt10"},c==null?void 0:c.username),v.a.createElement("p",{className:"mt20"},c==null?void 0:c.user_identity)),v.a.createElement("ul",{className:l.a.navInfo},v.a.createElement(R.a,{to:"/messages/".concat(c==null?void 0:c.login,"/user_tidings")},v.a.createElement("li",{className:S.pathname.indexOf("user_tidings")>-1&&l.a.actived},"\u6D88\u606F",!!(X!=null&&X.unread_tiding_count)&&v.a.createElement("span",{className:l.a.newTip},X==null?void 0:X.unread_tiding_count))),v.a.createElement(R.a,{to:"/messages/".concat(c==null?void 0:c.login,"/private_messages")},v.a.createElement("li",{className:(S.pathname.indexOf("private_messages")>-1||S.pathname.indexOf("message_detail")>-1)&&l.a.actived},"\u79C1\u4FE1",!!(X!=null&&X.unread_message_count)&&v.a.createElement("span",{className:l.a.newTip},X==null?void 0:X.unread_message_count)))))};rt.a=Object(w.a)(function(m){var p=m.messages,A=m.loading,E=m.user,f=m.globalSetting;return{messages:p,globalSetting:f,user:E,loading:A.effects}})(C)},"55Ip":function(ct,rt,le){"use strict";le.d(rt,"a",function(){return s});var fe=le("Ty5D"),$=le("dI71"),_=le("q1tI"),V=le.n(_),M=le("YS25"),D=le("17x9"),j=le.n(D),U=le("wx14"),I=le("zLVn"),O=le("9R94"),v=function(d){Object($.a)(u,d);function u(){for(var y,c=arguments.length,S=new Array(c),P=0;P<c;P++)S[P]=arguments[P];return y=d.call.apply(d,[this].concat(S))||this,y.history=Object(M.a)(y.props),y}var a=u.prototype;return a.render=function(){return V.a.createElement(fe.c,{history:this.history,children:this.props.children})},u}(V.a.Component),g=function(d){Object($.a)(u,d);function u(){for(var y,c=arguments.length,S=new Array(c),P=0;P<c;P++)S[P]=arguments[P];return y=d.call.apply(d,[this].concat(S))||this,y.history=Object(M.b)(y.props),y}var a=u.prototype;return a.render=function(){return V.a.createElement(fe.c,{history:this.history,children:this.props.children})},u}(V.a.Component),R=function(u,a){return typeof u=="function"?u(a):u},w=function(u,a){return typeof u=="string"?Object(M.c)(u,null,null,a):u},b=function(u){return u},x=V.a.forwardRef;typeof x=="undefined"&&(x=b);function l(d){return!!(d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)}var o=x(function(d,u){var a=d.innerRef,y=d.navigate,c=d.onClick,S=Object(I.a)(d,["innerRef","navigate","onClick"]),P=S.target,G=Object(U.a)({},S,{onClick:function(te){try{c&&c(te)}catch(z){throw te.preventDefault(),z}!te.defaultPrevented&&te.button===0&&(!P||P==="_self")&&!l(te)&&(te.preventDefault(),y())}});return b!==x?G.ref=u||a:G.ref=a,V.a.createElement("a",G)}),s=x(function(d,u){var a=d.component,y=a===void 0?o:a,c=d.replace,S=d.to,P=d.innerRef,G=Object(I.a)(d,["component","replace","to","innerRef"]);return V.a.createElement(fe.e.Consumer,null,function(X){X||Object(O.a)(!1);var te=X.history,z=w(R(S,X.location),X.location),F=z?te.createHref(z):"",ne=Object(U.a)({},G,{href:F,navigate:function(){var ge=R(S,X.location),xe=c?te.replace:te.push;xe(ge)}});return b!==x?ne.ref=u||P:ne.innerRef=P,V.a.createElement(y,ne)})});if(!1)var h,C;var m=function(u){return u},p=V.a.forwardRef;typeof p=="undefined"&&(p=m);function A(){for(var d=arguments.length,u=new Array(d),a=0;a<d;a++)u[a]=arguments[a];return u.filter(function(y){return y}).join(" ")}var E=p(function(d,u){var a=d["aria-current"],y=a===void 0?"page":a,c=d.activeClassName,S=c===void 0?"active":c,P=d.activeStyle,G=d.className,X=d.exact,te=d.isActive,z=d.location,F=d.sensitive,ne=d.strict,ce=d.style,ge=d.to,xe=d.innerRef,Ie=Object(I.a)(d,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return V.a.createElement(fe.e.Consumer,null,function(Te){Te||Object(O.a)(!1);var Oe=z||Te.location,Ce=w(R(ge,Oe),Oe),Ae=Ce.pathname,ve=Ae&&Ae.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),W=ve?Object(fe.f)(Oe.pathname,{path:ve,exact:X,sensitive:F,strict:ne}):null,L=!!(te?te(W,Oe):W),k=L?A(G,S):G,H=L?Object(U.a)({},ce,{},P):ce,q=Object(U.a)({"aria-current":L&&y||null,className:k,style:H,to:Ce},Ie);return m!==p?q.ref=u||xe:q.innerRef=xe,V.a.createElement(s,q)})});if(!1)var f},"7Cbv":function(ct,rt,le){"use strict";var fe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),$=new Uint8Array(16);function _(){if(!fe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fe($)}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 M(R){return typeof R=="string"&&V.test(R)}for(var D=M,j=[],U=0;U<256;++U)j.push((U+256).toString(16).substr(1));function I(R){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,b=(j[R[w+0]]+j[R[w+1]]+j[R[w+2]]+j[R[w+3]]+"-"+j[R[w+4]]+j[R[w+5]]+"-"+j[R[w+6]]+j[R[w+7]]+"-"+j[R[w+8]]+j[R[w+9]]+"-"+j[R[w+10]]+j[R[w+11]]+j[R[w+12]]+j[R[w+13]]+j[R[w+14]]+j[R[w+15]]).toLowerCase();if(!D(b))throw TypeError("Stringified UUID is invalid");return b}var O=I;function v(R,w,b){R=R||{};var x=R.random||(R.rng||_)();if(x[6]=x[6]&15|64,x[8]=x[8]&63|128,w){b=b||0;for(var l=0;l<16;++l)w[b+l]=x[l];return w}return O(x)}var g=rt.a=v},"7ahc":function(ct,rt,le){"use strict";le.d(rt,"a",function(){return C});var fe=le("k1fw"),$=le("0Owb"),_=le("+L6B"),V=le("2/Rp"),M=le("y8nQ"),D=le("Vl3Y"),j=le("tJVT"),U=le("OaEy"),I=le("2fM7"),O=le("q1tI"),v=le.n(O),g=le("VrN/"),R=le.n(g),w=le("p77/"),b=le.n(w),x=le("c5Ni"),l=le.n(x),o=I.a.Option,s={labelCol:{span:4},wrapperCol:{span:20}},h={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};rt.b=function(m){var p=m.callback,A=m.onCancel,E=Object(O.useState)("python"),f=Object(j.a)(E,2),d=f[0],u=f[1];function a(c){u(h[c][1])}function y(c){p(c)}return v.a.createElement(D.a,Object($.a)({},s,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:y}),v.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(I.a,{onChange:a},Object.keys(h).map(function(c){return v.a.createElement(o,{key:c,value:c},h[c][0])}))),v.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(C,{mode:d})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement(V.a,{type:"ghost",onClick:A},"\u53D6\u6D88")))};function C(m){var p=m.value,A=m.onChange,E=m.mode,f=m.options,d=f===void 0?{}:f,u=Object(O.useRef)(),a=Object(O.useState)(),y=Object(j.a)(a,2),c=y[0],S=y[1];return Object(O.useEffect)(function(){if(c){function P(G){var X=G.getValue();A&&A(X)}return c.on("change",P),function(){c.off("change",P)}}},[c,A]),Object(O.useEffect)(function(){c&&c.setOption("mode",E)},[c,E]),Object(O.useEffect)(function(){c&&((p!==c.getValue()||p==="")&&setTimeout(function(){c.setValue(p||" ")},300))},[c,p]),Object(O.useEffect)(function(){if(u.current&&!c){var P=R.a.fromTextArea(u.current,Object(fe.a)({mode:E,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},d));S(P)}},[u.current,c]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:u}))}},"8EBN":function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";fe.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var $=0;$<fe.modeInfo.length;$++){var _=fe.modeInfo[$];_.mimes&&(_.mime=_.mimes[0])}fe.findModeByMIME=function(V){V=V.toLowerCase();for(var M=0;M<fe.modeInfo.length;M++){var D=fe.modeInfo[M];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 fe.findModeByMIME("application/xml");if(/\+json$/.test(V))return fe.findModeByMIME("application/json")},fe.findModeByExtension=function(V){V=V.toLowerCase();for(var M=0;M<fe.modeInfo.length;M++){var D=fe.modeInfo[M];if(D.ext){for(var j=0;j<D.ext.length;j++)if(D.ext[j]==V)return D}}},fe.findModeByFileName=function(V){for(var M=0;M<fe.modeInfo.length;M++){var D=fe.modeInfo[M];if(D.file&&D.file.test(V))return D}var j=V.lastIndexOf("."),U=j>-1&&V.substring(j+1,V.length);if(U)return fe.findModeByExtension(U)},fe.findModeByName=function(V){V=V.toLowerCase();for(var M=0;M<fe.modeInfo.length;M++){var D=fe.modeInfo[M];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(ct,rt,le){ct.exports={button:"button___1wy9m"}},"9Bee":function(ct,rt,le){"use strict";var fe=le("DYRE"),$=le("zeV3"),_=le("+L6B"),V=le("2/Rp"),M=le("k1fw"),D=le("9og8"),j=le("tJVT"),U=le("WmNS"),I=le.n(U),O=le("q1tI"),v=le.n(O),g=le("vg9a"),R=le("DlQD"),w=le.n(R),b=le("rUJ1");function x(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 re=Object(j.a)(Q,1),se=re[0];return se.length>=ie.length?oe.slice(ie.length):oe}).join(`
`)}var l=[],o=["<ul>"],s=new w.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function C(){l.length=0,o=["<ul>"]}var m={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(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=p(ae,J,oe.level,Q),Q.length>0&&(ie.push("<ul>"),Q.forEach(function(re){ie.push(re)}),ie.push("</ul>")),ie.push("</li>"),J=p(ae,J,Z,ie),J}function A(){return p(l,0,0,o),o.push("</ul>"),o.join("")}var E={heading:function(J){var Z=h.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=x(ie,Z[3]||""),Q=Z[2]?Z[2].trim():Z[2];if(["latex","katex","math"].indexOf(Q)>=0){var re=u(),se=oe;oe=re,a[re]={type:"block",expression:se}}return{type:"code",raw:ie,lang:Q,text:oe}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,d=0,u=function(){return"__special_katext_id_".concat(d++,"__")},a={};function y(){return a}function c(){d=0,a={}}function S(ae){return ae=ae.replace(f,function(J,Z){var ie=u();return a[ie]={type:"inline",expression:Z},ie}),ae}var P=s.listitem;s.listitem=function(ae){return P(S(ae))};var G=s.paragraph;s.paragraph=function(ae){return G(S(ae))};var X=s.tablecell;s.tablecell=function(ae,J){return X(S(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(b.escape)(ae,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(Z?ae:Object(b.escape)(ae,!0))+"</code></pre>"},s.heading=function(ae,J,Z){var ie=this.options.headerPrefix+Z.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return l.push({anchor:ie,level:J,text:ae}),"<h"+J+' id="'+ie+'">'+ae+"</h"+J+">"},w.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),w.a.use({tokenizer:E,renderer:s});var te=w.a,z=le("SJMd"),F=le("ulZh"),ne=le.n(F),ce=le("m3rI"),ge=le("Oy/b"),xe=le("p5ED"),Ie=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 Oe=function(ae,J){return(Oe=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}Oe(ae,J),ae.prototype=J===null?Object.create(J):(Z.prototype=J.prototype,new Z)}function Ae(ae,J,Z,ie){return new(Z||(Z=Promise))(function(oe,Q){function re(pe){try{he(ie.next(pe))}catch(ye){Q(ye)}}function se(pe){try{he(ie.throw(pe))}catch(ye){Q(ye)}}function he(pe){var ye;pe.done?oe(pe.value):(ye=pe.value,ye instanceof Z?ye:new Z(function(ke){ke(ye)})).then(re,se)}he((ie=ie.apply(ae,J||[])).next())})}function ve(ae,J){var Z,ie,oe,Q,re={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(pe){return function(ye){if(Z)throw new TypeError("Generator is already executing.");for(;re;)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 re.label++,{value:ye[1],done:!1};case 5:re.label++,ie=ye[1],ye=[0];continue;case 7:ye=re.ops.pop(),re.trys.pop();continue;default:if(!(oe=re.trys,(oe=oe.length>0&&oe[oe.length-1])||ye[0]!==6&&ye[0]!==2)){re=0;continue}if(ye[0]===3&&(!oe||ye[1]>oe[0]&&ye[1]<oe[3])){re.label=ye[1];break}if(ye[0]===6&&re.label<oe[1]){re.label=oe[1],oe=ye;break}if(oe&&re.label<oe[2]){re.label=oe[2],re.ops.push(ye);break}oe[2]&&re.ops.pop(),re.trys.pop();continue}ye=J.call(ae,re)}catch(ke){ye=[6,ke],ie=0}finally{Z=oe=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([he,pe])}}}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}(),L=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],re=Q[0],se=Q[1];J.setAttribute(re,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 re=document.createElementNS("http://www.w3.org/2000/svg","line");return re.setAttribute("x1",J.toString()),re.setAttribute("y1",Z.toString()),re.setAttribute("x2",ie.toString()),re.setAttribute("y2",oe.toString()),Q&&ae.setAttributes(re,Q),re},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,re,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",re.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,re,se,he){return"M"+J+","+Z+"V"+(Z+oe)+"H"+(J+ie)+"V"+Z+"H"+Q+"V"+re+"H"+(Q+se)+"V"+(re+he)+"H"+Q+"V"+Z+"Z"},ae}(),k=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}(),ue=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}(),be=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}(ue),we=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}(),Pe=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}(ue),_e=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}(),De=function(){function ae(){}return ae.getIcon=function(J,Z){if(J>0&&Z>0){var ie=new _e(J,Z),oe=ie.ratio>=1?20:ie.getHorizontalLength(20),Q=ie.ratio<1?20:ie.getVerticalLength(20),re=document.createElementNS("http://www.w3.org/2000/svg","svg");re.setAttribute("xmlns","http://www.w3.org/2000/svg"),re.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(re);var se=L.createDefs();re.appendChild(se);var he=L.createElement("clipPath",[["id","text-bg-clip"]]);se.appendChild(he);var pe=L.createPath(L.getHollowRectanglePath((24-oe)/2,(24-Q)/2,oe,Q,(24-oe)/2+2,(24-Q)/2+2,oe-4,Q-4));re.appendChild(pe);var ye=L.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(L.createTSpan(J+":"+Z)),re.appendChild(ye);var ke=ye.getBBox();L.setAttributes(ye,[["x",((24-ke.width)/2).toString()],["y",((24-ke.height)/2-ke.y).toString()]]);var Ne=L.createPath(L.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(ke.width))/2,(24-Math.ceil(ke.height))/2,Math.ceil(ke.width),Math.ceil(ke.height)));return he.appendChild(Ne),L.setAttributes(pe,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(re),re.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}(),Me=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}(we),We=function(){function ae(J,Z){this.GRIP_SIZE=10,this.color=J,this.fillColor=Z,this.visual=L.createGroup(),this.visual.appendChild(L.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(L.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 L.setAttributes(ie,[["cx",J.toString()],["cy",Z.toString()]])})},ae}(),ze=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&&L.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=L.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=L.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var Z=0;Z<this.numberOfGridLines;Z++)this.horizontalGridLines.push(L.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(L.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=L.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),L.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,re){var se=Z.y+ie*(re+1);L.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,re){var se=Z.x+oe*(re+1);L.setAttributes(Q,[["x1",""+se],["y1",""+Z.y],["x2",""+se],["y2",""+(Z.y+Z.height)]])}),L.setAttributes(this.cropShadeElement,[["d",L.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,re){var se=ie/J,he=oe/Z;return{x:(Q.x-re)*se+re,y:(Q.y-re)*he+re,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}(),Xe=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();L.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=L.createPath(Z);var Q=L.createTransform();this.scaleShape.transform.baseVal.appendItem(Q),J.appendChild(this.scaleShape),this.angleLabelElement=L.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=L.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var re=L.createTSpan("");return re.innerHTML="&deg;",this.angleLabelElement.appendChild(re),J.appendChild(this.angleLabelElement),document.body.removeChild(J),J},ae}(),Ge=function(){function ae(){this.naturalSize=!1,this.imageType="image/png"}return ae.prototype.rasterize=function(J,Z,ie,oe,Q,re,se){var he=this;return new Promise(function(pe){var ye=document.createElement("canvas");ye.width=J.width.baseVal.value-2*oe,ye.height=J.height.baseVal.value-2*oe;var ke=1,Ne=1;he.naturalSize===!0?(ke=Z.naturalWidth/(J.width.baseVal.value-2*oe)/re,Ne=Z.naturalHeight/(J.height.baseVal.value-2*oe)/se,ye.width=Z.naturalWidth/re,ye.height=Z.naturalHeight/se):he.width!==void 0&&he.height!==void 0&&(ke=he.width/ie.width,Ne=he.height/ie.height,ye.width*=ke,ye.height*=Ne);var Ze=ye.getContext("2d");Ze.translate(ye.width/2,ye.height/2),Ze.rotate(Q*Math.PI/180),Ze.scale(re,se),Ze.translate(-ye.width/2,-ye.height/2),Ze.drawImage(Z,0,0,ye.width,ye.height);var Ke=document.createElement("canvas");Ke.width=ie.width*ke,Ke.height=ie.height*Ne,Ke.getContext("2d").putImageData(Ze.getImageData((ie.x-oe)*ke,(ie.y-oe)*Ne,ie.width*ke,ie.height*Ne),0,0),pe(Ke.toDataURL(he.imageType,he.imageQuality))})},ae}(),at=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 k(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",L.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();L.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=L.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=L.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=L.createGroup(),this.editingTargetRotationScaleContainer=L.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var J=L.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(J);var Z=L.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(Z),this.editingTargetContainer=L.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=L.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new ze(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 be;Z.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(Z);var ie=[];this.aspectRatios.forEach(function(Ne){var Ze=new we(De.getIcon(Ne.horizontal,Ne.vertical),Ne.horizontal===0&&Ne.vertical===0?"FREE":Ne.horizontal+":"+Ne.vertical);Ze.onClick=function(){return J.ratioButtonClicked(Ne)},ie.push(Ze)}),this.aspectRatioButton=new Me(De.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 we('<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 we('<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 re=new Pe;this.topToolbar.addElementBlock(re);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),re.addElement(se)}var pe=new be;pe.minWidth=3*this.toolbarHeight+"px",pe.contentAlign="end",this.topToolbar.addButtonBlock(pe);var ye=new we('<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,pe.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var ke=new we('<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");ke.onClick=this.close,pe.addButton(ke),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(ke.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 be;Z.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(Z);var ie=new we('<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 we('<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 Pe;Q.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(Q),this.straightener=new Xe("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(pe){J.rotateBy(pe),J.straightener.angle=J.rotationAngle},Q.addElement(this.straightener.getUI());var re=new be;re.minWidth=2*this.toolbarHeight+"px",re.contentAlign="end",this.bottomToolbar.addButtonBlock(re);var se=new we('<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,re.addButton(se);var he=new we('<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,re.addButton(he)},ae.prototype.ratioButtonClicked=function(J){this.aspectRatio=J,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},ae.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=De.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 _e(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 Ae(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 Ae(this,void 0,void 0,function(){var J;return ve(this,function(Z){switch(Z.label){case 0:return(J=new Ge).naturalSize=this.renderAtNaturalSize,J.imageType=this.renderImageType,J.imageQuality=this.renderImageQuality,J.width=this.renderWidth,J.height=this.renderHeight,this.unzoomFromCrop(),L.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}(),$e=le("8hTe"),Ve=le.n($e),Le=/<pre[^>]*>/g;function tt(ae){var J=document.createElement("div");return J.innerHTML=ae,J.childNodes.length===0?"":J.childNodes[0].nodeValue}var qe=rt.a=function(ae){var J=ae.value,Z=J===void 0?"":J,ie=ae.edit,oe=ie===void 0?!1:ie,Q=ae.className,re=ae.showTextOnly,se=ae.showLines,he=ae.replaces,pe=ae.zoomImg,ye=ae.hasMask,ke=ae.style,Ne=ke===void 0?{}:ke,Ze=ae.stylesPrev,Ke=Ze===void 0?{}:Ze,lt=String(Z),it=Object(O.useRef)(),Ye=Object(O.useRef)(),wt=Object(O.useState)(""),dt=Object(j.a)(wt,2),Ot=dt[0],Nt=dt[1],St=Object(O.useState)("office"),ar=Object(j.a)(St,2),br=ar[0],Kt=ar[1],tr=function(){var xt=new at(Ye.current);xt.displayMode="popup",xt.addRenderEventListener(function(){var Bt=Object(D.a)(I.a.mark(function pt(yt){var kt;return I.a.wrap(function(Ht){for(;;)switch(Ht.prev=Ht.next){case 0:return it.current.style.display="none",Ht.next=3,Object(Ie.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:yt}});case 3:kt=Ht.sent,kt!=null&&kt.id&&he(Ye.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(kt==null?void 0:kt.id,"?type=").concat(kt.content_type));case 5:case"end":return Ht.stop()}},pt)}));return function(pt){return Bt.apply(this,arguments)}}()),xt.show()},or=function(){var xt=new Te.a(Ye.current);xt.settings.displayMode="popup",xt.addEventListener("render",function(){var Bt=Object(D.a)(I.a.mark(function pt(yt){var kt;return I.a.wrap(function(Ht){for(;;)switch(Ht.prev=Ht.next){case 0:if(it.current.style.display="none",!Ye.current){Ht.next=6;break}return Ht.next=4,Object(Ie.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:yt.dataUrl}});case 4:kt=Ht.sent,kt!=null&&kt.id&&he(Ye.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(kt==null?void 0:kt.id,"?type=").concat(kt.content_type));case 6:case"end":return Ht.stop()}},pt)}));return function(pt){return Bt.apply(this,arguments)}}()),xt.show(),window.markerArea=xt},Pr=Object(O.useMemo)(function(){it.current&&(it.current.style.zIndex=-1);try{var He=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,xt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Bt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;lt=lt.replace(He,"("+ce.a.API_SERVER+"/api/attachments/").replace(xt,'"'+ce.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+ce.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(xr){}var pt=te(lt),yt=y();if(lt.match(/\[TOC\]/)&&(pt=pt.replace("<p>[TOC]</p>",A()),C()),pt=pt.replace(/(__special_katext_id_\d+__)/g,function(xr,Ht){var Ue=yt[Ht],ft=Ue.type,ri=Ue.expression;return Object(ge.renderToString)(tt(ri)||"",{displayMode:ft==="block",throwOnError:!1,output:"html"})}),pt=pt.replace(/▁/g,"\u2581\u2581\u2581"),c(),re){var kt=document.createElement("div");return kt.innerHTML=pt,kt.innerText}return setTimeout(function(){return Mt()},500),pt},[lt]),Vt=Object(O.useRef)();m.WebkitLineClamp=se,se&&(Ne=Object(M.a)(Object(M.a)({},Ne),m));function At(He){var xt=He.target;if(xt.tagName.toUpperCase()==="IMG"){if(pe){var Bt=xt.getAttribute("src");Nt(Bt),Kt("image")}}else if(xt.tagName.toUpperCase()==="A"){var pt=xt.getAttribute("href");if(pt.indexOf("office")>-1)He.preventDefault(),Nt(pt),Kt("office");else if(pt.indexOf("application/pdf")>-1)He.preventDefault(),Nt(pt),Kt("pdf");else if(pt.indexOf("text/html")>-1)He.preventDefault(),Nt(pt),Kt("html");else if(pt.startsWith("#")){He.preventDefault();var yt=document.getElementById(pt.replace("#",""));yt&&yt.scrollIntoView(!0)}}}var Mt=function(){var xt,Bt=(xt=Vt.current)===null||xt===void 0?void 0:xt.querySelectorAll("video");Bt==null||Bt.forEach(function(pt){if(pt.oncontextmenu=function(){return!1},pt.src.indexOf(".m3u8")>-1&&!pt.canPlayType("application/vnd.apple.mpegurl")){if(ne.a.isSupported()){var yt=new ne.a;yt.loadSource(pt.src),yt.attachMedia(pt)}}})};Object(O.useEffect)(function(){if(Vt.current&&Pr&&(Pr.match(Le)&&window.PR.prettyPrint()),Vt.current)return Vt.current.addEventListener("click",At),function(){Vt.current.removeEventListener("click",At),c(),C()}},[Pr,Vt.current,At]);var vt=function(xt){if(!oe)return;xt.target.nodeName==="IMG"?(it.current.style.zIndex=1,it.current.style.display="flex",it.current.style.width=xt.target.clientWidth+"px",it.current.style.height=xt.target.clientHeight+"px",it.current.style.top=xt.target.offsetTop+"px",it.current.style.left=xt.target.offsetLeft+"px",Ye.current.src=xt.target.getAttribute("src")):it.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:Vt,style:Object(M.a)({},Ne),className:"".concat(Q||""," markdown-body ").concat(Ve.a.mdBody),onMouseOver:vt,dangerouslySetInnerHTML:{__html:Pr}}),v.a.createElement("div",{ref:it,className:Ve.a.button},v.a.createElement($.a,null,v.a.createElement(V.a,{onClick:function(){return tr()}},"\u88C1\u526A"),v.a.createElement(V.a,{onClick:function(){return or()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Ye,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.a.createElement(xe.a,{close:!0,data:Ot,type:Ot!=null&&Ot.length?br:"",style:Object(M.a)({},Ke),onClose:function(){return Nt("")}}))}},"9VGf":function(ct,rt,le){"use strict";le.d(rt,"a",function(){return _});var fe=le("q1tI"),$=le.n(fe);function _(V,M){var D=Object(fe.useRef)();Object(fe.useEffect)(function(){D.current=V}),Object(fe.useEffect)(function(){function j(){D.current()}if(M!==null){var U=setInterval(j,M);return function(){return clearInterval(U)}}},[M])}},Bd2K:function(ct,rt,le){(function(fe){fe(le("VrN/"),le("osHv"))})(function(fe){fe.defineOption("autoCloseTags",!1,function(I,O,v){if(v!=fe.Init&&v&&I.removeKeyMap("autoCloseTags"),!O)return;var g={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(g["'/'"]=function(R){return D(R)}),(typeof O!="object"||O.whenOpening!==!1)&&(g["'>'"]=function(R){return V(R)}),I.addKeyMap(g)});var $=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_=["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(I){if(I.getOption("disableInput"))return fe.Pass;for(var O=I.listSelections(),v=[],g=I.getOption("autoCloseTags"),R=0;R<O.length;R++){if(!O[R].empty())return fe.Pass;var w=O[R].head,b=I.getTokenAt(w),x=fe.innerMode(I.getMode(),b.state),l=x.state,o=x.mode.xmlCurrentTag&&x.mode.xmlCurrentTag(l),s=o&&o.name;if(!s)return fe.Pass;var h=x.mode.configuration=="html",C=typeof g=="object"&&g.dontCloseTags||h&&$,m=typeof g=="object"&&g.indentTags||h&&_;b.end>w.ch&&(s=s.slice(0,s.length-b.end+w.ch));var p=s.toLowerCase();if(!s||b.type=="string"&&(b.end!=w.ch||!/[\"\']/.test(b.string.charAt(b.string.length-1))||b.string.length==1)||b.type=="tag"&&o.close||b.string.indexOf("/")==w.ch-b.start-1||C&&j(C,p)>-1||U(I,x.mode.xmlCurrentContext&&x.mode.xmlCurrentContext(l)||[],s,w,!0))return fe.Pass;var A=typeof g=="object"&&g.emptyTags;if(A&&j(A,s)>-1){v[R]={text:"/>",newPos:fe.Pos(w.line,w.ch+2)};continue}var E=m&&j(m,p)>-1;v[R]={indent:E,text:">"+(E?`
`:"")+"</"+s+">",newPos:E?fe.Pos(w.line+1,0):fe.Pos(w.line,w.ch+1)}}for(var f=typeof g=="object"&&g.dontIndentOnAutoClose,R=O.length-1;R>=0;R--){var d=v[R];I.replaceRange(d.text,O[R].head,O[R].anchor,"+insert");var u=I.listSelections().slice(0);u[R]={head:d.newPos,anchor:d.newPos},I.setSelections(u),!f&&d.indent&&(I.indentLine(d.newPos.line,null,!0),I.indentLine(d.newPos.line+1,null,!0))}}function M(I,O){for(var v=I.listSelections(),g=[],R=O?"/":"</",w=I.getOption("autoCloseTags"),b=typeof w=="object"&&w.dontIndentOnSlash,x=0;x<v.length;x++){if(!v[x].empty())return fe.Pass;var l=v[x].head,o=I.getTokenAt(l),s=fe.innerMode(I.getMode(),o.state),h=s.state;if(O&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=l.ch-1))return fe.Pass;var C,m=s.mode.name!="xml"&&I.getMode().name=="htmlmixed";if(m&&s.mode.name=="javascript")C=R+"script";else if(m&&s.mode.name=="css")C=R+"style";else{var p=s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(h);if(!p||p.length&&U(I,p,p[p.length-1],l))return fe.Pass;C=R+p[p.length-1]}I.getLine(l.line).charAt(o.end)!=">"&&(C+=">"),g[x]=C}if(I.replaceSelections(g),v=I.listSelections(),!b)for(var x=0;x<v.length;x++)(x==v.length-1||v[x].head.line<v[x+1].head.line)&&I.indentLine(v[x].head.line)}function D(I){return I.getOption("disableInput")?fe.Pass:M(I,!0)}fe.commands.closeTag=function(I){return M(I)};function j(I,O){if(I.indexOf)return I.indexOf(O);for(var v=0,g=I.length;v<g;++v)if(I[v]==O)return v;return-1}function U(I,O,v,g,R){if(!fe.scanForClosingTag)return!1;var w=Math.min(I.lastLine()+1,g.line+500),b=fe.scanForClosingTag(I,g,null,w);if(!b||b.tag!=v)return!1;for(var x=R?1:0,l=O.length-1;l>=0&&O[l]==v;l--)++x;g=b.to;for(var l=1;l<x;l++){var o=fe.scanForClosingTag(I,g,null,w);if(!o||o.tag!=v)return!1;g=o.to}return!0}})},BjJ7:function(ct,rt,le){"use strict";le.d(rt,"d",function(){return $}),le.d(rt,"c",function(){return _}),le.d(rt,"e",function(){return V}),le.d(rt,"b",function(){return M}),le.d(rt,"a",function(){return j});var fe=le("m3rI");function $(U){var I=!0;if(U.length>0){for(var O=0;O<U.length;O++)if(U[O].compile_success==0||!U[O].compile_success){I=!1;break}}else I=!1;return I}function _(U){for(var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],v=0;v<U.length;v++){var g=U[v],R=I?"".concat(I,"/").concat(g.name):"".concat(g.name);O.push({title:g.name,isLeaf:!(g.type==="tree"),key:R})}return O}function V(U,I,O){for(var v=0;v<U.length;v++){var g=U[v];if(g.key===I){g.children=O;break}g.children&&V(g.children,I,O)}return U}function M(U,I,O){var v;return function(){var g=this,R=arguments,w=function(){v=null,O||U.apply(g,R)},b=O&&!v;clearTimeout(v),v=setTimeout(w,I),b&&U.apply(g,R)}}var D=!0,j=fe.a.API_SERVER},"C+DQ":function(ct,rt,le){},DlQD:function(ct,rt,le){(function(fe,$){ct.exports=$()})(this,function(){"use strict";function fe(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 $(Z,ie,oe){return ie&&fe(Z.prototype,ie),oe&&fe(Z,oe),Z}function _(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 M(Z,ie){var oe;if(typeof Symbol=="undefined"||Z[Symbol.iterator]==null){if(Array.isArray(Z)||(oe=_(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}}),U=j.defaults,I=j.getDefaults,O=j.changeDefaults,v=/[&<>"']/,g=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,w=/[<>"']|&(?!#?\w+;)/g,b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},x=function(ie){return b[ie]};function l(Z,ie){if(ie){if(v.test(Z))return Z.replace(g,x)}else if(R.test(Z))return Z.replace(w,x);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 h=/(^|[^\[])\^/g;function C(Z,ie){Z=Z.source||Z,ie=ie||"";var oe={replace:function(re,se){return se=se.source||se,se=se.replace(h,"$1"),Z=Z.replace(re,se),oe},getRegex:function(){return new RegExp(Z,ie)}};return oe}var m=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function A(Z,ie,oe){if(Z){var Q;try{Q=decodeURIComponent(s(oe)).replace(m,"").toLowerCase()}catch(re){return null}if(Q.indexOf("javascript:")===0||Q.indexOf("vbscript:")===0||Q.indexOf("data:")===0)return null}ie&&!p.test(oe)&&(oe=a(ie,oe));try{oe=encodeURI(oe).replace(/%25/g,"%")}catch(re){return null}return oe}var E={},f=/^[^:]+:\/*[^/]*$/,d=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(Z,ie){E[" "+Z]||(f.test(Z)?E[" "+Z]=Z+"/":E[" "+Z]=P(Z,"/",!0)),Z=E[" "+Z];var oe=Z.indexOf(":")===-1;return ie.substring(0,2)==="//"?oe?ie:Z.replace(d,"$1")+ie:ie.charAt(0)==="/"?oe?ie:Z.replace(u,"$1")+ie:Z+ie}var y={exec:function(){}};function c(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 S(Z,ie){var oe=Z.replace(/\|/g,function(se,he,pe){for(var ye=!1,ke=he;--ke>=0&&pe[ke]==="\\";)ye=!ye;return ye?"|":" |"}),Q=oe.split(/ \|/),re=0;if(Q.length>ie)Q.splice(ie);else for(;Q.length<ie;)Q.push("");for(;re<Q.length;re++)Q[re]=Q[re].trim().replace(/\\\|/g,"|");return Q}function P(Z,ie,oe){var Q=Z.length;if(Q===0)return"";for(var re=0;re<Q;){var se=Z.charAt(Q-re-1);if(se===ie&&!oe)re++;else if(se!==ie&&oe)re++;else break}return Z.substr(0,Q-re)}function G(Z,ie){if(Z.indexOf(ie[1])===-1)return-1;for(var oe=Z.length,Q=0,re=0;re<oe;re++)if(Z[re]==="\\")re++;else if(Z[re]===ie[0])Q++;else if(Z[re]===ie[1]&&(Q--,Q<0))return re;return-1}function X(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 te={escape:l,unescape:s,edit:C,cleanUrl:A,resolveUrl:a,noopTest:y,merge:c,splitCells:S,rtrim:P,findClosingBracket:G,checkSanitizeDeprecation:X},z=j.defaults,F=te.rtrim,ne=te.splitCells,ce=te.escape,ge=te.findClosingBracket;function xe(Z,ie,oe){var Q=ie.href,re=ie.title?ce(ie.title):null,se=Z[1].replace(/\\([\[\]])/g,"$1");return Z[0].charAt(0)!=="!"?{type:"link",raw:oe,href:Q,title:re,text:se}:{type:"image",raw:oe,href:Q,title:re,text:ce(se)}}function Ie(Z,ie){var oe=Z.match(/^(\s+)(?:```)/);if(oe===null)return ie;var Q=oe[1];return ie.split(`
`).map(function(re){var se=re.match(/^\s+/);if(se===null)return re;var he=se[0];return he.length>=Q.length?re.slice(Q.length):re}).join(`
`)}var Te=function(){function Z(oe){this.options=oe||z}var ie=Z.prototype;return ie.space=function(Q){var re=this.rules.block.newline.exec(Q);if(re)return re[0].length>1?{type:"space",raw:re[0]}:{raw:`
`}},ie.code=function(Q,re){var se=this.rules.block.code.exec(Q);if(se){var he=re[re.length-1];if(he&&he.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var pe=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?pe:F(pe,`
`)}}},ie.fences=function(Q){var re=this.rules.block.fences.exec(Q);if(re){var se=re[0],he=Ie(se,re[3]||"");return{type:"code",raw:se,lang:re[2]?re[2].trim():re[2],text:he}}},ie.heading=function(Q){var re=this.rules.block.heading.exec(Q);if(re)return{type:"heading",raw:re[0],depth:re[1].length,text:re[2]}},ie.nptable=function(Q){var re=this.rules.block.nptable.exec(Q);if(re){var se={type:"table",header:ne(re[1].replace(/^ *| *\| *$/g,"")),align:re[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:re[3]?re[3].replace(/\n$/,"").split(`
`):[],raw:re[0]};if(se.header.length===se.align.length){var he=se.align.length,pe;for(pe=0;pe<he;pe++)/^ *-+: *$/.test(se.align[pe])?se.align[pe]="right":/^ *:-+: *$/.test(se.align[pe])?se.align[pe]="center":/^ *:-+ *$/.test(se.align[pe])?se.align[pe]="left":se.align[pe]=null;for(he=se.cells.length,pe=0;pe<he;pe++)se.cells[pe]=ne(se.cells[pe],se.header.length);return se}}},ie.hr=function(Q){var re=this.rules.block.hr.exec(Q);if(re)return{type:"hr",raw:re[0]}},ie.blockquote=function(Q){var re=this.rules.block.blockquote.exec(Q);if(re){var se=re[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:re[0],text:se}}},ie.list=function(Q){var re=this.rules.block.list.exec(Q);if(re){for(var se=re[0],he=re[2],pe=he.length>1,ye=he[he.length-1]===")",ke={type:"list",raw:se,ordered:pe,start:pe?+he.slice(0,-1):"",loose:!1,items:[]},Ne=re[0].match(this.rules.block.item),Ze=!1,Ke,lt,it,Ye,wt,dt,Ot,Nt=Ne.length,St=0;St<Nt;St++)Ke=Ne[St],se=Ke,lt=Ke.length,Ke=Ke.replace(/^ *([*+-]|\d+[.)]) */,""),~Ke.indexOf(`
`)&&(lt-=Ke.length,Ke=this.options.pedantic?Ke.replace(/^ {1,4}/gm,""):Ke.replace(new RegExp("^ {1,"+lt+"}","gm"),"")),St!==Nt-1&&(it=this.rules.block.bullet.exec(Ne[St+1])[0],(pe?it.length===1||!ye&&it[it.length-1]===")":it.length>1||this.options.smartLists&&it!==he)&&(Ye=Ne.slice(St+1).join(`
`),ke.raw=ke.raw.substring(0,ke.raw.length-Ye.length),St=Nt-1)),wt=Ze||/\n\n(?!\s*$)/.test(Ke),St!==Nt-1&&(Ze=Ke.charAt(Ke.length-1)===`
`,wt||(wt=Ze)),wt&&(ke.loose=!0),dt=/^\[[ xX]\] /.test(Ke),Ot=void 0,dt&&(Ot=Ke[1]!==" ",Ke=Ke.replace(/^\[[ xX]\] +/,"")),ke.items.push({type:"list_item",raw:se,task:dt,checked:Ot,loose:wt,text:Ke});return ke}},ie.html=function(Q){var re=this.rules.block.html.exec(Q);if(re)return{type:this.options.sanitize?"paragraph":"html",raw:re[0],pre:!this.options.sanitizer&&(re[1]==="pre"||re[1]==="script"||re[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(re[0]):ce(re[0]):re[0]}},ie.def=function(Q){var re=this.rules.block.def.exec(Q);if(re){re[3]&&(re[3]=re[3].substring(1,re[3].length-1));var se=re[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:re[0],href:re[2],title:re[3]}}},ie.table=function(Q){var re=this.rules.block.table.exec(Q);if(re){var se={type:"table",header:ne(re[1].replace(/^ *| *\| *$/g,"")),align:re[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:re[3]?re[3].replace(/\n$/,"").split(`
`):[]};if(se.header.length===se.align.length){se.raw=re[0];var he=se.align.length,pe;for(pe=0;pe<he;pe++)/^ *-+: *$/.test(se.align[pe])?se.align[pe]="right":/^ *:-+: *$/.test(se.align[pe])?se.align[pe]="center":/^ *:-+ *$/.test(se.align[pe])?se.align[pe]="left":se.align[pe]=null;for(he=se.cells.length,pe=0;pe<he;pe++)se.cells[pe]=ne(se.cells[pe].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},ie.lheading=function(Q){var re=this.rules.block.lheading.exec(Q);if(re)return{type:"heading",raw:re[0],depth:re[2].charAt(0)==="="?1:2,text:re[1]}},ie.paragraph=function(Q){var re=this.rules.block.paragraph.exec(Q);if(re)return{type:"paragraph",raw:re[0],text:re[1].charAt(re[1].length-1)===`
`?re[1].slice(0,-1):re[1]}},ie.text=function(Q,re){var se=this.rules.block.text.exec(Q);if(se){var he=re[re.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 re=this.rules.inline.escape.exec(Q);if(re)return{type:"escape",raw:re[0],text:ce(re[1])}},ie.tag=function(Q,re,se){var he=this.rules.inline.tag.exec(Q);if(he)return!re&&/^<a /i.test(he[0])?re=!0:re&&/^<\/a>/i.test(he[0])&&(re=!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:re,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(he[0]):ce(he[0]):he[0]}},ie.link=function(Q){var re=this.rules.inline.link.exec(Q);if(re){var se=ge(re[2],"()");if(se>-1){var he=re[0].indexOf("!")===0?5:4,pe=he+re[1].length+se;re[2]=re[2].substring(0,se),re[0]=re[0].substring(0,pe).trim(),re[3]=""}var ye=re[2],ke="";if(this.options.pedantic){var Ne=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ye);Ne?(ye=Ne[1],ke=Ne[3]):ke=""}else ke=re[3]?re[3].slice(1,-1):"";ye=ye.trim().replace(/^<([\s\S]*)>$/,"$1");var Ze=xe(re,{href:ye&&ye.replace(this.rules.inline._escapes,"$1"),title:ke&&ke.replace(this.rules.inline._escapes,"$1")},re[0]);return Ze}},ie.reflink=function(Q,re){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=re[he.toLowerCase()],!he||!he.href){var pe=se[0].charAt(0);return{type:"text",raw:pe,text:pe}}var ye=xe(se,he,se[0]);return ye}},ie.strong=function(Q,re,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)))){re=re.slice(-1*Q.length);var pe=he[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;pe.lastIndex=0;for(var ye;(he=pe.exec(re))!=null;)if(ye=this.rules.inline.strong.middle.exec(re.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,re,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)))){re=re.slice(-1*Q.length);var pe=he[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;pe.lastIndex=0;for(var ye;(he=pe.exec(re))!=null;)if(ye=this.rules.inline.em.middle.exec(re.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 re=this.rules.inline.code.exec(Q);if(re){var se=re[2].replace(/\n/g," "),he=/[^ ]/.test(se),pe=se.startsWith(" ")&&se.endsWith(" ");return he&&pe&&(se=se.substring(1,se.length-1)),se=ce(se,!0),{type:"codespan",raw:re[0],text:se}}},ie.br=function(Q){var re=this.rules.inline.br.exec(Q);if(re)return{type:"br",raw:re[0]}},ie.del=function(Q){var re=this.rules.inline.del.exec(Q);if(re)return{type:"del",raw:re[0],text:re[1]}},ie.autolink=function(Q,re){var se=this.rules.inline.autolink.exec(Q);if(se){var he,pe;return se[2]==="@"?(he=ce(this.options.mangle?re(se[1]):se[1]),pe="mailto:"+he):(he=ce(se[1]),pe=he),{type:"link",raw:se[0],text:he,href:pe,tokens:[{type:"text",raw:he,text:he}]}}},ie.url=function(Q,re){var se;if(se=this.rules.inline.url.exec(Q)){var he,pe;if(se[2]==="@")he=ce(this.options.mangle?re(se[0]):se[0]),pe="mailto:"+he;else{var ye;do ye=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(ye!==se[0]);he=ce(se[0]),se[1]==="www."?pe="http://"+he:pe=he}return{type:"link",raw:se[0],text:he,href:pe,tokens:[{type:"text",raw:he,text:he}]}}},ie.inlineText=function(Q,re,se){var he=this.rules.inline.text.exec(Q);if(he){var pe;return re?pe=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(he[0]):ce(he[0]):he[0]:pe=ce(this.options.smartypants?se(he[0]):he[0]),{type:"text",raw:he[0],text:pe}}},Z}(),Oe=te.noopTest,Ce=te.edit,Ae=te.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:Oe,table:Oe,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=Ae({},ve),ve.gfm=Ae({},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=Ae({},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:Oe,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:Oe,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:Oe,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=Ae({},W),W.pedantic=Ae({},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=Ae({},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=Ae({},W.gfm,{br:Ce(W.br).replace("{2,}","*").getRegex(),text:Ce(W.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var L={block:ve,inline:W},k=j.defaults,H=L.block,q=L.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 ue(Z){var ie="",oe,Q,re=Z.length;for(oe=0;oe<re;oe++)Q=Z.charCodeAt(oe),Math.random()>.5&&(Q="x"+Q.toString(16)),ie+="&#"+Q+";";return ie}var be=function(){function Z(oe){this.tokens=[],this.tokens.links=Object.create(null),this.options=oe||k,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,re){var se=new Z(re);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,re,se){re===void 0&&(re=[]),se===void 0&&(se=!0),Q=Q.replace(/^ +$/gm,"");for(var he,pe,ye,ke;Q;){if(he=this.tokenizer.space(Q)){Q=Q.substring(he.raw.length),he.type&&re.push(he);continue}if(he=this.tokenizer.code(Q,re)){Q=Q.substring(he.raw.length),he.type?re.push(he):(ke=re[re.length-1],ke.raw+=`
`+he.raw,ke.text+=`
`+he.text);continue}if(he=this.tokenizer.fences(Q)){Q=Q.substring(he.raw.length),re.push(he);continue}if(he=this.tokenizer.heading(Q)){Q=Q.substring(he.raw.length),re.push(he);continue}if(he=this.tokenizer.nptable(Q)){Q=Q.substring(he.raw.length),re.push(he);continue}if(he=this.tokenizer.hr(Q)){Q=Q.substring(he.raw.length),re.push(he);continue}if(he=this.tokenizer.blockquote(Q)){Q=Q.substring(he.raw.length),he.tokens=this.blockTokens(he.text,[],se),re.push(he);continue}if(he=this.tokenizer.list(Q)){for(Q=Q.substring(he.raw.length),ye=he.items.length,pe=0;pe<ye;pe++)he.items[pe].tokens=this.blockTokens(he.items[pe].text,[],!1);re.push(he);continue}if(he=this.tokenizer.html(Q)){Q=Q.substring(he.raw.length),re.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),re.push(he);continue}if(he=this.tokenizer.lheading(Q)){Q=Q.substring(he.raw.length),re.push(he);continue}if(se&&(he=this.tokenizer.paragraph(Q))){Q=Q.substring(he.raw.length),re.push(he);continue}if(he=this.tokenizer.text(Q,re)){Q=Q.substring(he.raw.length),he.type?re.push(he):(ke=re[re.length-1],ke.raw+=`
`+he.raw,ke.text+=`
`+he.text);continue}if(Q){var Ne="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(Ne);break}else throw new Error(Ne)}}return re},ie.inline=function(Q){var re,se,he,pe,ye,ke,Ne=Q.length;for(re=0;re<Ne;re++){ke=Q[re];switch(ke.type){case"paragraph":case"text":case"heading":{ke.tokens=[],this.inlineTokens(ke.text,ke.tokens);break}case"table":{for(ke.tokens={header:[],cells:[]},pe=ke.header.length,se=0;se<pe;se++)ke.tokens.header[se]=[],this.inlineTokens(ke.header[se],ke.tokens.header[se]);for(pe=ke.cells.length,se=0;se<pe;se++)for(ye=ke.cells[se],ke.tokens.cells[se]=[],he=0;he<ye.length;he++)ke.tokens.cells[se][he]=[],this.inlineTokens(ye[he],ke.tokens.cells[se][he]);break}case"blockquote":{this.inline(ke.tokens);break}case"list":{for(pe=ke.items.length,se=0;se<pe;se++)this.inline(ke.items[se].tokens);break}}}return Q},ie.inlineTokens=function(Q,re,se,he,pe){re===void 0&&(re=[]),se===void 0&&(se=!1),he===void 0&&(he=!1),pe===void 0&&(pe="");var ye,ke=Q,Ne;if(this.tokens.links){var Ze=Object.keys(this.tokens.links);if(Ze.length>0)for(;(Ne=this.tokenizer.rules.inline.reflinkSearch.exec(ke))!=null;)Ze.includes(Ne[0].slice(Ne[0].lastIndexOf("[")+1,-1))&&(ke=ke.slice(0,Ne.index)+"["+"a".repeat(Ne[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Ne=this.tokenizer.rules.inline.blockSkip.exec(ke))!=null;)ke=ke.slice(0,Ne.index)+"["+"a".repeat(Ne[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;Q;){if(ye=this.tokenizer.escape(Q)){Q=Q.substring(ye.raw.length),re.push(ye);continue}if(ye=this.tokenizer.tag(Q,se,he)){Q=Q.substring(ye.raw.length),se=ye.inLink,he=ye.inRawBlock,re.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)),re.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)),re.push(ye);continue}if(ye=this.tokenizer.strong(Q,ke,pe)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),re.push(ye);continue}if(ye=this.tokenizer.em(Q,ke,pe)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),re.push(ye);continue}if(ye=this.tokenizer.codespan(Q)){Q=Q.substring(ye.raw.length),re.push(ye);continue}if(ye=this.tokenizer.br(Q)){Q=Q.substring(ye.raw.length),re.push(ye);continue}if(ye=this.tokenizer.del(Q)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,he),re.push(ye);continue}if(ye=this.tokenizer.autolink(Q,ue)){Q=Q.substring(ye.raw.length),re.push(ye);continue}if(!se&&(ye=this.tokenizer.url(Q,ue))){Q=Q.substring(ye.raw.length),re.push(ye);continue}if(ye=this.tokenizer.inlineText(Q,he,B)){Q=Q.substring(ye.raw.length),pe=ye.raw.slice(-1),re.push(ye);continue}if(Q){var Ke="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(Ke);break}else throw new Error(Ke)}}return re},$(Z,null,[{key:"rules",get:function(){return{block:H,inline:q}}}]),Z}(),we=j.defaults,Pe=te.cleanUrl,_e=te.escape,De=function(){function Z(oe){this.options=oe||we}var ie=Z.prototype;return ie.code=function(Q,re,se){var he=(re||"").match(/\S*/)[0];if(this.options.highlight){var pe=this.options.highlight(Q,he);pe!=null&&pe!==Q&&(se=!0,Q=pe)}return he?'<pre><code class="'+this.options.langPrefix+_e(he,!0)+'">'+(se?Q:_e(Q,!0))+`</code></pre>
`:"<pre><code>"+(se?Q:_e(Q,!0))+`</code></pre>
`},ie.blockquote=function(Q){return`<blockquote>
`+Q+`</blockquote>
`},ie.html=function(Q){return Q},ie.heading=function(Q,re,se,he){return this.options.headerIds?"<h"+re+' id="'+this.options.headerPrefix+he.slug(se)+'">'+Q+"</h"+re+`>
`:"<h"+re+">"+Q+"</h"+re+`>
`},ie.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},ie.list=function(Q,re,se){var he=re?"ol":"ul",pe=re&&se!==1?' start="'+se+'"':"";return"<"+he+pe+`>
`+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,re){return re&&(re="<tbody>"+re+"</tbody>"),`<table>
<thead>
`+Q+`</thead>
`+re+`</table>
`},ie.tablerow=function(Q){return`<tr>
`+Q+`</tr>
`},ie.tablecell=function(Q,re){var se=re.header?"th":"td",he=re.align?"<"+se+' align="'+re.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,re,se){if(Q=Pe(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var he='<a href="'+_e(Q)+'"';return re&&(he+=' title="'+re+'"'),he+=">"+se+"</a>",he},ie.image=function(Q,re,se){if(Q=Pe(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var he='<img src="'+Q+'" alt="'+se+'"';return re&&(he+=' title="'+re+'"'),he+=this.options.xhtml?"/>":">",he},ie.text=function(Q){return Q},Z}(),Me=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,re,se){return""+se},ie.image=function(Q,re,se){return""+se},ie.br=function(){return""},Z}(),We=function(){function Z(){this.seen={}}var ie=Z.prototype;return ie.slug=function(Q){var re=Q.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(re)){var se=re;do this.seen[se]++,re=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(re))}return this.seen[re]=0,re},Z}(),ze=j.defaults,Xe=te.unescape,Ge=function(){function Z(oe){this.options=oe||ze,this.options.renderer=this.options.renderer||new De,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Me,this.slugger=new We}Z.parse=function(Q,re){var se=new Z(re);return se.parse(Q)};var ie=Z.prototype;return ie.parse=function(Q,re){re===void 0&&(re=!0);var se="",he,pe,ye,ke,Ne,Ze,Ke,lt,it,Ye,wt,dt,Ot,Nt,St,ar,br,Kt,tr=Q.length;for(he=0;he<tr;he++){Ye=Q[he];switch(Ye.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline(Ye.tokens),Ye.depth,Xe(this.parseInline(Ye.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code(Ye.text,Ye.lang,Ye.escaped);continue}case"table":{for(lt="",Ke="",ke=Ye.header.length,pe=0;pe<ke;pe++)Ke+=this.renderer.tablecell(this.parseInline(Ye.tokens.header[pe]),{header:!0,align:Ye.align[pe]});for(lt+=this.renderer.tablerow(Ke),it="",ke=Ye.cells.length,pe=0;pe<ke;pe++){for(Ze=Ye.tokens.cells[pe],Ke="",Ne=Ze.length,ye=0;ye<Ne;ye++)Ke+=this.renderer.tablecell(this.parseInline(Ze[ye]),{header:!1,align:Ye.align[ye]});it+=this.renderer.tablerow(Ke)}se+=this.renderer.table(lt,it);continue}case"blockquote":{it=this.parse(Ye.tokens),se+=this.renderer.blockquote(it);continue}case"list":{for(wt=Ye.ordered,dt=Ye.start,Ot=Ye.loose,ke=Ye.items.length,it="",pe=0;pe<ke;pe++)St=Ye.items[pe],ar=St.checked,br=St.task,Nt="",St.task&&(Kt=this.renderer.checkbox(ar),Ot?St.tokens.length>0&&St.tokens[0].type==="text"?(St.tokens[0].text=Kt+" "+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=Kt+" "+St.tokens[0].tokens[0].text)):St.tokens.unshift({type:"text",text:Kt}):Nt+=Kt),Nt+=this.parse(St.tokens,Ot),it+=this.renderer.listitem(Nt,br,ar);se+=this.renderer.list(it,wt,dt);continue}case"html":{se+=this.renderer.html(Ye.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline(Ye.tokens));continue}case"text":{for(it=Ye.tokens?this.parseInline(Ye.tokens):Ye.text;he+1<tr&&Q[he+1].type==="text";)Ye=Q[++he],it+=`
`+(Ye.tokens?this.parseInline(Ye.tokens):Ye.text);se+=re?this.renderer.paragraph(it):it;continue}default:{var or='Token with "'+Ye.type+'" type was not found.';if(this.options.silent){console.error(or);return}else throw new Error(or)}}}return se},ie.parseInline=function(Q,re){re=re||this.renderer;var se="",he,pe,ye=Q.length;for(he=0;he<ye;he++){pe=Q[he];switch(pe.type){case"escape":{se+=re.text(pe.text);break}case"html":{se+=re.html(pe.text);break}case"link":{se+=re.link(pe.href,pe.title,this.parseInline(pe.tokens,re));break}case"image":{se+=re.image(pe.href,pe.title,pe.text);break}case"strong":{se+=re.strong(this.parseInline(pe.tokens,re));break}case"em":{se+=re.em(this.parseInline(pe.tokens,re));break}case"codespan":{se+=re.codespan(pe.text);break}case"br":{se+=re.br();break}case"del":{se+=re.del(this.parseInline(pe.tokens,re));break}case"text":{se+=re.text(pe.text);break}default:{var ke='Token with "'+pe.type+'" type was not found.';if(this.options.silent){console.error(ke);return}else throw new Error(ke)}}}return se},Z}(),at=te.merge,$e=te.checkSanitizeDeprecation,Ve=te.escape,Le=j.getDefaults,tt=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=at({},ae.defaults,ie||{}),$e(ie),oe){var Q=ie.highlight,re;try{re=be.lex(Z,ie)}catch(ye){return oe(ye)}var se=function(ke){var Ne;if(!ke)try{Ne=Ge.parse(re,ie)}catch(Ze){ke=Ze}return ie.highlight=Q,ke?oe(ke):oe(null,Ne)};if(!Q||Q.length<3)return se();if(delete ie.highlight,!re.length)return se();var he=0;ae.walkTokens(re,function(ye){ye.type==="code"&&(he++,setTimeout(function(){Q(ye.text,ye.lang,function(ke,Ne){if(ke)return se(ke);Ne!=null&&Ne!==ye.text&&(ye.text=Ne,ye.escaped=!0),he--,he===0&&se()})},0))}),he===0&&se();return}try{var pe=be.lex(Z,ie);return ie.walkTokens&&ae.walkTokens(pe,ie.walkTokens),Ge.parse(pe,ie)}catch(ye){if(ye.message+=`
Please report this to https://github.com/markedjs/marked.`,ie.silent)return"<p>An error occurred:</p><pre>"+Ve(ye.message+"",!0)+"</pre>";throw ye}}ae.options=ae.setOptions=function(Z){return at(ae.defaults,Z),tt(ae.defaults),ae},ae.getDefaults=Le,ae.defaults=qe,ae.use=function(Z){var ie=at({},Z);if(Z.renderer&&function(){var Q=ae.defaults.renderer||new De,re=function(pe){var ye=Q[pe];Q[pe]=function(){for(var ke=arguments.length,Ne=new Array(ke),Ze=0;Ze<ke;Ze++)Ne[Ze]=arguments[Ze];var Ke=Z.renderer[pe].apply(Q,Ne);return Ke===!1&&(Ke=ye.apply(Q,Ne)),Ke}};for(var se in Z.renderer)re(se);ie.renderer=Q}(),Z.tokenizer&&function(){var Q=ae.defaults.tokenizer||new Te,re=function(pe){var ye=Q[pe];Q[pe]=function(){for(var ke=arguments.length,Ne=new Array(ke),Ze=0;Ze<ke;Ze++)Ne[Ze]=arguments[Ze];var Ke=Z.tokenizer[pe].apply(Q,Ne);return Ke===!1&&(Ke=ye.apply(Q,Ne)),Ke}};for(var se in Z.tokenizer)re(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=M(Z),Q;!(Q=oe()).done;){var re=Q.value;ie(re);switch(re.type){case"table":{for(var se=M(re.tokens.header),he;!(he=se()).done;){var pe=he.value;ae.walkTokens(pe,ie)}for(var ye=M(re.tokens.cells),ke;!(ke=ye()).done;)for(var Ne=ke.value,Ze=M(Ne),Ke;!(Ke=Ze()).done;){var lt=Ke.value;ae.walkTokens(lt,ie)}break}case"list":{ae.walkTokens(re.items,ie);break}default:re.tokens&&ae.walkTokens(re.tokens,ie)}}},ae.Parser=Ge,ae.parser=Ge.parse,ae.Renderer=De,ae.TextRenderer=Me,ae.Lexer=be,ae.lexer=be.lex,ae.Tokenizer=Te,ae.Slugger=We,ae.parse=ae;var J=ae;return J})},ELLl:function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=fe.Pos;fe.defineOption("autoCloseBrackets",!1,function(b,x,l){l&&l!=fe.Init&&(b.removeKeyMap(M),b.state.closeBrackets=null),x&&(D(V(x,"pairs")),b.state.closeBrackets=x,b.addKeyMap(M))});function V(b,x){return x=="pairs"&&typeof b=="string"?b:typeof b=="object"&&b[x]!=null?b[x]:$[x]}var M={Backspace:I,Enter:O};function D(b){for(var x=0;x<b.length;x++){var l=b.charAt(x),o="'"+l+"'";M[o]||(M[o]=j(l))}}D($.pairs+"`");function j(b){return function(x){return g(x,b)}}function U(b){var x=b.state.closeBrackets;if(!x||x.override)return x;var l=b.getModeAt(b.getCursor());return l.closeBrackets||x}function I(b){var x=U(b);if(!x||b.getOption("disableInput"))return fe.Pass;for(var l=V(x,"pairs"),o=b.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var h=R(b,o[s].head);if(!h||l.indexOf(h)%2!=0)return fe.Pass}for(var s=o.length-1;s>=0;s--){var C=o[s].head;b.replaceRange("",_(C.line,C.ch-1),_(C.line,C.ch+1),"+delete")}}function O(b){var x=U(b),l=x&&V(x,"explode");if(!l||b.getOption("disableInput"))return fe.Pass;for(var o=b.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var h=R(b,o[s].head);if(!h||l.indexOf(h)%2!=0)return fe.Pass}b.operation(function(){var C=b.lineSeparator()||`
`;b.replaceSelection(C+C,null),b.execCommand("goCharLeft"),o=b.listSelections();for(var m=0;m<o.length;m++){var p=o[m].head.line;b.indentLine(p,null,!0),b.indentLine(p+1,null,!0)}})}function v(b){var x=fe.cmpPos(b.anchor,b.head)>0;return{anchor:new _(b.anchor.line,b.anchor.ch+(x?-1:1)),head:new _(b.head.line,b.head.ch+(x?1:-1))}}function g(b,x){var l=U(b);if(!l||b.getOption("disableInput"))return fe.Pass;var o=V(l,"pairs"),s=o.indexOf(x);if(s==-1)return fe.Pass;for(var h=V(l,"closeBefore"),C=V(l,"triples"),m=o.charAt(s+1)==x,p=b.listSelections(),A=s%2==0,E,f=0;f<p.length;f++){var d=p[f],u=d.head,a,y=b.getRange(u,_(u.line,u.ch+1));if(A&&!d.empty())a="surround";else if((m||!A)&&y==x)m&&w(b,u)?a="both":C.indexOf(x)>=0&&b.getRange(u,_(u.line,u.ch+3))==x+x+x?a="skipThree":a="skip";else if(m&&u.ch>1&&C.indexOf(x)>=0&&b.getRange(_(u.line,u.ch-2),u)==x+x){if(u.ch>2&&/\bstring/.test(b.getTokenTypeAt(_(u.line,u.ch-2))))return fe.Pass;a="addFour"}else if(m){var c=u.ch==0?" ":b.getRange(_(u.line,u.ch-1),u);if(!fe.isWordChar(y)&&c!=x&&!fe.isWordChar(c))a="both";else return fe.Pass}else if(A&&(y.length===0||/\s/.test(y)||h.indexOf(y)>-1))a="both";else return fe.Pass;if(!E)E=a;else if(E!=a)return fe.Pass}var S=s%2?o.charAt(s-1):x,P=s%2?x:o.charAt(s+1);b.operation(function(){if(E=="skip")b.execCommand("goCharRight");else if(E=="skipThree")for(var G=0;G<3;G++)b.execCommand("goCharRight");else if(E=="surround"){for(var X=b.getSelections(),G=0;G<X.length;G++)X[G]=S+X[G]+P;b.replaceSelections(X,"around"),X=b.listSelections().slice();for(var G=0;G<X.length;G++)X[G]=v(X[G]);b.setSelections(X)}else E=="both"?(b.replaceSelection(S+P,null),b.triggerElectric(S+P),b.execCommand("goCharLeft")):E=="addFour"&&(b.replaceSelection(S+S+S+S,"before"),b.execCommand("goCharRight"))})}function R(b,x){var l=b.getRange(_(x.line,x.ch-1),_(x.line,x.ch+1));return l.length==2?l:null}function w(b,x){var l=b.getTokenAt(_(x.line,x.ch+1));return/\bstring/.test(l.type)&&l.start==x.ch&&(x.ch==0||!/\bstring/.test(b.getTokenTypeAt(x)))}})},HmJG:function(ct,rt,le){},LSTS:function(ct,rt,le){"use strict";Object.defineProperty(rt,"__esModule",{value:!0});var fe=function(){function g(R,w){for(var b=0;b<w.length;b++){var x=w[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(R,x.key,x)}}return function(R,w,b){return w&&g(R.prototype,w),b&&g(R,b),R}}(),$=le("q1tI"),_=D($),V=le("17x9"),M=D(V);function D(g){return g&&g.__esModule?g:{default:g}}function j(g,R){var w={};for(var b in g){if(R.indexOf(b)>=0)continue;if(!Object.prototype.hasOwnProperty.call(g,b))continue;w[b]=g[b]}return w}function U(g,R){if(!(g instanceof R))throw new TypeError("Cannot call a class as a function")}function I(g,R){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:g}function O(g,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);g.prototype=Object.create(R&&R.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(g,R):g.__proto__=R)}var v=function(g){O(R,g);function R(w){U(this,R);var b=I(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,w));return b.scrollListener=b.scrollListener.bind(b),b.eventListenerOptions=b.eventListenerOptions.bind(b),b.mousewheelListener=b.mousewheelListener.bind(b),b}return fe(R,[{key:"componentDidMount",value:function(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function(){if(this.props.isReverse&&this.loadMore){var b=this.getParentElement(this.scrollComponent);b.scrollTop=b.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function(){var b=!1,x={get passive(){b=!0}};try{document.addEventListener("test",null,x),document.removeEventListener("test",null,x)}catch(l){}return b}},{key:"eventListenerOptions",value:function(){var b=this.props.useCapture;return this.isPassiveSupported()&&(b={useCapture:this.props.useCapture,passive:!0}),b}},{key:"setDefaultLoader",value:function(b){this.defaultLoader=b}},{key:"detachMousewheelListener",value:function(){var b=window;this.props.useWindow===!1&&(b=this.scrollComponent.parentNode),b.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function(){var b=window;this.props.useWindow===!1&&(b=this.getParentElement(this.scrollComponent)),b.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),b.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function(b){var x=this.props.getScrollParent&&this.props.getScrollParent();return x!=null?x:b&&b.parentNode}},{key:"filterProps",value:function(b){return b}},{key:"attachScrollListener",value:function(){var b=this.getParentElement(this.scrollComponent);if(!this.props.hasMore||!b)return;var x=window;this.props.useWindow===!1&&(x=b),x.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),x.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),x.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}},{key:"mousewheelListener",value:function(b){b.deltaY===1&&!this.isPassiveSupported()&&b.preventDefault()}},{key:"scrollListener",value:function(){var b=this.scrollComponent,x=window,l=this.getParentElement(b),o=void 0;if(this.props.useWindow){var s=document.documentElement||document.body.parentNode||document.body,h=x.pageYOffset!==void 0?x.pageYOffset:s.scrollTop;this.props.isReverse?o=h:o=this.calculateOffset(b,h)}else this.props.isReverse?o=l.scrollTop:o=b.scrollHeight-l.scrollTop-l.clientHeight;o<Number(this.props.threshold)&&b&&b.offsetParent!==null&&(this.detachScrollListener(),this.beforeScrollHeight=l.scrollHeight,this.beforeScrollTop=l.scrollTop,typeof this.props.loadMore=="function"&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function(b,x){return b?this.calculateTopPosition(b)+(b.offsetHeight-x-window.innerHeight):0}},{key:"calculateTopPosition",value:function(b){return b?b.offsetTop+this.calculateTopPosition(b.offsetParent):0}},{key:"render",value:function(){var b=this,x=this.filterProps(this.props),l=x.children,o=x.element,s=x.hasMore,h=x.initialLoad,C=x.isReverse,m=x.loader,p=x.loadMore,A=x.pageStart,E=x.ref,f=x.threshold,d=x.useCapture,u=x.useWindow,a=x.getScrollParent,y=j(x,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]);y.ref=function(S){b.scrollComponent=S,E&&E(S)};var c=[l];return s&&(m?C?c.unshift(m):c.push(m):this.defaultLoader&&(C?c.unshift(this.defaultLoader):c.push(this.defaultLoader))),_.default.createElement(o,y,c)}}]),R}($.Component);v.propTypes={children:M.default.node.isRequired,element:M.default.node,hasMore:M.default.bool,initialLoad:M.default.bool,isReverse:M.default.bool,loader:M.default.node,loadMore:M.default.func.isRequired,pageStart:M.default.number,ref:M.default.func,getScrollParent:M.default.func,threshold:M.default.number,useCapture:M.default.bool,useWindow:M.default.bool},v.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},rt.default=v,ct.exports=rt.default},LdHM:function(ct,rt,le){"use strict";le.d(rt,"b",function(){return h}),le.d(rt,"a",function(){return m});var fe=le("1OyB"),$=le("vuIU"),_=le("Ji7U"),V=le("LK+K"),M=le("q1tI"),D=le("rePB"),j=le("Ff2n"),U=le("ODXe"),I=le("4IlW"),O=le("bX4T"),v=le("YrtM"),g=le("TSYQ"),R=le.n(g),w=le("+nKL"),b=le("8OUc"),x=function(ne,ce){var ge=ne.prefixCls,xe=ne.id,Ie=ne.flattenOptions,Te=ne.childrenAsData,Oe=ne.values,Ce=ne.searchValue,Ae=ne.multiple,ve=ne.defaultActiveFirstOption,W=ne.height,L=ne.itemHeight,k=ne.notFoundContent,H=ne.open,q=ne.menuItemSelectedIcon,B=ne.virtual,ue=ne.onSelect,be=ne.onToggleOpen,we=ne.onActiveValue,Pe=ne.onScroll,_e=ne.onMouseEnter,De="".concat(ge,"-item"),Me=Object(v.a)(function(){return Ie},[H,Ie],function(J,Z){return Z[0]&&J[1]!==Z[1]}),We=M.useRef(null),ze=function(Z){Z.preventDefault()},Xe=function(Z){We.current&&We.current.scrollTo({index:Z})},Ge=function(Z){for(var ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,oe=Me.length,Q=0;Q<oe;Q+=1){var re=(Z+Q*ie+oe)%oe,se=Me[re],he=se.group,pe=se.data;if(!he&&!pe.disabled)return re}return-1},at=M.useState(function(){return Ge(0)}),$e=Object(U.a)(at,2),Ve=$e[0],Le=$e[1],tt=function(Z){Le(Z);var ie=Me[Z];if(!ie){we(null,-1);return}we(ie.data.value,Z)};M.useEffect(function(){tt(ve!==!1?Ge(0):-1)},[Me.length,Ce]),M.useEffect(function(){var J=setTimeout(function(){if(!Ae&&H&&Oe.size===1){var Z=Array.from(Oe)[0],ie=Me.findIndex(function(oe){var Q=oe.data;return Q.value===Z});tt(ie),Xe(ie)}});return function(){return clearTimeout(J)}},[H]);var qe=function(Z){Z!==void 0&&ue(Z,{selected:!Oe.has(Z)}),Ae||be(!1)};if(M.useImperativeHandle(ce,function(){return{onKeyDown:function(Z){var ie=Z.which;switch(ie){case I.a.UP:case I.a.DOWN:{var oe=0;if(ie===I.a.UP?oe=-1:ie===I.a.DOWN&&(oe=1),oe!==0){var Q=Ge(Ve+oe,oe);Xe(Q),tt(Q)}break}case I.a.ENTER:{var re=Me[Ve];re&&!re.data.disabled?qe(re.data.value):qe(void 0),H&&Z.preventDefault();break}case I.a.ESC:be(!1)}},onKeyUp:function(){},scrollTo:function(Z){Xe(Z)}}}),Me.length===0)return M.createElement("div",{role:"listbox",id:"".concat(xe,"_list"),className:"".concat(De,"-empty"),onMouseDown:ze},k);function ae(J){var Z=Me[J];if(!Z)return null;var ie=Z.data||{},oe=ie.value,Q=ie.label,re=ie.children,se=Object(O.a)(ie,!0),he=Te?re:Q;return Z?M.createElement("div",Object.assign({"aria-label":typeof he=="string"?he:null},se,{key:J,role:"option",id:"".concat(xe,"_list_").concat(J),"aria-selected":Oe.has(oe)}),oe):null}return M.createElement(M.Fragment,null,M.createElement("div",{role:"listbox",id:"".concat(xe,"_list"),style:{height:0,width:0,overflow:"hidden"}},ae(Ve-1),ae(Ve),ae(Ve+1)),M.createElement(w.a,{itemKey:"key",ref:We,data:Me,height:W,itemHeight:L,fullHeight:!1,onMouseDown:ze,onScroll:Pe,virtual:B,onMouseEnter:_e},function(J,Z){var ie,oe=J.group,Q=J.groupOption,re=J.data,se=re.label,he=re.key;if(oe)return M.createElement("div",{className:R()(De,"".concat(De,"-group"))},se!==void 0?se:he);var pe=re.disabled,ye=re.value,ke=re.title,Ne=re.children,Ze=re.style,Ke=re.className,lt=Object(j.a)(re,["disabled","value","title","children","style","className"]),it=Oe.has(ye),Ye="".concat(De,"-option"),wt=R()(De,Ye,Ke,(ie={},Object(D.a)(ie,"".concat(Ye,"-grouped"),Q),Object(D.a)(ie,"".concat(Ye,"-active"),Ve===Z&&!pe),Object(D.a)(ie,"".concat(Ye,"-disabled"),pe),Object(D.a)(ie,"".concat(Ye,"-selected"),it),ie)),dt=Te?Ne:se,Ot=!q||typeof q=="function"||it;return M.createElement("div",Object.assign({},lt,{"aria-selected":it,className:wt,title:ke,onMouseMove:function(){if(Ve===Z||pe)return;tt(Z)},onClick:function(){pe||qe(ye)},style:Ze}),M.createElement("div",{className:"".concat(Ye,"-content")},dt||ye),M.isValidElement(q)||it,Ot&&M.createElement(b.a,{className:"".concat(De,"-option-state"),customizeIcon:q,customizeIconProps:{isSelected:it}},it?"\u2713":null))}))},l=M.forwardRef(x);l.displayName="OptionList";var o=l,s=function(){return null};s.isSelectOption=!0;var h=s,C=function(){return null};C.isSelectOptGroup=!0;var m=C,p=le("VTBJ"),A=le("Zm9Q");function E(F){var ne=F.key,ce=F.props,ge=ce.children,xe=ce.value,Ie=Object(j.a)(ce,["children","value"]);return Object(p.a)({key:ne,value:xe!==void 0?xe:ne,children:ge},Ie)}function f(F){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(A.a)(F).map(function(ce,ge){if(!M.isValidElement(ce)||!ce.type)return null;var xe=ce.type.isSelectOptGroup,Ie=ce.key,Te=ce.props,Oe=Te.children,Ce=Object(j.a)(Te,["children"]);return ne||!xe?E(ce):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(Ie===null?ge:Ie,"__"),label:Ie},Ce),{},{options:f(Oe)})}).filter(function(ce){return ce})}var d=le("2Qr1"),u=le("qNPg"),a=le("U8pU"),y=le("Kwbf"),c=le("WKfj");function S(F){var ne=F.mode,ce=F.options,ge=F.children,xe=F.backfill,Ie=F.allowClear,Te=F.placeholder,Oe=F.getInputElement,Ce=F.showSearch,Ae=F.onSearch,ve=F.defaultOpen,W=F.autoFocus,L=F.labelInValue,k=F.value,H=F.inputValue,q=F.optionLabelProp,B=ne==="multiple"||ne==="tags",ue=Ce!==void 0?Ce:B||ne==="combobox",be=ce||f(ge);if(Object(y.a)(ne!=="tags"||be.every(function(De){return!De.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ne==="tags"||ne==="combobox"){var we=be.some(function(De){return De.options?De.options.some(function(Me){return typeof("value"in Me?Me.value:Me.key)=="number"}):typeof("value"in De?De.value:De.key)=="number"});Object(y.a)(!we,"`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"||!xe,"`backfill` only works with `combobox` mode."),Object(y.a)(ne==="combobox"||!Oe,"`getInputElement` only work with `combobox` mode."),Object(y.b)(ne!=="combobox"||!Oe||!Ie||!Te,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ae&&!ue&&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."),k!=null){var Pe=Object(c.d)(k);Object(y.a)(!L||Pe.every(function(De){return Object(a.a)(De)==="object"&&("key"in De||"value"in De)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(y.a)(!B||Array.isArray(k),"`value` should be array when `mode` is `multiple` or `tags`")}if(ge){var _e=null;Object(A.a)(ge).some(function(De){if(!M.isValidElement(De)||!De.type)return!1;var Me=De.type;if(Me.isSelectOption)return!1;if(Me.isSelectOptGroup){var We=Object(A.a)(De.props.children).every(function(ze){return!M.isValidElement(ze)||!De.type||ze.type.isSelectOption?!0:(_e=ze.type,!1)});return!We}return _e=Me,!0}),_e&&Object(y.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(_e.displayName||_e.name||_e,"`.")),Object(y.a)(H===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=S,G=Object(u.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:d.d,getLabeledValue:d.e,filterOptions:d.b,isValueDisabled:d.g,findValueOption:d.c,warningProps:P,fillOptionsWithMissingValue:d.a}),X=function(F){Object(_.a)(ce,F);var ne=Object(V.a)(ce);function ce(){var ge;return Object(fe.a)(this,ce),ge=ne.apply(this,arguments),ge.selectRef=M.createRef(),ge.focus=function(){ge.selectRef.current.focus()},ge.blur=function(){ge.selectRef.current.blur()},ge}return Object($.a)(ce,[{key:"render",value:function(){return M.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ce}(M.Component);X.Option=h,X.OptGroup=m;var te=X,z=rt.c=te},M8RZ:function(ct,rt,le){"use strict";le.d(rt,"a",function(){return I});var fe=le("fWQN"),$=le("mtLc"),_=le("yKVA"),V=le("879j"),M=le("q1tI"),D=le.n(M),j=le("i8i4"),U=le.n(j),I=function(O){Object(_.a)(g,O);var v=Object(V.a)(g);function g(R){var w;Object(fe.a)(this,g),w=v.call(this,R);var b=window.document;return w.node=b.createElement("div"),b.body.appendChild(w.node),w}return Object($.a)(g,[{key:"render",value:function(){var w=this.props.children;return Object(j.createPortal)(w,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),g}(D.a.Component)},Ot1p:function(ct,rt,le){"use strict";var fe=le("2qtc"),$=le("kLXV"),_=le("rAM+"),V=le("miYZ"),M=le("tsqr"),D=le("9og8"),j=le("tJVT"),U=le("jrin"),I=le("WmNS"),O=le.n(I),v=le("q1tI"),g=le.n(v),R=le("VrN/"),w=le.n(R),b=le("bdgK"),x=le("p77/"),l=le("Bd2K"),o=le("ELLl"),s=le("19Vz"),h=le("lZu9"),C=le("+NIl"),m=le("kSUc"),p=le("9Bee"),A=function(pe){var ye=pe.value,ke=ye===void 0?"":ye,Ne=pe.className,Ze=pe.showTextOnly,Ke=pe.showLines,lt=pe.style,it=lt===void 0?{}:lt,Ye=Object(v.useMemo)(function(){return""},[ke]);return g.a.createElement(g.a.Fragment,null,g.a.createElement("div",{dangerouslySetInnerHTML:{__html:Ye}}))},E=le("0Owb"),f=le("dejd"),d=le("C+DQ"),u=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 c(pe){var ye=pe.onActionCallback,ke=pe.title,Ne=pe.icon,Ze=pe.actionName,Ke=pe.className,lt=Ke===void 0?"":Ke,it=pe.children;function Ye(){ye(Ze)}return g.a.createElement("a",{title:ke,className:lt,onClick:Ye},g.a.createElement("i",{className:"md-iconfont ".concat(Ne)}),it)}var S=function(pe){var ye=pe.watch,ke=pe.showNullButton,Ne=pe.onActionCallback,Ze=pe.fullScreen,Ke=pe.insertTemp,lt=pe.hidetoolBar,it=pe.uuid,Ye=pe.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(u.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(u.F)("_educoder_session"),"&key=").concat(it,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var wt=[].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 g.a.createElement("ul",{className:"markdown-toolbar-container"},!lt&&wt.map(function(dt,Ot){return g.a.createElement("li",{key:Ot},dt.actionName?g.a.createElement(c,Object(E.a)({},dt,{onActionCallback:Ne})):g.a.createElement("span",{className:"v-line"}))}),ke?g.a.createElement("li",null,g.a.createElement(c,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Ne},g.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,Ke&&g.a.createElement("li",null,g.a.createElement(c,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(Ke),onActionCallback:Ne},g.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),g.a.createElement("li",{className:"btn-full-screen"},g.a.createElement(c,{icon:"".concat(Ze?"icon-shrink":"icon-enlarge"),title:Ze?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Ne})))},P=le("M8RZ"),G=le("+L6B"),X=le("2/Rp"),te=le("y8nQ"),z=le("Vl3Y"),F=le("5NDa"),ne=le("5rEg"),ce={labelCol:{span:4},wrapperCol:{span:20}},ge=function(pe){var ye=pe.callback,ke=pe.onCancel;function Ne(Ze){ye(Ze)}return g.a.createElement(z.a,Object(E.a)({},ce,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Ne}),g.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},g.a.createElement(ne.a,null)),g.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},g.a.createElement(ne.a,null)),g.a.createElement("div",{className:"flex-container flex-end"},g.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),g.a.createElement(X.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},xe=le("7ahc"),Ie=le("HmJG"),Te=le("BjJ7"),Oe=z.a.useForm,Ce={width:280,marginRight:10},Ae={labelCol:{span:5},wrapperCol:{span:19}},ve=function(pe){var ye=pe.callback,ke=pe.onCancel,Ne=Oe(),Ze=Object(j.a)(Ne,1),Ke=Ze[0];function lt(wt){ye(wt)}function it(wt,dt){if(wt.status===-1){M.b.error(wt.message);return}Ke.setFieldsValue({src:"/api/attachments/".concat(wt.id),type:dt.type})}function Ye(wt){var dt=wt.target.files[0];L(dt,it)}return g.a.createElement(z.a,Object(E.a)({form:Ke},Ae,{className:"upload-image-panel",onFinish:lt}),g.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},g.a.createElement("div",{className:"flex-container"},g.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},g.a.createElement(ne.a,{style:Ce})),g.a.createElement(W,{onFileChange:Ye}))),g.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},g.a.createElement(ne.a,{style:{width:264}})),g.a.createElement(z.a.Item,{style:{textAlign:"right"}},g.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),g.a.createElement(X.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))};function W(pe){var ye=pe.onFileChange;return g.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",g.a.createElement("input",{type:"file",onChange:ye}))}function L(pe,ye){if(!pe)throw new String("\u6CA1\u6709\u6587\u4EF6");var ke=new FormData;ke.append("editormd-image-file",pe),ke.append("file_param_name","editormd-image-file"),ke.append("byxhr","true");var Ne=new window.XMLHttpRequest;Ne.withCredentials=!0,Ne.addEventListener("load",function(Ze){ye(JSON.parse(Ze.target.responseText),pe)},!1),Ne.addEventListener("error",function(Ze){console.error(Ze)},!1),Ne.open("POST","".concat(Te.a,"/api/attachments.json")),Ne.send(ke)}var k=le("giR+"),H=le("fyUT"),q=le("7Kak"),B=le("9yH6"),ue=B.a.Group,be={margin:"0 8px"},we=function(pe){var ye=pe.callback,ke=pe.onCancel;function Ne(Ze){ye(Ze)}return g.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Ne},g.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},g.a.createElement("span",{style:be},"\u5355\u5143\u683C\u6570\uFF1A"),g.a.createElement("span",{style:be},"\u884C\u6570"),g.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},g.a.createElement(H.a,null)),g.a.createElement("span",{style:be},"\u5217\u6570"),g.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},g.a.createElement(H.a,null))),g.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},g.a.createElement("span",{style:be},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),g.a.createElement(z.a.Item,{name:"align"},g.a.createElement(ue,null,g.a.createElement(B.a,{value:"default"},g.a.createElement("i",{className:"fa fa-align-justify"})),g.a.createElement(B.a,{value:"left"},g.a.createElement("i",{className:"fa fa-align-left"})),g.a.createElement(B.a,{value:"center"},g.a.createElement("i",{className:"fa fa-align-center"})),g.a.createElement(B.a,{value:"right"},g.a.createElement("i",{className:"fa fa-align-right"}))))),g.a.createElement("div",{className:"flex-container flex-end"},g.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),g.a.createElement(X.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},Pe=le("ErOA"),_e=le("7Cbv"),De="link",Me="upload-image",We="code-block",ze="add-table",Xe="------------",Ge={default:Xe,left:":".concat(Xe),center:":".concat(Xe,":"),right:"".concat(Xe,":")},at=le("9VGf"),$e,Ve;function Le(){}var tt=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(pe){return/^\d+$/.test(pe)?"".concat(pe,"px"):pe}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"],re=($e={},Object(U.a)($e,oe+"-B","bold"),Object(U.a)($e,oe+"-I","italic"),$e),se=(Ve={},Object(U.a)(Ve,De,"\u6DFB\u52A0\u94FE\u63A5"),Object(U.a)(Ve,We,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(U.a)(Ve,Me,"\u6DFB\u52A0\u6587\u4EF6"),Object(U.a)(Ve,ze,"\u6DFB\u52A0\u8868\u683C"),Ve),he=rt.a=function(pe){var ye=pe.defaultValue,ke=ye===void 0?"":ye,Ne=pe.onChange,Ze=pe.width,Ke=Ze===void 0?"100%":Ze,lt=pe.height,it=lt===void 0?400:lt,Ye=pe.miniToolbar,wt=Ye===void 0?!1:Ye,dt=pe.isFocus,Ot=dt===void 0?!1:dt,Nt=pe.watch,St=pe.insertTemp,ar=pe.mode,br=ar===void 0?"markdown":ar,Kt=pe.id,tr=Kt===void 0?"markdown-editor-id":Kt,or=pe.showResizeBar,Pr=or===void 0?!1:or,Vt=pe.noStorage,At=Vt===void 0?!1:Vt,Mt=pe.showNullButton,vt=Mt===void 0?!1:Mt,He=pe.hidetoolBar,xt=He===void 0?!1:He,Bt=pe.fullScreen,pt=Bt===void 0?!1:Bt,yt=pe.onBlur,kt=pe.onCMBeforeChange,xr=pe.onFullScreen,Ht=pe.className,Ue=Ht===void 0?"":Ht,ft=pe.disablePaste,ri=ft===void 0?!1:ft,bi=pe.placeholder,xi=bi===void 0?"":bi,ii=pe.values,Ei=ii===void 0?"":ii,gt=Object(v.useState)(null),An=Object(j.a)(gt,2),Fe=An[0],Si=An[1],Cr=Object(v.useState)(ke),Ki=Object(j.a)(Cr,2),ni=Ki[0],Lr=Ki[1],Vi=Object(v.useState)(Nt),Xi=Object(j.a)(Vi,2),Ar=Xi[0],Yi=Xi[1],kn=Object(v.useState)(pt),$i=Object(j.a)(kn,2),kr=$i[0],_n=$i[1],aa=Object(v.useState)(""),Zi=Object(j.a)(aa,2),sr=Zi[0],Vr=Zi[1],oa=Object(v.useState)(0),ai=Object(j.a)(oa,2),_r=ai[0],Ji=ai[1],sa=Object(v.useState)(it),Dn=Object(j.a)(sa,2),Rn=Dn[0],Ti=Dn[1],On=Object(v.useState)(!1),Mn=Object(j.a)(On,2),la=Mn[0],Ci=Mn[1],oi=Object(v.useRef)(Object(_e.a)()),si=Object(v.useRef)(!1),wi=Object(v.useRef)(),Fr=Object(v.useRef)(),jr=Object(v.useRef)(),Wr=Object(v.useRef)(),Li=Object(v.useRef)(),Pn=function(){var ot=Object(D.a)(O.a.mark(function mt(){var ut,Et;return O.a.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return Pt.next=2,Object(Pe.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:oi.current}});case 2:Et=Pt.sent,Et!=null&&(ut=Et.attachments)!==null&&ut!==void 0&&ut.length&&(console.log("cm:",Fe,Fr),Et.attachments.map(function(Ct){Ct.content_type.indexOf("image")>-1?Fe.replaceSelection("![,](/api/attachments/".concat(Ct.id,"?type=").concat(Ct.content_type,")")):Ct.content_type.indexOf("video")>-1?Fe.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Ct.content_type.indexOf("pdf")>-1?Fe.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>")):Fe.replaceSelection("[".concat(Ct.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ct.id,"?type=").concat(Ct.content_type,")"))}));case 4:case"end":return Pt.stop()}},mt)}));return function(){return ot.apply(this,arguments)}}();Object(v.useEffect)(function(){Lr(Ei),Fe==null||Fe.setValue(Ei)},[Ei]),Object(v.useEffect)(function(){xr==null||xr(kr)},[kr]),Object(v.useEffect)(function(){if(Fr.current){var ot=w.a.fromTextArea(Fr.current,{mode:br,lineNumbers:!wt,lineWrapping:!0,value:ke,autoCloseTags:!0,autoCloseBrackets:!0});Ot&&ot.focus();function mt(ut,Et){if(ri){Et.preventDefault();return}var Lt=Et.clipboardData;if(Lt){var Pt=Lt.types.toString(),Ct=Lt.items;if(Pt==="Files"||Lt.types.indexOf("Files")>-1){if(Et.preventDefault(),br=="stex")return;try{var Xt,hr=Ct[1];((Xt=Ct[0])===null||Xt===void 0?void 0:Xt.kind)==="file"&&(hr=Ct[0]);var Tt=hr.getAsFile(),Hr=Tt.name.split(".").pop();L(Tt,function(_t){if(_t.id){var dr,rr,wr;(Tt==null||((dr=Tt.type)===null||dr===void 0)?void 0:dr.indexOf("image"))>-1?ot.replaceSelection("![,](/api/attachments/".concat(_t.id,"?type=").concat(_t.content_type,")")):(Tt==null||((rr=Tt.type)===null||rr===void 0)?void 0:rr.indexOf("video"))>-1?ot.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,'"></video>')):(Tt==null||((wr=Tt.type)===null||wr===void 0)?void 0:wr.indexOf("pdf"))>-1?ot.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,"?type=").concat(Tt.type,'&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):Q.includes(Hr)?ot.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,'?type=office&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):ot.replaceSelection("[".concat(Tt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,"?type=").concat(_t.content_type,")"))}else(_t==null?void 0:_t.status)===401&&(document.location.href="/user/login")})}catch(_t){M.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return ot.on("paste",mt),ot.on("dragleave",function(ut,Et){jr.current.classList.remove("mouse-hover-md")}),ot.on("dragover",function(ut,Et){jr.current.classList.add("mouse-hover-md")}),ot.on("drop",function(ut,Et){jr.current.classList.add("mouse-hover-md");var Lt;if(Lt=Et.dataTransfer.files,Lt.length>0){Et.preventDefault(),Et.stopPropagation();for(var Pt=function(hr){var Tt=Lt[hr],Hr=Tt.name.split(".").pop();L(Tt,function(_t){if(_t.id){var dr,rr,wr;(Tt==null||((dr=Tt.type)===null||dr===void 0)?void 0:dr.indexOf("image"))>-1?ot.replaceSelection("![,](/api/attachments/".concat(_t.id,"?type=").concat(_t.content_type,")")):(Tt==null||((rr=Tt.type)===null||rr===void 0)?void 0:rr.indexOf("video"))>-1?ot.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,'"></video>')):(Tt==null||((wr=Tt.type)===null||wr===void 0)?void 0:wr.indexOf("pdf"))>-1?ot.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,"?type=").concat(Tt.type,'&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):Q.includes(Hr)?ot.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,'?type=office&disposition=inline" target="_blank">').concat(Tt.name,"</a>")):ot.replaceSelection("[".concat(Tt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(_t.id,"?type=").concat(_t.content_type,")"))}else(_t==null?void 0:_t.status)===401&&(document.location.href="/user/login")})},Ct=0;Ct<Lt.length;Ct++)Pt(Ct)}}),Si(ot),function(){ot.off("paste",mt)}}},[]);var Er=Object(v.useCallback)(function(){if(jr.current)try{}catch(ot){console.log(ot,"---- to set md editor body height")}},[Rn,jr,kr]);Object(v.useEffect)(function(){function ot(){var ut=new b.default(function(Et){var Lt=Object(_.a)(Et),Pt;try{for(Lt.s();!(Pt=Lt.n()).done;){var Ct=Pt.value;(Ct.target.offsetHeight>0||Ct.target.offsetWidth>0)&&(Er(),Fe.setSize("100%","100%"),Fe.refresh())}}catch(Xt){Lt.e(Xt)}finally{Lt.f()}});return ut.observe(Fr.current.parentElement),ut}if(Fe){var mt=ot();return function(){mt.unobserve(Fr.current.parentElement)}}},[Fe,Er]),Object(v.useEffect)(function(){if(Fe){for(var ot=[],mt=function(){var Ct=Et[ut];Lt=Object(j.a)(Ct,2);var Xt=Lt[0],hr=Lt[1],Tt=Object(U.a)({},Xt,function(){In(hr)});ot.push(Tt),Fe.addKeyMap(Tt)},ut=0,Et=Object.entries(re);ut<Et.length;ut++){var Lt;mt()}return wi.current=setInterval(function(){si.current&&Pn()},4e3),function(){clearInterval(wi.current);var Pt=Object(_.a)(ot),Ct;try{for(Pt.s();!(Ct=Pt.n()).done;){var Xt=Ct.value;Fe.removeKeyMap(Xt)}}catch(hr){Pt.e(hr)}finally{Pt.f()}}}},[Fe]),Object(v.useEffect)(function(){pt!==kr&&_n(pt)},[pt]),Object(at.a)(function(){if(!At&&_r>0){var ot=new Date().getTime(),mt=window.sessionStorage.getItem(tr);ot>=_r+qe&&(!mt||mt!==ni)&&(window.sessionStorage.setItem(tr,ni),Ci(!0))}},qe),Object(v.useEffect)(function(){Yi(Nt)},[Fe,Nt]),Object(v.useEffect)(function(){Fe&&(Ot&&Fe.focus())},[Fe,Ot]),Object(v.useEffect)(function(){if(Ar&&Fe){var ot=Fe.getScrollerElement();function mt(ut){var Et=ut.target;if(Li.current){var Lt=Et.scrollTop/Et.scrollHeight;Li.current.scrollTop=Li.current.scrollHeight*Lt}}return ot.addEventListener("scroll",mt),function(){ot.removeEventListener("scroll",mt)}}},[Fe,Ar]),Object(v.useEffect)(function(){if(Fe&&kt){function ot(mt,ut){kt(mt,ut)}return Fe.on("beforeChange",ot),function(){Fe.off("beforeChange",ot)}}},[Fe,kt]),Object(v.useEffect)(function(){if(Fe&&yt){function ot(){yt(Fe.getValue())}return Fe.on("blur",ot),function(){Fe.off("blur",ot)}}},[Fe,yt]),Object(v.useEffect)(function(){if(Fe){function ot(mt){var ut=mt.getValue();Lr(ut),Ji(new Date().getTime()),mt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Ne&&Ne(ut)}return Fe.on("change",ot),function(){Fe.off("change",ot)}}},[Fe,Ne]),Object(v.useEffect)(function(){Fe&&(ke==null?(Fe.setValue(""),Lr("")):ke!==Fe.getValue()&&(Fe.setValue(ke),Lr(ke),Fe.setCursor(Fe.lineCount(),0)))},[Fe,ke]);var In=Object(v.useCallback)(function(ot){var mt=Fe.getCursor(),ut=Fe.getSelection(),Et=ut.split(`
`);switch(ot){case"bold":return Fe.replaceSelection("**"+ut+"**"),ut===""&&Fe.setCursor(mt.line,mt.ch+2),Fe.focus();case"italic":return Fe.replaceSelection("*"+ut+"*"),ut===""&&Fe.setCursor(mt.line,mt.ch+1),Fe.focus();case"code":return Fe.replaceSelection("`"+ut+"`"),ut===""&&Fe.setCursor(mt.line,mt.ch+1),Fe.focus();case"inline-latex":return Fe.replaceSelection("`$$"+ut+"$$`"),ut===""&&Fe.setCursor(mt.line,mt.ch+3),Fe.focus();case"latex":return Fe.replaceSelection("```latex\n"+ut+"\n```"),Fe.setCursor(mt.line+1,ut.length+1),Fe.focus();case"line-break":return Fe.replaceSelection(`<br/>
`),Fe.focus();case"list-ul":return ut===""?Fe.replaceSelection("- "+ut):Fe.replaceSelection(Et.map(function(Lt){return Lt===""?"":"- ".concat(Lt)}).join(`
`)),Fe.focus();case"list-ol":return ut===""?Fe.replaceSelection("1. "+ut):Fe.replaceSelection(Et.map(function(Lt,Pt){return Lt===""?"":"".concat(Pt+1,". ").concat(Lt)}).join(`
`)),Fe.focus();case"add-null-ch":return ut===""&&Fe.setCursor(mt.line,mt.ch+1),Fe.replaceSelection(ae),Fe.focus();case"inster-template-1":return ut===""&&Fe.setCursor(mt.line,mt.ch),Fe.replaceSelection(J),Fe.focus();case"eraser":return Fe.setValue(""),Fe.focus();case"trigger-watch":return Yi(!Ar),Fe.focus();case"trigger-full-screen":return _n(!kr),Fe.focus();case De:Vr(De);return;case We:Vr(We);return;case Me:Vr(Me);return;case ze:Vr(ze);return;default:throw new Error}},[Fe,Ar,kr]),Ai=Object(v.useCallback)(function(ot){Vr("");switch(sr){case De:var mt=ot.title,ut=ot.link;return Fe.replaceSelection("[".concat(mt,"](").concat(ut,")")),Fe.focus();case We:var Et=ot.language,Lt=ot.content;return Fe.replaceSelection(["```"+Et,Lt,"```"].join(`
`)),Fe.focus();case Me:var Pt=ot.src,Ct=ot.alt;return Ct?Fe.replaceSelection("![ ".concat(Ct," ]( ").concat(Pt,' "').concat(Ct,'" )')):Fe.replaceSelection("![,](".concat(Pt,")")),Fe.focus();case ze:for(var Xt=ot.row,hr=ot.col,Tt=ot.align,Hr=`
`,_t=0;_t<Xt;_t++){for(var dr=[],rr=[],wr=0;wr<hr;wr++)_t===1&&rr.push(Ge[Tt]),dr.push(" ");_t===1&&(Hr+="| ".concat(rr.join(" | "),` |
`)),Hr+="| ".concat(dr.join(hr===1?"":" | "),` |
`)}return Fe.replaceSelection(Hr+`
`),Fe.focus();default:throw new Error}},[Fe,sr]),Qi=Object(v.useMemo)(function(){switch(sr){case De:return g.a.createElement(ge,{callback:Ai,onCancel:Xr});case We:return g.a.createElement(xe.b,{callback:Ai,onCancel:Xr});case Me:return g.a.createElement(ve,{callback:Ai,onCancel:Xr});case ze:return g.a.createElement(we,{callback:Ai,onCancel:Xr});default:return null}},[sr]);function Xr(){Vr("")}Object(v.useEffect)(function(){if(Wr.current){var ot=Wr.current,mt=!1,ut=0;function Et(Ct){mt=!0,ut=Ct.pageY}function Lt(){mt=!1}function Pt(Ct){if(mt){var Xt=Ct.pageY-ut;Xt<0&&(Xt=0),Xt>300&&(Xt=300);var hr=it+Xt+"px";Ti(hr)}}return ot.addEventListener("mousedown",Et),document.addEventListener("mousemove",Pt),document.addEventListener("mouseup",Lt),function(){ot.removeEventListener("mousedown",Et),document.removeEventListener("mousemove",Pt),document.removeEventListener("mouseup",Lt)}}},[Fe,Wr]),Object(v.useEffect)(function(){Ti(it)},[it]);var Ir=Z(Ke),qi=Z(Rn),Dr={width:Ir,height:qi},en=Object(v.useMemo)(function(){if(_r){var ot=new Date(_r),mt=ot.getHours(),ut=ot.getMinutes(),Et=ot.getSeconds();return mt=mt<10?"0"+mt:mt,ut=ut<10?"0"+ut:ut,Et=Et<10?"0"+Et:Et,"".concat(mt,":").concat(ut,":").concat(Et)}return 0},[_r]);function Nn(){window.sessionStorage.removeItem(tr),Ci(!1),Ji(0)}function li(){Ci(!1),Ji(0),Fe.setValue(window.sessionStorage.getItem(tr))}function ua(ot,mt){var ut=Fe.getValue();ut=ut.replace(ot,mt),Lr(ut),Fe==null||Fe.setValue(ut)}return g.a.createElement(v.Fragment,null,g.a.createElement("div",{className:"markdown-editor-wrapper",ref:jr},g.a.createElement("div",{className:"markdown-editor-container ".concat(Ue," ").concat(Ar?"on-preview":""," ").concat(wt?"mini":""," ").concat(kr?"full-screen":""),style:Dr},g.a.createElement(S,{insertTemp:St,watch:Ar,fullScreen:kr,showNullButton:vt,onActionCallback:In,hidetoolBar:xt,uuid:oi.current,setOpenPhones:function(){si.current=!0}}),g.a.createElement("div",{className:"markdown-editor-body"},g.a.createElement("div",{className:"codemirror-container"},g.a.createElement("textarea",{ref:Fr,placeholder:xi})),Ar?g.a.createElement("div",{ref:Li,className:"preview-container"},br==="stex"&&g.a.createElement(A,{value:ni}),br!=="stex"&&g.a.createElement(p.a,{edit:!0,value:ni,replaces:ua})):null))),Pr?g.a.createElement("a",{ref:Wr,className:"editor-resize"}):null,g.a.createElement(P.a,null,se[sr]?g.a.createElement($.a,{centered:!0,title:se[sr],visible:!0,onCancel:Xr,footer:null,className:"markdown-popup-form"},Qi):null))}},RotF:function(ct,rt,le){ct.exports=le("LSTS")},SJMd:function(ct,rt){/**
* @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,fe,$,_=!1,V,M;window.PR_SHOULD_USE_CONTINUATION=!0;var D,j;(function(){var U=window,I=["break,continue,do,else,for,if,return,while"],O=[I,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],v=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],g=[v,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],R=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],w=[v,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],b="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",x=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],l="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=[I,"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=[I,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],h=[I,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],C=[g,w,R,x,l,o,s,h],m=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,p="str",A="kwd",E="com",f="typ",d="lit",u="pun",a="pln",y="tag",c="dec",S="src",P="atn",G="atv",X="nocode",te="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(ue){for(var be=0,we=!1,Pe=!1,_e=0,De=ue.length;_e<De;++_e){var Me=ue[_e];if(Me.ignoreCase)Pe=!0;else if(/[a-z]/i.test(Me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){we=!0,Pe=!1;break}}var We={b:8,t:9,n:10,v:11,f:12,r:13};function ze(Ve){var Le=Ve.charCodeAt(0);if(Le!==92)return Le;var tt=Ve.charAt(1);return Le=We[tt],Le||("0"<=tt&&tt<="7"?parseInt(Ve.substring(1),8):tt==="u"||tt==="x"?parseInt(Ve.substring(2),16):Ve.charCodeAt(1))}function Xe(Ve){if(Ve<32)return(Ve<16?"\\x0":"\\x")+Ve.toString(16);var Le=String.fromCharCode(Ve);return Le==="\\"||Le==="-"||Le==="]"||Le==="^"?"\\"+Le:Le}function Ge(Ve){var Le=Ve.substring(1,Ve.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")),tt=[],qe=Le[0]==="^",ae=["["];qe&&ae.push("^");for(var J=qe?1:0,Z=Le.length;J<Z;++J){var ie=Le[J];if(/\\[bdsw]/i.test(ie))ae.push(ie);else{var oe=ze(ie),Q;J+2<Z&&Le[J+1]==="-"?(Q=ze(Le[J+2]),J+=2):Q=oe,tt.push([oe,Q]),Q<65||oe>122||(Q<65||oe>90||tt.push([Math.max(65,oe)|32,Math.min(Q,90)|32]),Q<97||oe>122||tt.push([Math.max(97,oe)&~32,Math.min(Q,122)&~32]))}}tt.sort(function(pe,ye){return pe[0]-ye[0]||ye[1]-pe[1]});for(var re=[],se=[],J=0;J<tt.length;++J){var he=tt[J];he[0]<=se[1]+1?se[1]=Math.max(se[1],he[1]):re.push(se=he)}for(var J=0;J<re.length;++J){var he=re[J];ae.push(Xe(he[0])),he[1]>he[0]&&(he[1]+1>he[0]&&ae.push("-"),ae.push(Xe(he[1])))}return ae.push("]"),ae.join("")}function at(Ve){for(var Le=Ve.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),tt=Le.length,qe=[],ae=0,J=0;ae<tt;++ae){var Z=Le[ae];if(Z==="(")++J;else if(Z.charAt(0)==="\\"){var ie=+Z.substring(1);ie&&(ie<=J?qe[ie]=-1:Le[ae]=Xe(ie))}}for(var ae=1;ae<qe.length;++ae)qe[ae]===-1&&(qe[ae]=++be);for(var ae=0,J=0;ae<tt;++ae){var Z=Le[ae];if(Z==="(")++J,qe[J]||(Le[ae]="(?:");else if(Z.charAt(0)==="\\"){var ie=+Z.substring(1);ie&&ie<=J&&(Le[ae]="\\"+qe[ie])}}for(var ae=0;ae<tt;++ae)Le[ae]==="^"&&Le[ae+1]!=="^"&&(Le[ae]="");if(Ve.ignoreCase&&we)for(var ae=0;ae<tt;++ae){var Z=Le[ae],oe=Z.charAt(0);Z.length>=2&&oe==="["?Le[ae]=Ge(Z):oe!=="\\"&&(Le[ae]=Z.replace(/[a-zA-Z]/g,function(se){var he=se.charCodeAt(0);return"["+String.fromCharCode(he&~32,he|32)+"]"}))}return Le.join("")}for(var $e=[],_e=0,De=ue.length;_e<De;++_e){var Me=ue[_e];if(Me.global||Me.multiline)throw new Error(""+Me);$e.push("(?:"+at(Me)+")")}return new RegExp($e.join("|"),Pe?"gi":"g")}function F(ue,be){var we=/(?:^|\s)nocode(?:\s|$)/,Pe=[],_e=0,De=[],Me=0;function We(ze){var Xe=ze.nodeType;if(Xe==1){if(we.test(ze.className))return;for(var Ge=ze.firstChild;Ge;Ge=Ge.nextSibling)We(Ge);var at=ze.nodeName.toLowerCase();(at==="br"||at==="li")&&(Pe[Me]=`
`,De[Me<<1]=_e++,De[Me++<<1|1]=ze)}else if(Xe==3||Xe==4){var $e=ze.nodeValue;$e.length&&(be?$e=$e.replace(/\r\n?/g,`
`):$e=$e.replace(/[ \t\r\n]+/g," "),Pe[Me]=$e,De[Me<<1]=_e,_e+=$e.length,De[Me++<<1|1]=ze)}}return We(ue),{sourceCode:Pe.join("").replace(/\n$/,""),spans:De}}function ne(ue,be,we,Pe,_e){if(!we)return;var De={sourceNode:ue,pre:1,langExtension:null,numberLines:null,sourceCode:we,spans:null,basePos:be,decorations:null};Pe(De),_e.push.apply(_e,De.decorations)}var ce=/\S/;function ge(ue){for(var be=void 0,we=ue.firstChild;we;we=we.nextSibling){var Pe=we.nodeType;be=Pe===1?be?ue:we:Pe===3&&ce.test(we.nodeValue)?ue:be}return be===ue?void 0:be}function xe(ue,be){var we={},Pe;(function(){for(var Me=ue.concat(be),We=[],ze={},Xe=0,Ge=Me.length;Xe<Ge;++Xe){var at=Me[Xe],$e=at[3];if($e)for(var Ve=$e.length;--Ve>=0;)we[$e.charAt(Ve)]=at;var Le=at[1],tt=""+Le;ze.hasOwnProperty(tt)||(We.push(Le),ze[tt]=null)}We.push(/[\0-\uffff]/),Pe=z(We)})();var _e=be.length,De=function(Me){for(var We=Me.sourceCode,ze=Me.basePos,Xe=Me.sourceNode,Ge=[ze,a],at=0,$e=We.match(Pe)||[],Ve={},Le=0,tt=$e.length;Le<tt;++Le){var qe=$e[Le],ae=Ve[qe],J=void 0,Z;if(typeof ae=="string")Z=!1;else{var ie=we[qe.charAt(0)];if(ie)J=qe.match(ie[1]),ae=ie[0];else{for(var oe=0;oe<_e;++oe)if(ie=be[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=S),Z||(Ve[qe]=ae)}var Q=at;if(at+=qe.length,!Z)Ge.push(ze+Q,ae);else{var re=J[1],se=qe.indexOf(re),he=se+re.length;J[2]&&(he=qe.length-J[2].length,se=he-re.length);var pe=ae.substring(5);ne(Xe,ze+Q,qe.substring(0,se),De,Ge),ne(Xe,ze+Q+se,re,W(pe,re),Ge),ne(Xe,ze+Q+he,qe.substring(he),De,Ge)}}Me.decorations=Ge};return De}function Ie(ue){var be=[],we=[];ue.tripleQuotedStrings?be.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):ue.multiLineStrings?be.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):be.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),ue.verbatimStrings&&we.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Pe=ue.hashComments;Pe&&(ue.cStyleComments?(Pe>1?be.push([E,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):be.push([E,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),we.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):be.push([E,/^#[^\r\n]*/,null,"#"])),ue.cStyleComments&&(we.push([E,/^\/\/[^\r\n]*/,null]),we.push([E,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var _e=ue.regexLiterals;if(_e){var De=_e>1?"":`
\r`,Me=De?".":"[\\S\\s]",We="/(?=[^/*"+De+"])(?:[^/\\x5B\\x5C"+De+"]|\\x5C"+Me+"|\\x5B(?:[^\\x5C\\x5D"+De+"]|\\x5C"+Me+")*(?:\\x5D|$))+/";we.push(["lang-regex",RegExp("^"+te+"("+We+")")])}var ze=ue.types;ze&&we.push([f,ze]);var Xe=(""+ue.keywords).replace(/^ | $/g,"");Xe.length&&we.push([A,new RegExp("^(?:"+Xe.replace(/[\s,]+/g,"|")+")\\b"),null]),be.push([a,/^\s+/,null,` \r
\xA0`]);var Ge="^.[^\\s\\w.$@'\"`/\\\\]*";return ue.regexLiterals&&(Ge+="(?!s*/)"),we.push([d,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[d,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[u,new RegExp(Ge),null]),xe(be,we)}var Te=Ie({keywords:C,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Oe(ue,be,we){for(var Pe=/(?:^|\s)nocode(?:\s|$)/,_e=/\r\n?|\n/,De=ue.ownerDocument,Me=De.createElement("li");ue.firstChild;)Me.appendChild(ue.firstChild);var We=[Me];function ze(Le){var tt=Le.nodeType;if(tt==1&&!Pe.test(Le.className))if(Le.nodeName==="br")Xe(Le),Le.parentNode&&Le.parentNode.removeChild(Le);else for(var qe=Le.firstChild;qe;qe=qe.nextSibling)ze(qe);else if((tt==3||tt==4)&&we){var ae=Le.nodeValue,J=ae.match(_e);if(J){var Z=ae.substring(0,J.index);Le.nodeValue=Z;var ie=ae.substring(J.index+J[0].length);if(ie){var oe=Le.parentNode;oe.insertBefore(De.createTextNode(ie),Le.nextSibling)}Xe(Le),Z||Le.parentNode.removeChild(Le)}}}function Xe(Le){for(;!Le.nextSibling;)if(Le=Le.parentNode,!Le)return;function tt(J,Z){var ie=Z?J.cloneNode(!1):J,oe=J.parentNode;if(oe){var Q=tt(oe,1),re=J.nextSibling;Q.appendChild(ie);for(var se=re;se;se=re)re=se.nextSibling,Q.appendChild(se)}return ie}for(var qe=tt(Le.nextSibling,0),ae;(ae=qe.parentNode)&&ae.nodeType===1;)qe=ae;We.push(qe)}for(var Ge=0;Ge<We.length;++Ge)ze(We[Ge]);be===(be|0)&&We[0].setAttribute("value",be);var at=De.createElement("ol");at.className="linenums";for(var $e=Math.max(0,be-1|0)||0,Ge=0,Ve=We.length;Ge<Ve;++Ge)Me=We[Ge],Me.className="L"+(Ge+$e)%10,Me.firstChild||Me.appendChild(De.createTextNode("\xA0")),at.appendChild(Me);ue.appendChild(at)}function Ce(ue){var be=/\bMSIE\s(\d+)/.exec(navigator.userAgent);be=be&&+be[1]<=8;var we=/\n/g,Pe=ue.sourceCode,_e=Pe.length,De=0,Me=ue.spans,We=Me.length,ze=0,Xe=ue.decorations,Ge=Xe.length,at=0;Xe[Ge]=_e;var $e,Ve;for(Ve=$e=0;Ve<Ge;)Xe[Ve]!==Xe[Ve+2]?(Xe[$e++]=Xe[Ve++],Xe[$e++]=Xe[Ve++]):Ve+=2;for(Ge=$e,Ve=$e=0;Ve<Ge;){for(var Le=Xe[Ve],tt=Xe[Ve+1],qe=Ve+2;qe+2<=Ge&&Xe[qe+1]===tt;)qe+=2;Xe[$e++]=Le,Xe[$e++]=tt,Ve=qe}Ge=Xe.length=$e;var ae=ue.sourceNode,J="";ae&&(J=ae.style.display,ae.style.display="none");try{for(var Z=null;ze<We;){var ie=Me[ze],oe=Me[ze+2]||_e,Q=Xe[at+2]||_e,qe=Math.min(oe,Q),re=Me[ze+1],se;if(re.nodeType!==1&&(se=Pe.substring(De,qe))){be&&(se=se.replace(we,"\r")),re.nodeValue=se;var he=re.ownerDocument,pe=he.createElement("span");pe.className=Xe[at+1];var ye=re.parentNode;ye.replaceChild(pe,re),pe.appendChild(re),De<oe&&(Me[ze+1]=re=he.createTextNode(Pe.substring(qe,oe)),ye.insertBefore(re,pe.nextSibling))}De=qe,De>=oe&&(ze+=2),De>=Q&&(at+=2)}}finally{ae&&(ae.style.display=J)}}var Ae={};function ve(ue,be){for(var we=be.length;--we>=0;){var Pe=be[we];Ae.hasOwnProperty(Pe)?U.console&&console.warn("cannot override language handler %s",Pe):Ae[Pe]=ue}}function W(ue,be){return ue&&Ae.hasOwnProperty(ue)||(ue=/^\s*</.test(be)?"default-markup":"default-code"),Ae[ue]}ve(Te,["default-code"]),ve(xe([],[[a,/^[^<?]+/],[c,/^<!\w[^>]*(?:>|$)/],[E,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[u,/^(?:<[%?]|[%?]>)/],["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(xe([[a,/^[\s]+/,null,` \r
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[y,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[u,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),ve(xe([],[[G,/^[\s\S]+/]]),["uq.val"]),ve(Ie({keywords:g,hashComments:!0,cStyleComments:!0,types:m}),["c","cc","cpp","cxx","cyc","m"]),ve(Ie({keywords:"null,true,false"}),["json"]),ve(Ie({keywords:w,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:m}),["cs"]),ve(Ie({keywords:R,cStyleComments:!0}),["java"]),ve(Ie({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(Ie({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(Ie({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(Ie({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(Ie({keywords:x,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(Ie({keywords:b,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(xe([],[[p,/^[\s\S]+/]]),["regex"]);function L(ue){var be=ue.langExtension;try{var we=F(ue.sourceNode,ue.pre),Pe=we.sourceCode;ue.sourceCode=Pe,ue.spans=we.spans,ue.basePos=0,W(be,Pe)(ue),Ce(ue)}catch(_e){U.console&&console.log(_e&&_e.stack||_e)}}function k(ue,be,we){var Pe=we||!1,_e=be||null,De=document.createElement("div");De.innerHTML="<pre>"+ue+"</pre>",De=De.firstChild,Pe&&Oe(De,Pe,!0);var Me={langExtension:_e,numberLines:Pe,sourceNode:De,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return L(Me),De.innerHTML}function H(ue,be){var we=be||document.body,Pe=we.ownerDocument||document;function _e(ie){return we.getElementsByTagName(ie)}for(var De=[_e("pre"),_e("code"),_e("xmp")],Me=[],We=0;We<De.length;++We)for(var ze=0,Xe=De[We].length;ze<Xe;++ze)Me.push(De[We][ze]);De=null;var Ge=Date;Ge.now||(Ge={now:function(){return+new Date}});var at=0,$e=/\blang(?:uage)?-([\w.]+)(?!\S)/,Ve=/\bprettyprint\b/,Le=/\bprettyprinted\b/,tt=/pre|xmp/i,qe=/^code$/i,ae=/^(?:pre|code|xmp)$/i,J={};function Z(){for(var ie=U.PR_SHOULD_USE_CONTINUATION?Ge.now()+250:Infinity;at<Me.length&&Ge.now()<ie;at++){for(var oe=Me[at],Q=J,re=oe;re=re.previousSibling;){var se=re.nodeType,he=(se===7||se===8)&&re.nodeValue;if(he?!/^\??prettify\b/.test(he):se!==3||/\S/.test(re.nodeValue))break;if(he){Q={},he.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Nt,St,ar){Q[St]=ar});break}}var pe=oe.className;if((Q!==J||Ve.test(pe))&&!Le.test(pe)){for(var ye=!1,ke=oe.parentNode;ke;ke=ke.parentNode){var Ne=ke.tagName;if(ae.test(Ne)&&ke.className&&Ve.test(ke.className)){ye=!0;break}}if(!ye){oe.className+=" prettyprinted";var Ze=Q.lang;if(!Ze){Ze=pe.match($e);var Ke;!Ze&&(Ke=ge(oe))&&qe.test(Ke.tagName)&&(Ze=Ke.className.match($e)),Ze&&(Ze=Ze[1])}var lt;if(tt.test(oe.tagName))lt=1;else{var it=oe.currentStyle,Ye=Pe.defaultView,wt=it?it.whiteSpace:Ye&&Ye.getComputedStyle?Ye.getComputedStyle(oe,null).getPropertyValue("white-space"):0;lt=wt&&wt.substring(0,3)==="pre"}var dt=Q.linenums;(dt=dt==="true"||+dt)||(dt=pe.match(/\blinenums\b(?::(\d+))?/),dt=dt?dt[1]&&dt[1].length?+dt[1]:!0:!1),dt&&Oe(oe,dt,lt);var Ot={langExtension:Ze,sourceNode:oe,numberLines:dt,pre:lt,sourceCode:null,basePos:null,spans:null,decorations:null};L(Ot)}}}at<Me.length?U.setTimeout(Z,250):typeof ue=="function"&&ue()}Z()}var q=U.PR={createSimpleLexer:xe,registerLangHandler:ve,sourceDecorator:Ie,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:G,PR_COMMENT:E,PR_DECLARATION:c,PR_KEYWORD:A,PR_LITERAL:d,PR_NOCODE:X,PR_PLAIN:a,PR_PUNCTUATION:u,PR_SOURCE:S,PR_STRING:p,PR_TAG:y,PR_TYPE:f,prettyPrintOne:_?U.prettyPrintOne=k:D=k,prettyPrint:j=_?U.prettyPrint=H:j=H},B=U.define;typeof B=="function"&&B.amd&&B("google-code-prettify",[],function(){return q})})()},STEk:function(ct,rt,le){"use strict";le.d(rt,"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 fe=function(W,L){return(fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,H){k.__proto__=H}||function(k,H){for(var q in H)Object.prototype.hasOwnProperty.call(H,q)&&(k[q]=H[q])})(W,L)};function $(W,L){function k(){this.constructor=W}fe(W,L),W.prototype=L===null?Object.create(L):(k.prototype=L.prototype,new k)}function _(W,L,k,H){return new(k||(k=Promise))(function(q,B){function ue(Pe){try{we(H.next(Pe))}catch(_e){B(_e)}}function be(Pe){try{we(H.throw(Pe))}catch(_e){B(_e)}}function we(Pe){var _e;Pe.done?q(Pe.value):(_e=Pe.value,_e instanceof k?_e:new k(function(De){De(_e)})).then(ue,be)}we((H=H.apply(W,L||[])).next())})}function V(W,L){var k,H,q,B,ue={label:0,sent:function(){if(1&q[0])throw q[1];return q[1]},trys:[],ops:[]};return B={next:be(0),throw:be(1),return:be(2)},typeof Symbol=="function"&&(B[Symbol.iterator]=function(){return this}),B;function be(we){return function(Pe){return function(_e){if(k)throw new TypeError("Generator is already executing.");for(;ue;)try{if(k=1,H&&(q=2&_e[0]?H.return:_e[0]?H.throw||((q=H.return)&&q.call(H),0):H.next)&&!(q=q.call(H,_e[1])).done)return q;switch(H=0,q&&(_e=[2&_e[0],q.value]),_e[0]){case 0:case 1:q=_e;break;case 4:return ue.label++,{value:_e[1],done:!1};case 5:ue.label++,H=_e[1],_e=[0];continue;case 7:_e=ue.ops.pop(),ue.trys.pop();continue;default:if(!(q=ue.trys,(q=q.length>0&&q[q.length-1])||_e[0]!==6&&_e[0]!==2)){ue=0;continue}if(_e[0]===3&&(!q||_e[1]>q[0]&&_e[1]<q[3])){ue.label=_e[1];break}if(_e[0]===6&&ue.label<q[1]){ue.label=q[1],q=_e;break}if(q&&ue.label<q[2]){ue.label=q[2],ue.ops.push(_e);break}q[2]&&ue.ops.pop(),ue.trys.pop();continue}_e=L.call(W,ue)}catch(De){_e=[6,De],H=0}finally{k=q=0}if(5&_e[0])throw _e[1];return{value:_e[0]?_e[1]:void 0,done:!0}}([we,Pe])}}}function M(){for(var W=0,L=0,k=arguments.length;L<k;L++)W+=arguments[L].length;var H=Array(W),q=0;for(L=0;L<k;L++)for(var B=arguments[L],ue=0,be=B.length;ue<be;ue++,q++)H[q]=B[ue];return H}var D=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(L,k){for(var H=0,q=k;H<q.length;H++){var B=q[H],ue=B[0],be=B[1];L.setAttribute(ue,be)}},W.createRect=function(L,k,H){var q=document.createElementNS("http://www.w3.org/2000/svg","rect");return q.setAttribute("width",L.toString()),q.setAttribute("height",k.toString()),H&&W.setAttributes(q,H),q},W.createLine=function(L,k,H,q,B){var ue=document.createElementNS("http://www.w3.org/2000/svg","line");return ue.setAttribute("x1",L.toString()),ue.setAttribute("y1",k.toString()),ue.setAttribute("x2",H.toString()),ue.setAttribute("y2",q.toString()),B&&W.setAttributes(ue,B),ue},W.createPolygon=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","polygon");return H.setAttribute("points",L),k&&W.setAttributes(H,k),H},W.createCircle=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","circle");return H.setAttribute("cx",(L/2).toString()),H.setAttribute("cy",(L/2).toString()),H.setAttribute("r",L.toString()),k&&W.setAttributes(H,k),H},W.createEllipse=function(L,k,H){var q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return q.setAttribute("cx",(L/2).toString()),q.setAttribute("cy",(k/2).toString()),q.setAttribute("rx",(L/2).toString()),q.setAttribute("ry",(k/2).toString()),H&&W.setAttributes(q,H),q},W.createGroup=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","g");return L&&W.setAttributes(k,L),k},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(L,k,H,q,B,ue,be){var we=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(we,[["id",L],["orient",k],["markerWidth",H.toString()],["markerHeight",q.toString()],["refX",B.toString()],["refY",ue.toString()]]),we.appendChild(be),we},W.createText=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","text");return k.setAttribute("x","0"),k.setAttribute("y","0"),L&&W.setAttributes(k,L),k},W.createTSpan=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","tspan");return H.textContent=L,k&&W.setAttributes(H,k),H},W.createImage=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","image");return L&&W.setAttributes(k,L),k},W.createPoint=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return H.x=L,H.y=k,H},W.createPath=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","path");return H.setAttribute("d",L),k&&W.setAttributes(H,k),H},W}(),j=function(){function W(){}return W.addKey=function(L){W.key=L},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}(),U=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(L,k,H){var q=this;return new Promise(function(B){var ue=H!==void 0?H:document.createElement("canvas");L===null&&(q.markersOnly=!0,q.naturalSize=!1);var be=document.createElementNS("http://www.w3.org/2000/svg","svg");be.setAttribute("xmlns","http://www.w3.org/2000/svg"),be.setAttribute("width",k.width.baseVal.valueAsString),be.setAttribute("height",k.height.baseVal.valueAsString),be.setAttribute("viewBox","0 0 "+k.viewBox.baseVal.width.toString()+" "+k.viewBox.baseVal.height.toString()),be.innerHTML=k.innerHTML,q.naturalSize===!0?(be.width.baseVal.value=L.naturalWidth,be.height.baseVal.value=L.naturalHeight):q.width!==void 0&&q.height!==void 0&&(be.width.baseVal.value=q.width,be.height.baseVal.value=q.height),ue.width=be.width.baseVal.value,ue.height=be.height.baseVal.value;var we=be.outerHTML,Pe=ue.getContext("2d");q.markersOnly!==!0&&Pe.drawImage(L,0,0,ue.width,ue.height);var _e=window.URL,De=new Image(ue.width,ue.height);De.setAttribute("crossOrigin","anonymous");var Me=new Blob([we],{type:"image/svg+xml"}),We=_e.createObjectURL(Me);De.onload=function(){Pe.drawImage(De,0,0),_e.revokeObjectURL(We);var ze=ue.toDataURL(q.imageType,q.imageQuality);B(ze)},De.src=We})},W}(),I=function(){},O=function(){function W(L){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+L+"_"}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(L){return this.styleSheet===void 0&&this.addStyleSheet(),L.name=""+this.classNamePrefix+L.localName,this.classes.push(L),this.styleSheet.sheet.insertRule("."+L.name+" {"+L.style+"}",this.styleSheet.sheet.cssRules.length),L},W.prototype.addRule=function(L){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(L),this.styleSheet.sheet.insertRule(L.selector+" {"+L.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var L;this.styleSheet=document.createElement("style"),((L=this.styleSheetRoot)!==null&&L!==void 0?L:document.head).appendChild(this.styleSheet),this.addRule(new v("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new v("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new v("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new g("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new g("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},W.prototype.removeStyleSheet=function(){var L;this.styleSheet&&(((L=this.styleSheetRoot)!==null&&L!==void 0?L:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),v=function(W,L){this.selector=W,this.style=L},g=function(W,L){this.localName=W,this.style=L},R=function(){function W(L,k,H,q,B){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=L,this.displayMode=k,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(L){var k=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=L,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 ue=document.createElement("div");ue.className=""+k.toolbarButtonStyleClass.name,ue.setAttribute("data-type-name",B.typeName),ue.innerHTML=B.icon,ue.addEventListener("click",function(){k.markerToolbarButtonClicked(ue,B)}),k.buttons.push(ue),k.markerButtons.push(ue)}),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(L){this.buttonClickListeners.push(L)},W.prototype.removeButtonClickListener=function(L){this.buttonClickListeners.indexOf(L)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(L),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var L=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var k=0;k<this.markerButtons.length;k++)k<L||k===L&&this.markerButtons.length-1===L?this.markerButtonBlock.appendChild(this.markerButtons[k]):(k===L&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[k]))}},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 L=this;this.buttons.forEach(function(k){k.className=k.className.replace(L.uiStyleSettings.toolbarButtonStyleColorsClassName?L.uiStyleSettings.toolbarButtonStyleColorsClassName:L.toolbarButtonStyleColorsClass.name,"").trim(),k.className=k.className.replace(L.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?L.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:L.toolbarActiveButtonStyleColorsClass.name,"").trim(),k.className+=" "+(L.uiStyleSettings.toolbarButtonStyleColorsClassName?L.uiStyleSettings.toolbarButtonStyleColorsClassName:L.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(L,k,H){var q=this,B=document.createElement("div");switch(B.className=""+this.toolbarButtonStyleClass.name,B.innerHTML=k,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}L.appendChild(B),this.buttons.push(B)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new g("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 g("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new g("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new g("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 g("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var L=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new g("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*L)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*L)+`px;
padding: `+L+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new g("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new g("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new v("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new v("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},W.prototype.markerToolbarButtonClicked=function(L,k){this.setActiveButton(L),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("marker",k)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(L,k){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("action",k)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(L){this.resetButtonStyles(),L.className=L.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),L.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(L){var k=this.markerButtons.find(function(H){return H.getAttribute("data-type-name")===L});k&&this.setActiveButton(k)},W.prototype.setCurrentMarker=function(L){var k=this;this.currentMarker=L,this.buttons.filter(function(H){return/delete|notes/.test(H.getAttribute("data-action"))}).forEach(function(H){k.currentMarker===void 0?(H.style.fillOpacity="0.4",H.style.pointerEvents="none"):(H.style.fillOpacity="1",H.style.pointerEvents="all")})},W}(),w=function(){function W(L,k,H,q){this.panels=[],this.panelButtons=[],this.markerjsContainer=L,this.displayMode=k,this.uiStyleSettings=H,this.styles=q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var L;this.toolboxStyleClass=this.styles.addClass(new g("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 g("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var k=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new g("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new g("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new g("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 g("toolbox-panel-row_colors",`
background-color: `+((L=this.uiStyleSettings.toolboxBackgroundColor)!==null&&L!==void 0?L:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new g("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
padding: `+k+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new g("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new g("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new v("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new v("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},W.prototype.show=function(L){var k;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=L,this.uiContainer.className=this.toolboxStyleClass.name+" "+((k=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&k!==void 0?k:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(L){var k,H,q=this;this.panels=L,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((k=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&k!==void 0?k: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 ue;B.uiStyleSettings=q.uiStyleSettings;var be=document.createElement("div");be.className=q.toolboxButtonStyleClass.name+" "+((ue=q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ue!==void 0?ue:q.toolboxButtonStyleColorsClass.name),be.innerHTML=B.icon,be.title=B.title,be.addEventListener("click",function(){q.panelButtonClick(B)}),q.panelButtons.push(be),q.buttonRow.appendChild(be)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(L){var k=this,H=-1;if(L!==this.activePanel){H=this.panels.indexOf(L),this.panelRow.innerHTML="";var q=L.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=L}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){k.displayMode==="inline"?k.panelRow.style.display="none":k.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(B,ue){var be,we;B.className=k.toolboxButtonStyleClass.name+" "+(ue===H?""+((be=k.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&be!==void 0?be:k.toolboxActiveButtonStyleColorsClass.name):""+((we=k.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&we!==void 0?we:k.toolboxButtonStyleColorsClass.name))})},W}(),b=function(W,L){this.title=W,this.icon=L},x=function(W){function L(k,H,q,B){var ue=W.call(this,k,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 ue.colors=[],ue.addTransparent=!1,ue.colorBoxes=[],ue.colors=H,ue.currentColor=q,ue.setCurrentColor=ue.setCurrentColor.bind(ue),ue.getColorBox=ue.getColorBox.bind(ue),ue}return $(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.whiteSpace="nowrap",this.colors.forEach(function(q){var B=k.getColorBox(q);H.appendChild(B),k.colorBoxes.push(B)}),H},L.prototype.getColorBox=function(k){var H=this,q=this.uiStyleSettings.toolbarHeight/4,B=this.uiStyleSettings.toolbarHeight-q,ue=document.createElement("div");ue.style.display="inline-block",ue.style.boxSizing="content-box",ue.style.width=B-2+"px",ue.style.height=B-2+"px",ue.style.padding="1px",ue.style.marginRight="2px",ue.style.marginBottom="2px",ue.style.borderWidth="2px",ue.style.borderStyle="solid",ue.style.borderRadius=(B+2)/2+"px",ue.style.borderColor=k===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ue.addEventListener("click",function(){H.setCurrentColor(k,ue)});var be=document.createElement("div");return be.style.display="inline-block",be.style.width=B-2+"px",be.style.height=B-2+"px",be.style.backgroundColor=k,be.style.borderRadius=B/2+"px",k==="transparent"&&(be.style.fill=this.uiStyleSettings.toolboxAccentColor,be.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>`),ue.appendChild(be),ue},L.prototype.setCurrentColor=function(k,H){var q=this;this.currentColor=k,this.colorBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(k)},L}(b),l=function(){function W(L,k,H){this._state="new",this._isSelected=!1,this._container=L,this._overlayContainer=k,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(L){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(L,k){},W.prototype.dblClick=function(L,k){},W.prototype.manipulate=function(L){},W.prototype.pointerUp=function(L){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(L){this.container.childNodes.length>0?this.container.insertBefore(L,this.container.childNodes[0]):this.container.appendChild(L)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(L){this._state=L.state,this.notes=L.notes},W.prototype.scale=function(L,k){},W.prototype.colorChanged=function(L){this.onColorChanged&&this.onColorChanged(L),this.stateChanged()},W.prototype.fillColorChanged=function(L){this.onFillColorChanged&&this.onFillColorChanged(L),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var L=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),L.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(L)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),o=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(L){return this.topLeft.ownsTarget(L)?this.topLeft:this.topCenter.ownsTarget(L)?this.topCenter:this.topRight.ownsTarget(L)?this.topRight:this.centerLeft.ownsTarget(L)?this.centerLeft:this.centerRight.ownsTarget(L)?this.centerRight:this.bottomLeft.ownsTarget(L)?this.bottomLeft:this.bottomCenter.ownsTarget(L)?this.bottomCenter:this.bottomRight.ownsTarget(L)?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(L){return L===this.visual||L===this.visual.childNodes[0]||L===this.visual.childNodes[1]},W}(),h=function(){function W(){}return W.toITransformMatrix=function(L){return{a:L.a,b:L.b,c:L.c,d:L.d,e:L.e,f:L.f}},W.toSVGMatrix=function(L,k){return L.a=k.a,L.b=k.b,L.c=k.c,L.d=k.d,L.e=k.e,L.f=k.f,L},W}(),C=function(W){function L(k,H,q){var B=W.call(this,k,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 $(L,W),Object.defineProperty(L.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"visual",{get:function(){return this._visual},set:function(k){this._visual=k;var H=D.createTransform();this._visual.transform.baseVal.appendItem(H)},enumerable:!1,configurable:!0}),L.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!!(this.controlGrips.findGripByVisual(k)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(k))},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.left=k.x,this.top=k.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var q=this.unrotatePoint(k);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 ue=this.container.transform.baseVal.getItem(0);ue.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ue,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},L.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},L.prototype.moveVisual=function(k){this.visual.style.transform="translate("+k.x+"px, "+k.y+"px)"},L.prototype.manipulate=function(k){var H=this.unrotatePoint(k);this.state==="creating"?this.resize(k):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(k)},L.prototype.resize=function(k){var H=this.manipulationStartLeft,q=this.manipulationStartWidth,B=this.manipulationStartTop,ue=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:H=this.manipulationStartLeft+k.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+k.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:B=this.manipulationStartTop+k.y-this.manipulationStartY,ue=this.manipulationStartHeight+this.manipulationStartTop-B;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ue=this.manipulationStartHeight+k.y-this.manipulationStartY}q>=0?(this.left=H,this.width=q):(this.left=H+q,this.width=-q),ue>=0?(this.top=B,this.height=ue):(this.top=B+ue,this.height=-ue),this.setSize()},L.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},L.prototype.rotate=function(k){if(Math.abs(k.x-this.centerX)>.1){var H=Math.sign(k.x-this.centerX);this.rotationAngle=180*Math.atan((k.y-this.centerY)/(k.x-this.centerX))/Math.PI+90*H,this.applyRotation()}},L.prototype.applyRotation=function(){var k=this.container.transform.baseVal.getItem(0);k.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(k,0)},L.prototype.rotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM(),q=D.createPoint(k.x,k.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},L.prototype.unrotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM();H=H.inverse();var q=D.createPoint(k.x,k.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},L.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},L.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},L.prototype.setupControlBox=function(){this.controlBox=D.createGroup();var k=D.createTransform();k.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(k),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"},L.prototype.adjustControlBox=function(){var k=this.controlBox.transform.baseVal.getItem(0);k.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(k,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()},L.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()},L.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(k.visual),k},L.prototype.positionGrips=function(){var k=this.controlGrips.topLeft.GRIP_SIZE,H=-k/2,q=H,B=(this.width+this.CB_DISTANCE)/2-k/2,ue=(this.height+this.CB_DISTANCE)/2-k/2,be=this.height+this.CB_DISTANCE-k/2,we=this.width+this.CB_DISTANCE-k/2;this.positionGrip(this.controlGrips.topLeft.visual,H,q),this.positionGrip(this.controlGrips.topCenter.visual,B,q),this.positionGrip(this.controlGrips.topRight.visual,we,q),this.positionGrip(this.controlGrips.centerLeft.visual,H,ue),this.positionGrip(this.controlGrips.centerRight.visual,we,ue),this.positionGrip(this.controlGrips.bottomLeft.visual,H,be),this.positionGrip(this.controlGrips.bottomCenter.visual,B,be),this.positionGrip(this.controlGrips.bottomRight.visual,we,be),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,B,q-3*this.CB_DISTANCE)},L.prototype.positionGrip=function(k,H,q){var B=k.transform.baseVal.getItem(0);B.setTranslate(H,q),k.transform.baseVal.replaceItem(B,0)},L.prototype.hideControlBox=function(){this.controlBox.style.display="none"},L.prototype.showControlBox=function(){this.controlBox.style.display=""},L.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:h.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:h.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;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(h.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,H.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(h.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,H.containerTransformMatrix))},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H);var q=this.rotatePoint({x:this.left,y:this.top}),B=this.unrotatePoint({x:q.x*k,y:q.y*H});this.left=B.x,this.top=B.y,this.width=this.width*k,this.height=this.height*H,this.adjustControlBox()},L}(l),m=function(W){function L(k,H,q){var B=W.call(this,k,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 $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},L.prototype.setSize=function(){W.prototype.setSize.call(this),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},L.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},L.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},L.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))},L.prototype.restoreState=function(k){var H=k;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,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},L.title="Rectangle marker",L}(C),p=function(W){function L(k,H,q,B){var ue=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ue.widths=[],ue.widthBoxes=[],ue.widths=H,ue.currentWidth=q,ue.setCurrentWidth=ue.setCurrentWidth.bind(ue),ue}return $(L,W),L.prototype.getUi=function(){var k=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===k.currentWidth?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentWidth(q,B)}),H.appendChild(B);var ue=document.createElement("div");ue.innerText=q.toString(),ue.style.marginRight="5px",B.appendChild(ue);var be=document.createElement("div");be.style.minHeight="20px",be.style.flexGrow="2",be.style.display="flex",be.style.alignItems="center";var we=document.createElement("hr");we.style.minWidth="20px",we.style.border="0px",we.style.borderTop=q+"px solid "+k.uiStyleSettings.toolboxColor,we.style.flexGrow="2",be.appendChild(we),B.appendChild(be),k.widthBoxes.push(B)}),H},L.prototype.setCurrentWidth=function(k,H){var q=this;this.currentWidth=k,this.widthBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},L}(b),A=function(W){function L(k,H,q,B){var ue=W.call(this,k,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 ue.styles=[],ue.styleBoxes=[],ue.styles=H,ue.currentStyle=q,ue.setCurrentStyle=ue.setCurrentStyle.bind(ue),ue}return $(L,W),L.prototype.getUi=function(){var k=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/k.styles.length-5+"%",B.style.borderColor=q===k.currentStyle?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentStyle(q,B)}),H.appendChild(B);var ue=document.createElement("div");ue.style.minHeight="20px",ue.style.flexGrow="2",ue.style.overflow="hidden";var be=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+k.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(q!==""?'stroke-dasharray="'+q+'"':"")+` />
</svg>`;ue.innerHTML=be,B.appendChild(ue),k.styleBoxes.push(B)}),H},L.prototype.setCurrentStyle=function(k,H){var q=this;this.currentStyle=k,this.styleBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},L}(b),E=function(W){function L(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new x("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new p("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new A("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return $(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="FrameMarker",L.title="Frame marker",L.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',L}(m),f=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},d=function(W){function L(k,H,q){var B=W.call(this,k,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 $(L,W),L.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!(!this.grip1.ownsTarget(k)&&!this.grip2.ownsTarget(k))},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartX=k.x,this.manipulationStartY=k.y,this.state==="new"&&(this.x1=k.x,this.y1=k.y,this.x2=k.x,this.y2=k.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")},L.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),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(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},L.prototype.adjustVisual=function(){},L.prototype.manipulate=function(k){this.state==="creating"?this.resize(k):this.state==="move"?(this.x1=this.manipulationStartX1+k.x-this.manipulationStartX,this.y1=this.manipulationStartY1+k.y-this.manipulationStartY,this.x2=this.manipulationStartX2+k.x-this.manipulationStartX,this.y2=this.manipulationStartY2+k.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(k)},L.prototype.resize=function(k){switch(this.activeGrip){case this.grip1:this.x1=k.x,this.y1=k.y;break;case this.grip2:case void 0:this.x2=k.x,this.y2=k.y}this.adjustVisual(),this.adjustControlBox()},L.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},L.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},L.prototype.setupControlBox=function(){this.controlBox=D.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},L.prototype.adjustControlBox=function(){this.positionGrips()},L.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},L.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(k.visual),k},L.prototype.positionGrips=function(){var k=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-k/2,this.y1-k/2),this.positionGrip(this.grip2.visual,this.x2-k/2,this.y2-k/2)},L.prototype.positionGrip=function(k,H,q){var B=k.transform.baseVal.getItem(0);B.setTranslate(H,q),k.transform.baseVal.replaceItem(B,0)},L.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.x1=H.x1,this.y1=H.y1,this.x2=H.x2,this.y2=H.y2},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.x1=this.x1*k,this.y1=this.y1*H,this.x2=this.x2*k,this.y2=this.y2*H,this.adjustVisual(),this.adjustControlBox()},L}(l),u=function(W){function L(k,H,q){var B=W.call(this,k,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 x("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new p("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new A("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorLine&&k!==this.visibleLine)},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},L.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()]]))},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.createVisual(),this.adjustVisual()},L.typeName="LineMarker",L.title="Line marker",L.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',L}(d),a=function(W){function L(k,H,q,B){var ue=W.call(this,k,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 ue.fonts=[],ue.fontBoxes=[],ue.fonts=H,ue.currentFont=q,ue.setCurrentFont=ue.setCurrentFont.bind(ue),ue}return $(L,W),L.prototype.getUi=function(){var k=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/k.fonts.length-5+"%",B.style.borderColor=q===k.currentFont?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentFont(q,B)}),H.appendChild(B);var ue=document.createElement("div");ue.style.display="flex",ue.style.minHeight="20px",ue.style.flexGrow="2",ue.style.fontFamily=q,ue.style.overflow="hidden";var be=document.createElement("div");be.style.whiteSpace="nowrap",be.style.overflow="hidden",be.style.textOverflow="ellipsis",be.innerHTML="The quick brown fox jumps over the lazy dog",ue.appendChild(be),B.appendChild(ue),k.fontBoxes.push(B)}),H},L.prototype.setCurrentFont=function(k,H){var q=this;this.currentFont=k,this.fontBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},L}(b),y=function(W){function L(k,H,q){var B=W.call(this,k,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 x("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 $(L,W),L.prototype.ownsTarget=function(k){if(W.prototype.ownsTarget.call(this,k)||k===this.visual||k===this.textElement||k===this.bgRectangle)return!0;var H=!1;return this.textElement.childNodes.forEach(function(q){q===k&&(H=!0)}),H},L.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()},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.isMoved=!1,this.pointerDownPoint=k,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.renderText=function(){var k=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){k.textElement.appendChild(D.createTSpan(H.trim()===""?" ":H.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},L.prototype.getTextScale=function(){var k=this.textElement.getBBox(),H=1;if(k.width>0&&k.height>0){var q=(1*this.width-this.width*this.padding*2/100)/k.width,B=(1*this.height-this.height*this.padding*2/100)/k.height;H=Math.min(q,B)}return H},L.prototype.getTextPosition=function(k){var H=this.textElement.getBBox(),q=0,B=0;return H.width>0&&H.height>0&&(q=(this.width-H.width*k)/2,B=this.height/2-H.height*k/2),{x:q,y:B}},L.prototype.sizeText=function(){var k=this.textElement.getBBox(),H=this.getTextScale(),q=this.getTextPosition(H);q.y-=k.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))},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(k.x-this.pointerDownPoint.x)>5||Math.abs(k.y-this.pointerDownPoint.y)>5)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.isMoved=!0,this.setSize(),this.sizeText()},L.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()]]))},L.prototype.pointerUp=function(k){var H=this.state;H==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,k),this.setSize(),(H==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},L.prototype.showTextEditor=function(){var k=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(k.textEditor.style.fontSize);k.textEditor.clientWidth>=Number.parseInt(k.textEditor.style.maxWidth)&&H>.9;)H-=.1,k.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(){k.textEditDivClicked(k.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},L.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var k=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*k,y:q.height*k};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*k,12)+"px",this.textElement.style.display="none"}},L.prototype.textEditDivClicked=function(k){this.text=k.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},L.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},L.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},L.prototype.dblClick=function(k,H){W.prototype.dblClick.call(this,k,H),this.showTextEditor()},L.prototype.setColor=function(k){this.textElement&&D.setAttributes(this.textElement,[["fill",k]]),this.color=k,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(k)},L.prototype.setFont=function(k){this.textElement&&D.setAttributes(this.textElement,[["font-family",k]]),this.fontFamily=k,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},L.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},L.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;this.color=H.color,this.fontFamily=H.fontFamily,this.padding=H.padding,this.text=H.text,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize(),this.sizeText(),this.positionTextEditor()},L.typeName="TextMarker",L.title="Text marker",L.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>',L}(C),c=function(W){function L(k,H,q){var B=W.call(this,k,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 x("Color",q.defaultColorSet,q.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.lineWidthPanel=new p("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.lineWidthPanel.onWidthChanged=B.setLineWidth,B}return $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.drawingImage)},L.prototype.createVisual=function(){this.visual=D.createGroup(),this.drawingImage=D.createImage(),this.visual.appendChild(this.drawingImage);var k=D.createTransform();this.visual.transform.baseVal.appendItem(k),this.addMarkerVisualToContainer(this.visual)},L.prototype.pointerDown=function(k,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(k.x,k.y),this.drawing=!0):W.prototype.pointerDown.call(this,k,H)},L.prototype.manipulate=function(k){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(k.x,k.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},L.prototype.pointerUp=function(k){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,k)},L.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)},L.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},L.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},L.prototype.finishCreation=function(){for(var k=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],ue=H[2],be=H[3],we=!1,Pe=0;Pe<this.canvasElement.height;Pe++)for(var _e=0;_e<this.canvasElement.width;_e++)k.data[Pe*this.canvasElement.width*4+4*_e+3]>0&&(we=!0,Pe<B&&(B=Pe),_e<q&&(q=_e),Pe>be&&(be=Pe),_e>ue&&(ue=_e));if(we){this.left=q/this.pixelRatio,this.top=B/this.pixelRatio,this.width=(ue-q)/this.pixelRatio,this.height=(be-B)/this.pixelRatio;var De=document.createElement("canvas");De.width=ue-q,De.height=be-B,De.getContext("2d").putImageData(this.canvasContext.getImageData(q,B,ue-q,be-B),0,0),this.drawingImgUrl=De.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},L.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})},L.prototype.setColor=function(k){this.color=k,this.colorChanged(k)},L.prototype.setLineWidth=function(k){this.lineWidth=k},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){this.createVisual(),W.prototype.restoreState.call(this,k),this.drawingImgUrl=k.drawingImgUrl,this.setDrawingImage()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setDrawingImage()},L.typeName="FreehandMarker",L.title="Freehand marker",L.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>',L}(C),S=function(W){function L(k,H,q){var B=W.call(this,k,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 $(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2";for(var q=function(be){var we="both";switch(be){case 0:we="both";break;case 1:we="start";break;case 2:we="end";break;case 3:we="none"}var Pe=document.createElement("div");if(Pe.style.display="flex",Pe.style.flexGrow="2",Pe.style.alignItems="center",Pe.style.justifyContent="space-between",Pe.style.padding="5px",Pe.style.borderWidth="2px",Pe.style.borderStyle="solid",Pe.style.borderColor=we===B.currentType?B.uiStyleSettings.toolboxAccentColor:"transparent",Pe.addEventListener("click",function(){k.setCurrentType(we,Pe)}),H.appendChild(Pe),we==="both"||we==="start"){var _e=document.createElement("div");_e.style.display="flex",_e.style.alignItems="center",_e.style.minHeight="20px",_e.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>`,_e.style.marginLeft="5px",Pe.appendChild(_e)}var De=document.createElement("div");De.style.display="flex",De.style.alignItems="center",De.style.minHeight="20px",De.style.flexGrow="2";var Me=document.createElement("hr");if(Me.style.minWidth="20px",Me.style.border="0px",Me.style.borderTop="3px solid "+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee"),Me.style.flexGrow="2",De.appendChild(Me),Pe.appendChild(De),we==="both"||we==="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",Pe.appendChild(We)}B.typeBoxes.push(Pe)},B=this,ue=0;ue<4;ue++)q(ue);return H},L.prototype.setCurrentType=function(k,H){var q=this;this.currentType=k,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)},L}(b),P=function(W){function L(k,H,q){var B=W.call(this,k,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 S("Arrow type","end"),B.arrowTypePanel.onArrowTypeChanged=B.setArrowType,B}return $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.arrow1&&k!==this.arrow2)},L.prototype.getArrowPoints=function(k,H){var q=this.arrowBaseWidth+2*this.strokeWidth,B=this.arrowBaseHeight+2*this.strokeWidth;return k-q/2+","+(H+B/2)+" "+k+","+(H-B/2)+" "+(k+q/2)+","+(H+B/2)},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},L.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 k=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(k,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(H,0);var q=this.arrow2.transform.baseVal.getItem(0);q.setRotate(k+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(q,0)}},L.prototype.setArrowType=function(k){this.arrowType=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.arrowType=H.arrowType,this.createTips(),this.adjustVisual()},L.typeName="ArrowMarker",L.title="Arrow marker",L.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',L}(u),G=function(W){function L(k,H,q){var B=W.call(this,k,H,q)||this;return B.fillColor=q.defaultFillColor,B.strokeWidth=0,B.fillPanel=new x("Color",q.defaultColorSet,q.defaultFillColor),B.fillPanel.onColorChanged=B.setFillColor,B}return $(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="CoverMarker",L.title="Cover marker",L.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',L}(m),X=function(W){function L(k,H,q,B){var ue=W.call(this,k,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 ue.opacities=[],ue.opacityBoxes=[],ue.opacities=H,ue.currentOpacity=q,ue.setCurrentOpacity=ue.setCurrentOpacity.bind(ue),ue}return $(L,W),L.prototype.getUi=function(){var k=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===k.currentOpacity?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentOpacity(q,B)}),H.appendChild(B);var ue=document.createElement("div");ue.innerText=100*q+"%",B.appendChild(ue),k.opacityBoxes.push(B)}),H},L.prototype.setCurrentOpacity=function(k,H){var q=this;this.currentOpacity=k,this.opacityBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},L}(b),te=function(W){function L(k,H,q){var B=W.call(this,k,H,q)||this;return B.setOpacity=B.setOpacity.bind(B),B.fillColor=q.defaultHighlightColor,B.strokeWidth=0,B.opacity=q.defaultHighlightOpacity,B.fillPanel=new x("Color",q.defaultColorSet,B.fillColor),B.fillPanel.onColorChanged=B.setFillColor,B.opacityPanel=new X("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return $(L,W),L.prototype.setOpacity=function(k){this.opacity=k,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="HighlightMarker",L.title="Highlight marker",L.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>',L}(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>',F=function(W){function L(k,H,q){var B=W.call(this,k,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 x("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 x("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 $(L,W),L.prototype.ownsTarget=function(k){return W.prototype.ownsTarget.call(this,k)||this.tipGrip.ownsTarget(k)||this.tip===k},L.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)},L.prototype.pointerDown=function(k,H){this.state==="new"&&W.prototype.pointerDown.call(this,k,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,k,H)},L.prototype.pointerUp=function(k){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,k);else{var H=this.state==="creating";W.prototype.pointerUp.call(this,k),this.setTipPoints(H),this.positionTip()}},L.prototype.manipulate=function(k){if(this.tipMoving){var H=this.unrotatePoint(k);this.tipPosition={x:H.x-this.manipulationStartLeft,y:H.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,k)},L.prototype.setBgColor=function(k){this.bgRectangle&&this.tip&&(D.setAttributes(this.bgRectangle,[["fill",k]]),D.setAttributes(this.tip,[["fill",k]])),this.bgColor=k,this.fillColorChanged(k)},L.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},L.prototype.setTipPoints=function(k){k===void 0&&(k=!1);var H=Math.min(this.height/2,15),q=this.height/5;k&&(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})},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.positionTip()},L.prototype.positionTip=function(){D.setAttributes(this.tip,[["points",this.getTipPoints()]]);var k=this.tipGrip.visual.transform.baseVal.getItem(0);k.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(k,0)},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),L.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},L.prototype.getState=function(){var k=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;this.bgColor=H.bgColor,this.tipPosition=H.tipPosition,W.prototype.restoreState.call(this,k),this.createTip(),this.setTipPoints()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.tipPosition={x:this.tipPosition.x*k,y:this.tipPosition.y*H},this.positionTip()},L.typeName="CalloutMarker",L.title="Callout marker",L.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>',L}(y),ne=function(W){function L(k,H,q){var B=W.call(this,k,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 x("Line color",M(q.defaultColorSet,["transparent"]),q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.fillPanel=new x("Fill color",M(q.defaultColorSet,["transparent"]),B.fillColor,z),B.fillPanel.onColorChanged=B.setFillColor,B.strokeWidthPanel=new p("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new A("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B.opacityPanel=new X("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},L.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()]])},L.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},L.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(k),this.stateChanged()},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},L.prototype.setOpacity=function(k){this.opacity=k,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;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,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},L.typeName="EllipseMarker",L.title="Ellipse marker",L.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>',L}(C),ce=function(W){function L(k,H,q){return W.call(this,k,H,q)||this}return $(L,W),Object.defineProperty(L.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.tip1&&k!==this.tip2)},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},L.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 k=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(k,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(H,0);var q=this.tip2.transform.baseVal.getItem(0);q.setRotate(k+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(q,0)}},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k),this.createTips(),this.adjustVisual()},L.typeName="MeasurementMarker",L.title="Measurement marker",L.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>',L}(u),ge=function(W){function L(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokePanel.colors=q.defaultColorSet,B.fillColor="transparent",B}return $(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="EllipseFrameMarker",L.title="Ellipse frame marker",L.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>',L}(ne),xe=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(L){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(L)||(this.undoStack.push(L),JSON.stringify(this.lastRedoStep)!==JSON.stringify(L)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(L){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=L)},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 L=this.undoStack.pop();return L!==void 0&&this.redoStack.push(L),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}(),Ie=function(W){function L(k,H,q){var B=W.call(this,k,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 x("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new p("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new A("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return $(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorCurve&&k!==this.visibleCurve&&!this.curveGrip.ownsTarget(k))},L.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},L.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=k.x,this.curveY=k.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(H)&&(this.activeGrip=this.curveGrip,this._state="resize")},L.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()]]))},L.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)},L.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},L.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var k=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-k/2,this.curveY-k/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()))},L.prototype.manipulate=function(k){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+k.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+k.y-this.manipulationStartY),W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){this.activeGrip===this.curveGrip&&(this.curveX=k.x,this.curveY=k.y),W.prototype.resize.call(this,k),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual()},L.prototype.scale=function(k,H){this.curveX=this.curveX*k,this.curveY=this.curveY*H,W.prototype.scale.call(this,k,H)},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.curveX=H.curveX,this.curveY=H.curveY,this.createVisual(),this.adjustVisual()},L.typeName="CurveMarker",L.title="Curve marker",L.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>',L}(d),Te=function(){function W(L,k){k===void 0&&(k=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=L,this.cancelable=k}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),Oe=function(W){function L(k,H,q){var B=W.call(this,k,!1)||this;return B.dataUrl=H,B.state=q,B}return $(L,W),L}(Te),Ce=function(W){function L(k,H,q){q===void 0&&(q=!1);var B=W.call(this,k,q)||this;return B.marker=H,B}return $(L,W),L}(Te),Ae=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(L,k){this[L].push(k)},W.prototype.removeEventListener=function(L,k){var H=this[L].indexOf(k);H>-1&&this[L].splice(H,1)},W}(),ve=function(){function W(L){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new f,this._isOpen=!1,this.undoRedoManager=new xe,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 Ae,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new O(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=L,this.targetRoot=document.body,this.width=L.clientWidth,this.height=L.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[E,c,P,y,ge,ne,te,F,ce,G,u,Ie]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[E,c,P,y,ne,te,F]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[E,c,P,y,te]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(L){var k=this;this._availableMarkerTypes.splice(0),L.forEach(function(H){if(typeof H=="string"){var q=k.ALL_MARKER_TYPES.find(function(B){return B.typeName===H});q!==void 0&&k._availableMarkerTypes.push(q)}else k._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(L){this._zoomLevel=L,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 L=this;this.styles.styleSheetRoot===void 0&&I.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=I.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(k){return k(new Te(L))})},W.prototype.render=function(){return _(this,void 0,void 0,function(){var L;return V(this,function(k){switch(k.label){case 0:return this.setCurrentMarker(),(L=new U).naturalSize=this.renderAtNaturalSize,L.imageType=this.renderImageType,L.imageQuality=this.renderImageQuality,L.markersOnly=this.renderMarkersOnly,L.width=this.renderWidth,L.height=this.renderHeight,[4,L.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return k.sent(),[4,L.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,k.sent()]}})})},W.prototype.close=function(L){var k=this;if(L===void 0&&(L=!1),this.isOpen){var H=!1;L||this.eventListeners.beforeclose.forEach(function(q){var B=new Te(k,!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(k))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var L,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];(L=this._availableMarkerTypes).push.apply(L,k)},W.prototype.addRenderEventListener=function(L){this.addEventListener("render",function(k){L(k.dataUrl,k.state)})},W.prototype.removeRenderEventListener=function(L){},W.prototype.addCloseEventListener=function(L){this.addEventListener("close",function(){L()})},W.prototype.removeCloseEventListener=function(L){},W.prototype.setupResizeObserver=function(){var L=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){L.resize(L.target.clientWidth,L.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return L.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var L=1*this.target.clientWidth/this.target.clientHeight,k=this.editorCanvas.clientWidth/L>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*L:this.editorCanvas.clientWidth,H=k<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/L;this.resize(k,H)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(L,k){this._isResizing=!0;var H=L/this.imageWidth,q=k/this.imageHeight;this.imageWidth=Math.round(L),this.imageHeight=Math.round(k),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(L,k){var H,q=this;this._currentMarker&&this._currentMarker instanceof y?this._currentMarker.scale(L,k):(H=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(B){B!==q._currentMarker&&B.scale(L,k)}),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 L=this.editingTarget.getBoundingClientRect(),k=this.editorCanvas.getBoundingClientRect();this.left=L.left-k.left,this.top=L.top-k.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 L,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];this.defs=D.createDefs(),this.addDefsToImage(),(L=this.defs).append.apply(L,k)},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 L=document.createElement("a");L.href="https://markerjs.com/",L.target="_blank",L.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>',L.title="Powered by marker.js",L.style.display="grid",L.style.alignItems="center",L.style.justifyItems="center",L.style.padding="3px",L.style.width="20px",L.style.height="20px",this.logoUI.appendChild(L),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 L=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=L+"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 w(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(L){this.markerImage.removeChild(L.container),this.markers.indexOf(L)>-1&&this.markers.splice(this.markers.indexOf(L),1),L.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(L,k){if(L==="marker"&&k!==void 0)this.createNewMarker(k);else if(L==="action")switch(k){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 L=this;if(this._currentMarker!==void 0){var k=!1;if(this.eventListeners.markerbeforedelete.forEach(function(q){var B=new Ce(L,L._currentMarker,!0);q(B),B.defaultPrevented&&(k=!0)}),!k){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(L,H))})}}},W.prototype.clear=function(){var L=this,k=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ue){var be=new Ce(L,void 0,!0);ue(be),be.defaultPrevented&&(k=!0)}),!k)){this.setCurrentMarker();for(var H=function(ue){var be=q.markers[ue];q.setCurrentMarker(q.markers[ue]),q._currentMarker.dispose(),q.markerImage.removeChild(q._currentMarker.container),q.markers.splice(q.markers.indexOf(q._currentMarker),1),q.eventListeners.markerdelete.forEach(function(we){return we(new Ce(L,be))})},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 L;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=(L=this._currentMarker.notes)!==null&&L!==void 0?L:"",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 L=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var k=this.getState(),H=this.undoRedoManager.getLastUndoStep();if(!H||H.width===k.width&&H.height===k.height){var q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(k),q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(B){return B(new Te(L))})}else this.undoRedoManager.replaceLastUndoStep(k),this.eventListeners.statechange.forEach(function(B){return B(new Te(L))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var L=this,k=this.undoRedoManager.undo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(L))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var L=this,k=this.undoRedoManager.redo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(L))}))},W.prototype.stepZoom=function(){var L=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=L<this.zoomSteps.length-1?this.zoomSteps[L+1]:this.zoomSteps[0]},W.prototype.panTo=function(L){this.contentDiv.scrollBy({left:this.prevPanPoint.x-L.x,top:this.prevPanPoint.y-L.y}),this.prevPanPoint=L},W.prototype.startRenderAndClose=function(){return _(this,void 0,void 0,function(){var L,k,H=this;return V(this,function(q){switch(q.label){case 0:return[4,this.render()];case 1:return L=q.sent(),k=this.getState(),this.eventListeners.render.forEach(function(B){return B(new Oe(H,L,k))}),this.close(!0),[2]}})})},W.prototype.getState=function(L){L===!0&&this.setCurrentMarker();var k={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(H){return k.markers.push(H.getState())}),k},W.prototype.restoreState=function(L){var k=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);L.markers.forEach(function(H){var q=k._availableMarkerTypes.find(function(ue){return ue.typeName===H.typeName});if(q!==void 0){var B=k.addNewMarker(q);B.restoreState(H),k.markers.push(B)}}),L.width&&L.height&&(L.width!==this.imageWidth||L.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/L.width,this.imageHeight/L.height),this.eventListeners.restorestate.forEach(function(H){return H(new Te(k))})},W.prototype.addNewMarker=function(L){var k=D.createGroup();return this.markerImage.appendChild(k),new L(k,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(L){var k,H=this;(k=typeof L=="string"?this._availableMarkerTypes.find(function(q){return q.typeName===L}):L)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(k),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(k.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(q){return q(new Ce(H,H._currentMarker))}))},W.prototype.markerCreated=function(L){var k=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(L),this.setCurrentMarker(L),L instanceof c&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(c):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(H){return H(new Ce(k,k._currentMarker))})},W.prototype.colorChanged=function(L){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=L,this.settings.defaultStrokeColor=L)},W.prototype.fillColorChanged=function(L){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=L)},W.prototype.markerStateChanged=function(L){var k=this;this.eventListeners.markerchange.forEach(function(H){return H(new Ce(k,L))})},W.prototype.setCurrentMarker=function(L){var k=this;this._currentMarker!==L&&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(k,k._currentMarker))})),this._currentMarker=L,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(k,k._currentMarker))}))},W.prototype.onPointerDown=function(L){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||L.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(L.target)});k!==void 0?(this.setCurrentMarker(k),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(L.clientX,L.clientY),L.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:L.clientX,y:L.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(L.clientX,L.clientY))},W.prototype.onDblClick=function(L){if(this._isFocused||this.focus(),this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(L.target)});k!==void 0&&k!==this._currentMarker&&this.setCurrentMarker(k),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(L.clientX,L.clientY),L.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(L){this.touchPoints!==1&&L.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||L.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(L.clientX,L.clientY)):this.zoomLevel>1&&this.panTo({x:L.clientX,y:L.clientY}))},W.prototype.onPointerUp=function(L){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(L.clientX,L.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(L){this._currentMarker===void 0||this.notesArea!==void 0||L.key!=="Delete"&&L.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(L,k){var H=this.markerImage.getBoundingClientRect();return{x:(L-H.left)/this.zoomLevel,y:(k-H.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var L=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=L+"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(L){j.addKey(L)},W.prototype.addEventListener=function(L,k){this.eventListeners.addEventListener(L,k)},W.prototype.removeEventListener=function(L,k){this.eventListeners.removeEventListener(L,k)},W.prototype.renderState=function(L){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(L),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var L=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(k){return k(new Te(L))}))},W.prototype.blur=function(){var L=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(k){return k(new Te(L))}))},W.instanceCounter=0,W}()},SbmS:function(ct,rt,le){ct.exports={flex_box_center:"flex_box_center___HG_ui",flex_space_between:"flex_space_between___i7dgQ",flex_box_vertical_center:"flex_box_vertical_center___25J9O",flex_box_center_end:"flex_box_center_end___Q7-xc",flex_box_column:"flex_box_column___2Q6GJ",userInfo:"userInfo___2ECUY",navInfo:"navInfo___3H3dt",actived:"actived___ilDpa",topBar:"topBar___2O4NK",tabs:"tabs___yp4Rb",active:"active___3Xgtk",list:"list___U4GMG",tags:"tags___2IWIk",searchWrp:"searchWrp___1-W5t",listMessage:"listMessage___1M4jE",deleteMsg:"deleteMsg___1HDtB",listRightMessage:"listRightMessage___1rCRK",content:"content___KsZrb",msg:"msg___35IM3",msgDate:"msgDate___ovoCe"}},UZu5:function(ct,rt,le){},"VrN/":function(ct,rt,le){(function(fe,$){ct.exports=$()})(this,function(){"use strict";var fe=navigator.userAgent,$=navigator.platform,_=/gecko\/\d/i.test(fe),V=/MSIE \d/.test(fe),M=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fe),D=/Edge\/(\d+)/.exec(fe),j=V||M||D,U=j&&(V?document.documentMode||6:+(D||M)[1]),I=!D&&/WebKit\//.test(fe),O=I&&/Qt\/\d+\.\d+/.test(fe),v=!D&&/Chrome\//.test(fe),g=/Opera\//.test(fe),R=/Apple Computer/.test(navigator.vendor),w=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(fe),b=/PhantomJS/.test(fe),x=!D&&/AppleWebKit/.test(fe)&&/Mobile\/\w+/.test(fe),l=/Android/.test(fe),o=x||l||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(fe),s=x||/Mac/.test($),h=/\bCrOS\b/.test(fe),C=/win/i.test($),m=g&&fe.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&m>=15&&(g=!1,I=!0);var p=s&&(O||g&&(m==null||m<12.11)),A=_||j&&U>=9;function E(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var i=e.className,r=E(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 d(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function u(e,t){return d(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var T=0;T<t.length;++T)n.appendChild(t[T]);return n}function y(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var c;document.createRange?c=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:c=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 S(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function P(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;E(t).test(i)||(e.className+=(i?" ":"")+t)}function X(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!E(i[r]).test(t)&&(t+=" "+i[r]);return t}var te=function(e){e.select()};x?te=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:j&&(te=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 F(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 T=r||0,N=n||0;;){var K=e.indexOf(" ",T);if(K<0||K>=t)return N+(t-T);N+=K-T,N+=i-N%i,T=K+1}}var ce=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ce.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ce.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 xe=50,Ie={toString:function(){return"CodeMirror.Pass"}},Te={scroll:!1},Oe={origin:"*mouse"},Ce={origin:"+move"};function Ae(e,t,i){for(var r=0,n=0;;){var T=e.indexOf(" ",r);T==-1&&(T=e.length);var N=T-r;if(T==e.length||n+N>=t)return r+Math.min(N,t-n);if(n+=T-r,n+=i-n%i,r=T+1,n>=t)return r}}var ve=[""];function W(e){for(;ve.length<=e;)ve.push(L(ve)+" ");return ve[e]}function L(e){return e[e.length-1]}function k(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&&F(t,i),i}var ue=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function be(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||ue.test(e))}function we(e,t){return t?t.source.indexOf("\\w")>-1&&be(e)?!0:t.test(e):be(e)}function Pe(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var _e=/[\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 De(e){return e.charCodeAt(0)>=768&&_e.test(e)}function Me(e,t,i){for(;(i<0?t>0:t<e.length)&&De(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,T=r<0?Math.ceil(n):Math.floor(n);if(T==t)return e(T)?t:i;e(T)?i=T:t=T+r}}function ze(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,T=0;T<e.length;++T){var N=e[T];(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",T),n=!0)}n||r(t,i,"ltr")}var Xe=null;function Ge(e,t,i){var r;Xe=null;for(var n=0;n<e.length;++n){var T=e[n];if(T.from<t&&T.to>t)return n;T.to==t&&(T.from!=T.to&&i=="before"?r=n:Xe=n),T.from==t&&(T.from!=T.to&&i!="before"?r=n:Xe=n)}return r!=null?r:Xe}var at=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]/,T=/[LRr]/,N=/[Lb1n]/,K=/[1n]/;function Y(ee,de,me){this.level=ee,this.from=de,this.to=me}return function(ee,de){var me=de=="ltr"?"L":"R";if(ee.length==0||de=="ltr"&&!r.test(ee))return!1;for(var Se=ee.length,Ee=[],Re=0;Re<Se;++Re)Ee.push(i(ee.charCodeAt(Re)));for(var Be=0,je=me;Be<Se;++Be){var Je=Ee[Be];Je=="m"?Ee[Be]=je:je=Je}for(var et=0,Qe=me;et<Se;++et){var nt=Ee[et];nt=="1"&&Qe=="r"?Ee[et]="n":T.test(nt)&&(Qe=nt,nt=="r"&&(Ee[et]="R"))}for(var ht=1,st=Ee[0];ht<Se-1;++ht){var bt=Ee[ht];bt=="+"&&st=="1"&&Ee[ht+1]=="1"?Ee[ht]="1":bt==","&&st==Ee[ht+1]&&(st=="1"||st=="n")&&(Ee[ht]=st),st=bt}for(var It=0;It<Se;++It){var Jt=Ee[It];if(Jt==",")Ee[It]="N";else if(Jt=="%"){var Ft=void 0;for(Ft=It+1;Ft<Se&&Ee[Ft]=="%";++Ft);for(var yr=It&&Ee[It-1]=="!"||Ft<Se&&Ee[Ft]=="1"?"1":"N",pr=It;pr<Ft;++pr)Ee[pr]=yr;It=Ft-1}}for(var Gt=0,mr=me;Gt<Se;++Gt){var er=Ee[Gt];mr=="L"&&er=="1"?Ee[Gt]="L":T.test(er)&&(mr=er)}for(var Yt=0;Yt<Se;++Yt)if(n.test(Ee[Yt])){var zt=void 0;for(zt=Yt+1;zt<Se&&n.test(Ee[zt]);++zt);for(var jt=(Yt?Ee[Yt-1]:me)=="L",gr=(zt<Se?Ee[zt]:me)=="L",Gi=jt==gr?jt?"L":"R":me,ti=Yt;ti<zt;++ti)Ee[ti]=Gi;Yt=zt-1}for(var nr=[],Ur,Qt=0;Qt<Se;)if(N.test(Ee[Qt])){var Va=Qt;for(++Qt;Qt<Se&&N.test(Ee[Qt]);++Qt);nr.push(new Y(0,Va,Qt))}else{var Kr=Qt,vi=nr.length,yi=de=="rtl"?1:0;for(++Qt;Qt<Se&&Ee[Qt]!="L";++Qt);for(var ur=Kr;ur<Qt;)if(K.test(Ee[ur])){Kr<ur&&(nr.splice(vi,0,new Y(1,Kr,ur)),vi+=yi);var zi=ur;for(++ur;ur<Qt&&K.test(Ee[ur]);++ur);nr.splice(vi,0,new Y(2,zi,ur)),vi+=yi,Kr=ur}else++ur;Kr<Qt&&nr.splice(vi,0,new Y(1,Kr,Qt))}return de=="ltr"&&(nr[0].level==1&&(Ur=ee.match(/^\s+/))&&(nr[0].from=Ur[0].length,nr.unshift(new Y(0,0,Ur[0].length))),L(nr).level==1&&(Ur=ee.match(/\s+$/))&&(L(nr).to-=Ur[0].length,nr.push(new Y(0,Se-Ur[0].length,Se)))),de=="rtl"?nr.reverse():nr}}();function $e(e,t){var i=e.order;return i==null&&(i=e.order=at(e.text,t)),i}var Ve=[],Le=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]||Ve).concat(i)}};function tt(e,t){return e._handlers&&e._handlers[t]||Ve}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 T=ge(n,i);T>-1&&(r[t]=n.slice(0,T).concat(n.slice(T+1)))}}}function ae(e,t){var i=tt(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 tt(e,t).length>0}function oe(e){e.prototype.on=function(t,i){Le(this,t,i)},e.prototype.off=function(t,i){qe(this,t,i)}}function Q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function re(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),re(e)}function pe(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 ke=function(){if(j&&U<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Ne;function Ze(e){if(Ne==null){var t=a("span","\u200B");u(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Ne=t.offsetWidth<=1&&t.offsetHeight>2&&!(j&&U<8))}var i=Ne?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Ke;function lt(e){if(Ke!=null)return Ke;var t=u(e,document.createTextNode("A\u062EA")),i=c(t,0,1).getBoundingClientRect(),r=c(t,1,2).getBoundingClientRect();return d(e),!i||i.left==i.right?!1:Ke=r.right-i.right<3}var it=`
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
`,t);n==-1&&(n=e.length);var T=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=T.indexOf("\r");N!=-1?(i.push(T.slice(0,N)),t+=N+1):(i.push(T),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},Ye=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},wt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),dt=null;function Ot(e){if(dt!=null)return dt;var t=u(e,a("span","x")),i=t.getBoundingClientRect(),r=c(t,0,1).getBoundingClientRect();return dt=Math.abs(i.left-r.left)>1}var Nt={},St={};function ar(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Nt[e]=t}function br(e,t){St[e]=t}function Kt(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 Kt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Kt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function tr(e,t){t=Kt(t);var i=Nt[t.name];if(!i)return tr(e,"text/plain");var r=i(e,t);if(or.hasOwnProperty(t.name)){var n=or[t.name];for(var T in n){if(!n.hasOwnProperty(T))continue;r.hasOwnProperty(T)&&(r["_"+T]=r[T]),r[T]=n[T]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var N in t.modeProps)r[N]=t.modeProps[N];return r}var or={};function Pr(e,t){var i=or.hasOwnProperty(e)?or[e]:or[e]={};F(t,i)}function Vt(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 At(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 Mt(e,t,i){return e.startState?e.startState(t,i):!0}var vt=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};vt.prototype.eol=function(){return this.pos>=this.string.length},vt.prototype.sol=function(){return this.pos==this.lineStart},vt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},vt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},vt.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},vt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},vt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},vt.prototype.skipToEnd=function(){this.pos=this.string.length},vt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},vt.prototype.backUp=function(e){this.pos-=e},vt.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)},vt.prototype.indentation=function(){return ne(this.string,null,this.tabSize)-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},vt.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 T=this.string.slice(this.pos).match(e);return T&&T.index>0?null:(T&&t!==!1&&(this.pos+=T[0].length),T)}},vt.prototype.current=function(){return this.string.slice(this.start,this.pos)},vt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},vt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},vt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function He(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],T=n.chunkSize();if(t<T){i=n;break}t-=T}return i.lines[t]}function xt(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(T){var N=T.text;n==i.line&&(N=N.slice(0,i.ch)),n==t.line&&(N=N.slice(t.ch)),r.push(N),++n}),r}function Bt(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function pt(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 kt(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],T=n.height;if(t<T){e=n;continue e}t-=T,i+=n.chunkSize()}return i}while(!e.lines);for(var N=0;N<e.lines.length;++N){var K=e.lines[N],Y=K.height;if(t<Y)break;t-=Y}return i+N}function xr(e,t){return t>=e.first&&t<e.first+e.size}function Ht(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ue(e,t,i){if(i===void 0&&(i=null),!(this instanceof Ue))return new Ue(e,t,i);this.line=e,this.ch=t,this.sticky=i}function 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 Ue(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 gt(e,t){if(t.line<e.first)return Ue(e.first,0);var i=e.first+e.size-1;return t.line>i?Ue(i,He(e,i).text.length):An(t,He(e,t.line).text.length)}function An(e,t){var i=e.ch;return i==null||i>t?Ue(e.line,t):i<0?Ue(e.line,0):e}function Fe(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=gt(e,t[r]);return i}var Si=function(e,t){this.state=e,this.lookAhead=t},Cr=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};Cr.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Cr.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}},Cr.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Cr.fromSaved=function(e,t,i){return t instanceof Si?new Cr(e,Vt(e.mode,t.state),i,t.lookAhead):new Cr(e,Vt(e.mode,t),i)},Cr.prototype.save=function(e){var t=e!==!1?Vt(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],T={};kr(e,t.text,e.doc.mode,i,function(ee,de){return n.push(ee,de)},T,r);for(var N=i.state,K=function(ee){i.baseTokens=n;var de=e.state.overlays[ee],me=1,Se=0;i.state=!0,kr(e,t.text,de.mode,i,function(Ee,Re){for(var Be=me;Se<Ee;){var je=n[me];je>Ee&&n.splice(me,1,Ee,n[me+1],je),me+=2,Se=Math.min(Ee,je)}if(!Re)return;if(de.opaque)n.splice(Be,me-Be,Ee,"overlay "+Re),me=Be+2;else for(;Be<me;Be+=2){var Je=n[Be+1];n[Be+1]=(Je?Je+" ":"")+"overlay "+Re}},T),i.state=N,i.baseTokens=null,i.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:n,classes:T.bgClass||T.textClass?T:null}}function ni(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Lr(e,yt(t)),n=t.text.length>e.options.maxHighlightLength&&Vt(e.doc.mode,r.state),T=Ki(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=T.styles,T.classes?t.styleClasses=T.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Lr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Cr(r,!0,t);var T=_n(e,t,i),N=T>r.first&&He(r,T-1).stateAfter,K=N?Cr.fromSaved(r,N,T):new Cr(r,Mt(r.mode),T);return r.iter(T,t,function(Y){Vi(e,Y.text,K);var ee=K.line;Y.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,T=new vt(t,e.options.tabSize,i);for(T.start=T.pos=r||0,t==""&&Xi(n,i.state);!T.eol();)Ar(n,T,i.state),T.start=T.pos}function Xi(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=At(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]=At(e,i).mode);var T=e.token(t,i);if(t.pos>t.start)return T}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 kn(e,t,i,r){var n=e.doc,T=n.mode,N;t=gt(n,t);var K=He(n,t.line),Y=Lr(e,t.line,i),ee=new vt(K.text,e.options.tabSize,Y),de;for(r&&(de=[]);(r||ee.pos<t.ch)&&!ee.eol();)ee.start=ee.pos,N=Ar(T,ee,Y.state),r&&de.push(new Yi(ee,N,Vt(n.mode,Y.state)));return r?de:new Yi(ee,N,Y.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 kr(e,t,i,r,n,T,N){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,ee=null,de=new vt(t,e.options.tabSize,r),me,Se=e.options.addModeClass&&[null];for(t==""&&$i(Xi(i,r.state),T);!de.eol();){if(de.pos>e.options.maxHighlightLength?(K=!1,N&&Vi(e,t,r,de.pos),de.pos=t.length,me=null):me=$i(Ar(i,de,r.state,Se),T),Se){var Ee=Se[0].name;Ee&&(me="m-"+(me?Ee+" "+me:Ee))}if(!K||ee!=me){for(;Y<de.start;)Y=Math.min(de.start,Y+5e3),n(Y,ee);ee=me}de.start=de.pos}for(;Y<de.pos;){var Re=Math.min(de.pos,Y+5e3);n(Re,ee),Y=Re}}function _n(e,t,i){for(var r,n,T=e.doc,N=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>N;--K){if(K<=T.first)return T.first;var Y=He(T,K-1),ee=Y.stateAfter;if(ee&&(!i||K+(ee instanceof Si?ee.lookAhead:0)<=T.modeFrontier))return K;var de=ne(Y.text,null,e.options.tabSize);(n==null||r>de)&&(n=K-1,r=de)}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=He(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,sr=!1;function Vr(){Zi=!0}function oa(){sr=!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 T=e[n],N=T.marker,K=T.from==null||(N.inclusiveLeft?T.from<=t:T.from<t);if(K||T.from==t&&N.type=="bookmark"&&(!i||!T.marker.insertLeft)){var Y=T.to==null||(N.inclusiveRight?T.to>=t:T.to>t);(r||(r=[])).push(new ai(N,T.from,Y?null:T.to))}}return r}function Rn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var T=e[n],N=T.marker,K=T.to==null||(N.inclusiveRight?T.to>=t:T.to>t);if(K||T.from==t&&N.type=="bookmark"&&(!i||T.marker.insertLeft)){var Y=T.from==null||(N.inclusiveLeft?T.from<=t:T.from<t);(r||(r=[])).push(new ai(N,Y?null:T.from-t,T.to==null?null:T.to-t))}}return r}function Ti(e,t){if(t.full)return null;var i=xr(e,t.from.line)&&He(e,t.from.line).markedSpans,r=xr(e,t.to.line)&&He(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,T=t.to.ch,N=ft(t.from,t.to)==0,K=Dn(i,n,N),Y=Rn(r,T,N),ee=t.text.length==1,de=L(t.text).length+(ee?n:0);if(K)for(var me=0;me<K.length;++me){var Se=K[me];if(Se.to==null){var Ee=_r(Y,Se.marker);Ee?ee&&(Se.to=Ee.to==null?null:Ee.to+de):Se.to=n}}if(Y)for(var Re=0;Re<Y.length;++Re){var Be=Y[Re];if(Be.to!=null&&(Be.to+=de),Be.from==null){var je=_r(K,Be.marker);je||(Be.from=de,ee&&(K||(K=[])).push(Be))}else Be.from+=de,ee&&(K||(K=[])).push(Be)}K&&(K=On(K)),Y&&Y!=K&&(Y=On(Y));var Je=[K];if(!ee){var et=t.text.length-2,Qe;if(et>0&&K)for(var nt=0;nt<K.length;++nt)K[nt].to==null&&(Qe||(Qe=[])).push(new ai(K[nt].marker,null,null));for(var ht=0;ht<et;++ht)Je.push(Qe);Je.push(Y)}return Je}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 Mn(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(Ee){if(Ee.markedSpans)for(var Re=0;Re<Ee.markedSpans.length;++Re){var Be=Ee.markedSpans[Re].marker;Be.readOnly&&(!r||ge(r,Be)==-1)&&(r||(r=[])).push(Be)}}),!r)return null;for(var n=[{from:t,to:i}],T=0;T<r.length;++T)for(var N=r[T],K=N.find(0),Y=0;Y<n.length;++Y){var ee=n[Y];if(ft(ee.to,K.from)<0||ft(ee.from,K.to)>0)continue;var de=[Y,1],me=ft(ee.from,K.from),Se=ft(ee.to,K.to);(me<0||!N.inclusiveLeft&&!me)&&de.push({from:ee.from,to:K.from}),(Se>0||!N.inclusiveRight&&!Se)&&de.push({from:K.to,to:ee.to}),n.splice.apply(n,de),Y+=de.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(),T=ft(r.from,n.from)||oi(e)-oi(t);if(T)return-T;var N=ft(r.to,n.to)||si(e)-si(t);return N||t.id-e.id}function Fr(e,t){var i=sr&&e.markedSpans,r;if(i)for(var n=void 0,T=0;T<i.length;++T)n=i[T],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||wi(r,n.marker)<0)&&(r=n.marker);return r}function jr(e){return Fr(e,!0)}function Wr(e){return Fr(e,!1)}function Li(e,t){var i=sr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var T=i[n];T.marker.collapsed&&(T.from==null||T.from<t)&&(T.to==null||T.to>t)&&(!r||wi(r,T.marker)<0)&&(r=T.marker)}return r}function Pn(e,t,i,r,n){var T=He(e,t),N=sr&&T.markedSpans;if(N)for(var K=0;K<N.length;++K){var Y=N[K];if(!Y.marker.collapsed)continue;var ee=Y.marker.find(0),de=ft(ee.from,i)||oi(Y.marker)-oi(n),me=ft(ee.to,r)||si(Y.marker)-si(n);if(de>=0&&me<=0||de<=0&&me>=0)continue;if(de<=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?ft(ee.to,i)>=0:ft(ee.to,i)>0)||de>=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?ft(ee.from,r)<=0:ft(ee.from,r)<0))return!0}}function Er(e){for(var t;t=jr(e);)e=t.find(-1,!0).line;return e}function In(e){for(var t;t=Wr(e);)e=t.find(1,!0).line;return e}function Ai(e){for(var t,i;t=Wr(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Qi(e,t){var i=He(e,t),r=Er(i);return i==r?t:yt(r)}function Xr(e,t){if(t>e.lastLine())return t;var i=He(e,t),r;if(!Ir(e,i))return t;for(;r=Wr(i);)i=r.find(1,!0).line;return yt(i)+1}function Ir(e,t){var i=sr&&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,T=0;T<t.markedSpans.length;++T)if(n=t.markedSpans[T],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 Dr(e){e=Er(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 T=i.parent;T;i=T,T=i.parent)for(var N=0;N<T.children.length;++N){var K=T.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=jr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wr(r);){var T=i.find(0,!0);t-=r.text.length-T.from.ch,r=T.to.line,t+=r.text.length-T.to.ch}return t}function Nn(e){var t=e.display,i=e.doc;t.maxLine=He(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&&pt(e,n)}function ot(e){e.parent=null,la(e)}var mt={},ut={};function Et(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 Lt(e,t){var i=y("span",null,null,I?"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 T=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=Ct,lt(e.display.measure)&&(N=$e(T,e.doc.direction))&&(r.addToken=hr(r.addToken,N)),r.map=[];var K=t!=e.display.externalMeasured&&yt(T);Hr(T,r,ni(e,T,K)),T.styleClasses&&(T.styleClasses.bgClass&&(r.bgClass=X(T.styleClasses.bgClass,r.bgClass||"")),T.styleClasses.textClass&&(r.textClass=X(T.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(Ze(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(I){var Y=r.content.lastChild;(/\bcm-tab\b/.test(Y.className)||Y.querySelector&&Y.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=X(r.pre.className,r.textClass||"")),r}function Pt(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,T,N){if(!t)return;var K=e.splitSpaces?Xt(t,e.trailingSpace):t,Y=e.cm.state.specialChars,ee=!1,de;if(!Y.test(t))e.col+=t.length,de=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,de),j&&U<9&&(ee=!0),e.pos+=t.length;else{de=document.createDocumentFragment();for(var me=0;;){Y.lastIndex=me;var Se=Y.exec(t),Ee=Se?Se.index-me:t.length-me;if(Ee){var Re=document.createTextNode(K.slice(me,me+Ee));j&&U<9?de.appendChild(a("span",[Re])):de.appendChild(Re),e.map.push(e.pos,e.pos+Ee,Re),e.col+=Ee,e.pos+=Ee}if(!Se)break;me+=Ee+1;var Be=void 0;if(Se[0]==" "){var je=e.cm.options.tabSize,Je=je-e.col%je;Be=de.appendChild(a("span",W(Je),"cm-tab")),Be.setAttribute("role","presentation"),Be.setAttribute("cm-text"," "),e.col+=Je}else Se[0]=="\r"||Se[0]==`
`?(Be=de.appendChild(a("span",Se[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Be.setAttribute("cm-text",Se[0]),e.col+=1):(Be=e.cm.options.specialCharPlaceholder(Se[0]),Be.setAttribute("cm-text",Se[0]),j&&U<9?de.appendChild(a("span",[Be])):de.appendChild(Be),e.col+=1);e.map.push(e.pos,e.pos+1,Be),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||ee||T||N){var et=i||"";r&&(et+=r),n&&(et+=n);var Qe=a("span",[de],et,T);if(N)for(var nt in N)N.hasOwnProperty(nt)&&nt!="style"&&nt!="class"&&Qe.setAttribute(nt,N[nt]);return e.content.appendChild(Qe)}e.content.appendChild(de)}function Xt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var T=e.charAt(n);T==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(T="\xA0"),r+=T,i=T==" "}return r}function hr(e,t){return function(i,r,n,T,N,K,Y){n=n?n+" cm-force-border":"cm-force-border";for(var ee=i.pos,de=ee+r.length;;){for(var me=void 0,Se=0;Se<t.length&&!(me=t[Se],me.to>ee&&me.from<=ee);Se++);if(me.to>=de)return e(i,r,n,T,N,K,Y);e(i,r.slice(0,me.to-ee),n,T,null,K,Y),T=null,r=r.slice(me.to-ee),ee=me.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 Hr(e,t,i){var r=e.markedSpans,n=e.text,T=0;if(!r){for(var N=1;N<i.length;N+=2)t.addToken(t,n.slice(T,T=i[N]),Et(i[N+1],t.cm.options));return}for(var K=n.length,Y=0,ee=1,de="",me,Se,Ee=0,Re,Be,je,Je,et;;){if(Ee==Y){Re=Be=je=Se="",et=null,Je=null,Ee=Infinity;for(var Qe=[],nt=void 0,ht=0;ht<r.length;++ht){var st=r[ht],bt=st.marker;if(bt.type=="bookmark"&&st.from==Y&&bt.widgetNode)Qe.push(bt);else if(st.from<=Y&&(st.to==null||st.to>Y||bt.collapsed&&st.to==Y&&st.from==Y)){if(st.to!=null&&st.to!=Y&&Ee>st.to&&(Ee=st.to,Be=""),bt.className&&(Re+=" "+bt.className),bt.css&&(Se=(Se?Se+";":"")+bt.css),bt.startStyle&&st.from==Y&&(je+=" "+bt.startStyle),bt.endStyle&&st.to==Ee&&(nt||(nt=[])).push(bt.endStyle,st.to),bt.title&&((et||(et={})).title=bt.title),bt.attributes)for(var It in bt.attributes)(et||(et={}))[It]=bt.attributes[It];bt.collapsed&&(!Je||wi(Je.marker,bt)<0)&&(Je=st)}else st.from>Y&&Ee>st.from&&(Ee=st.from)}if(nt)for(var Jt=0;Jt<nt.length;Jt+=2)nt[Jt+1]==Ee&&(Be+=" "+nt[Jt]);if(!Je||Je.from==Y)for(var Ft=0;Ft<Qe.length;++Ft)Tt(t,0,Qe[Ft]);if(Je&&(Je.from||0)==Y){if(Tt(t,(Je.to==null?K+1:Je.to)-Y,Je.marker,Je.from==null),Je.to==null)return;Je.to==Y&&(Je=!1)}}if(Y>=K)break;for(var yr=Math.min(K,Ee);;){if(de){var pr=Y+de.length;if(!Je){var Gt=pr>yr?de.slice(0,yr-Y):de;t.addToken(t,Gt,me?me+Re:Re,je,Y+Gt.length==Ee?Be:"",Se,et)}if(pr>=yr){de=de.slice(yr-Y),Y=yr;break}Y=pr,je=""}de=n.slice(T,T=i[ee++]),me=Et(i[ee++],t.cm.options)}}}function _t(e,t,i){this.line=t,this.rest=Ai(t),this.size=this.rest?yt(L(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Ir(e,t)}function dr(e,t,i){for(var r=[],n,T=t;T<i;T=n){var N=new _t(e.doc,He(e.doc,T),T);n=T+N.size,r.push(N)}return r}var rr=null;function wr(e){rr?rr.ops.push(e):e.ownsGroup=rr={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{rr=null,t(i)}}var tn=null;function qt(e,t){var i=tt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;rr?n=rr.delayedCallbacks:tn?n=tn:(n=tn=[],setTimeout(Os,0));for(var T=function(K){n.push(function(){return i[K].apply(null,r)})},N=0;N<i.length;++N)T(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 T=t.changes[n];T=="text"?Ps(e,t):T=="gutter"?Za(e,t,i,r):T=="class"?ha(e,t):T=="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&&U<8&&(e.node.style.zIndex=2)),e.node}function Ms(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):Lt(e,t)}function Ps(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){Ms(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 T=t.line.gutterMarkers;if(e.options.lineNumbers||T){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&&(!T||!T["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",Ht(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),T)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var ee=e.display.gutterSpecs[Y].className,de=T.hasOwnProperty(ee)&&T[ee];de&&K.appendChild(a("div",[de],"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=E("CodeMirror-linewidget"),n=t.node.firstChild,T=void 0;n;n=T)T=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 T=rn(i),N=0,K=t.widgets;N<K.length;++N){var Y=K[N],ee=a("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||ee.setAttribute("cm-ignore-events","true"),Bs(Y,ee,i,r),e.display.input.setUneditable(ee),n&&Y.above?T.insertBefore(ee,i.gutter||i.text):T.appendChild(ee),qt(Y,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function nn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!S(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;"),u(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function Gr(e,t){for(var i=pe(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function 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=u(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 Nr(e){return xe-e.display.nativeBarWidth}function ui(e){return e.display.scroller.clientWidth-Nr(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-Nr(e)-e.display.barHeight}function Us(e,t,i){var r=e.options.lineWrapping,n=r&&ui(e);if(!t.measure.heights||r&&t.measure.width!=n){var T=t.measure.heights=[];if(r){t.measure.width=n;for(var N=t.text.firstChild.getClientRects(),K=0;K<N.length-1;K++){var Y=N[K],ee=N[K+1];Math.abs(Y.bottom-ee.bottom)>2&&T.push((Y.bottom+ee.top)/2-i.top)}}T.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 Fs(e,t){t=Er(t);var i=yt(t),r=e.display.externalMeasured=new _t(e.doc,t,i);r.lineN=i;var n=r.built=Lt(e,r);return r.text=n.pre,u(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return Br(e,ki(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 ki(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=Fs(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function Br(e,t,i,r,n){t.before&&(i=-1);var T=i+(r||""),N;return t.cache.hasOwnProperty(T)?N=t.cache[T]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Us(e,t.view,t.rect),t.hasHeights=!0),N=Ws(e,t,i,r),N.bogus||(t.cache[T]=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,T,N,K,Y,ee=0;ee<e.length;ee+=3)if(K=e[ee],Y=e[ee+1],t<K?(n=0,T=1,N="left"):t<Y?(n=t-K,T=n+1):(ee==e.length-3||t==Y&&e[ee+3]>t)&&(T=Y-K,n=T-1,t>=Y&&(N="right")),n!=null){if(r=e[ee+2],K==Y&&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==Y-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:T,collapse:N,coverStart:K,coverEnd:Y}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),T=n.node,N=n.start,K=n.end,Y=n.collapse,ee;if(T.nodeType==3){for(var de=0;de<4;de++){for(;N&&De(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+K<n.coverEnd&&De(t.line.text.charAt(n.coverStart+K));)++K;if(j&&U<9&&N==0&&K==n.coverEnd-n.coverStart?ee=T.parentNode.getBoundingClientRect():ee=js(c(T,N,K).getClientRects(),r),ee.left||ee.right||N==0)break;K=N,N=N-1,Y="right"}j&&U<11&&(ee=Hs(e.display.measure,ee))}else{N>0&&(Y=r="right");var me;e.options.lineWrapping&&(me=T.getClientRects()).length>1?ee=me[r=="right"?me.length-1:0]:ee=T.getBoundingClientRect()}if(j&&U<9&&!N&&(!ee||!ee.left&&!ee.right)){var Se=T.parentNode.getClientRects()[0];Se?ee={left:Se.left,right:Se.left+Di(e.display),top:Se.top,bottom:Se.bottom}:ee=ro}for(var Ee=ee.top-t.rect.top,Re=ee.bottom-t.rect.top,Be=(Ee+Re)/2,je=t.view.measure.heights,Je=0;Je<je.length-1&&!(Be<je[Je]);Je++);var et=Je?je[Je-1]:0,Qe=je[Je],nt={left:(Y=="right"?ee.right:ee.left)-t.rect.left,right:(Y=="left"?ee.left:ee.right)-t.rect.left,top:et,bottom:Qe};return!ee.left&&!ee.right&&(nt.bogus=!0),e.options.singleCursorHeightPerLine||(nt.rtop=Ee,nt.rbottom=Re),nt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Ot(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,d(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 v&&l?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return v&&l?-(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 Un(e,t,i,r,n){if(!n){var T=pa(t);i.top+=T,i.bottom+=T}if(r=="line")return i;r||(r="local");var N=Dr(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 Y=K.left+(r=="window"?0:oo());i.left+=Y,i.right+=Y}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 T=e.display.sizer.getBoundingClientRect();r+=T.left,n+=T.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=He(e.doc,t.line)),Un(e,r,to(e,r,t.ch,n),i)}function Rr(e,t,i,r,n,T){r=r||He(e.doc,t.line),n||(n=ki(e,r));function N(Re,Be){var je=Br(e,n,Re,Be?"right":"left",T);return Be?je.left=je.right:je.right=je.left,Un(e,r,je,i)}var K=$e(r,e.doc.direction),Y=t.ch,ee=t.sticky;if(Y>=r.text.length?(Y=r.text.length,ee="before"):Y<=0&&(Y=0,ee="after"),!K)return N(ee=="before"?Y-1:Y,ee=="before");function de(Re,Be,je){var Je=K[Be],et=Je.level==1;return N(je?Re-1:Re,et!=je)}var me=Ge(K,Y,ee),Se=Xe,Ee=de(Y,me,ee=="before");return Se!=null&&(Ee.other=de(Y,Se,ee!="before")),Ee}function uo(e,t){var i=0;t=gt(e.doc,t),e.options.lineWrapping||(i=Di(e.display)*t.ch);var r=He(e.doc,t.line),n=Dr(r)+Bn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var T=Ue(e,t,i);return T.xRel=n,r&&(T.outside=r),T}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=kt(r,i),T=r.first+r.size-1;if(n>T)return ga(r.first+r.size-1,He(r,T).text.length,null,1,1);t<0&&(t=0);for(var N=He(r,n);;){var K=Gs(e,N,n,t,i),Y=Li(N,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var ee=Y.find(1);if(ee.line==n)return ee;N=He(r,n=ee.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,T=We(function(N){return Br(e,i,N-1).bottom<=r},n,0);return n=We(function(N){return Br(e,i,N).top>r},T,n),{begin:T,end:n}}function co(e,t,i,r){i||(i=ki(e,t));var n=Un(e,t,Br(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-=Dr(t);var T=ki(e,t),N=pa(t),K=0,Y=t.text.length,ee=!0,de=$e(t,e.doc.direction);if(de){var me=(e.options.lineWrapping?Ks:zs)(e,t,i,T,de,r,n);ee=me.level!=1,K=ee?me.from:me.to-1,Y=ee?me.to:me.from-1}var Se=null,Ee=null,Re=We(function(ht){var st=Br(e,T,ht);return st.top+=N,st.bottom+=N,ya(st,r,n,!1)?(st.top<=n&&st.left<=r&&(Se=ht,Ee=st),!0):!1},K,Y),Be,je,Je=!1;if(Ee){var et=r-Ee.left<Ee.right-r,Qe=et==ee;Re=Se+(Qe?0:1),je=Qe?"after":"before",Be=et?Ee.left:Ee.right}else{!ee&&(Re==Y||Re==K)&&Re++,je=Re==0?"after":Re==t.text.length?"before":Br(e,T,Re-(ee?1:0)).bottom+N<=n==ee?"after":"before";var nt=Rr(e,Ue(i,Re,je),"line",t,T);Be=nt.left,Je=n<nt.top?-1:n>=nt.bottom?1:0}return Re=Me(t.text,Re,1),ga(i,Re,je,Je,r-Be)}function zs(e,t,i,r,n,T,N){var K=We(function(me){var Se=n[me],Ee=Se.level!=1;return ya(Rr(e,Ue(i,Ee?Se.to:Se.from,Ee?"before":"after"),"line",t,r),T,N,!0)},0,n.length-1),Y=n[K];if(K>0){var ee=Y.level!=1,de=Rr(e,Ue(i,ee?Y.from:Y.to,ee?"after":"before"),"line",t,r);ya(de,T,N,!0)&&de.top>N&&(Y=n[K-1])}return Y}function Ks(e,t,i,r,n,T,N){var K=ho(e,t,r,N),Y=K.begin,ee=K.end;/\s/.test(t.text.charAt(ee-1))&&ee--;for(var de=null,me=null,Se=0;Se<n.length;Se++){var Ee=n[Se];if(Ee.from>=ee||Ee.to<=Y)continue;var Re=Ee.level!=1,Be=Br(e,r,Re?Math.min(ee,Ee.to)-1:Math.max(Y,Ee.from)).right,je=Be<T?T-Be+1e9:Be-T;(!de||me>je)&&(de=Ee,me=je)}return de||(de=n[n.length-1]),de.from<Y&&(de={from:Y,to:de.to,level:de.level}),de.to>ee&&(de={from:de.from,to:ee,level:de.level}),de}var hi;function _i(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"))}u(e.measure,hi);var i=hi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),d(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");u(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,T=t.gutters.firstChild,N=0;T;T=T.nextSibling,++N){var K=e.display.gutterSpecs[N].className;i[K]=T.offsetLeft+T.clientLeft+n,r[K]=T.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=_i(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Di(e.display)-3);return function(n){if(Ir(e.doc,n))return 0;var T=0;if(n.widgets)for(var N=0;N<n.widgets.length;N++)n.widgets[N].height&&(T+=n.widgets[N].height);return i?T+(Math.ceil(n.text.length/r)||1)*t:T+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&pt(r,n)})}function di(e,t,i,r){var n=e.display;if(!i&&pe(t).getAttribute("cm-not-content")=="true")return null;var T,N,K=n.lineSpace.getBoundingClientRect();try{T=t.clientX-K.left,N=t.clientY-K.top}catch(me){return null}var Y=va(e,T,N),ee;if(r&&Y.xRel>0&&(ee=He(e.doc,Y.line).text).length==Y.ch){var de=ne(ee,ee.length,e.options.tabSize)-ee.length;Y=Ue(Y.line,Math.max(0,Math.round((T-qa(e.display).left)/Di(e.display))-de))}return Y}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)sr&&Qi(e.doc,t)<n.viewTo&&$r(e);else if(i<=n.viewFrom)sr&&Xr(e.doc,i+r)>n.viewFrom?$r(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)$r(e);else if(t<=n.viewFrom){var T=Fn(e,i,i+r,1);T?(n.view=n.view.slice(T.index),n.viewFrom=T.lineN,n.viewTo+=r):$r(e)}else if(i>=n.viewTo){var N=Fn(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):$r(e)}else{var K=Fn(e,t,t,-1),Y=Fn(e,i,i+r,1);K&&Y?(n.view=n.view.slice(0,K.index).concat(dr(e,K.lineN,Y.lineN)).concat(n.view.slice(Y.index)),n.viewTo+=r):$r(e)}var ee=n.externalMeasured;ee&&(i<ee.lineN?ee.lineN+=r:t<ee.lineN+ee.size&&(n.externalMeasured=null))}function Yr(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 T=r.view[ci(e,t)];if(T.node==null)return;var N=T.changes||(T.changes=[]);ge(N,i)==-1&&N.push(i)}function $r(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Fn(e,t,i,r){var n=ci(e,t),T,N=e.display.view;if(!sr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,Y=0;Y<n;Y++)K+=N[Y].size;if(K!=t){if(r>0){if(n==N.length-1)return null;T=K+N[n].size-t,n++}else T=K-t;t+=T,i+=T}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(),T=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 Y=K.empty();(Y||e.options.showCursorWhenSelecting)&&go(e,K.head,n),Y||Xs(e,K,T)}return r}function go(e,t,i){var r=Rr(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 T=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));T.style.display="",T.style.left=r.other.left+"px",T.style.top=r.other.top+"px",T.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,T=document.createDocumentFragment(),N=qa(e.display),K=N.left,Y=Math.max(r.sizerWidth,ui(e)-r.sizer.offsetLeft)-N.right,ee=n.direction=="ltr";function de(Qe,nt,ht,st){nt<0&&(nt=0),nt=Math.round(nt),st=Math.round(st),T.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Qe+`px;
top: `+nt+"px; width: "+(ht==null?Y-Qe:ht)+`px;
height: `+(st-nt)+"px"))}function me(Qe,nt,ht){var st=He(n,Qe),bt=st.text.length,It,Jt;function Ft(Gt,mr){return ma(e,Ue(Qe,Gt),"div",st,mr)}function yr(Gt,mr,er){var Yt=co(e,st,null,Gt),zt=mr=="ltr"==(er=="after")?"left":"right",jt=er=="after"?Yt.begin:Yt.end-(/\s/.test(st.text.charAt(Yt.end-1))?2:1);return Ft(jt,zt)[zt]}var pr=$e(st,n.direction);return ze(pr,nt||0,ht==null?bt:ht,function(Gt,mr,er,Yt){var zt=er=="ltr",jt=Ft(Gt,zt?"left":"right"),gr=Ft(mr-1,zt?"right":"left"),Gi=nt==null&&Gt==0,ti=ht==null&&mr==bt,nr=Yt==0,Ur=!pr||Yt==pr.length-1;if(gr.top-jt.top<=3){var Qt=(ee?Gi:ti)&&nr,Va=(ee?ti:Gi)&&Ur,Kr=Qt?K:(zt?jt:gr).left,vi=Va?Y:(zt?gr:jt).right;de(Kr,jt.top,vi-Kr,jt.bottom)}else{var yi,ur,zi,Xa;zt?(yi=ee&&Gi&&nr?K:jt.left,ur=ee?Y:yr(Gt,er,"before"),zi=ee?K:yr(mr,er,"after"),Xa=ee&&ti&&Ur?Y:gr.right):(yi=ee?yr(Gt,er,"before"):K,ur=!ee&&Gi&&nr?Y:jt.right,zi=!ee&&ti&&Ur?K:gr.left,Xa=ee?yr(mr,er,"after"):Y),de(yi,jt.top,ur-yi,jt.bottom),jt.bottom<gr.top&&de(K,jt.bottom,null,gr.top),de(zi,gr.top,Xa-zi,gr.bottom)}(!It||jn(jt,It)<0)&&(It=jt),jn(gr,It)<0&&(It=gr),(!Jt||jn(jt,Jt)<0)&&(Jt=jt),jn(gr,Jt)<0&&(Jt=gr)}),{start:It,end:Jt}}var Se=t.from(),Ee=t.to();if(Se.line==Ee.line)me(Se.line,Se.ch,Ee.ch);else{var Re=He(n,Se.line),Be=He(n,Ee.line),je=Er(Re)==Er(Be),Je=me(Se.line,Se.ch,je?Re.text.length+1:null).end,et=me(Ee.line,je?0:null,Ee.ch).start;je&&(Je.top<et.top-2?(de(Je.right,Je.top,null,Je.bottom),de(K,et.top,et.left,et.bottom)):de(Je.right,Je.top,et.left-Je.right,Je.bottom)),Je.bottom<et.top&&de(K,Je.bottom,null,et.top)}i.appendChild(T)}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(),I&&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,f(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],T=e.options.lineWrapping,N=void 0,K=0;if(n.hidden)continue;if(j&&U<8){var Y=n.node.offsetTop+n.node.offsetHeight;N=Y-i,i=Y}else{var ee=n.node.getBoundingClientRect();N=ee.bottom-ee.top,!T&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-ee.left-1)}var de=n.line.height-N;if((de>.005||de<-.005)&&(pt(n.line,N),bo(n.line),n.rest))for(var me=0;me<n.rest.length;me++)bo(n.rest[me]);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,T=kt(t,r),N=kt(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<T?(T=K,N=kt(t,Dr(He(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=N&&(T=kt(t,Dr(He(t,Y))-e.wrapper.clientHeight),N=Y)}return{from:T,to:Math.max(N,T+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&&!b){var T=a("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Bn(e.display))+`px;
height: `+(t.bottom-t.top+Nr(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(T),T.scrollIntoView(n),e.display.lineSpace.removeChild(T)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Ue(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Ue(t.line,t.ch+1,"before"):t);for(var T=0;T<5;T++){var N=!1,K=Rr(e,t),Y=!i||i==t?K:Rr(e,i);n={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var ee=Ca(e,n),de=e.doc.scrollTop,me=e.doc.scrollLeft;if(ee.scrollTop!=null&&(ln(e,ee.scrollTop),Math.abs(e.doc.scrollTop-de)>1&&(N=!0)),ee.scrollLeft!=null&&(fi(e,ee.scrollLeft),Math.abs(e.doc.scrollLeft-me)>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=_i(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,T=ca(e),N={};t.bottom-t.top>T&&(t.bottom=t.top+T);var K=e.doc.height+da(i),Y=t.top<r,ee=t.bottom>K-r;if(t.top<n)N.scrollTop=Y?0:t.top;else if(t.bottom>n+T){var de=Math.min(t.top,(ee?K:t.bottom)-T);de!=n&&(N.scrollTop=de)}var me=e.options.fixedGutter?0:i.gutters.offsetWidth,Se=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-me,Ee=ui(e)-i.gutters.offsetWidth,Re=t.right-t.left>Ee;return Re&&(t.right=t.left+Ee),t.left<10?N.scrollLeft=0:t.left<Se?N.scrollLeft=Math.max(0,t.left+me-(Re?0:10)):t.right>Ee+Se-3&&(N.scrollLeft=t.right+(Re?0:10)-Ee),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;_||Aa(e,{top:t}),Eo(e,t,!0),_&&Aa(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,Lo(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+Nr(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),Le(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Le(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,j&&U<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 T=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+T)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},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&&!w?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ce,this.disableVert=new ce},pi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),T=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);T!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},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 Mi(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&&f(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Le(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},wr(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 T=0;T<t.length;T++)il(t[T]);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&&La(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+Nr(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==P();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Mi(t,e.barMeasure),e.updatedDisplay&&_a(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,gt(r,e.scrollToPos.from),gt(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var T=e.maybeHiddenMarkers,N=e.maybeUnhiddenMarkers;if(T)for(var K=0;K<T.length;++K)T[K].lines.length||ae(T[K],"hide");if(N)for(var Y=0;Y<N.length;++Y)N[Y].lines.length&&ae(N[Y],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function vr(e,t){if(e.curOp)return t();mi(e);try{return t()}finally{gi(e)}}function $t(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mi(e);try{return t.apply(e,arguments)}finally{gi(e)}}}function lr(e){return function(){if(this.curOp)return e.apply(this,arguments);mi(this);try{return e.apply(this,arguments)}finally{gi(this)}}}function Zt(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=Lr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(T){if(r.line>=e.display.viewFrom){var N=T.styles,K=T.text.length>e.options.maxHighlightLength?Vt(t.mode,r.state):null,Y=Ki(e,T,r,!0);K&&(r.state=K),T.styles=Y.styles;var ee=T.styleClasses,de=Y.classes;de?T.styleClasses=de:ee&&(T.styleClasses=null);for(var me=!N||N.length!=T.styles.length||ee!=de&&(!ee||!de||ee.bgClass!=de.bgClass||ee.textClass!=de.textClass),Se=0;!me&&Se<N.length;++Se)me=N[Se]!=T.styles[Se];me&&n.push(r.line),T.stateAfter=r.save(),r.nextLine()}else T.text.length<=e.options.maxHighlightLength&&Vi(e,T.text,r),T.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 T=0;T<n.length;T++)Yr(e,n[T],"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=Nr(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Nr(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=P();if(!t||!S(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&S(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==P())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&S(document.body,e.anchorNode)&&S(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 La(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return $r(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;Ao(e)&&($r(e),t.dims=ba(e));var n=r.first+r.size,T=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<T&&T-i.viewFrom<20&&(T=Math.max(r.first,i.viewFrom)),i.viewTo>N&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),sr&&(T=Qi(e.doc,T),N=Xr(e.doc,N));var K=T!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,T,N),i.viewOffset=Dr(He(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var ee=sl(e);return Y>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),Y>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(ee),d(i.cursorDiv),d(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(!La(e,t))break;Wn(e);var n=un(e);on(e),Mi(e,n),_a(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 Aa(e,t){var i=new zn(e,t);if(La(e,i)){Wn(e),wo(e,i);var r=un(e);on(e),Mi(e,r),_a(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,T=r.lineDiv,N=T.firstChild;function K(Re){var Be=Re.nextSibling;return I&&s&&e.display.currentWheelTarget==Re?Re.style.display="none":Re.parentNode.removeChild(Re),Be}for(var Y=r.view,ee=r.viewFrom,de=0;de<Y.length;de++){var me=Y[de];if(!me.hidden)if(!me.node||me.node.parentNode!=T){var Se=Ns(e,me,ee,i);T.insertBefore(Se,N)}else{for(;N!=me.node;)N=K(N);var Ee=n&&t!=null&&t<=ee&&me.lineNumber;me.changes&&(ge(me.changes,"gutter")>-1&&(Ee=!1),Ya(e,me,ee,i)),Ee&&(d(me.lineNumber),me.lineNumber.appendChild(document.createTextNode(Ht(e.options,ee)))),N=me.node.nextSibling}ee+=me.size}for(;N;)N=K(N)}function ka(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function _a(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+Nr(e)+"px"}function Lo(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,T=r+"px",N=0;N<i.length;N++)if(!i[N].hidden){e.options.fixedGutter&&(i[N].gutter&&(i[N].gutter.style.left=T),i[N].gutterBackground&&(i[N].gutterBackground.style.left=T));var K=i[N].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=T}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=Ht(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")),T=n.firstChild.offsetWidth,N=n.offsetWidth-T;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(T,r.lineGutter.offsetWidth-N)+1,r.lineNumWidth=r.lineNumInnerWidth+N,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",ka(e.display),!0}return!1}function Da(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var T=e[n],N=null;if(typeof T!="string"&&(N=T.style,T=T.className),T=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:T,style:N})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;d(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],T=n.className,N=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+T));N&&(K.style.cssText=N),T=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function cn(e){ko(e.display),cr(e),Lo(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 T=y("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[T],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+xe+"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&&U<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!I&&!(_&&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),ko(n),i.init(n)}var Kn=0,Sr=null;j?Sr=-.53:_?Sr=15:v?Sr=-.7:R&&(Sr=-1/3);function _o(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=_o(e);return t.x*=Sr,t.y*=Sr,t}function Do(e,t){var i=_o(t),r=i.x,n=i.y,T=e.display,N=T.scroller,K=N.scrollWidth>N.clientWidth,Y=N.scrollHeight>N.clientHeight;if(!(r&&K||n&&Y))return;if(n&&s&&I){e:for(var ee=t.target,de=T.view;ee!=N;ee=ee.parentNode)for(var me=0;me<de.length;me++)if(de[me].node==ee){e.display.currentWheelTarget=ee;break e}}if(r&&!_&&!g&&Sr!=null){n&&Y&&ln(e,Math.max(0,N.scrollTop+n*Sr)),fi(e,Math.max(0,N.scrollLeft+r*Sr)),(!n||n&&Y)&&Q(t),T.wheelStartX=null;return}if(n&&Sr!=null){var Se=n*Sr,Ee=e.doc.scrollTop,Re=Ee+T.wrapper.clientHeight;Se<0?Ee=Math.max(0,Ee+Se-50):Re=Math.min(e.doc.height,Re+Se+50),Aa(e,{top:Ee,bottom:Re})}Kn<20&&(T.wheelStartX==null?(T.wheelStartX=N.scrollLeft,T.wheelStartY=N.scrollTop,T.wheelDX=r,T.wheelDY=n,setTimeout(function(){if(T.wheelStartX==null)return;var Be=N.scrollLeft-T.wheelStartX,je=N.scrollTop-T.wheelStartY,Je=je&&T.wheelDY&&je/T.wheelDY||Be&&T.wheelDX&&Be/T.wheelDX;if(T.wheelStartX=T.wheelStartY=null,!Je)return;Sr=(Sr*Kn+Je)/(Kn+1),++Kn},200)):(T.wheelDX+=r,T.wheelDY+=n))}var Tr=function(e,t){this.ranges=e,this.primIndex=t};Tr.prototype.primary=function(){return this.ranges[this.primIndex]},Tr.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},Tr.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 Tr(e,this.primIndex)},Tr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Tr.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 Or(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(Se,Ee){return ft(Se.from(),Ee.from())}),i=ge(t,n);for(var T=1;T<t.length;T++){var N=t[T],K=t[T-1],Y=ft(K.to(),N.from());if(r&&!N.empty()?Y>0:Y>=0){var ee=ii(K.from(),N.from()),de=xi(K.to(),N.to()),me=K.empty()?N.from()==N.head:K.from()==K.head;T<=i&&--i,t.splice(--T,2,new Dt(me?de:ee,me?ee:de))}}return new Tr(t,i)}function Zr(e,t){return new Tr([new Dt(e,t||e)],0)}function Jr(e){return e.text?Ue(e.from.line+e.text.length-1,L(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 Jr(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+=Jr(t).ch-t.to.ch),Ue(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Dt(Ro(n.anchor,t),Ro(n.head,t)))}return Or(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?Ue(i.line,e.ch-t.ch+i.ch):Ue(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Ue(e.first,0),T=n,N=0;N<t.length;N++){var K=t[N],Y=Oo(K.from,n,T),ee=Oo(Jr(K),n,T);if(n=K.to,T=ee,i=="around"){var de=e.sel.ranges[N],me=ft(de.head,de.anchor)<0;r[N]=new Dt(me?ee:Y,me?Y:ee)}else r[N]=new Dt(Y,Y)}return new Tr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=tr(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 Mo(e,t){return t.from.ch==0&&t.to.ch==0&&L(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ma(e,t,i,r){function n(et){return i?i[et]:null}function T(et,Qe,nt){ua(et,Qe,nt,r),qt(et,"change",et,t)}function N(et,Qe){for(var nt=[],ht=et;ht<Qe;++ht)nt.push(new li(ee[ht],n(ht),r));return nt}var K=t.from,Y=t.to,ee=t.text,de=He(e,K.line),me=He(e,Y.line),Se=L(ee),Ee=n(ee.length-1),Re=Y.line-K.line;if(t.full)e.insert(0,N(0,ee.length)),e.remove(ee.length,e.size-ee.length);else if(Mo(e,t)){var Be=N(0,ee.length-1);T(me,me.text,Ee),Re&&e.remove(K.line,Re),Be.length&&e.insert(K.line,Be)}else if(de==me)if(ee.length==1)T(de,de.text.slice(0,K.ch)+Se+de.text.slice(Y.ch),Ee);else{var je=N(1,ee.length-1);je.push(new li(Se+de.text.slice(Y.ch),Ee,r)),T(de,de.text.slice(0,K.ch)+ee[0],n(0)),e.insert(K.line+1,je)}else if(ee.length==1)T(de,de.text.slice(0,K.ch)+ee[0]+me.text.slice(Y.ch),n(0)),e.remove(K.line+1,Re);else{T(de,de.text.slice(0,K.ch)+ee[0],n(0)),T(me,Se+me.text.slice(Y.ch),Ee);var Je=N(1,ee.length-1);Re>1&&e.remove(K.line+1,Re-1),e.insert(K.line+1,Je)}qt(e,"change",e,t)}function Qr(e,t,i){function r(n,T,N){if(n.linked)for(var K=0;K<n.linked.length;++K){var Y=n.linked[K];if(Y.doc==T)continue;var ee=N&&Y.sharedHist;if(i&&!ee)continue;t(Y.doc,ee),r(Y.doc,n,ee)}}r(e,null,!0)}function Po(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:f)(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 Pa(e,t){var i={from:bi(t.from),to:Jr(t),text:xt(e,t.from,t.to)};return Uo(e,i,t.from.line,t.to.line+1),Qr(e,function(r){return Uo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=L(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),L(e.done);if(e.done.length&&!L(e.done).ranges)return L(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),L(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var T=+new Date,N,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>T-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))K=L(N.changes),ft(t.from,t.to)==0&&ft(t.from,K.to)==0?K.to=Jr(t):N.changes.push(Pa(e,t));else{var Y=L(n.done);for((!Y||!Y.ranges)&&Xn(e.sel,n.done),N={changes:[Pa(e,t)],generation:n.generation},n.done.push(N);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=T,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,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,T=r&&r.origin;i==n.lastSelOp||T&&n.lastSelOrigin==T&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==T||ml(e,T,L(n.done),t))?n.done[n.done.length-1]=t:Xn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=T,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Xn(e,t){var i=L(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Uo(e,t,i,r){var n=t["spans_"+e.id],T=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(N){N.markedSpans&&((n||(n=t["spans_"+e.id]={}))[T]=N.markedSpans),++T})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Fo(e,t){var i=yl(e,t),r=Ti(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var T=i[n],N=r[n];if(T&&N){e:for(var K=0;K<N.length;++K){for(var Y=N[K],ee=0;ee<T.length;++ee)if(T[ee].marker==Y.marker)continue e;T.push(Y)}}else N&&(i[n]=N)}return i}function Pi(e,t,i){for(var r=[],n=0;n<e.length;++n){var T=e[n];if(T.ranges){r.push(i?Tr.prototype.deepCopy.call(T):T);continue}var N=T.changes,K=[];r.push({changes:K});for(var Y=0;Y<N.length;++Y){var ee=N[Y],de=void 0;if(K.push({from:ee.from,to:ee.to,text:ee.text}),t)for(var me in ee)(de=me.match(/^spans_(\d+)$/))&&(ge(t,Number(de[1]))>-1&&(L(K)[me]=ee[me],delete ee[me]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var T=ft(t,n)<0;T!=ft(i,n)<0?(n=t,t=i):T!=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)),ir(e,new Tr([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),T=0;T<e.sel.ranges.length;T++)r[T]=Ia(e.sel.ranges[T],t[T],null,n);var N=Or(e.cm,r,e.sel.primIndex);ir(e,N,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,ir(e,Or(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){ir(e,Zr(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var T=0;T<n.length;T++)this.ranges[T]=new Dt(gt(e,n[T].anchor),gt(e,n[T].head))},origin:i&&i.origin};return ae(e,"beforeSelectionChange",e,r),e.cm&&ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Or(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=L(r);n&&n.ranges?(r[r.length-1]=t,$n(e,t,i)):ir(e,t,i)}function ir(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)),qt(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,T=0;T<t.ranges.length;T++){var N=t.ranges[T],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[T],Y=Zn(e,N.anchor,K&&K.anchor,i,r),ee=Zn(e,N.head,K&&K.head,i,r);(n||Y!=N.anchor||ee!=N.head)&&(n||(n=t.ranges.slice(0,T)),n[T]=new Dt(Y,ee))}return n?Or(e.cm,n,t.primIndex):t}function Ii(e,t,i,r,n){var T=He(e,t.line);if(T.markedSpans)for(var N=0;N<T.markedSpans.length;++N){var K=T.markedSpans[N],Y=K.marker,ee="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,de="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(ee?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(de?K.to>=t.ch:K.to>t.ch))){if(n&&(ae(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(T.markedSpans){--N;continue}else break;if(!Y.atomic)continue;if(i){var me=Y.find(r<0?1:-1),Se=void 0;if((r<0?de:ee)&&(me=Vo(e,me,-r,me&&me.line==t.line?T:null)),me&&me.line==t.line&&(Se=ft(me,i))&&(r<0?Se<0:Se>0))return Ii(e,me,t,r,n)}var Ee=Y.find(r<0?-1:1);return(r<0?ee:de)&&(Ee=Vo(e,Ee,r,Ee.line==t.line?T:null)),Ee?Ii(e,Ee,t,r,n):null}}return t}function Zn(e,t,i,r,n){var T=r||1,N=Ii(e,t,i,T,n)||!n&&Ii(e,t,i,T,!0)||Ii(e,t,i,-T,n)||!n&&Ii(e,t,i,-T,!0);return N||(e.cantEdit=!0,Ue(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?gt(e,Ue(t.line-1)):null:i>0&&t.ch==(r||He(e,t.line)).text.length?t.line<e.first+e.size-1?Ue(t.line+1,0):null:new Ue(t.line,t.ch+i)}function Xo(e){e.setSelection(Ue(e.firstLine(),0),Ue(e.lastLine()),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,T,N,K){n&&(r.from=gt(e,n)),T&&(r.to=gt(e,T)),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 $t(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&&Mn(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=[];Qr(e,function(n,T){!T&&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,T,N=e.sel,K=t=="undo"?n.done:n.undone,Y=t=="undo"?n.undone:n.done,ee=0;ee<K.length&&!(T=K[ee],i?T.ranges&&!T.equals(e.sel):!T.ranges);ee++);if(ee==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(T=K.pop(),T.ranges){if(Xn(T,Y),i&&!T.equals(e.sel)){ir(e,T,{clearRedo:!1});return}N=T}else if(r){K.push(T);return}else break;var de=[];Xn(N,Y),Y.push({changes:de,generation:n.generation}),n.generation=T.generation||++n.maxGeneration;for(var me=ie(e,"beforeChange")||e.cm&&ie(e.cm,"beforeChange"),Se=function(Be){var je=T.changes[Be];if(je.origin=t,me&&!Yo(e,je,!1))return K.length=0,{};de.push(Pa(e,je));var Je=Be?Ra(e,je):L(K);pn(e,je,Je,Fo(e,je)),!Be&&e.cm&&e.cm.scrollIntoView({from:je.from,to:Jr(je)});var et=[];Qr(e,function(Qe,nt){!nt&&ge(et,Qe.history)==-1&&(qo(Qe.history,je),et.push(Qe.history)),pn(Qe,je,null,Fo(Qe,je))})},Ee=T.changes.length-1;Ee>=0;--Ee){var Re=Se(Ee);if(Re)return Re.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Tr(k(e.sel.ranges,function(n){return new Dt(Ue(n.anchor.line+t,n.anchor.ch),Ue(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++)Yr(e.cm,r,"gutter")}}function pn(e,t,i,r){if(e.cm&&!e.cm.curOp)return $t(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:Ue(e.first,0),to:Ue(t.to.line+n,t.to.ch),text:[L(t.text)],origin:t.origin}}var T=e.lastLine();t.to.line>T&&(t={from:t.from,to:Ue(T,He(e,T).text.length),text:[t.text[0]],origin:t.origin}),t.removed=xt(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Ma(e,t,r),$n(e,i,Te),e.cantEdit&&Zn(e,Ue(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,T=t.from,N=t.to,K=!1,Y=T.line;e.options.lineWrapping||(Y=yt(Er(He(r,T.line))),r.iter(Y,N.line+1,function(Ee){if(Ee==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Z(e),Ma(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(Y,T.line+t.text.length,function(Ee){var Re=en(Ee);Re>n.maxLineLength&&(n.maxLine=Ee,n.maxLineLength=Re,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),aa(r,T.line),dn(e,400);var ee=t.text.length-(N.line-T.line)-1;t.full?cr(e):T.line==N.line&&t.text.length==1&&!Mo(e.doc,t)?Yr(e,T.line,"text"):cr(e,T.line,N.line+1,ee);var de=ie(e,"changes"),me=ie(e,"change");if(me||de){var Se={from:T,to:N,text:t.text,removed:t.removed,origin:t.origin};me&&qt(e,"change",e,Se),de&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Se)}e.display.selForContextMenu=null}function Bi(e,t,i,r,n){var T;r||(r=i),ft(r,i)<0&&(T=[r,i],i=T[0],r=T[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 T=e[n],N=!0;if(T.ranges){T.copied||(T=e[n]=T.deepCopy(),T.copied=!0);for(var K=0;K<T.ranges.length;K++)Jo(T.ranges[K].anchor,t,i,r),Jo(T.ranges[K].head,t,i,r);continue}for(var Y=0;Y<T.changes.length;++Y){var ee=T.changes[Y];if(i<ee.from.line)ee.from=Ue(ee.from.line+r,ee.from.ch),ee.to=Ue(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,T=t;return typeof t=="number"?T=He(e,Ei(e,t)):n=yt(t),n==null?null:(r(T,n)&&e.cm&&Yr(e.cm,n,i),T)}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,ot(n),qt(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 T=Math.min(t,n-e),N=r.height;if(r.removeInner(e,T),this.height-=N-r.height,n==T&&(this.children.splice(i--,1),r.parent=null),(t-=T)==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],T=n.chunkSize();if(e<=T){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 Y=new gn(n.lines.slice(K,K+=25));n.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}n.lines=n.lines.slice(0,N),this.maybeSpill()}break}e-=T}},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],T=n.chunkSize();if(e<T){var N=Math.min(t,T-e);if(n.iterN(e,N,i))return!0;if((t-=N)==0)break;e=0}else e-=T}}};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 T=nn(this);pt(i,Math.max(0,i.height-T)),e&&(vr(e,function(){es(e,i,-T),Yr(e,r,"widget")}),qt(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;Ir(this.doc,r)||pt(r,r.height+n),i&&vr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),qt(i,"lineWidgetChanged",i,e,yt(r))})},oe(yn);function es(e,t,i){Dr(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),T=e.cm;return T&&n.noHScroll&&(T.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,T&&!Ir(e,N)){var Y=Dr(N)<e.scrollTop;pt(N,N.height+nn(n)),Y&&wa(T,n.height),T.curOp.forceUpdate=!0}return!0}),T&&qt(T,"lineWidgetAdded",T,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&&qt(this,"clear",i.from,i.to)}for(var r=null,n=null,T=0;T<this.lines.length;++T){var N=this.lines[T],K=_r(N.markedSpans,this);e&&!this.collapsed?Yr(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&&!Ir(this.doc,N)&&e&&pt(N,_i(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Y=0;Y<this.lines.length;++Y){var ee=Er(this.lines[Y]),de=en(ee);de>e.display.maxLineLength&&(e.display.maxLine=ee,e.display.maxLineLength=de,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&&qt(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 T=this.lines[n],N=_r(T.markedSpans,this);if(N.from!=null&&(i=Ue(t?T:yt(T),N.from),e==-1))return i;if(N.to!=null&&(r=Ue(t?T:yt(T),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,T=yt(t.line),N=fa(r,T);if(N&&(no(N),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Ir(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var Y=nn(i)-K;Y&&pt(n,n.height+Y)}qt(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 Ui(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return $t(e.cm,Ui)(e,t,i,r,n);var T=new qr(e,n),N=ft(t,i);if(r&&F(r,T,!1),N>0||N==0&&T.clearWhenEmpty!==!1)return T;if(T.replacedWith&&(T.collapsed=!0,T.widgetNode=y("span",[T.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||T.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(T.widgetNode.insertLeft=!0)),T.collapsed){if(Pn(e,t.line,t,i,T)||t.line!=i.line&&Pn(e,i.line,t,i,T))throw new Error("Inserting collapsed marker partially overlapping an existing one");oa()}T.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,ee;if(e.iter(K,i.line+1,function(me){Y&&T.collapsed&&!Y.options.lineWrapping&&Er(me)==Y.display.maxLine&&(ee=!0),T.collapsed&&K!=t.line&&pt(me,0),sa(me,new ai(T,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),T.collapsed&&e.iter(t.line,i.line+1,function(me){Ir(e,me)&&pt(me,0)}),T.clearOnEnter&&Le(T,"beforeCursorEnter",function(){return T.clear()}),T.readOnly&&(Vr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),T.collapsed&&(T.id=++ts,T.atomic=!0),Y){if(ee&&(Y.curOp.updateMaxLine=!0),T.collapsed)cr(Y,t.line,i.line+1);else if(T.className||T.startStyle||T.endStyle||T.css||T.attributes||T.title)for(var de=t.line;de<=i.line;de++)Yr(Y,de,"text");T.atomic&&zo(Y.doc),qt(Y,"markerAdded",Y,T)}return T}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();qt(this,"clear")},bn.prototype.find=function(e,t){return this.primary.find(e,t)},oe(bn);function Sl(e,t,i,r,n){r=F(r),r.shared=!1;var T=[Ui(e,t,i,r,n)],N=T[0],K=r.widgetNode;return Qr(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),T.push(Ui(Y,gt(Y,t),gt(Y,i),r,n));for(var ee=0;ee<Y.linked.length;++ee)if(Y.linked[ee].isParent)return;N=L(T)}),new bn(T,N)}function rs(e){return e.findMarks(Ue(e.first,0),e.clipPos(Ue(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),T=e.clipPos(n.from),N=e.clipPos(n.to);if(ft(T,N)){var K=Ui(e,T,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],T=[n.primary.doc];Qr(n.primary.doc,function(Y){return T.push(Y)});for(var N=0;N<n.markers.length;N++){var K=n.markers[N];ge(T,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 T=Ue(i,0);this.sel=Zr(T),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)),Ma(this,{from:T,to:T,text:e}),ir(this,Zr(T),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=Bt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Zt(function(e){var t=Ue(this.first,0),i=this.first+this.size-1;Ni(this,{from:t,to:Ue(i,He(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&sn(this.cm,0,0),ir(this,Zr(t),Te)}),replaceRange:function(e,t,i,r){t=gt(this,t),i=i?gt(this,i):t,Bi(this,e,t,i,r)},getRange:function(e,t,i){var r=xt(this,gt(this,e),gt(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(xr(this,e))return He(this,e)},getLineNumber:function(e){return yt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=He(this,e)),Er(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return gt(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:Zt(function(e,t,i){Wo(this,gt(this,typeof e=="number"?Ue(e,t||0):e),null,i)}),setSelection:Zt(function(e,t,i){Wo(this,gt(this,e),gt(this,t||e),i)}),extendSelection:Zt(function(e,t,i){Yn(this,gt(this,e),t&&gt(this,t),i)}),extendSelections:Zt(function(e,t){jo(this,Fe(this,e),t)}),extendSelectionsBy:Zt(function(e,t){var i=k(this.sel.ranges,e);jo(this,Fe(this,i),t)}),setSelections:Zt(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new Dt(gt(this,e[n].anchor),gt(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),ir(this,Or(this.cm,r,t),i)}),addSelection:Zt(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Dt(gt(this,e),gt(this,t||e))),ir(this,Or(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=xt(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=xt(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:Zt(function(e,t,i){for(var r=[],n=this.sel,T=0;T<n.ranges.length;T++){var N=n.ranges[T];r[T]={from:N.from(),to:N.to(),text:this.splitLines(e[T]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),Y=r.length-1;Y>=0;Y--)Ni(this,r[Y]);K?Ho(this,K):this.cm&&Oi(this.cm)}),undo:Zt(function(){Jn(this,"undo")}),redo:Zt(function(){Jn(this,"redo")}),undoSelection:Zt(function(){Jn(this,"undo",!0)}),redoSelection:Zt(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),Qr(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:Pi(this.history.done),undone:Pi(this.history.undone)}},setHistory:function(e){var t=this.history=new Vn(this.history.maxGeneration);t.done=Pi(e.done.slice(0),null,!0),t.undone=Pi(e.undone.slice(0),null,!0)},setGutterMarker:Zt(function(e,t,i){return mn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Pe(n)&&(r.gutterMarkers=null),!0})}),clearGutter:Zt(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&mn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Pe(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!xr(this,e))return null;if(t=e,e=He(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:Zt(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(E(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:Zt(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",T=r[n];if(T)if(i==null)r[n]=null;else{var N=T.match(E(i));if(!N)return!1;var K=N.index+N[0].length;r[n]=T.slice(0,N.index)+(!N.index||K==T.length?"":" ")+T.slice(K)||null}else return!1;return!0})}),addLineWidget:Zt(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Ui(this,gt(this,e),gt(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=gt(this,e),Ui(this,e,e,i,"bookmark")},findMarksAt:function(e){e=gt(this,e);var t=[],i=He(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=gt(this,e),t=gt(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(T){var N=T.markedSpans;if(N)for(var K=0;K<N.length;K++){var Y=N[K];!(Y.to!=null&&n==e.line&&e.ch>=Y.to||Y.from==null&&n!=e.line||Y.from!=null&&n==t.line&&Y.from>=t.ch)&&(!i||i(Y.marker))&&r.push(Y.marker.parent||Y.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var T=n.text.length+r;if(T>e)return t=e,!0;e-=T,++i}),gt(this,Ue(i,t))},indexFromPos:function(e){e=gt(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(Bt(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(Bt(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 Ut&&(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];Qr(e,function(n){return r.push(n.id)},!0),e.history=new Vn(null),e.history.done=Pi(this.history.done,r),e.history.undone=Pi(this.history.undone,r)}},iterLinkedDocs:function(e){Qr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):it(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:Zt(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 Ll(e){var t=this;if(ns(t),J(t,e)||Gr(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,T=Array(n),N=0,K=function(){++N==n&&$t(t,function(){i=gt(t.doc,i);var Ee={from:i,to:i,text:t.doc.splitLines(T.filter(function(Re){return Re!=null}).join(t.doc.lineSeparator())),origin:"paste"};Ni(t.doc,Ee),Ho(t.doc,Zr(gt(t.doc,i),gt(t.doc,Jr(Ee))))})()},Y=function(Ee,Re){if(t.options.allowDropFileTypes&&ge(t.options.allowDropFileTypes,Ee.type)==-1){K();return}var Be=new FileReader;Be.onerror=function(){return K()},Be.onload=function(){var je=Be.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(je)){K();return}T[Re]=je,K()},Be.readAsText(Ee)},ee=0;ee<r.length;ee++)Y(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 de=e.dataTransfer.getData("Text");if(de){var me;if(t.state.draggingText&&!t.state.draggingText.copy&&(me=t.listSelections()),$n(t.doc,Zr(i,i)),me)for(var Se=0;Se<me.length;++Se)Bi(t.doc,"",me[Se].anchor,me[Se].head,"drag");t.replaceSelection(de,"around","paste"),t.display.input.focus()}}catch(Ee){}}}function Al(e,t){if(j&&(!e.state.draggingText||+new Date-is<100)){he(t);return}if(J(e,t)||Gr(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==",g&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),g&&i.parentNode.removeChild(i)}}function kl(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)),u(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 T=0;T<i.length;T++)e(i[T])})}var os=!1;function _l(){if(os)return;Dl(),os=!0}function Dl(){var e;Le(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),Le(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 ei={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++)ei[xn+48]=ei[xn+96]=String(xn);for(var Qn=65;Qn<=90;Qn++)ei[Qn]=String.fromCharCode(Qn);for(var En=1;En<=12;En++)ei[En+111]=ei[En+63235]="F"+En;var zr={};zr.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"},zr.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"},zr.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"},zr.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"]},zr.default=s?zr.macDefault:zr.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,T,N=0;N<t.length-1;N++){var K=t[N];if(/^(cmd|meta|m)$/i.test(K))T=!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),T&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Ml(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=k(i.split(" "),Ol),T=0;T<n.length;T++){var N=void 0,K=void 0;T==n.length-1?(K=n.join(" "),N=r):(K=n.slice(0,T+1).join(" "),N="...");var Y=t[K];if(!Y)t[K]=N;else if(Y!=N)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var ee in t)e[ee]=t[ee];return e}function Fi(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 Fi(e,t.fallthrough,i,r);for(var T=0;T<t.fallthrough.length;T++){var N=Fi(e,t.fallthrough[T],i,r);if(N)return N}}}function ss(e){var t=typeof e=="string"?e:ei[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),(p?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(p?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(g&&e.keyCode==34&&e.char)return!1;var i=ei[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"?zr[e]:e}function ji(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var T=t(i[n]);r.length&&ft(T.from,L(r).to)<=0;){var N=r.pop();if(ft(N.from,T.from)<0){T.from=N.from;break}}r.push(T)}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=Me(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ua(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Ue(t.line,r,i<0?"after":"before")}function Fa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var T=$e(i,t.doc.direction);if(T){var N=n<0?L(T):T[0],K=n<0==(N.level==1),Y=K?"after":"before",ee;if(N.level>0||t.doc.direction=="rtl"){var de=ki(t,i);ee=n<0?i.text.length-1:0;var me=Br(t,de,ee).top;ee=We(function(Se){return Br(t,de,Se).top==me},n<0==(N.level==1)?N.from:N.to-1,ee),Y=="before"&&(ee=Ba(i,ee,1))}else ee=n<0?N.to:N.from;return new Ue(r,ee,Y)}}return new Ue(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=$e(t,e.doc.direction);if(!n)return Ua(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var T=Ge(n,i.ch,i.sticky),N=n[T];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from<i.ch))return Ua(t,i,r);var K=function(Je,et){return Ba(t,Je instanceof Ue?Je.ch:Je,et)},Y,ee=function(Je){return e.options.lineWrapping?(Y=Y||ki(e,t),co(e,t,Y,Je)):{begin:0,end:t.text.length}},de=ee(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||N.level==1){var me=N.level==1==r<0,Se=K(i,me?1:-1);if(Se!=null&&(me?Se<=N.to&&Se<=de.end:Se>=N.from&&Se>=de.begin)){var Ee=me?"before":"after";return new Ue(i.line,Se,Ee)}}var Re=function(Je,et,Qe){for(var nt=function(It,Jt){return Jt?new Ue(i.line,K(It,1),"before"):new Ue(i.line,It,"after")};Je>=0&&Je<n.length;Je+=et){var ht=n[Je],st=et>0==(ht.level!=1),bt=st?Qe.begin:K(Qe.end,-1);if(ht.from<=bt&&bt<ht.to)return nt(bt,st);if(bt=st?ht.from:K(ht.to,-1),Qe.begin<=bt&&bt<Qe.end)return nt(bt,st)}},Be=Re(T+r,r,de);if(Be)return Be;var je=r>0?de.end:K(de.begin,-1);return je!=null&&!(r>0&&je==t.text.length)&&(Be=Re(r>0?0:n.length-1,r,ee(je)),Be)?Be: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=He(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Ue(t.head.line+1,0)}:{from:t.head,to:Ue(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return ji(e,function(t){return{from:Ue(t.from().line,0),to:gt(e.doc,Ue(t.to().line+1,0))}})},delLineLeft:function(e){return ji(e,function(t){return{from:Ue(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(Ue(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ue(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},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 T=i[n].from(),N=ne(e.getLine(T.line),T.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,T=He(e.doc,n.line).text;if(T){if(n.ch==T.length&&(n=new Ue(n.line,n.ch-1)),n.ch>0)n=new Ue(n.line,n.ch+1),e.replaceRange(T.charAt(n.ch-1)+T.charAt(n.ch-2),Ue(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=He(e.doc,n.line-1).text;N&&(n=new Ue(n.line,1),e.replaceRange(T.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),Ue(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=He(e.doc,t),r=Er(i);return r!=i&&(t=yt(r)),Fa(!0,e,r,t,1)}function Il(e,t){var i=He(e.doc,t),r=In(i);return r!=i&&(t=yt(r)),Fa(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=He(e.doc,i.line),n=$e(r,e.doc.direction);if(!n||n[0].level==0){var T=Math.max(i.ch,r.text.search(/\S/)),N=t.line==i.line&&t.ch<=T&&t.ch;return Ue(i.line,N?0:T,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)!=Ie}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=Fi(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&Fi(t,e.options.extraKeys,i,e)||Fi(t,e.options.keyMap,i,e)}var Bl=new ce;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"&&qt(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 Ul(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=P(),J(t,e))return;j&&U<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);g&&(ja=r?i:null,!r&&i==88&&!wt&&(s?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),_&&!s&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),qe(document,"keyup",i),qe(document,"mouseover",i))}Le(document,"keyup",i),Le(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(Gr(t.display,e)||J(t,e)||e.ctrlKey&&!e.altKey||s&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(g&&i==ja){ja=null,Q(e);return}if(g&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Ul(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&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,Gr(i,e)){I||(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),T=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,T,e))return;n==1?r?zl(t,r,T,e):pe(e)==i.scroller&&Q(e):n==2?(r&&Yn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(A?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var T="Click";return r=="double"?T="Double"+T:r=="triple"&&(T="Triple"+T),T=(t==1?"Left":t==2?"Middle":"Right")+T,Tn(e,ls(T,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)!=Ie}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 T=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=T?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=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=P();var n=Gl(e,i,r),T=e.doc.sel,N;e.options.dragDrop&&ke&&!e.isReadOnly()&&i=="single"&&(N=T.contains(t))>-1&&(ft((N=T.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,T=!1,N=$t(e,function(ee){I&&(n.scroller.draggable=!1),e.state.draggingText=!1,qe(n.wrapper.ownerDocument,"mouseup",N),qe(n.wrapper.ownerDocument,"mousemove",K),qe(n.scroller,"dragstart",Y),qe(n.scroller,"drop",N),T||(Q(ee),r.addNew||Yn(e.doc,i,null,null,r.extend),I&&!R||j&&U==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(ee){T=T||Math.abs(t.clientX-ee.clientX)+Math.abs(t.clientY-ee.clientY)>=10},Y=function(){return T=!0};I&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Le(n.wrapper.ownerDocument,"mouseup",N),Le(n.wrapper.ownerDocument,"mousemove",K),Le(n.scroller,"dragstart",Y),Le(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(Ue(t.line,0),gt(e.doc,Ue(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,T=e.doc;Q(t);var N,K,Y=T.sel,ee=Y.ranges;if(r.addNew&&!r.extend?(K=T.sel.contains(i),K>-1?N=ee[K]:N=new Dt(i,i)):(N=T.sel.primary(),K=T.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new Dt(i,i)),i=di(e,t,!0,!0),K=-1;else{var de=ys(e,i,r.unit);r.extend?N=Ia(N,de.anchor,de.head,r.extend):N=de}r.addNew?K==-1?(K=ee.length,ir(T,Or(e,ee.concat([N]),K),{scroll:!1,origin:"*mouse"})):ee.length>1&&ee[K].empty()&&r.unit=="char"&&!r.extend?(ir(T,Or(e,ee.slice(0,K).concat(ee.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=T.sel):Na(T,K,N,Oe):(K=0,ir(T,new Tr([N],0),Oe),Y=T.sel);var me=i;function Se(Qe){if(ft(me,Qe)==0)return;if(me=Qe,r.unit=="rectangle"){for(var nt=[],ht=e.options.tabSize,st=ne(He(T,i.line).text,i.ch,ht),bt=ne(He(T,Qe.line).text,Qe.ch,ht),It=Math.min(st,bt),Jt=Math.max(st,bt),Ft=Math.min(i.line,Qe.line),yr=Math.min(e.lastLine(),Math.max(i.line,Qe.line));Ft<=yr;Ft++){var pr=He(T,Ft).text,Gt=Ae(pr,It,ht);It==Jt?nt.push(new Dt(Ue(Ft,Gt),Ue(Ft,Gt))):pr.length>Gt&&nt.push(new Dt(Ue(Ft,Gt),Ue(Ft,Ae(pr,Jt,ht))))}nt.length||nt.push(new Dt(i,i)),ir(T,Or(e,Y.ranges.slice(0,K).concat(nt),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Qe)}else{var mr=N,er=ys(e,Qe,r.unit),Yt=mr.anchor,zt;ft(er.anchor,Yt)>0?(zt=er.head,Yt=ii(mr.from(),er.anchor)):(zt=er.anchor,Yt=xi(mr.to(),er.head));var jt=Y.ranges.slice(0);jt[K]=Xl(e,new Dt(gt(T,Yt),zt)),ir(T,Or(e,jt,K),Oe)}}var Ee=n.wrapper.getBoundingClientRect(),Re=0;function Be(Qe){var nt=++Re,ht=di(e,Qe,!0,r.unit=="rectangle");if(!ht)return;if(ft(ht,me)!=0){e.curOp.focus=P(),Se(ht);var st=Hn(n,T);(ht.line>=st.to||ht.line<st.from)&&setTimeout($t(e,function(){Re==nt&&Be(Qe)}),150)}else{var bt=Qe.clientY<Ee.top?-20:Qe.clientY>Ee.bottom?20:0;bt&&setTimeout($t(e,function(){if(Re!=nt)return;n.scroller.scrollTop+=bt,Be(Qe)}),50)}}function je(Qe){e.state.selectingText=!1,Re=Infinity,Qe&&(Q(Qe),n.input.focus()),qe(n.wrapper.ownerDocument,"mousemove",Je),qe(n.wrapper.ownerDocument,"mouseup",et),T.history.lastSelOrigin=null}var Je=$t(e,function(Qe){Qe.buttons===0||!ye(Qe)?je(Qe):Be(Qe)}),et=$t(e,je);e.state.selectingText=et,Le(n.wrapper.ownerDocument,"mousemove",Je),Le(n.wrapper.ownerDocument,"mouseup",et)}function Xl(e,t){var i=t.anchor,r=t.head,n=He(e.doc,i.line);if(ft(i,r)==0&&i.sticky==r.sticky)return t;var T=$e(n);if(!T)return t;var N=Ge(T,i.ch,i.sticky),K=T[N];if(K.from!=i.ch&&K.to!=i.ch)return t;var Y=N+(K.from==i.ch==(K.level!=1)?0:1);if(Y==0||Y==T.length)return t;var ee;if(r.line!=i.line)ee=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var de=Ge(T,r.ch,r.sticky),me=de-N||(r.ch-i.ch)*(K.level==1?-1:1);de==Y-1||de==Y?ee=me<0:ee=me>0}var Se=T[Y+(ee?-1:0)],Ee=ee==(Se.level==1),Re=Ee?Se.from:Se.to,Be=Ee?"after":"before";return i.ch==Re&&i.sticky==Be?t:new Dt(new Ue(i.line,Re,Be),r)}function bs(e,t,i,r){var n,T;if(t.touches)n=t.touches[0].clientX,T=t.touches[0].clientY;else try{n=t.clientX,T=t.clientY}catch(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(T>K.bottom||!ie(e,i))return se(t);T-=K.top-N.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var ee=N.gutters.childNodes[Y];if(ee&&ee.getBoundingClientRect().right>=n){var de=kt(e.doc,T),me=e.display.gutterSpecs[Y];return ae(e,i,e,de,me.className,t),se(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(Gr(e.display,t)||Yl(e,t))return;if(J(e,t,"contextmenu"))return;A||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,T,N){e.defaults[r]=n,T&&(t[r]=N?function(K,Y,ee){ee!=Wi&&T(K,Y,ee)}:T)}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 T=[],N=r.doc.first;r.doc.iter(function(Y){for(var ee=0;;){var de=Y.text.indexOf(n,ee);if(de==-1)break;ee=de+n.length,T.push(Ue(N,de))}N++});for(var K=T.length-1;K>=0;K--)Bi(r.doc,n,T[K],Ue(T[K].line,T[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,T){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),T!=Wi&&r.refresh()}),i("specialCharPlaceholder",Pt,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",!C),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),cn(r)},!0),i("keyMap","default",function(r,n,T){var N=qn(n),K=T!=Wi&&qn(T);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 Mi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Mi(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,T=t?Le:qe;T(e.display.scroller,"dragstart",n.start),T(e.display.scroller,"dragenter",n.enter),T(e.display.scroller,"dragover",n.over),T(e.display.scroller,"dragleave",n.leave),T(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(f(e.display.wrapper,"CodeMirror-wrap"),Nn(e)),Ea(e),cr(e),an(e),setTimeout(function(){return Mi(e)},100)}function Ut(e,t){var i=this;if(!(this instanceof Ut))return new Ut(e,t);this.options=t=t?F(t):{},F(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 Ut.inputStyles[t.inputStyle](this),T=this.display=new hl(e,r,n,t);T.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 ce,keySeq:null,specialChars:null},t.autofocus&&!o&&T.input.focus(),j&&U<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),_l(),mi(this),this.curOp.forceUpdate=!0,Po(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);Ao(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);gi(this),I&&t.lineWrapping&&getComputedStyle(T.lineDiv).textRendering=="optimizelegibility"&&(T.lineDiv.style.textRendering="auto")}Ut.defaults=Ss,Ut.optionHandlers=ta;function Ql(e){var t=e.display;Le(t.scroller,"mousedown",$t(e,vs)),j&&U<11?Le(t.scroller,"dblclick",$t(e,function(Y){if(J(e,Y))return;var ee=di(e,Y);if(!ee||Ha(e,Y)||Gr(e.display,Y))return;Q(Y);var de=e.findWordAt(ee);Yn(e.doc,de.anchor,de.head)})):Le(t.scroller,"dblclick",function(Y){return J(e,Y)||Q(Y)}),Le(t.scroller,"contextmenu",function(Y){return xs(e,Y)}),Le(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||xs(e,Y)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function T(Y){if(Y.touches.length!=1)return!1;var ee=Y.touches[0];return ee.radiusX<=1&&ee.radiusY<=1}function N(Y,ee){if(ee.left==null)return!0;var de=ee.left-Y.left,me=ee.top-Y.top;return de*de+me*me>20*20}Le(t.scroller,"touchstart",function(Y){if(!J(e,Y)&&!T(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(i);var ee=+new Date;t.activeTouch={start:ee,moved:!1,prev:ee-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),Le(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Le(t.scroller,"touchend",function(Y){var ee=t.activeTouch;if(ee&&!Gr(t,Y)&&ee.left!=null&&!ee.moved&&new Date-ee.start<300){var de=e.coordsChar(t.activeTouch,"page"),me;!ee.prev||N(ee,ee.prev)?me=new Dt(de,de):!ee.prev.prev||N(ee,ee.prev.prev)?me=e.findWordAt(de):me=new Dt(Ue(de.line,0),gt(e.doc,Ue(de.line+1,0))),e.setSelection(me.anchor,me.head),e.focus(),Q(Y)}n()}),Le(t.scroller,"touchcancel",n),Le(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ln(e,t.scroller.scrollTop),fi(e,t.scroller.scrollLeft,!0),ae(e,"scroll",e))}),Le(t.scroller,"mousewheel",function(Y){return Do(e,Y)}),Le(t.scroller,"DOMMouseScroll",function(Y){return Do(e,Y)}),Le(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){J(e,Y)||he(Y)},over:function(Y){J(e,Y)||(kl(e,Y),he(Y))},start:function(Y){return Al(e,Y)},drop:$t(e,Ll),leave:function(Y){J(e,Y)||ns(e)}};var K=t.input.getField();Le(K,"keyup",function(Y){return ms.call(e,Y)}),Le(K,"keydown",$t(e,ps)),Le(K,"keypress",$t(e,gs)),Le(K,"focus",function(Y){return Ta(e,Y)}),Le(K,"blur",function(Y){return Ri(e,Y)})}var Ga=[];Ut.defineInitHook=function(e){return Ga.push(e)};function Ln(e,t,i,r){var n=e.doc,T;i==null&&(i="add"),i=="smart"&&(n.mode.indent?T=Lr(e,t).state:i="prev");var N=e.options.tabSize,K=He(n,t),Y=ne(K.text,null,N);K.stateAfter&&(K.stateAfter=null);var ee=K.text.match(/^\s*/)[0],de;if(!r&&!/\S/.test(K.text))de=0,i="not";else if(i=="smart"&&(de=n.mode.indent(T,K.text.slice(ee.length),K.text),de==Ie||de>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?de=ne(He(n,t-1).text,null,N):de=0:i=="add"?de=Y+e.options.indentUnit:i=="subtract"?de=Y-e.options.indentUnit:typeof i=="number"&&(de=Y+i),de=Math.max(0,de);var me="",Se=0;if(e.options.indentWithTabs)for(var Ee=Math.floor(de/N);Ee;--Ee)Se+=N,me+=" ";if(Se<de&&(me+=W(de-Se)),me!=ee)return Bi(n,me,Ue(t,0),Ue(t,ee.length),"+input"),K.stateAfter=null,!0;for(var Re=0;Re<n.sel.ranges.length;Re++){var Be=n.sel.ranges[Re];if(Be.head.line==t&&Be.head.ch<ee.length){var je=Ue(t,ee.length);Na(n,Re,new Dt(je,je));break}}}var Mr=null;function ra(e){Mr=e}function za(e,t,i,r,n){var T=e.doc;e.display.shift=!1,r||(r=T.sel);var N=+new Date-200,K=n=="paste"||e.state.pasteIncoming>N,Y=it(t),ee=null;if(K&&r.ranges.length>1)if(Mr&&Mr.text.join(`
`)==t){if(r.ranges.length%Mr.text.length==0){ee=[];for(var de=0;de<Mr.text.length;de++)ee.push(T.splitLines(Mr.text[de]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(ee=k(Y,function(Je){return[Je]}));for(var me=e.curOp.updateInput,Se=r.ranges.length-1;Se>=0;Se--){var Ee=r.ranges[Se],Re=Ee.from(),Be=Ee.to();Ee.empty()&&(i&&i>0?Re=Ue(Re.line,Re.ch-i):e.state.overwrite&&!K?Be=Ue(Be.line,Math.min(He(T,Be.line).text.length,Be.ch+L(Y).length)):K&&Mr&&Mr.lineWise&&Mr.text.join(`
`)==Y.join(`
`)&&(Re=Be=Ue(Re.line,0)));var je={from:Re,to:Be,text:ee?ee[Se%ee.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>N?"cut":"+input")};Ni(e.doc,je),qt(e,"inputRead",e,je)}t&&!K&&Cs(e,t),Oi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=me),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 T=e.getModeAt(n.head),N=!1;if(T.electricChars){for(var K=0;K<T.electricChars.length;K++)if(t.indexOf(T.electricChars.charAt(K))>-1){N=Ln(e,n.head.line,"smart");break}}else T.electricInput&&(T.electricInput.test(He(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=Ln(e,n.head.line,"smart")));N&&qt(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,T={anchor:Ue(n,0),head:Ue(n+1,0)};i.push(T),t.push(e.getRange(T.anchor,T.head))}return{text:t,ranges:i}}function Ls(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){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 I?e.style.width="1000px":e.setAttribute("wrap","off"),x&&(e.style.border="1px solid black"),Ls(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 T=this.options,N=T[r];if(T[r]==n&&r!="mode")return;T[r]=n,t.hasOwnProperty(r)&&$t(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,T=0;T<n.length;++T)if(n[T]==r||n[T].name==r)return n.splice(T,1),!0},addOverlay:lr(function(r,n){var T=r.token?r:e.getMode(this.options,r);if(T.startState)throw new Error("Overlays may not be stateful.");H(this.state.overlays,{mode:T,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(N){return N.priority}),this.state.modeGen++,cr(this)}),removeOverlay:lr(function(r){for(var n=this.state.overlays,T=0;T<n.length;++T){var N=n[T].modeSpec;if(N==r||typeof r=="string"&&N.name==r){n.splice(T,1),this.state.modeGen++,cr(this);return}}}),indentLine:lr(function(r,n,T){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),xr(this.doc,r)&&Ln(this,r,n,T)}),indentSelection:lr(function(r){for(var n=this.doc.sel.ranges,T=-1,N=0;N<n.length;N++){var K=n[N];if(K.empty())K.head.line>T&&(Ln(this,K.head.line,r,!0),T=K.head.line,N==this.doc.sel.primIndex&&Oi(this));else{var Y=K.from(),ee=K.to(),de=Math.max(T,Y.line);T=Math.min(this.lastLine(),ee.line-(ee.ch?0:1))+1;for(var me=de;me<T;++me)Ln(this,me,r);var Se=this.doc.sel.ranges;Y.ch==0&&n.length==Se.length&&Se[N].from().ch>0&&Na(this.doc,N,new Dt(Y,Se[N].to()),Te)}}}),getTokenAt:function(r,n){return kn(this,r,n)},getLineTokens:function(r,n){return kn(this,Ue(r),n,!0)},getTokenTypeAt:function(r){r=gt(this.doc,r);var n=ni(this,He(this.doc,r.line)),T=0,N=(n.length-1)/2,K=r.ch,Y;if(K==0)Y=n[2];else for(;;){var ee=T+N>>1;if((ee?n[ee*2-1]:0)>=K)N=ee;else if(n[ee*2+1]<K)T=ee+1;else{Y=n[ee*2+2];break}}var de=Y?Y.indexOf("overlay "):-1;return de<0?Y:de==0?null:Y.slice(0,de-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 T=[];if(!i.hasOwnProperty(n))return T;var N=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")N[K[n]]&&T.push(N[K[n]]);else if(K[n])for(var Y=0;Y<K[n].length;Y++){var ee=N[K[n][Y]];ee&&T.push(ee)}else K.helperType&&N[K.helperType]?T.push(N[K.helperType]):N[K.name]&&T.push(N[K.name]);for(var de=0;de<N._global.length;de++){var me=N._global[de];me.pred(K,this)&&ge(T,me.val)==-1&&T.push(me.val)}return T},getStateAfter:function(r,n){var T=this.doc;return r=Ei(T,r==null?T.first+T.size-1:r),Lr(this,r+1,n).state},cursorCoords:function(r,n){var T,N=this.doc.sel.primary();return r==null?T=N.head:typeof r=="object"?T=gt(this.doc,r):T=r?N.from():N.to(),Rr(this,T,n||"page")},charCoords:function(r,n){return ma(this,gt(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,kt(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,T){var N=!1,K;if(typeof r=="number"){var Y=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>Y&&(r=Y,N=!0),K=He(this.doc,r)}else K=r;return Un(this,K,{top:0,left:0},n||"page",T||N).top+(N?this.doc.height-Dr(K):0)},defaultTextHeight:function(){return _i(this.display)},defaultCharWidth:function(){return Di(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,T,N,K){var Y=this.display;r=Rr(this,gt(this.doc,r));var ee=r.bottom,de=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),Y.sizer.appendChild(n),N=="over")ee=r.top;else if(N=="above"||N=="near"){var me=Math.max(Y.wrapper.clientHeight,this.doc.height),Se=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>me)&&r.top>n.offsetHeight?ee=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=me&&(ee=r.bottom),de+n.offsetWidth>Se&&(de=Se-n.offsetWidth)}n.style.top=ee+"px",n.style.left=n.style.right="",K=="right"?(de=Y.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?de=0:K=="middle"&&(de=(Y.sizer.clientWidth-n.offsetWidth)/2),n.style.left=de+"px"),T&&Zs(this,{left:de,top:ee,right:de+n.offsetWidth,bottom:ee+n.offsetHeight})},triggerOnKeyDown:lr(ps),triggerOnKeyPress:lr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:lr(vs),execCommand:function(r){if(Sn.hasOwnProperty(r))return Sn[r].call(null,this)},triggerElectric:lr(function(r){Cs(this,r)}),findPosH:function(r,n,T,N){var K=1;n<0&&(K=-1,n=-n);for(var Y=gt(this.doc,r),ee=0;ee<n&&!(Y=Ka(this.doc,Y,K,T,N),Y.hitSide);++ee);return Y},moveH:lr(function(r,n){var T=this;this.extendSelectionsBy(function(N){return T.display.shift||T.doc.extend||N.empty()?Ka(T.doc,N.head,r,n,T.options.rtlMoveVisually):r<0?N.from():N.to()},Ce)}),deleteH:lr(function(r,n){var T=this.doc.sel,N=this.doc;T.somethingSelected()?N.replaceSelection("",null,"+delete"):ji(this,function(K){var Y=Ka(N,K.head,r,n,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,n,T,N){var K=1,Y=N;n<0&&(K=-1,n=-n);for(var ee=gt(this.doc,r),de=0;de<n;++de){var me=Rr(this,ee,"div");if(Y==null?Y=me.left:me.left=Y,ee=ks(this,me,K,T),ee.hitSide)break}return ee},moveV:lr(function(r,n){var T=this,N=this.doc,K=[],Y=!this.display.shift&&!N.extend&&N.sel.somethingSelected();if(N.extendSelectionsBy(function(de){if(Y)return r<0?de.from():de.to();var me=Rr(T,de.head,"div");de.goalColumn!=null&&(me.left=de.goalColumn),K.push(me.left);var Se=ks(T,me,r,n);return n=="page"&&de==N.sel.primary()&&wa(T,ma(T,Se,"div").top-me.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,T=He(n,r.line).text,N=r.ch,K=r.ch;if(T){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==T.length)&&N?--N:++K;for(var ee=T.charAt(N),de=we(ee,Y)?function(me){return we(me,Y)}:/\s/.test(ee)?function(me){return/\s/.test(me)}:function(me){return!/\s/.test(me)&&!we(me)};N>0&&de(T.charAt(N-1));)--N;for(;K<T.length&&de(T.charAt(K));)++K}return new Dt(Ue(r.line,N),Ue(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):f(this.display.cursorDiv,"CodeMirror-overwrite"),ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==P()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:lr(function(r,n){sn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-Nr(this)-this.display.barHeight,width:r.scrollWidth-Nr(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:ui(this)}},scrollIntoView:lr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Ue(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Js(this,r):xo(this,r.from,r.to,r.margin)}),setSize:lr(function(r,n){var T=this,N=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};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(Y){if(Y.widgets){for(var ee=0;ee<Y.widgets.length;ee++)if(Y.widgets[ee].noHScroll){Yr(T,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:lr(function(){var r=this.display.cachedTextHeight;cr(this),this.curOp.forceUpdate=!0,an(this),sn(this,this.doc.scrollLeft,this.doc.scrollTop),ka(this.display),(r==null||Math.abs(r-_i(this.display))>.5||this.options.lineWrapping)&&Ea(this),ae(this,"refresh",this)}),swapDoc:lr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Po(this,r),an(this),this.display.input.reset(),sn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,qt(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,T){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=T},e.registerGlobalHelper=function(r,n,T,N){e.registerHelper(r,n,N),i[r]._global.push({pred:T,val:N})}}function Ka(e,t,i,r,n){var T=t,N=i,K=He(e,t.line),Y=n&&e.direction=="rtl"?-i:i;function ee(){var et=t.line+Y;return et<e.first||et>=e.first+e.size?!1:(t=new Ue(et,t.ch,t.sticky),K=He(e,et))}function de(et){var Qe;if(r=="codepoint"){var nt=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(nt)?Qe=null:Qe=new Ue(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(nt>=55296&&nt<56320?2:1))),-i)}else n?Qe=Pl(e.cm,K,t,i):Qe=Ua(K,t,i);if(Qe==null)if(!et&&ee())t=Fa(n,e.cm,K,t.line,Y);else return!1;else t=Qe;return!0}if(r=="char"||r=="codepoint")de();else if(r=="column")de(!0);else if(r=="word"||r=="group")for(var me=null,Se=r=="group",Ee=e.cm&&e.cm.getHelper(t,"wordChars"),Re=!0;!(i<0&&!de(!Re));Re=!1){var Be=K.text.charAt(t.ch)||`
`,je=we(Be,Ee)?"w":Se&&Be==`
`?"n":!Se||/\s/.test(Be)?null:"p";if(Se&&!Re&&!je&&(je="s"),me&&me!=je){i<0&&(i=1,de(),t.sticky="after");break}if(je&&(me=je),i>0&&!de(!Re))break}var Je=Zn(e,t,T,N,!0);return ri(T,Je)&&(Je.hitSide=!0),Je}function ks(e,t,i,r){var n=e.doc,T=t.left,N;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*_i(e.display),3);N=(i>0?t.bottom:t.top)+i*Y}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var ee;!(ee=va(e,T,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 ce,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;Ls(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function T(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}Le(n,"paste",function(K){if(!T(K)||J(r,K)||Ts(K,r))return;U<=11&&setTimeout($t(r,function(){return t.updateFromDOM()}),20)}),Le(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),Le(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),Le(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Le(n,"touchstart",function(){return i.forceCompositionEnd()}),Le(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(K){if(!T(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 Y=ws(r);ra({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,Te),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var ee=Mr.text.join(`
`);if(K.clipboardData.setData("Text",ee),K.clipboardData.getData("Text")==ee){K.preventDefault();return}}var de=As(),me=de.firstChild;r.display.lineSpace.insertBefore(de,r.display.lineSpace.firstChild),me.value=Mr.text.join(`
`);var Se=document.activeElement;te(me),setTimeout(function(){r.display.lineSpace.removeChild(de),Se.focus(),Se==n&&i.showPrimarySelection()},50)}Le(n,"copy",N),Le(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 T=ia(t,e.anchorNode,e.anchorOffset),N=ia(t,e.focusNode,e.focusOffset);if(T&&!T.bad&&N&&!N.bad&&ft(ii(T,N),r)==0&&ft(xi(T,N),n)==0)return;var K=t.display.view,Y=r.line>=t.display.viewFrom&&_s(t,r)||{node:K[0].measure.map[2],offset:0},ee=n.line<t.display.viewTo&&_s(t,n);if(!ee){var de=K[K.length-1].measure,me=de.maps?de.maps[de.maps.length-1]:de.map;ee={node:me[me.length-1],offset:me[me.length-2]-me[me.length-3]}}if(!Y||!ee){e.removeAllRanges();return}var Se=e.rangeCount&&e.getRangeAt(0),Ee;try{Ee=c(Y.node,Y.offset,ee.offset,ee.node)}catch(Re){}Ee&&(!_&&t.state.focused?(e.collapse(Y.node,Y.offset),Ee.collapsed||(e.removeAllRanges(),e.addRange(Ee))):(e.removeAllRanges(),e.addRange(Ee)),Se&&e.anchorNode==null?e.addRange(Se):_&&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){u(this.cm.display.cursorDiv,e.cursors),u(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 S(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(l&&v&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=ia(t,e.anchorNode,e.anchorOffset),r=ia(t,e.focusNode,e.focusOffset);i&&r&&vr(t,function(){ir(t.doc,Zr(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=Ue(r.line-1,He(e.doc,r.line-1).length)),n.ch==He(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Ue(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var T,N,K;r.line==t.viewFrom||(T=ci(e,r.line))==0?(N=yt(t.view[0].line),K=t.view[0].node):(N=yt(t.view[T].line),K=t.view[T-1].node.nextSibling);var Y=ci(e,n.line),ee,de;if(Y==t.view.length-1?(ee=t.viewTo-1,de=t.lineDiv.lastChild):(ee=yt(t.view[Y+1].line)-1,de=t.view[Y+1].node.previousSibling),!K)return!1;for(var me=e.doc.splitLines(tu(e,K,de,N,ee)),Se=xt(e.doc,Ue(N,0),Ue(ee,He(e.doc,ee).text.length));me.length>1&&Se.length>1;)if(L(me)==L(Se))me.pop(),Se.pop(),ee--;else if(me[0]==Se[0])me.shift(),Se.shift(),N++;else break;for(var Ee=0,Re=0,Be=me[0],je=Se[0],Je=Math.min(Be.length,je.length);Ee<Je&&Be.charCodeAt(Ee)==je.charCodeAt(Ee);)++Ee;for(var et=L(me),Qe=L(Se),nt=Math.min(et.length-(me.length==1?Ee:0),Qe.length-(Se.length==1?Ee:0));Re<nt&&et.charCodeAt(et.length-Re-1)==Qe.charCodeAt(Qe.length-Re-1);)++Re;if(me.length==1&&Se.length==1&&N==r.line)for(;Ee&&Ee>r.ch&&et.charCodeAt(et.length-Re-1)==Qe.charCodeAt(Qe.length-Re-1);)Ee--,Re++;me[me.length-1]=et.slice(0,et.length-Re).replace(/^\u200b+/,""),me[0]=me[0].slice(Ee).replace(/\u200b+$/,"");var ht=Ue(N,Ee),st=Ue(ee,Se.length?L(Se).length-Re:0);if(me.length>1||me[0]||ft(ht,st))return Bi(e.doc,me,ht,st,"+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()||$t(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 _s(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=He(e.doc,t.line),n=eo(i,r,t.line),T=$e(r,e.doc.direction),N="left";if(T){var K=Ge(T,t.ch);N=K%2?"right":"left"}var Y=io(n.map,t.ch,N);return Y.offset=Y.collapse=="right"?Y.end:Y.start,Y}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hi(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var T="",N=!1,K=e.doc.lineSeparator(),Y=!1;function ee(Ee){return function(Re){return Re.id==Ee}}function de(){N&&(T+=K,Y&&(T+=K),N=Y=!1)}function me(Ee){Ee&&(de(),T+=Ee)}function Se(Ee){if(Ee.nodeType==1){var Re=Ee.getAttribute("cm-text");if(Re){me(Re);return}var Be=Ee.getAttribute("cm-marker"),je;if(Be){var Je=e.findMarks(Ue(r,0),Ue(n+1,0),ee(+Be));Je.length&&(je=Je[0].find(0))&&me(xt(e.doc,je.from,je.to).join(K));return}if(Ee.getAttribute("contenteditable")=="false")return;var et=/^(pre|div|p|li|table|br)$/i.test(Ee.nodeName);if(!/^br$/i.test(Ee.nodeName)&&Ee.textContent.length==0)return;et&&de();for(var Qe=0;Qe<Ee.childNodes.length;Qe++)Se(Ee.childNodes[Qe]);/^(pre|p)$/i.test(Ee.nodeName)&&(Y=!0),et&&(N=!0)}else Ee.nodeType==3&&me(Ee.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Se(t),t==i);)t=t.nextSibling,Y=!1;return T}function ia(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return Hi(e.clipPos(Ue(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var n=0;n<e.display.view.length;n++){var T=e.display.view[n];if(T.node==r)return ru(T,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!S(r,t))return Hi(Ue(yt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var T=e.rest?L(e.rest):e.line;return Hi(Ue(yt(T),T.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 Y=e.measure,ee=Y.maps;function de(je,Je,et){for(var Qe=-1;Qe<(ee?ee.length:0);Qe++)for(var nt=Qe<0?Y.map:ee[Qe],ht=0;ht<nt.length;ht+=3){var st=nt[ht+2];if(st==je||st==Je){var bt=yt(Qe<0?e.line:e.rest[Qe]),It=nt[ht]+et;return(et<0||st!=je)&&(It=nt[ht+(et?1:0)]),Ue(bt,It)}}}var me=de(N,K,i);if(me)return Hi(me,n);for(var Se=K.nextSibling,Ee=N?N.nodeValue.length-i:0;Se;Se=Se.nextSibling){if(me=de(Se,Se.firstChild,0),me)return Hi(Ue(me.line,me.ch-Ee),n);Ee+=Se.textContent.length}for(var Re=K.previousSibling,Be=i;Re;Re=Re.previousSibling){if(me=de(Re,Re.firstChild,-1),me)return Hi(Ue(me.line,me.ch+Be),n);Be+=Re.textContent.length}}var Wt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ce,this.hasSelection=!1,this.composing=null};Wt.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),x&&(n.style.width="0px"),Le(n,"input",function(){j&&U>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Le(n,"paste",function(N){if(J(r,N)||Ts(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function T(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(`
`),te(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Le(n,"cut",T),Le(n,"copy",T),Le(e.scroller,"paste",function(N){if(Gr(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)}),Le(e.lineSpace,"selectstart",function(N){Gr(e,N)||Q(N)}),Le(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"})}}),Le(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Wt.prototype.createField=function(e){this.wrapper=As(),this.textarea=this.wrapper.firstChild},Wt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Wt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Rr(e,i.sel.primary().head,"div"),T=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-T.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-T.left))}return r},Wt.prototype.showSelection=function(e){var t=this.cm,i=t.display;u(i.cursorDiv,e.cursors),u(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Wt.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&&te(this.textarea),j&&U>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",j&&U>=9&&(this.hasSelection=null))},Wt.prototype.getField=function(){return this.textarea},Wt.prototype.supportsTouch=function(){return!1},Wt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},Wt.prototype.blur=function(){this.textarea.blur()},Wt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Wt.prototype.receivedFocus=function(){this.slowPoll()},Wt.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()})},Wt.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)},Wt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ye(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&&U>=9&&this.hasSelection===n||s&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var T=n.charCodeAt(0);if(T==8203&&!r&&(r="\u200B"),T==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,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},Wt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Wt.prototype.onKeyPress=function(){j&&U>=9&&(this.hasSelection=null),this.fastPoll()},Wt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var T=di(i,e),N=r.scroller.scrollTop;if(!T||g)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(T)==-1&&$t(i,ir)(i.doc,Zr(T),Te);var Y=n.style.cssText,ee=t.wrapper.style.cssText,de=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-de.top-5)+"px; left: "+(e.clientX-de.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 me;I&&(me=window.scrollY),r.input.focus(),I&&window.scrollTo(null,me),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=Ee,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function Se(){if(n.selectionStart!=null){var Be=i.somethingSelected(),je="\u200B"+(Be?n.value:"");n.value="\u21DA",n.value=je,t.prevInput=Be?"":"\u200B",n.selectionStart=1,n.selectionEnd=je.length,r.selForContextMenu=i.doc.sel}}function Ee(){if(t.contextMenuPending!=Ee)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=ee,n.style.cssText=Y,j&&U<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!j||j&&U<9)&&Se();var Be=0,je=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?$t(i,Xo)(i):Be++<10?r.detectingSelectAll=setTimeout(je,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(je,200)}}if(j&&U>=9&&Se(),A){he(e);var Re=function(){qe(window,"mouseup",Re),setTimeout(Ee,20)};Le(window,"mouseup",Re)}else setTimeout(Ee,50)},Wt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Wt.prototype.setUneditable=function(){},Wt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?F(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=P();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(Le(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var T=e.form;n=T.submit;try{var N=T.submit=function(){r(),T.submit=n,T.submit(),T.submit=N}}catch(Y){}}t.finishInit=function(Y){Y.save=r,Y.getTextArea=function(){return e},Y.toTextArea=function(){Y.toTextArea=isNaN,r(),e.parentNode.removeChild(Y.getWrapperElement()),e.style.display="",e.form&&(qe(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Ut(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function nu(e){e.off=qe,e.on=Le,e.wheelEventPixels=dl,e.Doc=fr,e.splitLines=it,e.countColumn=ne,e.findColumn=Ae,e.isWordChar=be,e.Pass=Ie,e.signal=ae,e.Line=li,e.changeEnd=Jr,e.scrollbarModel=To,e.Pos=Ue,e.cmpPos=ft,e.modes=Nt,e.mimeModes=St,e.resolveMode=Kt,e.getMode=tr,e.modeExtensions=or,e.extendMode=Pr,e.copyState=Vt,e.startState=Mt,e.innerMode=At,e.commands=Sn,e.keyMap=zr,e.keyName=us,e.isModifierKey=ss,e.lookupKey=Fi,e.normalizeKeyMap=Ml,e.StringStream=vt,e.SharedTextMarker=bn,e.TextMarker=qr,e.LineWidget=yn,e.e_preventDefault=Q,e.e_stopPropagation=re,e.e_stop=he,e.addClass=G,e.contains=S,e.rmClass=f,e.keyNames=ei}$l(Ut),ql(Ut);var au="iter insert remove copy getEditor constructor".split(" ");for(var na in fr.prototype)fr.prototype.hasOwnProperty(na)&&ge(au,na)<0&&(Ut.prototype[na]=function(e){return function(){return e.apply(this.doc,arguments)}}(fr.prototype[na]));return oe(fr),Ut.inputStyles={textarea:Wt,contenteditable:Rt},Ut.defineMode=function(e){!Ut.defaults.mode&&e!="null"&&(Ut.defaults.mode=e),ar.apply(this,arguments)},Ut.defineMIME=br,Ut.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Ut.defineMIME("text/plain","null"),Ut.defineExtension=function(e,t){Ut.prototype[e]=t},Ut.defineDocExtension=function(e,t){fr.prototype[e]=t},Ut.fromTextArea=iu,nu(Ut),Ut.version="5.58.2",Ut})},Y1PL:function(ct,rt,le){"use strict";le.r(rt),le.d(rt,"ResizableTextArea",function(){return ge});var fe=le("wx14"),$=le("1OyB"),_=le("vuIU"),V=le("Ji7U"),M=le("LK+K"),D=le("q1tI"),j=le("VTBJ"),U=le("rePB"),I=le("Zm9Q"),O=le("Kwbf"),v=le("c+Xe"),g=le("m+aA"),R=le("bdgK"),w=new Map;function b(Te){Te.forEach(function(Oe){var Ce,Ae=Oe.target;(Ce=w.get(Ae))===null||Ce===void 0||Ce.forEach(function(ve){return ve(Ae)})})}var x=new R.default(b),l=null,o=null;function s(Te,Oe){w.has(Te)||(w.set(Te,new Set),x.observe(Te)),w.get(Te).add(Oe)}function h(Te,Oe){w.has(Te)&&(w.get(Te).delete(Oe),w.get(Te).size||(x.unobserve(Te),w.delete(Te)))}var C=function(Te){Object(V.a)(Ce,Te);var Oe=Object(M.a)(Ce);function Ce(){return Object($.a)(this,Ce),Oe.apply(this,arguments)}return Object(_.a)(Ce,[{key:"render",value:function(){return this.props.children}}]),Ce}(D.Component),m=D.createContext(null);function p(Te){var Oe=Te.children,Ce=Te.onBatchResize,Ae=D.useRef(0),ve=D.useRef([]),W=D.useContext(m),L=D.useCallback(function(k,H,q){Ae.current+=1;var B=Ae.current;ve.current.push({size:k,element:H,data:q}),Promise.resolve().then(function(){B===Ae.current&&(Ce==null||Ce(ve.current),ve.current=[])}),W==null||W(k,H,q)},[Ce,W]);return D.createElement(m.Provider,{value:L},Oe)}function A(Te){var Oe=Te.children,Ce=Te.disabled,Ae=D.useRef(null),ve=D.useRef(null),W=D.useContext(m),L=D.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),k=D.isValidElement(Oe)&&Object(v.c)(Oe),H=k?Oe.ref:null,q=D.useMemo(function(){return Object(v.a)(H,Ae)},[H,Ae]),B=D.useRef(Te);B.current=Te;var ue=D.useCallback(function(be){var we=B.current,Pe=we.onResize,_e=we.data,De=be.getBoundingClientRect(),Me=De.width,We=De.height,ze=be.offsetWidth,Xe=be.offsetHeight,Ge=Math.floor(Me),at=Math.floor(We);if(L.current.width!==Ge||L.current.height!==at||L.current.offsetWidth!==ze||L.current.offsetHeight!==Xe){var $e={width:Ge,height:at,offsetWidth:ze,offsetHeight:Xe};L.current=$e;var Ve=ze===Math.round(Me)?Me:ze,Le=Xe===Math.round(We)?We:Xe,tt=Object(j.a)(Object(j.a)({},$e),{},{offsetWidth:Ve,offsetHeight:Le});W==null||W(tt,be,_e),Pe&&Promise.resolve().then(function(){Pe(tt,be)})}},[]);return D.useEffect(function(){var be=Object(g.a)(Ae.current)||Object(g.a)(ve.current);return be&&!Ce&&s(be,ue),function(){return h(be,ue)}},[Ae.current,Ce]),D.createElement(C,{ref:ve},k?D.cloneElement(Oe,{ref:q}):Oe)}var E="rc-observer-key";function f(Te){var Oe=Te.children,Ce=Object(I.a)(Oe);return Ce.map(function(Ae,ve){var W=(Ae==null?void 0:Ae.key)||"".concat(E,"-").concat(ve);return D.createElement(A,Object(fe.a)({},Te,{key:W}),Ae)})}f.Collection=p;var d=f,u=le("bT9E"),a=le("TSYQ"),y=le.n(a),c=`
min-height:0 !important;
max-height:none !important;
height:0 !important;
visibility:hidden !important;
overflow:hidden !important;
position:absolute !important;
z-index:-1000 !important;
top:0 !important;
right:0 !important
`,S=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],P={},G;function X(Te){var Oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=Te.getAttribute("id")||Te.getAttribute("data-reactid")||Te.getAttribute("name");if(Oe&&P[Ce])return P[Ce];var Ae=window.getComputedStyle(Te),ve=Ae.getPropertyValue("box-sizing")||Ae.getPropertyValue("-moz-box-sizing")||Ae.getPropertyValue("-webkit-box-sizing"),W=parseFloat(Ae.getPropertyValue("padding-bottom"))+parseFloat(Ae.getPropertyValue("padding-top")),L=parseFloat(Ae.getPropertyValue("border-bottom-width"))+parseFloat(Ae.getPropertyValue("border-top-width")),k=S.map(function(q){return"".concat(q,":").concat(Ae.getPropertyValue(q))}).join(";"),H={sizingStyle:k,paddingSize:W,borderSize:L,boxSizing:ve};return Oe&&Ce&&(P[Ce]=H),H}function te(Te){var Oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ae=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=X(Te,Oe),W=ve.paddingSize,L=ve.borderSize,k=ve.boxSizing,H=ve.sizingStyle;G.setAttribute("style","".concat(H,";").concat(c)),G.value=Te.value||Te.placeholder||"";var q=Number.MIN_SAFE_INTEGER,B=Number.MAX_SAFE_INTEGER,ue=G.scrollHeight,be;if(k==="border-box"?ue+=L:k==="content-box"&&(ue-=W),Ce!==null||Ae!==null){G.value=" ";var we=G.scrollHeight-W;Ce!==null&&(q=we*Ce,k==="border-box"&&(q=q+W+L),ue=Math.max(q,ue)),Ae!==null&&(B=we*Ae,k==="border-box"&&(B=B+W+L),be=ue>B?"":"hidden",ue=Math.min(B,ue))}return{height:ue,minHeight:q,maxHeight:B,overflowY:be,resize:"none"}}var z=le("Gytx"),F=le.n(z),ne;(function(Te){Te[Te.NONE=0]="NONE",Te[Te.RESIZING=1]="RESIZING",Te[Te.RESIZED=2]="RESIZED"})(ne||(ne={}));var ce=function(Te){Object(V.a)(Ce,Te);var Oe=Object(M.a)(Ce);function Ce(Ae){var ve;return Object($.a)(this,Ce),ve=Oe.call(this,Ae),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(W){ve.textArea=W},ve.handleResize=function(W){var L=ve.state.resizeStatus,k=ve.props,H=k.autoSize,q=k.onResize;if(L!==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 L=W.minRows,k=W.maxRows,H=te(ve.textArea,!1,L,k);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,L=W.prefixCls,k=L===void 0?"rc-textarea":L,H=W.autoSize,q=W.onResize,B=W.className,ue=W.disabled,be=ve.state,we=be.textareaStyles,Pe=be.resizeStatus,_e=Object(u.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),De=y()(k,B,Object(U.a)({},"".concat(k,"-disabled"),ue));"value"in _e&&(_e.value=_e.value||"");var Me=Object(j.a)(Object(j.a)(Object(j.a)({},ve.props.style),we),Pe===ne.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return D.createElement(d,{onResize:ve.handleResize,disabled:!(H||q)},D.createElement("textarea",Object(fe.a)({},_e,{className:De,style:Me,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:ne.NONE},ve}return Object(_.a)(Ce,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!F()(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(L){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ce}(D.Component),ge=ce,xe=function(Te){Object(V.a)(Ce,Te);var Oe=Object(M.a)(Ce);function Ce(Ae){var ve;Object($.a)(this,Ce),ve=Oe.call(this,Ae),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(L){ve.resizableTextArea=L},ve.handleChange=function(L){var k=ve.props.onChange;ve.setValue(L.target.value,function(){ve.resizableTextArea.resizeTextarea()}),k&&k(L)},ve.handleKeyDown=function(L){var k=ve.props,H=k.onPressEnter,q=k.onKeyDown;L.keyCode===13&&H&&H(L),q&&q(L)};var W=typeof Ae.value=="undefined"||Ae.value===null?Ae.defaultValue:Ae.value;return ve.state={value:W},ve}return Object(_.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(fe.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),Ie=rt.default=xe},bT9E:function(ct,rt,le){"use strict";le.d(rt,"a",function(){return $});var fe=le("VTBJ");function $(_,V){var M=Object(fe.a)({},_);return Array.isArray(V)&&V.forEach(function(D){delete M[D]}),M}},c5Ni:function(ct,rt,le){},dejd:function(ct,rt,le){},dmUQ:function(ct,rt,le){"use strict";var fe=le("Ff2n"),$=le("rePB"),_=le("1OyB"),V=le("vuIU"),M=le("Ji7U"),D=le("md7G"),j=le("foSv"),U=le("q1tI"),I=le.n(U),O=le("TSYQ"),v=le.n(O),g=le("4IlW");function R(u,a){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(u);a&&(c=c.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),y.push.apply(y,c)}return y}function w(u){for(var a=1;a<arguments.length;a++){var y=arguments[a]!=null?arguments[a]:{};a%2?R(Object(y),!0).forEach(function(c){Object($.a)(u,c,y[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):R(Object(y)).forEach(function(c){Object.defineProperty(u,c,Object.getOwnPropertyDescriptor(y,c))})}return u}function b(u){var a=x();return function(){var c=Object(j.a)(u),S;if(a){var P=Object(j.a)(this).constructor;S=Reflect.construct(c,arguments,P)}else S=c.apply(this,arguments);return Object(D.a)(this,S)}}function x(){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(u){return!1}}function l(){}function o(u){u.preventDefault()}var s=function(a){return a.replace(/[^\w.-]+/g,"")},h=200,C=600,m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,p=function(a){return a!=null},A=function(a,y){return y===a||typeof y=="number"&&typeof a=="number"&&isNaN(y)&&isNaN(a)},E=function(u){Object(M.a)(y,u);var a=b(y);function y(c){var S;Object(_.a)(this,y),S=a.call(this,c),S.onKeyDown=function(X){var te=S.props,z=te.onKeyDown,F=te.onPressEnter;if(X.keyCode===g.a.UP){var ne=S.getRatio(X);S.up(X,ne,null),S.stop()}else if(X.keyCode===g.a.DOWN){var ce=S.getRatio(X);S.down(X,ce,null),S.stop()}else X.keyCode===g.a.ENTER&&F&&F(X);if(S.recordCursorPosition(),S.lastKeyCode=X.keyCode,z){for(var ge=arguments.length,xe=new Array(ge>1?ge-1:0),Ie=1;Ie<ge;Ie++)xe[Ie-1]=arguments[Ie];z.apply(void 0,[X].concat(xe))}},S.onKeyUp=function(X){var te=S.props.onKeyUp;if(S.stop(),S.recordCursorPosition(),te){for(var z=arguments.length,F=new Array(z>1?z-1:0),ne=1;ne<z;ne++)F[ne-1]=arguments[ne];te.apply(void 0,[X].concat(F))}},S.onChange=function(X){var te=S.props.onChange;S.state.focused&&(S.inputting=!0),S.rawInput=S.props.parser(S.getValueFromEvent(X)),S.setState({inputValue:S.rawInput}),te(S.toNumber(S.rawInput))},S.onMouseUp=function(){var X=S.props.onMouseUp;S.recordCursorPosition(),X&&X.apply(void 0,arguments)},S.onFocus=function(){var X;S.setState({focused:!0}),(X=S.props).onFocus.apply(X,arguments)},S.onBlur=function(){var X=S.props.onBlur;S.inputting=!1,S.setState({focused:!1});var te=S.getCurrentValidValue(S.state.inputValue),z=S.setValue(te,l);if(X){var F=S.input.value,ne=S.getInputDisplayValue({focus:!1,value:z});S.input.value=ne&&Number(ne),X.apply(void 0,arguments),S.input.value=F}},S.getRatio=function(X){var te=1;return X.metaKey||X.ctrlKey?te=.1:X.shiftKey&&(te=10),te},S.getFullNum=function(X){return isNaN(X)?X:/e/i.test(String(X))?Number(X).toFixed(18).replace(/\.?0+$/,""):X},S.getPrecision=function(X){if(p(S.props.precision))return S.props.precision;var te=String(X);if(te.indexOf("e-")>=0)return parseInt(te.slice(te.indexOf("e-")+2),10);var z=0;return te.indexOf(".")>=0&&(z=te.length-te.indexOf(".")-1),z},S.getInputDisplayValue=function(X){var te=X||S.state,z=te.focused,F=te.inputValue,ne=te.value,ce;z?ce=F:ce=S.toPrecisionAsStep(ne),ce==null&&(ce="");var ge=S.formatWrapper(ce);return p(S.props.decimalSeparator)&&(ge=ge.toString().replace(".",S.props.decimalSeparator)),ge},S.recordCursorPosition=function(){try{S.cursorStart=S.input.selectionStart,S.cursorEnd=S.input.selectionEnd,S.currentValue=S.input.value,S.cursorBefore=S.input.value.substring(0,S.cursorStart),S.cursorAfter=S.input.value.substring(S.cursorEnd)}catch(X){}},S.restoreByAfter=function(X){if(X===void 0)return!1;var te=S.input.value,z=te.lastIndexOf(X);if(z===-1)return!1;var F=S.cursorBefore.length;return S.lastKeyCode===g.a.DELETE&&S.cursorBefore.charAt(F-1)===X[0]?(S.fixCaret(F,F),!0):z+X.length===te.length?(S.fixCaret(z,z),!0):!1},S.partRestoreByAfter=function(X){return X===void 0?!1:Array.prototype.some.call(X,function(te,z){var F=X.substring(z);return S.restoreByAfter(F)})},S.isNotCompleteNumber=function(X){return isNaN(X)||X===""||X===null||X&&X.toString().indexOf(".")===X.toString().length-1},S.stop=function(){S.autoStepTimer&&clearTimeout(S.autoStepTimer)},S.down=function(X,te,z){S.pressingUpOrDown=!0,S.step("down",X,te,z)},S.up=function(X,te,z){S.pressingUpOrDown=!0,S.step("up",X,te,z)},S.saveInput=function(X){S.input=X};var P=c.value;P===void 0&&(P=c.defaultValue),S.state={focused:c.autoFocus};var G=S.getValidValue(S.toNumber(P));return S.state=w(w({},S.state),{},{inputValue:S.toPrecisionAsStep(G),value:G}),S}return Object(V.a)(y,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(S){var P=this.props,G=P.value,X=P.onChange,te=P.max,z=P.min,F=this.state.focused;if(S){if(!A(S.value,G)||!A(S.max,te)||!A(S.min,z)){var ne=F?G:this.getValidValue(G),ce;this.pressingUpOrDown?ce=ne:this.inputting?ce=this.rawInput:ce=this.toPrecisionAsStep(ne),this.setState({value:ne,inputValue:ce})}var ge="value"in this.props?G:this.state.value;"max"in this.props&&S.max!==te&&typeof ge=="number"&&ge>te&&X&&X(te),"min"in this.props&&S.min!==z&&typeof ge=="number"&&ge<z&&X&&X(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var xe=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===g.a.BACKSPACE?xe=this.cursorStart-1:this.lastKeyCode===g.a.DELETE&&(xe=this.cursorStart):xe=this.input.value.length,this.fixCaret(xe,xe)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case g.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case g.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Ie){}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(S){var P=S;return P===""?P="":this.isNotCompleteNumber(parseFloat(P))?P=this.state.value:P=this.getValidValue(P),this.toNumber(P)}},{key:"getValueFromEvent",value:function(S){var P=S.target.value.trim().replace(/。/g,".");return p(this.props.decimalSeparator)&&(P=P.replace(this.props.decimalSeparator,".")),P}},{key:"getValidValue",value:function(S){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,X=parseFloat(S);return isNaN(X)?S:(X<P&&(X=P),X>G&&(X=G),X)}},{key:"setValue",value:function(S,P){var G=this.props.precision,X=this.isNotCompleteNumber(parseFloat(S))?null:parseFloat(S),te=this.state.value,z=te===void 0?null:te,F=this.state.inputValue,ne=F===void 0?null:F,ce=typeof X=="number"?X.toFixed(G):"".concat(X),ge=X!==z||ce!=="".concat(ne);return"value"in this.props?(ne=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ne},P)):this.setState({value:X,inputValue:this.toPrecisionAsStep(S)},P),ge&&this.props.onChange(X),X}},{key:"getMaxPrecision",value:function(S){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,X=G.precision,te=G.step;if(p(X))return X;var z=this.getPrecision(P),F=this.getPrecision(te),ne=this.getPrecision(S);return S?Math.max(ne,z+F):z+F}},{key:"getPrecisionFactor",value:function(S){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(S,P);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(S){return this.props.formatter?this.props.formatter(S):S}},{key:"toPrecisionAsStep",value:function(S){if(this.isNotCompleteNumber(S)||S==="")return S;var P=Math.abs(this.getMaxPrecision(S));return isNaN(P)?S.toString():Number(S).toFixed(P)}},{key:"toNumber",value:function(S){var P=this.props.precision,G=this.state.focused,X=S&&S.length>16&&G;return this.isNotCompleteNumber(S)||X?S:p(P)?Math.round(S*Math.pow(10,P))/Math.pow(10,P):Number(S)}},{key:"upStep",value:function(S,P){var G=this.props.step,X=this.getPrecisionFactor(S,P),te=Math.abs(this.getMaxPrecision(S,P)),z=((X*S+X*G*P)/X).toFixed(te);return this.toNumber(z)}},{key:"downStep",value:function(S,P){var G=this.props.step,X=this.getPrecisionFactor(S,P),te=Math.abs(this.getMaxPrecision(S,P)),z=((X*S-X*G*P)/X).toFixed(te);return this.toNumber(z)}},{key:"step",value:function(S,P){var G=this,X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,te=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var z=this.props;if(z.disabled)return;var F=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(F))return;var ne=this["".concat(S,"Step")](F,X),ce=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}),ce)return;this.autoStepTimer=setTimeout(function(){G[S](P,X,!0)},te?h:C)}},{key:"fixCaret",value:function(S,P){if(S===void 0||P===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,X=this.input.selectionEnd;(S!==G||P!==X)&&this.input.setSelectionRange(S,P)}catch(te){}}},{key:"render",value:function(){var S,P=this.props,G=P.prefixCls,X=P.disabled,te=P.readOnly,z=P.useTouch,F=P.autoComplete,ne=P.upHandler,ce=P.downHandler,ge=P.className,xe=P.max,Ie=P.min,Te=P.style,Oe=P.title,Ce=P.onMouseEnter,Ae=P.onMouseLeave,ve=P.onMouseOver,W=P.onMouseOut,L=P.required,k=P.onClick,H=P.tabIndex,q=P.type,B=P.placeholder,ue=P.id,be=P.inputMode,we=P.pattern,Pe=P.step,_e=P.maxLength,De=P.autoFocus,Me=P.name,We=P.onPaste,ze=P.onInput,Xe=Object(fe.a)(P,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),Ge=this.state,at=Ge.value,$e=Ge.focused,Ve=v()(G,(S={},Object($.a)(S,ge,!!ge),Object($.a)(S,"".concat(G,"-disabled"),X),Object($.a)(S,"".concat(G,"-focused"),$e),S)),Le={};Object.keys(Xe).forEach(function(he){(he.substr(0,5)==="data-"||he.substr(0,5)==="aria-"||he==="role")&&(Le[he]=Xe[he])});var tt=!te&&!X,qe=this.getInputDisplayValue(null),ae=(at||at===0)&&(isNaN(at)||Number(at)>=xe),J=(at||at===0)&&(isNaN(at)||Number(at)<=Ie),Z=ae||X||te,ie=J||X||te,oe=v()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object($.a)({},"".concat(G,"-handler-up-disabled"),Z)),Q=v()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object($.a)({},"".concat(G,"-handler-down-disabled"),ie)),re=z?{onTouchStart:Z?l:this.up,onTouchEnd:this.stop}:{onMouseDown:Z?l:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=z?{onTouchStart:ie?l:this.down,onTouchEnd:this.stop}:{onMouseDown:ie?l:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return I.a.createElement("div",{className:Ve,style:Te,title:Oe,onMouseEnter:Ce,onMouseLeave:Ae,onMouseOver:ve,onMouseOut:W,onFocus:function(){return null},onBlur:function(){return null}},I.a.createElement("div",{className:"".concat(G,"-handler-wrap")},I.a.createElement("span",Object.assign({unselectable:"on"},re,{role:"button","aria-label":"Increase Value","aria-disabled":Z,className:oe}),ne||I.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),I.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":ie,className:Q}),ce||I.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),I.a.createElement("div",{className:"".concat(G,"-input-wrap")},I.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Ie,"aria-valuemax":xe,"aria-valuenow":at,required:L,type:q,placeholder:B,onPaste:We,onClick:k,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:H,autoComplete:F,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:tt?this.onKeyDown:l,onKeyUp:tt?this.onKeyUp:l,autoFocus:De,maxLength:_e,readOnly:te,disabled:X,max:xe,min:Ie,step:Pe,name:Me,title:Oe,id:ue,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(qe),pattern:we,inputMode:be,onInput:ze},Le))))}}]),y}(I.a.Component);E.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:m,min:-m,step:1,style:{},onChange:l,onKeyDown:l,onPressEnter:l,onFocus:l,onBlur:l,parser:s,required:!1,autoComplete:"off"};var f=E,d=rt.a=f},fB9n:function(ct,rt,le){"use strict";le.r(rt);var fe=le("14J3"),$=le("BMrR"),_=le("jCWc"),V=le("kPKH"),M=le("k1fw"),D=le("9og8"),j=le("tJVT"),U=le("PpiC"),I=le("WmNS"),O=le.n(I),v=le("q1tI"),g=le.n(v),R=le("55Ip"),w=le("9kvl"),b=le("T2oS"),x=le("W9HT"),l=le("oBTY"),o=le("B9cy"),s=le("Ol7k"),h=le("lUTK"),C=le("BvKs"),m=le("Ty5D"),p=le("wd/R"),A=le.n(p),E=le("RotF"),f=le.n(E),d=le("m3rI"),u=le("9Bee"),a=le("SbmS"),y=le.n(a),c=C.a.SubMenu,S=s.a.Sider,P=s.a.Content,G=function(be){var we=be.messages,Pe=be.globalSetting,_e=be.loading,De=be.user,Me=be.dispatch,We=Object(U.a)(be,["messages","globalSetting","loading","user","dispatch"]),ze=Object(m.i)(),Xe=Object(m.h)(),Ge=De.userInfo,at=Object(v.useState)(!1),$e=Object(j.a)(at,2),Ve=$e[0],Le=$e[1],tt=Object(v.useState)({per_page:20,page:1}),qe=Object(j.a)(tt,2),ae=qe[0],J=qe[1],Z=Object(v.useState)({per_page:20,page:1}),ie=Object(j.a)(Z,2),oe=ie[0],Q=ie[1],re=Object(v.useState)([]),se=Object(j.a)(re,2),he=se[0],pe=se[1];Object(v.useEffect)(function(){ae.page=1,ke()},[ze.userId]);var ye=function(Ze){var Ke,lt;w.d.push("/messages/".concat(De==null||((Ke=De.userInfo)===null||Ke===void 0)?void 0:Ke.login,"/message_detail?target_ids=").concat(Ze==null||((lt=Ze.target)===null||lt===void 0)?void 0:lt.id))},ke=function(){var Ne=Object(D.a)(O.a.mark(function Ze(){var Ke,lt;return O.a.wrap(function(Ye){for(;;)switch(Ye.prev=Ye.next){case 0:return Le(!1),Ye.next=3,Me({type:"messages/getPrivateMessages",payload:Object(M.a)(Object(M.a)({},ze),oe)});case 3:Ke=Ye.sent,Ke!=null&&Ke.private_messages&&(pe([].concat(Object(l.a)(he),Object(l.a)(Ke.private_messages))),((lt=Ke.private_messages)===null||lt===void 0?void 0:lt.length)===20&&Le(!0));case 5:case"end":return Ye.stop()}},Ze)}));return function(){return Ne.apply(this,arguments)}}();return g.a.createElement("aside",{className:y.a.listRightMessage},g.a.createElement(f.a,{loadMore:function(){oe.page++,ke()},hasMore:Ve,useWindow:!1},g.a.createElement(x.a,{spinning:_e["messages/getPrivateMessages"]},g.a.createElement("div",{className:"minH500"},he==null?void 0:he.map(function(Ne,Ze){var Ke,lt;return g.a.createElement("aside",{key:Ze},g.a.createElement($.a,{onClick:function(){return ye(Ne)}},g.a.createElement(V.a,{flex:"58px"},g.a.createElement("img",{src:d.a.IMG_SERVER+"/images/"+(Ne==null||((Ke=Ne.target)===null||Ke===void 0)?void 0:Ke.image_url),alt:""})),g.a.createElement(V.a,{flex:"1"},g.a.createElement($.a,null,g.a.createElement(V.a,{span:24},g.a.createElement($.a,null,g.a.createElement(V.a,{flex:"1"},g.a.createElement("span",{className:y.a.userName},Ne==null||((lt=Ne.target)===null||lt===void 0)?void 0:lt.name)),g.a.createElement(V.a,null,g.a.createElement("span",{className:"ml15 c-grey-c"},A()(Ne.send_time).fromNow())))),g.a.createElement(V.a,{span:24},g.a.createElement("div",{className:["mt15",y.a.content].join(" ")},g.a.createElement(u.a,{value:Ne.content||""})))))))})))))},X=Object(w.a)(function(ue){var be=ue.messages,we=ue.loading,Pe=ue.user,_e=ue.globalSetting;return{messages:be,globalSetting:_e,user:Pe,loading:we.effects}})(G),te=le("+L6B"),z=le("2/Rp"),F=le("miYZ"),ne=le("tsqr"),ce=le("y8nQ"),ge=le("Vl3Y"),xe=le("kaH+"),Ie=le("1vsH"),Te=le("5WQS"),Oe=le("Ot1p"),Ce=le("dhSg"),Ae=C.a.SubMenu,ve=s.a.Sider,W=s.a.Content,L=function(be){var we=be.messages,Pe=be.globalSetting,_e=be.loading,De=be.user,Me=be.dispatch,We=Object(U.a)(be,["messages","globalSetting","loading","user","dispatch"]),ze=Object(m.i)(),Xe=Object(m.h)(),Ge=Xe.query,at=Object(v.useState)({per_page:20,page:1}),$e=Object(j.a)(at,2),Ve=$e[0],Le=$e[1],tt=Object(v.useState)([]),qe=Object(j.a)(tt,2),ae=qe[0],J=qe[1],Z=Object(v.useState)(!1),ie=Object(j.a)(Z,2),oe=ie[0],Q=ie[1],re=Object(v.useState)(!1),se=Object(j.a)(re,2),he=se[0],pe=se[1],ye=Object(v.useState)(""),ke=Object(j.a)(ye,2),Ne=ke[0],Ze=ke[1],Ke=Object(v.useRef)(),lt=ge.a.useForm(),it=Object(j.a)(lt,1),Ye=it[0],wt=Object(v.useState)([]),dt=Object(j.a)(wt,2),Ot=dt[0],Nt=dt[1],St=Object(v.useState)(!0),ar=Object(j.a)(St,2),br=ar[0],Kt=ar[1];Object(v.useEffect)(function(){Ve.page=1,tr()},[Ge.target_ids]);var tr=function(){var At=Object(D.a)(O.a.mark(function Mt(){var vt,He;return O.a.wrap(function(Bt){for(;;)switch(Bt.prev=Bt.next){case 0:return Q(!1),Bt.next=3,Me({type:"messages/getPrivateMessageDetails",payload:Object(M.a)(Object(M.a)({},ze),{},{target_id:Ge==null?void 0:Ge.target_ids},Ve)});case 3:vt=Bt.sent,vt!=null&&vt.messages&&(Ot=vt==null?void 0:vt.messages,((He=Ot)===null||He===void 0?void 0:He.length)===20&&setTimeout(function(){Q(!0),Kt(!1)},500),Ve.page===1?J(Object(l.a)(vt==null?void 0:vt.messages.reverse())):J([].concat(Object(l.a)(ae),Object(l.a)(vt==null?void 0:vt.messages.reverse()))));case 5:case"end":return Bt.stop()}},Mt)}));return function(){return At.apply(this,arguments)}}();Object(v.useEffect)(function(){console.log("newData.length:",Ve,Ot.length,Ot),Ve.page===1&&br&&(Ke.current.scrollTop=Ke.current.scrollHeight)},[ae]),Object(v.useEffect)(function(){Ke.current.onclick=function(At){At.target.nodeName==="IMG"&&At.target.alt!==""&&Ce.a.publish("preview-image",At.target.src)}},[]);var or=function(){var At=Object(D.a)(O.a.mark(function Mt(vt,He){var xt;return O.a.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:return pt.next=2,Object(Te.a)(Object(M.a)(Object(M.a)({},ze),{},{id:vt.id}));case 2:xt=pt.sent,xt.status===0&&(ae.splice(He,1),J(Object(l.a)(ae)));case 4:case"end":return pt.stop()}},Mt)}));return function(vt,He){return At.apply(this,arguments)}}(),Pr=function(){var At=Object(D.a)(O.a.mark(function Mt(){return O.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:if(!(Ne==="")){He.next=3;break}return ne.b.error("\u8BF7\u8F93\u5165\u60A8\u7684\u56DE\u590D"),He.abrupt("return",!1);case 3:return Ze(""),pe(!0),He.next=7,Object(Te.g)(Object(M.a)(Object(M.a)({},ze),{},{content:Ne,target_id:Ge==null?void 0:Ge.target_ids}));case 7:pe(!1),Ve.page=1,Ye.resetFields(),tr();case 11:case"end":return He.stop()}},Mt)}));return function(){return At.apply(this,arguments)}}(),Vt=Object(v.useMemo)(function(){var At=De||{},Mt=At.userInfo;return(Mt==null?void 0:Mt.is_teacher)&&(Mt==null?void 0:Mt.professional_certification)},[De]);return g.a.createElement("section",null,g.a.createElement("aside",{className:y.a.listMessage,ref:Ke},g.a.createElement(f.a,{isReverse:!0,loadMore:function(){Ve.page++,tr()},hasMore:oe,useWindow:!1},!oe&&g.a.createElement("div",{className:"tc mt20 animated fadeIn"},g.a.createElement("span",{className:y.a.msgDate},"\u6CA1\u6709\u4FE1\u606F\u4E86\uFF5E\uFF5E")),g.a.createElement(x.a,{spinning:_e["messages/getPrivateMessageDetails"]},g.a.createElement("aside",{className:"minH500"},ae==null?void 0:ae.map(function(At,Mt){var vt;return g.a.createElement("aside",{key:Mt},g.a.createElement($.a,{justify:"center"},g.a.createElement(V.a,{flex:"1",className:"tc"},g.a.createElement("span",{className:y.a.msgDate},A()(At.send_time).format("YYYY-MM-DD")))),g.a.createElement($.a,{onClick:function(){return Object(Ie.J)(At)}},g.a.createElement(V.a,{flex:"58px"},g.a.createElement("img",{src:d.a.IMG_SERVER+"/images/"+(At==null||((vt=At.sender)===null||vt===void 0)?void 0:vt.image_url),alt:""})),g.a.createElement(V.a,null,g.a.createElement("div",{className:y.a.msg},g.a.createElement(u.a,{value:At.content||""}),g.a.createElement("span",{onClick:function(){return or(At,Mt)},className:["current",y.a.deleteMsg].join(" ")},"\u5220\u9664"))),g.a.createElement(V.a,null,g.a.createElement("span",{className:"c-grey-c ml10"},A()(At.send_time).format("HH:mm")))))}))))),g.a.createElement("aside",{className:"pl30 pr30 mb30 mt30"},Vt?g.a.createElement(ge.a,{form:Ye},g.a.createElement(ge.a.Item,{name:"content"},g.a.createElement(Oe.a,{placeholder:"\u8BF7\u8F93\u5165\u4F60\u7684\u56DE\u590D",height:150,onChange:function(Mt){return Ze(Mt)}})),g.a.createElement($.a,null,g.a.createElement(V.a,{flex:"1"},g.a.createElement("span",{className:"c-red font14"},"\u5728\u95EE\u9898\u53CD\u9988\u65F6\uFF0C\u8BF7\u540C\u65F6\u53D1\u9001\u95EE\u9898\u53D1\u751F\u9875\u7684\u7F51\u5740\u94FE\u63A5\uFF0C\u4EE5\u4FBF\u6211\u4EEC\u9AD8\u6548\u7684\u4E3A\u60A8\u670D\u52A1")),g.a.createElement(V.a,null,g.a.createElement(z.a,{loading:he,type:"primary",onClick:function(){return Pr()}},"\u56DE\u590D")))):g.a.createElement("p",{className:"c-red font14",style:{textAlign:"center"}},"\u4EC5\u804C\u4E1A\u8BA4\u8BC1\u7684\u6559\u5E08\u53EF\u4EE5\u4F7F\u7528\u79C1\u4FE1\u529F\u80FD")),g.a.createElement(xe.a,null))},k=Object(w.a)(function(ue){var be=ue.messages,we=ue.loading,Pe=ue.user,_e=ue.globalSetting;return{messages:be,globalSetting:_e,user:Pe,loading:we.effects}})(L),H=le("30zm"),q=function(be){var we,Pe=be.messages,_e=be.globalSetting,De=be.loading,Me=be.user,We=be.dispatch,ze=Object(U.a)(be,["messages","globalSetting","loading","user","dispatch"]),Xe=ze.match.params,Ge=ze.location.query,at=Me.userInfo,$e=Pe.tidingsList,Ve=Pe.privateMessageDetails,Le=Object(v.useState)({per_page:20,page:1}),tt=Object(j.a)(Le,2),qe=tt[0],ae=tt[1],J=Object(v.useState)({per_page:20,page:1}),Z=Object(j.a)(J,2),ie=Z[0],oe=Z[1],Q=Object(v.useState)([]),re=Object(j.a)(Q,2),se=re[0],he=re[1],pe=Object(v.useState)([]),ye=Object(j.a)(pe,2),ke=ye[0],Ne=ye[1];Object(v.useEffect)(function(){qe.page=1},[Xe.userId]);var Ze=function(){var lt=Object(D.a)(O.a.mark(function it(){var Ye;return O.a.wrap(function(dt){for(;;)switch(dt.prev=dt.next){case 0:return dt.next=2,We({type:"messages/getPrivateMessageDetails",payload:Object(M.a)(Object(M.a)({},Xe),{},{target_id:Ge==null?void 0:Ge.target_ids})});case 2:Ye=dt.sent,Ye!=null&&Ye.messages&&he(Ye.messages);case 4:case"end":return dt.stop()}},it)}));return function(){return lt.apply(this,arguments)}}(),Ke=function(){var lt=Object(D.a)(O.a.mark(function it(){var Ye;return O.a.wrap(function(dt){for(;;)switch(dt.prev=dt.next){case 0:return dt.next=2,We({type:"messages/getPrivateMessages",payload:Object(M.a)(Object(M.a)({},Xe),ie)});case 2:Ye=dt.sent,Ye!=null&&Ye.private_messages&&Ne(Ye.private_messages);case 4:case"end":return dt.stop()}},it)}));return function(){return lt.apply(this,arguments)}}();return g.a.createElement("section",{className:y.a.bg},g.a.createElement("section",{className:"edu-container mt20"},g.a.createElement($.a,{gutter:[20,20]},g.a.createElement(H.a,null),g.a.createElement(V.a,{flex:"1"},g.a.createElement("aside",{className:"bg-white"},g.a.createElement("aside",{className:["font16",y.a.topBar].join(" ")},g.a.createElement($.a,null,g.a.createElement(V.a,{flex:"30px",className:"tc"},g.a.createElement(R.a,{to:"/messages/".concat(Xe.userId,"/private_messages"),className:"iconfont icon-zuojiantou c-black pl10"})),g.a.createElement(V.a,{flex:"1",className:"tc"},Ve==null||((we=Ve.target)===null||we===void 0)?void 0:we.name,"\u4E0E\u4F60\u7684\u79C1\u4FE1"),g.a.createElement(V.a,{flex:"290px",className:"tl"},g.a.createElement("span",{className:"pl30"},"\u79C1\u4FE1\u5217\u8868")))),g.a.createElement($.a,null,g.a.createElement(V.a,{flex:"1"},g.a.createElement(k,null)),g.a.createElement(V.a,{flex:"290px"},g.a.createElement(X,null))))))))},B=rt.default=Object(w.a)(function(ue){var be=ue.messages,we=ue.loading,Pe=ue.user,_e=ue.globalSetting;return{messages:be,globalSetting:_e,user:Pe,loading:we.effects}})(q)},kSUc:function(ct,rt,le){},"kaH+":function(ct,rt,le){"use strict";var fe=le("+L6B"),$=le("2/Rp"),_=le("tJVT"),V=le("q1tI"),M=le.n(V),D=le("UZu5"),j=le.n(D),U=le("dhSg"),I=le("rLCj"),O=le("dF/Y"),v=le("4i/N");rt.a=function(){var g=Object(V.useState)(""),R=Object(_.a)(g,2),w=R[0],b=R[1],x=Object(V.useState)(0),l=Object(_.a)(x,2),o=l[0],s=l[1],h=Object(V.useRef)("");Object(V.useEffect)(function(){var d=U.a.subscribe("preview-image",function(u){b(u),document.body.style.overflow="hidden"});return d},[]),Object(V.useEffect)(function(){return document.addEventListener("keydown",C),function(){document.removeEventListener("keydown",C)}},[]),Object(V.useEffect)(function(){h.current=w},[w]);function C(d){d.keyCode==27&&h.current&&m()}function m(){document.body.style.overflow="auto",b("")}function p(){s(o+90)}var A=Object(V.useRef)(),E=Object(V.useRef)(),f=function(u){(u.nativeEvent.target===A.current||u.nativeEvent.target===E.current)&&m()};return M.a.createElement(V.Fragment,null,w?M.a.createElement("div",{className:"image-preview-container",ref:A,onClick:f},M.a.createElement("div",{className:"button-group"},M.a.createElement($.a,{onClick:p},"\u65CB\u8F6C",M.a.createElement(I.a,null)),M.a.createElement($.a,{href:w},"\u4E0B\u8F7D",M.a.createElement(O.a,null)),M.a.createElement($.a,{onClick:m},"\u5173\u95ED",M.a.createElement(v.a,null))),M.a.createElement("div",{className:"preview-wrp-group",ref:E},M.a.createElement("img",{className:"image-preview",src:w,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(o,"deg)")}}))):null)}},kzJb:function(ct,rt,le){ct.exports={flex_box_center:"flex_box_center___2qtoc",flex_space_between:"flex_space_between___NF1Yf",flex_box_vertical_center:"flex_box_vertical_center___2qH_j",flex_box_center_end:"flex_box_center_end___22P0N",flex_box_column:"flex_box_column___1IKP8",userInfo:"userInfo___2Dupy",navInfo:"navInfo___3fEvD",actived:"actived___3F322",newTip:"newTip___1Ta-b"}},lZu9:function(ct,rt,le){(function(fe){fe(le("VrN/"),le("1eCo"),le("8EBN"))})(function(fe){"use strict";fe.defineMode("markdown",function($,_){var V=fe.getMode($,"text/html"),M=V.name=="null";function D(z){if(fe.findModeByName){var F=fe.findModeByName(z);F&&(z=F.mime||F.mimes[0])}var ne=fe.getMode($,z);return ne.name=="null"?null:ne}_.highlightFormatting===void 0&&(_.highlightFormatting=!1),_.maxBlockquoteDepth===void 0&&(_.maxBlockquoteDepth=0),_.taskLists===void 0&&(_.taskLists=!1),_.strikethrough===void 0&&(_.strikethrough=!1),_.emoji===void 0&&(_.emoji=!1),_.fencedCodeBlockHighlighting===void 0&&(_.fencedCodeBlockHighlighting=!0),_.fencedCodeBlockDefaultMode===void 0&&(_.fencedCodeBlockDefaultMode="text/plain"),_.xml===void 0&&(_.xml=!0),_.tokenTypeOverrides===void 0&&(_.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 U in j)j.hasOwnProperty(U)&&_.tokenTypeOverrides[U]&&(j[U]=_.tokenTypeOverrides[U]);var I=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,g=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,w=/^[^#!\[\]*_\\<>` "'(~:]+/,b=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,x=/^\s*\[[^\]]+?\]:.*$/,l=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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,F,ne){return F.f=F.inline=ne,ne(z,F)}function h(z,F,ne){return F.f=F.block=ne,ne(z,F)}function C(z){return!z||!/\S/.test(z.string)}function m(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==A){var F=M;if(!F){var ne=fe.innerMode(V,z.htmlState);F=ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText}F&&(z.f=u,z.block=p,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function p(z,F){var ne=z.column()===F.indentation,ce=C(F.prevLine.stream),ge=F.indentedCode,xe=F.prevLine.hr,Ie=F.list!==!1,Te=(F.listStack[F.listStack.length-1]||0)+3;F.indentedCode=!1;var Oe=F.indentation;if(F.indentationDiff===null&&(F.indentationDiff=F.indentation,Ie)){for(F.list=null;Oe<F.listStack[F.listStack.length-1];)F.listStack.pop(),F.listStack.length?F.indentation=F.listStack[F.listStack.length-1]:F.list=!1;F.list!==!1&&(F.indentationDiff=Oe-F.listStack[F.listStack.length-1])}var Ce=!ce&&!xe&&!F.prevLine.header&&(!Ie||!ge)&&!F.prevLine.fencedCodeEnd,Ae=(F.list===!1||xe||ce)&&F.indentation<=Te&&z.match(I),ve=null;if(F.indentationDiff>=4&&(ge||F.prevLine.fencedCodeEnd||F.prevLine.header||ce))return z.skipToEnd(),F.indentedCode=!0,j.code;if(z.eatSpace())return null;if(ne&&F.indentation<=Te&&(ve=z.match(g))&&ve[1].length<=6)return F.quote=0,F.header=ve[1].length,F.thisLine.header=!0,_.highlightFormatting&&(F.formatting="header"),F.f=F.inline,f(F);if(F.indentation<=Te&&z.eat(">"))return F.quote=ne?1:F.quote+1,_.highlightFormatting&&(F.formatting="quote"),z.eatSpace(),f(F);if(!Ae&&!F.setext&&ne&&F.indentation<=Te&&(ve=z.match(O))){var W=ve[1]?"ol":"ul";return F.indentation=Oe+z.current().length,F.list=!0,F.quote=0,F.listStack.push(F.indentation),F.em=!1,F.strong=!1,F.code=!1,F.strikethrough=!1,_.taskLists&&z.match(v,!1)&&(F.taskList=!0),F.f=F.inline,_.highlightFormatting&&(F.formatting=["list","list-"+W]),f(F)}else{if(ne&&F.indentation<=Te&&(ve=z.match(b,!0)))return F.quote=0,F.fencedEndRE=new RegExp(ve[1]+"+ *$"),F.localMode=_.fencedCodeBlockHighlighting&&D(ve[2]||_.fencedCodeBlockDefaultMode),F.localMode&&(F.localState=fe.startState(F.localMode)),F.f=F.block=E,_.highlightFormatting&&(F.formatting="code-block"),F.code=-1,f(F);if(F.setext||(!Ce||!Ie)&&!F.quote&&F.list===!1&&!F.code&&!Ae&&!x.test(z.string)&&(ve=z.lookAhead(1))&&(ve=ve.match(R)))return F.setext?(F.header=F.setext,F.setext=0,z.skipToEnd(),_.highlightFormatting&&(F.formatting="header")):(F.header=ve[0].charAt(0)=="="?1:2,F.setext=F.header),F.thisLine.header=!0,F.f=F.inline,f(F);if(Ae)return z.skipToEnd(),F.hr=!0,F.thisLine.hr=!0,j.hr;if(z.peek()==="[")return s(z,F,P)}return s(z,F,F.inline)}function A(z,F){var ne=V.token(z,F.htmlState);if(!M){var ce=fe.innerMode(V,F.htmlState);(ce.mode.name=="xml"&&ce.state.tagStart===null&&!ce.state.context&&ce.state.tokenize.isInText||F.md_inside&&z.current().indexOf(">")>-1)&&(F.f=u,F.block=p,F.htmlState=null)}return ne}function E(z,F){var ne=F.listStack[F.listStack.length-1]||0,ce=F.indentation<ne,ge=ne+3;if(F.fencedEndRE&&F.indentation<=ge&&(ce||z.match(F.fencedEndRE))){_.highlightFormatting&&(F.formatting="code-block");var xe;return ce||(xe=f(F)),F.localMode=F.localState=null,F.block=p,F.f=u,F.fencedEndRE=null,F.code=0,F.thisLine.fencedCodeEnd=!0,ce?h(z,F,F.block):xe}else return F.localMode?F.localMode.token(z,F.localState):(z.skipToEnd(),j.code)}function f(z){var F=[];if(z.formatting){F.push(j.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var ne=0;ne<z.formatting.length;ne++)F.push(j.formatting+"-"+z.formatting[ne]),z.formatting[ne]==="header"&&F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.header),z.formatting[ne]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.quote):F.push("error"))}if(z.taskOpen)return F.push("meta"),F.length?F.join(" "):null;if(z.taskClosed)return F.push("property"),F.length?F.join(" "):null;if(z.linkHref?F.push(j.linkHref,"url"):(z.strong&&F.push(j.strong),z.em&&F.push(j.em),z.strikethrough&&F.push(j.strikethrough),z.emoji&&F.push(j.emoji),z.linkText&&F.push(j.linkText),z.code&&F.push(j.code),z.image&&F.push(j.image),z.imageAltText&&F.push(j.imageAltText,"link"),z.imageMarker&&F.push(j.imageMarker)),z.header&&F.push(j.header,j.header+"-"+z.header),z.quote&&(F.push(j.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?F.push(j.quote+"-"+z.quote):F.push(j.quote+"-"+_.maxBlockquoteDepth)),z.list!==!1){var ce=(z.listStack.length-1)%3;ce?ce===1?F.push(j.list2):F.push(j.list3):F.push(j.list1)}return z.trailingSpaceNewLine?F.push("trailing-space-new-line"):z.trailingSpace&&F.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),F.length?F.join(" "):null}function d(z,F){return z.match(w,!0)?f(F):void 0}function u(z,F){var ne=F.text(z,F);if(typeof ne!="undefined")return ne;if(F.list)return F.list=null,f(F);if(F.taskList){var ce=z.match(v,!0)[1]===" ";return ce?F.taskOpen=!0:F.taskClosed=!0,_.highlightFormatting&&(F.formatting="task"),F.taskList=!1,f(F)}if(F.taskOpen=!1,F.taskClosed=!1,F.header&&z.match(/^#+$/,!0))return _.highlightFormatting&&(F.formatting="header"),f(F);var ge=z.next();if(F.linkTitle){F.linkTitle=!1;var xe=ge;ge==="("&&(xe=")"),xe=(xe+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Ie="^\\s*(?:[^"+xe+"\\\\]+|\\\\\\\\|\\\\.)"+xe;if(z.match(new RegExp(Ie),!0))return j.linkHref}if(ge==="`"){var Te=F.formatting;_.highlightFormatting&&(F.formatting="code"),z.eatWhile("`");var Oe=z.current().length;if(F.code==0&&(!F.quote||Oe==1))return F.code=Oe,f(F);if(Oe==F.code){var Ce=f(F);return F.code=0,Ce}else return F.formatting=Te,f(F)}else if(F.code)return f(F);if(ge==="\\"&&(z.next(),_.highlightFormatting)){var Ae=f(F),ve=j.formatting+"-escape";return Ae?Ae+" "+ve:ve}if(ge==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return F.imageMarker=!0,F.image=!0,_.highlightFormatting&&(F.formatting="image"),f(F);if(ge==="["&&F.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return F.imageMarker=!1,F.imageAltText=!0,_.highlightFormatting&&(F.formatting="image"),f(F);if(ge==="]"&&F.imageAltText){_.highlightFormatting&&(F.formatting="image");var Ae=f(F);return F.imageAltText=!1,F.image=!1,F.inline=F.f=y,Ae}if(ge==="["&&!F.image)return F.linkText&&z.match(/^.*?\]/)||(F.linkText=!0,_.highlightFormatting&&(F.formatting="link")),f(F);if(ge==="]"&&F.linkText){_.highlightFormatting&&(F.formatting="link");var Ae=f(F);return F.linkText=!1,F.inline=F.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?y:u,Ae}if(ge==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,_.highlightFormatting&&(F.formatting="link");var Ae=f(F);return Ae?Ae+=" ":Ae="",Ae+j.linkInline}if(ge==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,_.highlightFormatting&&(F.formatting="link");var Ae=f(F);return Ae?Ae+=" ":Ae="",Ae+j.linkEmail}if(_.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 L=z.string.substring(z.start,W);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(L)&&(F.md_inside=!0)}return z.backUp(1),F.htmlState=fe.startState(V),h(z,F,A)}if(_.xml&&ge==="<"&&z.match(/^\/\w*?>/))return F.md_inside=!1,"tag";if(ge==="*"||ge==="_"){for(var k=1,H=z.pos==1?" ":z.string.charAt(z.pos-2);k<3&&z.eat(ge);)k++;var q=z.peek()||" ",B=!/\s/.test(q)&&(!l.test(q)||/\s/.test(H)||l.test(H)),ue=!/\s/.test(H)&&(!l.test(H)||/\s/.test(q)||l.test(q)),be=null,we=null;if(k%2&&(!F.em&&B&&(ge==="*"||!ue||l.test(H))?be=!0:F.em==ge&&ue&&(ge==="*"||!B||l.test(q))&&(be=!1)),k>1&&(!F.strong&&B&&(ge==="*"||!ue||l.test(H))?we=!0:F.strong==ge&&ue&&(ge==="*"||!B||l.test(q))&&(we=!1)),we!=null||be!=null){_.highlightFormatting&&(F.formatting=be==null?"strong":we==null?"em":"strong em"),be===!0&&(F.em=ge),we===!0&&(F.strong=ge);var Ce=f(F);return be===!1&&(F.em=!1),we===!1&&(F.strong=!1),Ce}}else if(ge===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return f(F);z.backUp(1)}if(_.strikethrough){if(ge==="~"&&z.eatWhile(ge)){if(F.strikethrough){_.highlightFormatting&&(F.formatting="strikethrough");var Ce=f(F);return F.strikethrough=!1,Ce}else if(z.match(/^[^\s]/,!1))return F.strikethrough=!0,_.highlightFormatting&&(F.formatting="strikethrough"),f(F)}else if(ge===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return f(F);z.backUp(2)}}if(_.emoji&&ge===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){F.emoji=!0,_.highlightFormatting&&(F.formatting="emoji");var Pe=f(F);return F.emoji=!1,Pe}return ge===" "&&(z.match(/^ +$/,!1)?F.trailingSpace++:F.trailingSpace&&(F.trailingSpaceNewLine=!0)),f(F)}function a(z,F){var ne=z.next();if(ne===">"){F.f=F.inline=u,_.highlightFormatting&&(F.formatting="link");var ce=f(F);return ce?ce+=" ":ce="",ce+j.linkInline}return z.match(/^[^>]+/,!0),j.linkInline}function y(z,F){if(z.eatSpace())return null;var ne=z.next();return ne==="("||ne==="["?(F.f=F.inline=S(ne==="("?")":"]"),_.highlightFormatting&&(F.formatting="link-string"),F.linkHref=!0,f(F)):"error"}var c={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function S(z){return function(F,ne){var ce=F.next();if(ce===z){ne.f=ne.inline=u,_.highlightFormatting&&(ne.formatting="link-string");var ge=f(ne);return ne.linkHref=!1,ge}return F.match(c[z]),ne.linkHref=!0,f(ne)}}function P(z,F){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(F.f=G,z.next(),_.highlightFormatting&&(F.formatting="link"),F.linkText=!0,f(F)):s(z,F,u)}function G(z,F){if(z.match(/^\]:/,!0)){F.f=F.inline=X,_.highlightFormatting&&(F.formatting="link");var ne=f(F);return F.linkText=!1,ne}return z.match(/^([^\]\\]|\\.)+/,!0),j.linkText}function X(z,F){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?F.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),F.f=F.inline=u,j.linkHref+" url")}var te={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:u,text:d,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&&fe.copyState(V,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?fe.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,F){if(F.formatting=!1,z!=F.thisLine.stream){if(F.header=0,F.hr=!1,z.match(/^\s*$/,!0))return m(F),null;if(F.prevLine=F.thisLine,F.thisLine={stream:z},F.taskList=!1,F.trailingSpace=0,F.trailingSpaceNewLine=!1,!F.localState&&(F.f=F.block,F.f!=A)){var ne=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(F.indentation=ne,F.indentationDiff=null,ne>0)return null}}return F.f(z,F)},innerMode:function(z){return z.block==A?{state:z.htmlState,mode:V}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:te}},indent:function(z,F,ne){return z.block==A&&V.indent?V.indent(z.htmlState,F,ne):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,F,ne):fe.Pass},blankLine:m,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return te},"xml"),fe.defineMIME("text/markdown","markdown"),fe.defineMIME("text/x-markdown","markdown")})},osHv:function(ct,rt,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";var $=fe.Pos;function _(l,o){return l.line-o.line||l.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",M=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",D=new RegExp("<(/?)(["+V+"]["+M+"]*)","g");function j(l,o,s,h){this.line=o,this.ch=s,this.cm=l,this.text=l.getLine(o),this.min=h?Math.max(h.from,l.firstLine()):l.firstLine(),this.max=h?Math.min(h.to-1,l.lastLine()):l.lastLine()}function U(l,o){var s=l.cm.getTokenTypeAt($(l.line,o));return s&&/\btag\b/.test(s)}function I(l){return l.line>=l.max?void 0:(l.ch=0,l.text=l.cm.getLine(++l.line),!0)}function O(l){return l.line<=l.min?void 0:(l.text=l.cm.getLine(--l.line),l.ch=l.text.length,!0)}function v(l){for(;;){var o=l.text.indexOf(">",l.ch);if(o==-1){if(I(l))continue;return}if(!U(l,o+1)){l.ch=o+1;continue}var s=l.text.lastIndexOf("/",o),h=s>-1&&!/\S/.test(l.text.slice(s+1,o));return l.ch=o+1,h?"selfClose":"regular"}}function g(l){for(;;){var o=l.ch?l.text.lastIndexOf("<",l.ch-1):-1;if(o==-1){if(O(l))continue;return}if(!U(l,o+1)){l.ch=o;continue}D.lastIndex=o,l.ch=o;var s=D.exec(l.text);if(s&&s.index==o)return s}}function R(l){for(;;){D.lastIndex=l.ch;var o=D.exec(l.text);if(!o){if(I(l))continue;return}if(!U(l,o.index+1)){l.ch=o.index+1;continue}return l.ch=o.index+o[0].length,o}}function w(l){for(;;){var o=l.ch?l.text.lastIndexOf(">",l.ch-1):-1;if(o==-1){if(O(l))continue;return}if(!U(l,o+1)){l.ch=o;continue}var s=l.text.lastIndexOf("/",o),h=s>-1&&!/\S/.test(l.text.slice(s+1,o));return l.ch=o+1,h?"selfClose":"regular"}}function b(l,o){for(var s=[];;){var h=R(l),C,m=l.line,p=l.ch-(h?h[0].length:0);if(!h||!(C=v(l)))return;if(C=="selfClose")continue;if(h[1]){for(var A=s.length-1;A>=0;--A)if(s[A]==h[2]){s.length=A;break}if(A<0&&(!o||o==h[2]))return{tag:h[2],from:$(m,p),to:$(l.line,l.ch)}}else s.push(h[2])}}function x(l,o){for(var s=[];;){var h=w(l);if(!h)return;if(h=="selfClose"){g(l);continue}var C=l.line,m=l.ch,p=g(l);if(!p)return;if(p[1])s.push(p[2]);else{for(var A=s.length-1;A>=0;--A)if(s[A]==p[2]){s.length=A;break}if(A<0&&(!o||o==p[2]))return{tag:p[2],from:$(l.line,l.ch),to:$(C,m)}}}}fe.registerHelper("fold","xml",function(l,o){for(var s=new j(l,o.line,0);;){var h=R(s);if(!h||s.line!=o.line)return;var C=v(s);if(!C)return;if(!h[1]&&C!="selfClose"){var m=$(s.line,s.ch),p=b(s,h[2]);return p&&_(p.from,m)>0?{from:m,to:p.from}:null}}}),fe.findMatchingTag=function(l,o,s){var h=new j(l,o.line,o.ch,s);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var C=v(h),m=C&&$(h.line,h.ch),p=C&&g(h);if(!C||!p||_(h,o)>0)return;var A={from:$(h.line,h.ch),to:m,tag:p[2]};return C=="selfClose"?{open:A,close:null,at:"open"}:p[1]?{open:x(h,p[2]),close:A,at:"close"}:(h=new j(l,m.line,m.ch,s),{open:A,close:b(h,p[2]),at:"open"})},fe.findEnclosingTag=function(l,o,s,h){for(var C=new j(l,o.line,o.ch,s);;){var m=x(C,h);if(!m)break;var p=new j(l,o.line,o.ch,s),A=b(p,m.tag);if(A)return{open:m,close:A}}},fe.scanForClosingTag=function(l,o,s,h){var C=new j(l,o.line,o.ch,h?{from:0,to:h}:null);return b(C,s)}})},p5ED:function(ct,rt,le){"use strict";var fe=le("+L6B"),$=le("2/Rp"),_=le("5Dmo"),V=le("3S7+"),M=le("k1fw"),D=le("9og8"),j=le("tJVT"),U=le("WmNS"),I=le.n(U),O=le("q1tI"),v=le.n(O),g=le("vHTk"),R=le.n(g),w=le("yEEn"),b=le("ZW9T"),x=le("1vsH"),l=le("V0Rq"),o=le("m3rI");rt.a=function(s){var h,C,m,p,A,E,f,d=s.editOffice,u=d===void 0?"view":d,a=s.data,y=s.theme,c=s.type,S=s.filename,P=s.monacoEditor,G=s.className,X=s.style,te=s.close,z=s.onClose,F=s.hasMask,ne=s.disabledDownload,ce=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)(ce,2),xe=ge[0],Ie=ge[1],Te=Object(O.useState)(""),Oe=Object(j.a)(Te,2),Ce=Oe[0],Ae=Oe[1],ve=Object(O.useState)(),W=Object(j.a)(ve,2),L=W[0],k=W[1],H=window.ENV==="build"?"/react/build":"",q=o.a.PROXY_SERVER||location.origin,B,ue=1024*1024,be=10*ue,we=Object(O.useRef)();(h=a)!==null&&h!==void 0&&h.startsWith("/api")&&c!=="txt"&&(a=(o.a.API_SERVER||location.origin)+a),c==="office"&&(B=Object(x.T)(a).filesize,B>be&&(c="other")),S&&P&&(P.filename=S),Object(O.useEffect)(function(){var Me,We,ze=(Me=document.cookie)===null||Me===void 0||((We=Me.replace(/\s/g,""))===null||We===void 0)?void 0:We.split(";");ze==null||ze.map(function(Xe){var Ge=Xe.split("=");Ge[0]==="_educoder_session"&&Ae(Ge[1])})},[]),Object(O.useEffect)(function(){c==="office"&&Pe()},[c,a]);var Pe=function(){var Me=Object(D.a)(I.a.mark(function We(){var ze,Xe,Ge;return I.a.wrap(function($e){for(;;)switch($e.prev=$e.next){case 0:return console.log("data:",a),ze=a,a.startsWith("http")||(ze=location.origin+ze),Xe=new URL(ze).pathname.split("/").pop(),$e.next=6,Object(l.V)({attachment_id:Xe});case 6:Ge=$e.sent,k(Ge);case 8:case"end":return $e.stop()}},We)}));return function(){return Me.apply(this,arguments)}}(),_e=function(){if(a.startsWith("http")||a.startsWith("blob:")){De();return}Object(x.z)(S||"educoder",a,S)},De=function(){Object(x.x)(S||"educoder",decodeURIComponent(a))};return v.a.createElement("div",{style:Object(M.a)({},X||{}),className:"".concat(F&&R.a.bgBlack," ").concat(c?R.a.wrp:"hide")},te&&v.a.createElement("div",{className:R.a.close,ref:we},!ne&&v.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return we.current}},v.a.createElement("span",{onClick:De},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return we.current}},v.a.createElement("span",{className:"",onClick:z},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(R.a[G]," ").concat(G," ").concat(R.a.monaco," ").concat(c==="txt"?"show":"hide")},c==="txt"&&v.a.createElement(b.b,P)),c==="audio"&&v.a.createElement("audio",{src:"".concat(((C=a)===null||C===void 0?void 0:C.indexOf("http://"))>-1||((m=a)===null||m===void 0?void 0:m.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),c==="video"&&v.a.createElement(v.a.Fragment,null,((p=a)===null||p===void 0?void 0:p.indexOf("http"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),c==="office"&&L&&v.a.createElement("iframe",{src:"".concat(H,"/office.html?key=").concat(L.key,"&url=").concat(q+L.url,"&callbackUrl=").concat(q+L.callbackUrl,"&fileType=").concat(L.fileType,"&title=").concat(L.title,"&model=").concat(u,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!ne)}),c==="html"&&v.a.createElement("iframe",{src:a+"&disposition=inline"}),c==="pdf"&&v.a.createElement("iframe",{src:"".concat(H,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!ne)}),c==="image"&&v.a.createElement("img",{src:"".concat(((A=a)===null||A===void 0?void 0:A.indexOf("http://"))>-1||((E=a)===null||E===void 0?void 0:E.indexOf("https://"))>-1||(f=a)!==null&&f!==void 0&&f.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),c==="other"&&v.a.createElement("div",null,v.a.createElement($.a,{type:"primary",size:"large",onClick:_e},v.a.createElement(w.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),c==="download"&&v.a.createElement($.a,{type:"primary",size:"large",onClick:_e},v.a.createElement(w.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(ct,rt,le){},rUJ1:function(ct,rt){const le=/[&<>"']/,fe=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,V={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},M=E=>V[E];function D(E,f){if(f){if(le.test(E))return E.replace(fe,M)}else if($.test(E))return E.replace(_,M);return E}const j=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function U(E){return E.replace(j,(f,d)=>(d=d.toLowerCase(),d==="colon"?":":d.charAt(0)==="#"?d.charAt(1)==="x"?String.fromCharCode(parseInt(d.substring(2),16)):String.fromCharCode(+d.substring(1)):""))}const I=/(^|[^\[])\^/g;function O(E,f){E=E.source||E,f=f||"";const d={replace:(u,a)=>(a=a.source||a,a=a.replace(I,"$1"),E=E.replace(u,a),d),getRegex:()=>new RegExp(E,f)};return d}const v=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(E,f,d){if(E){let u;try{u=decodeURIComponent(U(d)).replace(v,"").toLowerCase()}catch(a){return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}f&&!g.test(d)&&(d=o(f,d));try{d=encodeURI(d).replace(/%25/g,"%")}catch(u){return null}return d}const w={},b=/^[^:]+:\/*[^/]*$/,x=/^([^:]+:)[\s\S]*$/,l=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(E,f){w[" "+E]||(b.test(E)?w[" "+E]=E+"/":w[" "+E]=m(E,"/",!0)),E=w[" "+E];const d=E.indexOf(":")===-1;return f.substring(0,2)==="//"?d?f:E.replace(x,"$1")+f:f.charAt(0)==="/"?d?f:E.replace(l,"$1")+f:E+f}const s={exec:function(){}};function h(E){let f=1,d,u;for(;f<arguments.length;f++){d=arguments[f];for(u in d)Object.prototype.hasOwnProperty.call(d,u)&&(E[u]=d[u])}return E}function C(E,f){const d=E.replace(/\|/g,(y,c,S)=>{let P=!1,G=c;for(;--G>=0&&S[G]==="\\";)P=!P;return P?"|":" |"}),u=d.split(/ \|/);let a=0;if(u.length>f)u.splice(f);else for(;u.length<f;)u.push("");for(;a<u.length;a++)u[a]=u[a].trim().replace(/\\\|/g,"|");return u}function m(E,f,d){const u=E.length;if(u===0)return"";let a=0;for(;a<u;){const y=E.charAt(u-a-1);if(y===f&&!d)a++;else if(y!==f&&d)a++;else break}return E.substr(0,u-a)}function p(E,f){if(E.indexOf(f[1])===-1)return-1;const d=E.length;let u=0,a=0;for(;a<d;a++)if(E[a]==="\\")a++;else if(E[a]===f[0])u++;else if(E[a]===f[1]&&(u--,u<0))return a;return-1}function A(E){E&&E.sanitize&&!E.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")}ct.exports={escape:D,unescape:U,edit:O,cleanUrl:R,resolveUrl:o,noopTest:s,merge:h,splitCells:C,rtrim:m,findClosingBracket:p,checkSanitizeDeprecation:A}},ulZh:function(ct,rt,le){typeof window!="undefined"&&function($,_){ct.exports=_()}(this,function(){return function(fe){var $={};function _(V){if($[V])return $[V].exports;var M=$[V]={i:V,l:!1,exports:{}};return fe[V].call(M.exports,M,M.exports,_),M.l=!0,M.exports}return _.m=fe,_.c=$,_.d=function(V,M,D){_.o(V,M)||Object.defineProperty(V,M,{enumerable:!0,get:D})},_.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},_.t=function(V,M){if(M&1&&(V=_(V)),M&8)return V;if(M&4&&typeof V=="object"&&V&&V.__esModule)return V;var D=Object.create(null);if(_.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:V}),M&2&&typeof V!="string")for(var j in V)_.d(D,j,function(U){return V[U]}.bind(null,j));return D},_.n=function(V){var M=V&&V.__esModule?function(){return V.default}:function(){return V};return _.d(M,"a",M),M},_.o=function(V,M){return Object.prototype.hasOwnProperty.call(V,M)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(fe,$,_){"use strict";var V=Object.prototype.hasOwnProperty,M="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(M=!1));function j(v,g,R){this.fn=v,this.context=g,this.once=R||!1}function U(v,g,R,w,b){if(typeof R!="function")throw new TypeError("The listener must be a function");var x=new j(R,w||v,b),l=M?M+g:g;return v._events[l]?v._events[l].fn?v._events[l]=[v._events[l],x]:v._events[l].push(x):(v._events[l]=x,v._eventsCount++),v}function I(v,g){--v._eventsCount===0?v._events=new D:delete v._events[g]}function O(){this._events=new D,this._eventsCount=0}O.prototype.eventNames=function(){var g=[],R,w;if(this._eventsCount===0)return g;for(w in R=this._events)V.call(R,w)&&g.push(M?w.slice(1):w);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(R)):g},O.prototype.listeners=function(g){var R=M?M+g:g,w=this._events[R];if(!w)return[];if(w.fn)return[w.fn];for(var b=0,x=w.length,l=new Array(x);b<x;b++)l[b]=w[b].fn;return l},O.prototype.listenerCount=function(g){var R=M?M+g:g,w=this._events[R];return w?w.fn?1:w.length:0},O.prototype.emit=function(g,R,w,b,x,l){var o=M?M+g:g;if(!this._events[o])return!1;var s=this._events[o],h=arguments.length,C,m;if(s.fn){s.once&&this.removeListener(g,s.fn,void 0,!0);switch(h){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,w),!0;case 4:return s.fn.call(s.context,R,w,b),!0;case 5:return s.fn.call(s.context,R,w,b,x),!0;case 6:return s.fn.call(s.context,R,w,b,x,l),!0}for(m=1,C=new Array(h-1);m<h;m++)C[m-1]=arguments[m];s.fn.apply(s.context,C)}else{var p=s.length,A;for(m=0;m<p;m++){s[m].once&&this.removeListener(g,s[m].fn,void 0,!0);switch(h){case 1:s[m].fn.call(s[m].context);break;case 2:s[m].fn.call(s[m].context,R);break;case 3:s[m].fn.call(s[m].context,R,w);break;case 4:s[m].fn.call(s[m].context,R,w,b);break;default:if(!C)for(A=1,C=new Array(h-1);A<h;A++)C[A-1]=arguments[A];s[m].fn.apply(s[m].context,C)}}}return!0},O.prototype.on=function(g,R,w){return U(this,g,R,w,!1)},O.prototype.once=function(g,R,w){return U(this,g,R,w,!0)},O.prototype.removeListener=function(g,R,w,b){var x=M?M+g:g;if(!this._events[x])return this;if(!R)return I(this,x),this;var l=this._events[x];if(l.fn)l.fn===R&&(!b||l.once)&&(!w||l.context===w)&&I(this,x);else{for(var o=0,s=[],h=l.length;o<h;o++)(l[o].fn!==R||b&&!l[o].once||w&&l[o].context!==w)&&s.push(l[o]);s.length?this._events[x]=s.length===1?s[0]:s:I(this,x)}return this},O.prototype.removeAllListeners=function(g){var R;return g?(R=M?M+g:g,this._events[R]&&I(this,R)):(this._events=new D,this._eventsCount=0),this},O.prototype.off=O.prototype.removeListener,O.prototype.addListener=O.prototype.on,O.prefixed=M,O.EventEmitter=O,fe.exports=O},"./node_modules/url-toolkit/src/url-toolkit.js":function(fe,$,_){(function(V){var M=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,D=/^([^\/?#]*)([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,U=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,I={buildAbsoluteURL:function(O,v,g){if(g=g||{},O=O.trim(),v=v.trim(),!v){if(!g.alwaysNormalize)return O;var R=I.parseURL(O);if(!R)throw new Error("Error trying to parse base URL.");return R.path=I.normalizePath(R.path),I.buildURLFromParts(R)}var w=I.parseURL(v);if(!w)throw new Error("Error trying to parse relative URL.");if(w.scheme)return g.alwaysNormalize?(w.path=I.normalizePath(w.path),I.buildURLFromParts(w)):v;var b=I.parseURL(O);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var x=D.exec(b.path);b.netLoc=x[1],b.path=x[2]}b.netLoc&&!b.path&&(b.path="/");var l={scheme:b.scheme,netLoc:w.netLoc,path:null,params:w.params,query:w.query,fragment:w.fragment};if(!w.netLoc&&(l.netLoc=b.netLoc,w.path[0]!=="/"))if(!w.path)l.path=b.path,w.params||(l.params=b.params,w.query||(l.query=b.query));else{var o=b.path,s=o.substring(0,o.lastIndexOf("/")+1)+w.path;l.path=I.normalizePath(s)}return l.path===null&&(l.path=g.alwaysNormalize?I.normalizePath(w.path):w.path),I.buildURLFromParts(l)},parseURL:function(O){var v=M.exec(O);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(j,"");O.length!==(O=O.replace(U,"")).length;);return O.split("").reverse().join("")},buildURLFromParts:function(O){return O.scheme+O.netLoc+O.path+O.params+O.query+O.fragment}};fe.exports=I})(this)},"./node_modules/webworkify-webpack/index.js":function(fe,$,_){function V(g){var R={};function w(x){if(R[x])return R[x].exports;var l=R[x]={i:x,l:!1,exports:{}};return g[x].call(l.exports,l,l.exports,w),l.l=!0,l.exports}w.m=g,w.c=R,w.i=function(x){return x},w.d=function(x,l,o){w.o(x,l)||Object.defineProperty(x,l,{configurable:!1,enumerable:!0,get:o})},w.r=function(x){Object.defineProperty(x,"__esModule",{value:!0})},w.n=function(x){var l=x&&x.__esModule?function(){return x.default}:function(){return x};return w.d(l,"a",l),l},w.o=function(x,l){return Object.prototype.hasOwnProperty.call(x,l)},w.p="/",w.oe=function(x){throw console.error(x),x};var b=w(w.s=ENTRY_MODULE);return b.default||b}var M="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function j(g){return(g+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function U(g){return!isNaN(1*g)}function I(g,R,w){var b={};b[w]=[];var x=R.toString(),l=x.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!l)return b;for(var o=l[1],s=new RegExp("(\\\\n|\\W)"+j(o)+D,"g"),h;h=s.exec(x);){if(h[3]==="dll-reference")continue;b[w].push(h[3])}for(s=new RegExp("\\("+j(o)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+D,"g");h=s.exec(x);)g[h[2]]||(b[w].push(h[1]),g[h[2]]=_(h[1]).m),b[h[2]]=b[h[2]]||[],b[h[2]].push(h[4]);for(var C=Object.keys(b),m=0;m<C.length;m++)for(var p=0;p<b[C[m]].length;p++)U(b[C[m]][p])&&(b[C[m]][p]=1*b[C[m]][p]);return b}function O(g){var R=Object.keys(g);return R.reduce(function(w,b){return w||g[b].length>0},!1)}function v(g,R){for(var w={main:[R]},b={main:[]},x={main:{}};O(w);)for(var l=Object.keys(w),o=0;o<l.length;o++){var s=l[o],h=w[s],C=h.pop();if(x[s]=x[s]||{},x[s][C]||!g[s][C])continue;x[s][C]=!0,b[s]=b[s]||[],b[s].push(C);for(var m=I(g,g[s][C],s),p=Object.keys(m),A=0;A<p.length;A++)w[p[A]]=w[p[A]]||[],w[p[A]]=w[p[A]].concat(m[p[A]])}return b}fe.exports=function(g,R){R=R||{};var w={main:_.m},b=R.all?{main:Object.keys(w.main)}:v(w,g),x="";Object.keys(b).filter(function(C){return C!=="main"}).forEach(function(C){for(var m=0;b[C][m];)m++;b[C].push(m),w[C][m]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",x=x+"var "+C+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+b[C].map(function(p){return""+JSON.stringify(p)+": "+w[C][p].toString()}).join(",")+`});
`}),x=x+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(g))+")({"+b.main.map(function(C){return""+JSON.stringify(C)+": "+w.main[C].toString()}).join(",")+"}))(self);";var l=new window.Blob([x],{type:"text/javascript"});if(R.bare)return l;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,s=o.createObjectURL(l),h=new window.Worker(s);return h.objectURL=s,h}},"./src/config.ts":function(fe,$,_){"use strict";_.r($),_.d($,"hlsDefaultConfig",function(){return A}),_.d($,"mergeConfig",function(){return f}),_.d($,"enableStreamingMode",function(){return d});var V=_("./src/controller/abr-controller.ts"),M=_("./src/controller/audio-stream-controller.ts"),D=_("./src/controller/audio-track-controller.ts"),j=_("./src/controller/subtitle-stream-controller.ts"),U=_("./src/controller/subtitle-track-controller.ts"),I=_("./src/controller/buffer-controller.ts"),O=_("./src/controller/timeline-controller.ts"),v=_("./src/controller/cap-level-controller.ts"),g=_("./src/controller/fps-controller.ts"),R=_("./src/controller/eme-controller.ts"),w=_("./src/controller/cmcd-controller.ts"),b=_("./src/utils/xhr-loader.ts"),x=_("./src/utils/fetch-loader.ts"),l=_("./src/utils/cues.ts"),o=_("./src/utils/mediakeys-helper.ts"),s=_("./src/utils/logger.ts");function h(){return h=Object.assign||function(u){for(var a=1;a<arguments.length;a++){var y=arguments[a];for(var c in y)Object.prototype.hasOwnProperty.call(y,c)&&(u[c]=y[c])}return u},h.apply(this,arguments)}function C(u,a){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(u);a&&(c=c.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),y.push.apply(y,c)}return y}function m(u){for(var a=1;a<arguments.length;a++){var y=arguments[a]!=null?arguments[a]:{};a%2?C(Object(y),!0).forEach(function(c){p(u,c,y[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):C(Object(y)).forEach(function(c){Object.defineProperty(u,c,Object.getOwnPropertyDescriptor(y,c))})}return u}function p(u,a,y){return a in u?Object.defineProperty(u,a,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[a]=y,u}var A=m(m({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:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:I.default,capLevelController:v.default,fpsController:g.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},E()),{},{subtitleStreamController:j.SubtitleStreamController,subtitleTrackController:U.default,timelineController:O.TimelineController,audioStreamController:M.default,audioTrackController:D.default,emeController:R.default,cmcdController:w.default});function E(){return{cueHandler:l.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function f(u,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,a)}function d(u){var a=u.loader;if(a!==x.default&&a!==b.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var y=Object(x.fetchSupported)();y&&(u.loader=x.default,u.progressive=!0,u.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),M=_("./src/utils/ewma-bandwidth-estimator.ts"),D=_("./src/events.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/errors.ts"),I=_("./src/types/loader.ts"),O=_("./src/utils/logger.ts");function v(w,b){for(var x=0;x<b.length;x++){var l=b[x];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(w,l.key,l)}}function g(w,b,x){return b&&v(w.prototype,b),x&&v(w,x),w}var R=function(){function w(x){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=x;var l=x.config;this.bwEstimator=new M.default(l.abrEwmaSlowVoD,l.abrEwmaFastVoD,l.abrEwmaDefaultEstimate),this.registerListeners()}var b=w.prototype;return b.registerListeners=function(){var l=this.hls;l.on(D.Events.FRAG_LOADING,this.onFragLoading,this),l.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),l.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(D.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var l=this.hls;l.off(D.Events.FRAG_LOADING,this.onFragLoading,this),l.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),l.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(D.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(l,o){var s=o.frag;if(s.type===I.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=s,this.partCurrent=(h=o.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(l,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var l=this.fragCurrent,o=this.partCurrent,s=this.hls,h=s.autoLevelEnabled,C=s.config,m=s.media;if(!l||!m)return;var p=o?o.stats:l.stats,A=o?o.duration:l.duration;if(p.aborted){O.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||m.paused||!m.playbackRate||!m.readyState)return;var E=performance.now()-p.loading.start,f=Math.abs(m.playbackRate);if(E<=500*A/f)return;var d=s.levels,u=s.minAutoLevel,a=d[l.level],y=p.total||Math.max(p.loaded,Math.round(A*a.maxBitrate/8)),c=Math.max(1,p.bwEstimate?p.bwEstimate/8:p.loaded*1e3/E),S=(y-p.loaded)/c,P=m.currentTime,G=(j.BufferHelper.bufferInfo(m,P,C.maxBufferHole).end-P)/f;if(G>=2*A/f||S<=G)return;var X=Number.POSITIVE_INFINITY,te;for(te=l.level-1;te>u;te--){var z=d[te].maxBitrate;if(X=A*z/(8*.8*c),X<G)break}if(X>=S)return;var F=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+l.sn+(o?" part "+o.index:"")+" of level "+l.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+te+`
Current BW estimate: `+(Object(V.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+S.toFixed(3)+` s
Estimated load time for the next fragment: `+X.toFixed(3)+` s
Time to underbuffer: `+G.toFixed(3)+" s"),s.nextLoadLevel=te,this.bwEstimator.sample(E,p.loaded),this.clearTimer(),l.loader&&(this.fragCurrent=this.partCurrent=null,l.loader.abort()),s.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:o,stats:p})},b.onFragLoaded=function(l,o){var s=o.frag,h=o.part;if(s.type===I.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(s.sn)){var C=h?h.stats:s.stats,m=h?h.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[s.level],A=(p.loaded?p.loaded.bytes:0)+C.loaded,E=(p.loaded?p.loaded.duration:0)+m;p.loaded={bytes:A,duration:E},p.realBitrate=Math.round(8*A/E)}if(s.bitrateTest){var f={stats:C,frag:s,part:h,id:s.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,f),s.bitrateTest=!1}}},b.onFragBuffered=function(l,o){var s=o.frag,h=o.part,C=h?h.stats:s.stats;if(C.aborted)return;if(s.type!==I.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var m=C.parsing.end-C.loading.start;this.bwEstimator.sample(m,C.loaded),C.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=m/1e3:this.bitrateTestDelay=0},b.onError=function(l,o){switch(o.details){case U.ErrorDetails.FRAG_LOAD_ERROR:case U.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var l=this.fragCurrent,o=this.partCurrent,s=this.hls,h=s.maxAutoLevel,C=s.config,m=s.minAutoLevel,p=s.media,A=o?o.duration:l?l.duration:0,E=p?p.currentTime:0,f=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():C.abrEwmaDefaultEstimate,u=(j.BufferHelper.bufferInfo(p,E,C.maxBufferHole).end-E)/f,a=this.findBestLevel(d,m,h,u,C.abrBandWidthFactor,C.abrBandWidthUpFactor);if(a>=0)return a;O.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=A?Math.min(A,C.maxStarvationDelay):C.maxStarvationDelay,c=C.abrBandWidthFactor,S=C.abrBandWidthUpFactor;if(!u){var P=this.bitrateTestDelay;if(P){var G=A?Math.min(A,C.maxLoadingDelay):C.maxLoadingDelay;y=G-P,O.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),c=S=1}}return a=this.findBestLevel(d,m,h,u+y,c,S),Math.max(a,0)},b.findBestLevel=function(l,o,s,h,C,m){for(var p,A=this.fragCurrent,E=this.partCurrent,f=this.lastLoadedFragLevel,d=this.hls.levels,u=d[f],a=!!(u!=null&&(p=u.details)!==null&&p!==void 0&&p.live),y=u==null?void 0:u.codecSet,c=E?E.duration:A?A.duration:0,S=s;S>=o;S--){var P=d[S];if(!P||y&&P.codecSet!==y)continue;var G=P.details,X=(E?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||c,te=void 0;S<=f?te=C*l:te=m*l;var z=d[S].maxBitrate,F=z*X/te;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(te)+"/"+z+"/"+X+"/"+h+"/"+F),te>z&&(!F||a&&!this.bitrateTestDelay||F<h))return S}return-1},g(w,[{key:"nextAutoLevel",get:function(){var l=this._nextAutoLevel,o=this.bwEstimator;if(l!==-1&&(!o||!o.canEstimate()))return l;var s=this.getNextABRAutoLevel();return l!==-1&&(s=Math.min(l,s)),s},set:function(l){this._nextAutoLevel=l}}]),w}();$.default=R},"./src/controller/audio-stream-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),M=_("./src/controller/base-stream-controller.ts"),D=_("./src/events.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/controller/fragment-tracker.ts"),I=_("./src/types/level.ts"),O=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),g=_("./src/demux/chunk-cache.ts"),R=_("./src/demux/transmuxer-interface.ts"),w=_("./src/types/transmuxer.ts"),b=_("./src/controller/fragment-finders.ts"),x=_("./src/utils/discontinuities.ts"),l=_("./src/errors.ts"),o=_("./src/utils/logger.ts");function s(){return s=Object.assign||function(A){for(var E=1;E<arguments.length;E++){var f=arguments[E];for(var d in f)Object.prototype.hasOwnProperty.call(f,d)&&(A[d]=f[d])}return A},s.apply(this,arguments)}function h(A,E){A.prototype=Object.create(E.prototype),A.prototype.constructor=A,C(A,E)}function C(A,E){return C=Object.setPrototypeOf||function(d,u){return d.__proto__=u,d},C(A,E)}var m=100,p=function(A){h(E,A);function E(d,u){var a;return a=A.call(this,d,u,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var f=E.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var u=this.hls;u.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(D.Events.ERROR,this.onError,this),u.on(D.Events.BUFFER_RESET,this.onBufferReset,this),u.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),u.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f._unregisterListeners=function(){var u=this.hls;u.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(D.Events.ERROR,this.onError,this),u.off(D.Events.BUFFER_RESET,this.onBufferReset,this),u.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),u.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f.onInitPtsFound=function(u,a){var y=a.frag,c=a.id,S=a.initPTS;if(c==="main"){var P=y.cc;this.initPTS[y.cc]=S,this.log("InitPTS for cc: "+P+" found from main: "+S),this.videoTrackCC=P,this.state===M.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(u){if(!this.levels){this.startPosition=u,this.state=M.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(m),this.fragLoadError=0,a>0&&u===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=M.State.IDLE):(this.loadedmetadata=!1,this.state=M.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()},f.doTick=function(){switch(this.state){case M.State.IDLE:this.doTickIdle();break;case M.State.WAITING_TRACK:{var u,a=this.levels,y=this.trackId,c=a==null||((u=a[y])===null||u===void 0)?void 0:u.details;if(c){if(this.waitForCdnTuneIn(c))break;this.state=M.State.WAITING_INIT_PTS}break}case M.State.FRAG_LOADING_WAITING_RETRY:{var S,P=performance.now(),G=this.retryDate;(!G||P>=G||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=M.State.IDLE);break}case M.State.WAITING_INIT_PTS:{var X=this.waitingData;if(X){var te=X.frag,z=X.part,F=X.cache,ne=X.complete;if(this.initPTS[te.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=M.State.FRAG_LOADING;var ce=F.flush(),ge={frag:te,part:z,payload:ce,networkDetails:null};this._handleFragmentLoadProgress(ge),ne&&A.prototype._handleFragmentLoadComplete.call(this,ge)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+te.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var xe=this.getLoadPosition(),Ie=j.BufferHelper.bufferInfo(this.mediaBuffer,xe,this.config.maxBufferHole),Te=Object(b.fragmentWithinToleranceTest)(Ie.end,this.config.maxFragLookUpTolerance,te);Te<0&&(o.logger.log("Waiting fragment cc ("+te.cc+") @ "+te.start+" cancelled because another fragment at "+Ie.end+" is needed"),this.clearWaitingFragment())}}else this.state=M.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var u=this.waitingData;u&&(this.fragmentTracker.removeFragment(u.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=M.State.IDLE)},f.onTickEnd=function(){var u=this.media;if(!u||!u.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:u,y=a.buffered;!this.loadedmetadata&&y.length&&(this.loadedmetadata=!0),this.lastCurrentTime=u.currentTime},f.doTickIdle=function(){var u,a,y=this.hls,c=this.levels,S=this.media,P=this.trackId,G=y.config;if(!c||!c[P])return;if(!S&&(this.startFragRequested||!G.startFragPrefetch))return;var X=c[P],te=X.details;if(!te||te.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(te)){this.state=M.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(),ce=this.audioSwitch;if(F>=ne&&!ce)return;if(!ce&&this._streamEnded(z,te)){y.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=M.State.ENDED;return}var ge=te.fragments,xe=ge[0].start,Ie=z.end;if(ce){var Te=this.getLoadPosition();Ie=Te,te.PTSKnown&&Te<xe&&((z.end>xe||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),S.currentTime=xe+.05))}var Oe=this.getNextFragment(Ie,te);if(!Oe){this.bufferFlushed=!0;return}((u=Oe.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((a=Oe.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Oe,te):this.loadFragment(Oe,te,Ie)},f.getMaxBufferLength=function(){var u=A.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return a===null?u:Math.max(u,a.len)},f.onMediaDetaching=function(){this.videoBuffer=null,A.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(u,a){var y=a.audioTracks;this.resetTransmuxer(),this.levels=y.map(function(c){return new I.Level(c)})},f.onAudioTrackSwitching=function(u,a){var y=!!a.url;this.trackId=a.id;var c=this.fragCurrent;c!=null&&c.loader&&c.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),y?this.setInterval(m):this.resetTransmuxer(),y?(this.audioSwitch=!0,this.state=M.State.IDLE):this.state=M.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(u,a){this.mainDetails=a.details},f.onAudioTrackLoaded=function(u,a){var y,c=this.levels,S=a.details,P=a.id;if(!c){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+S.startSN+","+S.endSN+"],duration:"+S.totalduration);var G=c[P],X=0;if(S.live||(y=G.details)!==null&&y!==void 0&&y.live){var te=this.mainDetails;if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed||!te)return;!G.details&&S.hasProgramDateTime&&te.hasProgramDateTime?(Object(x.alignMediaPlaylistByPDT)(S,te),X=S.fragments[0].start):X=this.alignPlaylists(S,G.details)}G.details=S,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!S.live)&&this.setStartPosition(G.details,X),this.state===M.State.WAITING_TRACK&&!this.waitForCdnTuneIn(S)&&(this.state=M.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(u){var a,y=u.frag,c=u.part,S=u.payload,P=this.config,G=this.trackId,X=this.levels;if(!X){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 te=X[G];console.assert(te,"Audio track is defined on fragment load progress");var z=te.details;console.assert(z,"Audio track details are defined on fragment load progress");var F=P.defaultAudioCodec||te.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 ce=this.initPTS[y.cc],ge=(a=y.initSegment)===null||a===void 0?void 0:a.data;if(ce!==void 0){var xe=!1,Ie=c?c.index:-1,Te=Ie!==-1,Oe=new w.ChunkMetadata(y.level,y.sn,y.stats.chunkCount,S.byteLength,Ie,Te);ne.push(S,ge,F,"",y,c,z.totalduration,xe,Oe,ce)}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:c,cache:new g.default,complete:!1},Ae=Ce.cache;Ae.push(new Uint8Array(S)),this.waitingVideoCC=this.videoTrackCC,this.state=M.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(u){if(this.waitingData){this.waitingData.complete=!0;return}A.prototype._handleFragmentLoadComplete.call(this,u)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(u,a){var y=a.tracks.audio;y&&(this.mediaBuffer=y.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(u,a){var y=a.frag,c=a.part;if(y.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(y)){this.warn("Fragment "+y.sn+(c?" p: "+c.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,c)},f.onError=function(u,a){switch(a.details){case l.ErrorDetails.FRAG_LOAD_ERROR:case l.ErrorDetails.FRAG_LOAD_TIMEOUT:case l.ErrorDetails.KEY_LOAD_ERROR:case l.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,a);break;case l.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case l.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==M.State.ERROR&&this.state!==M.State.STOPPED&&(this.state=a.fatal?M.State.ERROR:M.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case l.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===M.State.PARSING||this.state===M.State.PARSED)){var y=!0,c=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);c&&c.len>.5&&(y=!this.reduceMaxBufferLength(c.len)),y&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,A.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},f.onBufferFlushed=function(u,a){var y=a.type;y===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(u){var a,y="audio",c=this.hls,S=u.remuxResult,P=u.chunkMeta,G=this.getCurrentContext(P);if(!G){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var X=G.frag,te=G.part,z=S.audio,F=S.text,ne=S.id3,ce=S.initSegment;if(this.fragContextChanged(X))return;if(this.state=M.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ce!=null&&ce.tracks&&(this._bufferInitSegment(ce.tracks,X,P),c.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:X,id:y,tracks:ce.tracks})),z){var ge=z.startPTS,xe=z.endPTS,Ie=z.startDTS,Te=z.endDTS;te&&(te.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ge,endPTS:xe,startDTS:Ie,endDTS:Te}),X.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ge,xe,Ie,Te),this.bufferFragmentData(z,X,te,P)}if(ne!=null&&(a=ne.samples)!==null&&a!==void 0&&a.length){var Oe=s({frag:X,id:y},ne);c.trigger(D.Events.FRAG_PARSING_METADATA,Oe)}if(F){var Ce=s({frag:X,id:y},F);c.trigger(D.Events.FRAG_PARSING_USERDATA,Ce)}},f._bufferInitSegment=function(u,a,y){if(this.state!==M.State.PARSING)return;u.video&&delete u.video;var c=u.audio;if(!c)return;c.levelCodec=c.codec,c.id="audio",this.log("Init audio buffer, container:"+c.container+", codecs[parsed]=["+c.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,u);var S=c.initSegment;if(S!=null&&S.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:y,parent:a.type,data:S};this.hls.trigger(D.Events.BUFFER_APPENDING,P)}this.tick()},f.loadFragment=function(u,a,y){var c=this.fragmentTracker.getState(u);this.fragCurrent=u,(this.audioSwitch||c===U.FragmentState.NOT_LOADED||c===U.FragmentState.PARTIAL)&&(u.sn==="initSegment"?this._loadInitSegment(u):a.live&&!Object(V.isFiniteNumber)(this.initPTS[u.cc])?(this.log("Waiting for video PTS in continuity counter "+u.cc+" of live stream before loading audio fragment "+u.sn+" of level "+this.trackId),this.state=M.State.WAITING_INIT_PTS):(this.startFragRequested=!0,A.prototype.loadFragment.call(this,u,a,y)))},f.completeAudioSwitch=function(){var u=this.hls,a=this.media,y=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),A.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,u.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:y})},E}(M.default);$.default=p},"./src/controller/audio-track-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts"),M=_("./src/errors.ts"),D=_("./src/controller/base-playlist-controller.ts"),j=_("./src/types/loader.ts");function U(R,w){for(var b=0;b<w.length;b++){var x=w[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(R,x.key,x)}}function I(R,w,b){return w&&U(R.prototype,w),b&&U(R,b),R}function O(R,w){R.prototype=Object.create(w.prototype),R.prototype.constructor=R,v(R,w)}function v(R,w){return v=Object.setPrototypeOf||function(x,l){return x.__proto__=l,x},v(R,w)}var g=function(R){O(w,R);function w(x){var l;return l=R.call(this,x,"[audio-track-controller]")||this,l.tracks=[],l.groupId=null,l.tracksInGroup=[],l.trackId=-1,l.trackName="",l.selectDefaultTrack=!0,l.registerListeners(),l}var b=w.prototype;return b.registerListeners=function(){var l=this.hls;l.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),l.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),l.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.on(V.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var l=this.hls;l.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),l.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),l.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.off(V.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(l,o){this.tracks=o.audioTracks||[]},b.onAudioTrackLoaded=function(l,o){var s=o.id,h=o.details,C=this.tracksInGroup[s];if(!C){this.warn("Invalid audio track id "+s);return}var m=C.details;C.details=o.details,this.log("audioTrack "+s+" loaded ["+h.startSN+"-"+h.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,o,m))},b.onLevelLoading=function(l,o){this.switchLevel(o.level)},b.onLevelSwitching=function(l,o){this.switchLevel(o.level)},b.switchLevel=function(l){var o=this.hls.levels[l];if(!(o!=null&&o.audioGroupIds))return;var s=o.audioGroupIds[o.urlId];if(this.groupId!==s){this.groupId=s;var h=this.tracks.filter(function(m){return!s||m.groupId===s});this.selectDefaultTrack&&!h.some(function(m){return m.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var C={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,C),this.selectInitialTrack()}},b.onError=function(l,o){if(R.prototype.onError.call(this,l,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)},b.setAudioTrack=function(l){var o=this.tracksInGroup;if(l<0||l>=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 "+l);var h=o[l],C=h.id,m=h.groupId,p=m===void 0?"":m,A=h.name,E=h.type,f=h.url;if(this.trackId=l,this.trackName=A,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:C,groupId:p,name:A,type:E,url:f}),h.details&&!h.details.live)return;var d=this.switchParams(h.url,s==null?void 0:s.details);this.loadPlaylist(d)},b.selectInitialTrack=function(){var l=this.tracksInGroup;console.assert(l.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:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(l){for(var o=this.tracksInGroup,s=0;s<o.length;s++){var h=o[s];if((!this.selectDefaultTrack||h.default)&&(!l||l===h.name))return h.id}return-1},b.loadPlaylist=function(l){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var s=o.id,h=o.groupId,C=o.url;if(l)try{C=l.addDirectives(C)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:C,id:s,groupId:h,deliveryDirectives:l||null})}},I(w,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(l){this.selectDefaultTrack=!1,this.setAudioTrack(l)}}]),w}(D.default);$.default=g},"./src/controller/base-playlist-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return I});var V=_("./src/polyfills/number.ts"),M=_("./src/types/level.ts"),D=_("./src/controller/level-helper.ts"),j=_("./src/utils/logger.ts"),U=_("./src/errors.ts"),I=function(){function O(g,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=g}var v=O.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(R,w){w.fatal&&w.type===U.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},v.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},v.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},v.stopLoad=function(){this.canLoad=!1,this.clearTimer()},v.switchParams=function(R,w){var b=w==null?void 0:w.renditionReports;if(b)for(var x=0;x<b.length;x++){var l=b[x],o=""+l.URI;if(o===R.substr(-o.length)){var s=parseInt(l["LAST-MSN"]),h=parseInt(l["LAST-PART"]);if(w&&this.hls.config.lowLatencyMode){var C=Math.min(w.age-w.partTarget,w.targetduration);h!==void 0&&C>w.partTarget&&(h+=1)}if(Object(V.isFiniteNumber)(s))return new M.HlsUrlParameters(s,Object(V.isFiniteNumber)(h)?h:void 0,M.HlsSkip.No)}}},v.loadPlaylist=function(R){},v.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},v.playlistLoaded=function(R,w,b){var x=this,l=w.details,o=w.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(l.advancedDateTime=Date.now()-s,l.live||b!=null&&b.live){if(l.reloaded(b),b&&this.log("live playlist "+R+" "+(l.advanced?"REFRESHED "+l.lastPartSn+"-"+l.lastPartIndex:"MISSED")),b&&l.fragments.length>0&&Object(D.mergeDetails)(b,l),!this.canLoad||!l.live)return;var h,C=void 0,m=void 0;if(l.canBlockReload&&l.endSN&&l.advanced){var p=this.hls.config.lowLatencyMode,A=l.lastPartSn,E=l.endSN,f=l.lastPartIndex,d=f!==-1,u=A===E,a=p?0:f;d?(C=u?E+1:A,m=u?a:f+1):C=E+1;var y=l.age,c=y+l.ageHeader,S=Math.min(c-l.partTarget,l.targetduration*1.5);if(S>0){if(b&&S>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+S+" with playlist age: "+l.age),S=0;else{var P=Math.floor(S/l.targetduration);if(C+=P,m!==void 0){var G=Math.round(S%l.targetduration/l.partTarget);m+=G}this.log("CDN Tune-in age: "+l.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+S+" skip sn "+P+" to part "+m)}l.tuneInGoal=S}if(h=this.getDeliveryDirectives(l,w.deliveryDirectives,C,m),p||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(l,w.deliveryDirectives,C,m);var X=Object(D.computeReloadInterval)(l,o);C!==void 0&&l.canBlockReload&&(X-=l.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round(X)+" ms"),this.timer=self.setTimeout(function(){return x.loadPlaylist(h)},X)}else this.clearTimer()},v.getDeliveryDirectives=function(R,w,b,x){var l=Object(M.getSkipValue)(R,b);return w!=null&&w.skip&&R.deltaUpdateFailed&&(b=w.msn,x=w.part,l=M.HlsSkip.No),new M.HlsUrlParameters(b,x,l)},v.retryLoadingOrFail=function(R){var w=this,b=this.hls.config,x=this.retryCount<b.levelLoadingMaxRetry;if(x){var l;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(l=R.context)!==null&&l!==void 0&&l.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return w.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 x},O}()},"./src/controller/base-stream-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"State",function(){return E}),_.d($,"default",function(){return f});var V=_("./src/polyfills/number.ts"),M=_("./src/task-loop.ts"),D=_("./src/controller/fragment-tracker.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/utils/logger.ts"),I=_("./src/events.ts"),O=_("./src/errors.ts"),v=_("./src/types/transmuxer.ts"),g=_("./src/utils/mp4-tools.ts"),R=_("./src/utils/discontinuities.ts"),w=_("./src/controller/fragment-finders.ts"),b=_("./src/controller/level-helper.ts"),x=_("./src/loader/fragment-loader.ts"),l=_("./src/crypt/decrypter.ts"),o=_("./src/utils/time-ranges.ts"),s=_("./src/types/loader.ts");function h(d,u){for(var a=0;a<u.length;a++){var y=u[a];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(d,y.key,y)}}function C(d,u,a){return u&&h(d.prototype,u),a&&h(d,a),d}function m(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function p(d,u){d.prototype=Object.create(u.prototype),d.prototype.constructor=d,A(d,u)}function A(d,u){return A=Object.setPrototypeOf||function(y,c){return y.__proto__=c,y},A(d,u)}var E={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},f=function(d){p(u,d);function u(y,c,S){var P;return P=d.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=E.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=S,P.log=U.logger.log.bind(U.logger,S+":"),P.warn=U.logger.warn.bind(U.logger,S+":"),P.hls=y,P.fragmentLoader=new x.default(y.config),P.fragmentTracker=c,P.config=y.config,P.decrypter=new l.default(y,y.config),y.on(I.Events.KEY_LOADED,P.onKeyLoaded,m(P)),P}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(c){},a.stopLoad=function(){this.fragmentLoader.abort();var c=this.fragCurrent;c&&this.fragmentTracker.removeFragment(c),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},a._streamEnded=function(c,S){var P=this.fragCurrent,G=this.fragmentTracker;if(!S.live&&P&&P.sn===S.endSN&&!c.nextStart){var X=G.getState(P);return X===D.FragmentState.PARTIAL||X===D.FragmentState.OK}return!1},a.onMediaAttached=function(c,S){var P=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var c=this.media;c!=null&&c.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),c&&(c.removeEventListener("seeking",this.onvseeking),c.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 c=this.config,S=this.fragCurrent,P=this.media,G=this.mediaBuffer,X=this.state,te=P?P.currentTime:0,z=j.BufferHelper.bufferInfo(G||P,te,c.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(te)?te.toFixed(3):te)+", state: "+X),X===E.ENDED)this.resetLoadingState();else if(S&&!z.len){var F=c.maxFragLookUpTolerance,ne=S.start-F,ce=S.start+S.duration+F,ge=te>ce;(te<ne||ge)&&(ge&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=te),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=te),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(c,S){if(this.state!==E.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)return;this.state=E.IDLE;var P=this.levels[S.frag.level].details;P&&this.loadFragment(S.frag,P,S.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=E.STOPPED,this.hls.off(I.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,d.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(c,S){this.log("Loading key for "+c.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+c.level),this.state=E.KEY_LOADING,this.fragCurrent=c,this.hls.trigger(I.Events.KEY_LOADING,{frag:c})},a.loadFragment=function(c,S,P){this._loadFragForPlayback(c,S,P)},a._loadFragForPlayback=function(c,S,P){var G=this,X=function(z){if(G.fragContextChanged(c)){G.warn("Fragment "+c.sn+(z.part?" p: "+z.part.index:"")+" of level "+c.level+" was dropped during download."),G.fragmentTracker.removeFragment(c);return}c.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(c,S,P,X).then(function(te){if(!te)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(c)){(z===E.FRAG_LOADING||z===E.BACKTRACKING||!G.fragCurrent&&z===E.PARSING)&&(G.fragmentTracker.removeFragment(c),G.state=E.IDLE);return}if("payload"in te&&(G.log("Loaded fragment "+c.sn+" of level "+c.level),G.hls.trigger(I.Events.FRAG_LOADED,te),G.state===E.BACKTRACKING)){G.fragmentTracker.backtrack(c,te),G.resetFragmentLoading(c);return}G._handleFragmentLoadComplete(te)}).catch(function(te){G.warn(te),G.resetFragmentLoading(c)})},a.flushMainBuffer=function(c,S,P){if(P===void 0&&(P=null),!(c-S))return;var G={startOffset:c,endOffset:S,type:P};this.fragLoadError=0,this.hls.trigger(I.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(c){var S=this;this._doFragLoad(c).then(function(P){if(!P||S.fragContextChanged(c)||!S.levels)throw new Error("init load aborted");return P}).then(function(P){var G=S.hls,X=P.payload,te=c.decryptdata;if(X&&X.byteLength>0&&te&&te.key&&te.iv&&te.method==="AES-128"){var z=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(X),te.key.buffer,te.iv.buffer).then(function(F){var ne=self.performance.now();return G.trigger(I.Events.FRAG_DECRYPTED,{frag:c,payload:F,stats:{tstart:z,tdecrypt:ne}}),P.payload=F,P})}return P}).then(function(P){var G=S.fragCurrent,X=S.hls,te=S.levels;if(!te)throw new Error("init load aborted, missing levels");var z=te[c.level].details;console.assert(z,"Level details are defined when init segment is loaded");var F=c.stats;S.state=E.IDLE,S.fragLoadError=0,c.data=new Uint8Array(P.payload),F.parsing.start=F.buffering.start=self.performance.now(),F.parsing.end=F.buffering.end=self.performance.now(),P.frag===G&&X.trigger(I.Events.FRAG_BUFFERED,{stats:F,frag:G,part:null,id:c.type}),S.tick()}).catch(function(P){S.warn(P),S.resetFragmentLoading(c)})},a.fragContextChanged=function(c){var S=this.fragCurrent;return!c||!S||c.level!==S.level||c.sn!==S.sn||c.urlId!==S.urlId},a.fragBufferedComplete=function(c,S){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+c.type+" sn: "+c.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+c.level+" "+o.default.toString(j.BufferHelper.getBuffered(P))),this.state=E.IDLE,this.tick()},a._handleFragmentLoadComplete=function(c){var S=this.transmuxer;if(!S)return;var P=c.frag,G=c.part,X=c.partsLoaded,te=!X||X.length===0||X.some(function(F){return!F}),z=new v.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,G?G.index:-1,!te);S.flush(z)},a._handleFragmentLoadProgress=function(c){},a._doFragLoad=function(c,S,P,G){var X=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(c.start,P||0),this.config.lowLatencyMode&&S){var te=S.partList;if(te&&G){P>c.end&&S.fragmentHint&&(c=S.fragmentHint);var z=this.getNextPart(te,c,P);if(z>-1){var F=te[z];return this.log("Loading part sn: "+c.sn+" p: "+F.index+" cc: "+c.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+z+"-"+(te.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+c.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=F.start+F.duration,this.state=E.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:c,part:te[z],targetBufferTime:P}),this.doFragPartsLoad(c,te,z,G).catch(function(ne){return X.handleFragLoadError(ne)})}else if(!c.url||this.loadedEndOfParts(te,P))return Promise.resolve(null)}}return this.log("Loading fragment "+c.sn+" cc: "+c.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+c.level+", target: "+parseFloat(P.toFixed(3))),Object(V.isFiniteNumber)(c.sn)&&!this.bitrateTest&&(this.nextLoadPosition=c.start+c.duration),this.state=E.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:c,targetBufferTime:P}),this.fragmentLoader.load(c,G).catch(function(ne){return X.handleFragLoadError(ne)})},a.doFragPartsLoad=function(c,S,P,G){var X=this;return new Promise(function(te,z){var F=[],ne=function ce(ge){var xe=S[ge];X.fragmentLoader.loadPart(c,xe,G).then(function(Ie){F[xe.index]=Ie;var Te=Ie.part;X.hls.trigger(I.Events.FRAG_LOADED,Ie);var Oe=S[ge+1];if(Oe&&Oe.fragment===c)ce(ge+1);else return te({frag:c,part:Te,partsLoaded:F})}).catch(z)};ne(P)})},a.handleFragLoadError=function(c){var S=c.data;return S&&S.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(I.Events.ERROR,S),null},a._handleTransmuxerFlush=function(c){var S=this.getCurrentContext(c);if(!S||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var P=S.frag,G=S.part,X=S.level,te=self.performance.now();P.stats.parsing.end=te,G&&(G.stats.parsing.end=te),this.updateLevelTiming(P,G,X,c.partial)},a.getCurrentContext=function(c){var S=this.levels,P=c.level,G=c.sn,X=c.part;if(!S||!S[P])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+P+". The current chunk will not be buffered."),null;var te=S[P],z=X>-1?Object(b.getPartWith)(te,G,X):null,F=z?z.fragment:Object(b.getFragmentWithSN)(te,G,this.fragCurrent);return F?{frag:F,part:z,level:te}:null},a.bufferFragmentData=function(c,S,P,G){if(!c||this.state!==E.PARSING)return;var X=c.data1,te=c.data2,z=X;if(X&&te&&(z=Object(g.appendUint8Array)(X,te)),!z||!z.length)return;var F={type:c.type,frag:S,part:P,chunkMeta:G,parent:S.type,data:z};this.hls.trigger(I.Events.BUFFER_APPENDING,F),c.dropped&&c.independent&&!P&&this.flushBufferGap(S)},a.flushBufferGap=function(c){var S=this.media;if(!S)return;if(!j.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,c.start);return}var P=S.currentTime,G=j.BufferHelper.bufferInfo(S,P,0),X=c.duration,te=Math.min(this.config.maxFragLookUpTolerance*2,X*.25),z=Math.max(Math.min(c.start-te,G.end-te),P+te);c.start-z>te&&this.flushMainBuffer(z,c.start)},a.getFwdBufferInfo=function(c,S){var P=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var X=j.BufferHelper.bufferInfo(c,G,P.maxBufferHole);if(X.len===0&&X.nextStart!==void 0){var te=this.fragmentTracker.getBufferedFrag(G,S);if(te&&X.nextStart<te.end)return j.BufferHelper.bufferInfo(c,G,Math.max(X.nextStart,P.maxBufferHole))}return X},a.getMaxBufferLength=function(c){var S=this.config,P;return c?P=Math.max(8*S.maxBufferSize/c,S.maxBufferLength):P=S.maxBufferLength,Math.min(P,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(c){var S=this.config,P=c||S.maxBufferLength;return S.maxMaxBufferLength>=P?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(c,S){var P,G,X=S.fragments,te=X.length;if(!te)return null;var z=this.config,F=X[0].start,ne;if(S.live){var ce=z.initialLiveManifestSize;if(te<ce)return this.warn("Not enough fragments to start playback (have: "+te+", need: "+ce+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ne=this.getInitialLiveFragment(S,X),this.startPosition=ne?this.hls.liveSyncPosition||ne.start:c)}else c<=F&&(ne=X[0]);if(!ne){var ge=z.lowLatencyMode?S.partEnd:S.fragmentEnd;ne=this.getFragmentAtPosition(c,ge,S)}return(P=ne)!==null&&P!==void 0&&P.initSegment&&!((G=ne)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(ne=ne.initSegment),ne},a.getNextPart=function(c,S,P){for(var G=-1,X=!1,te=!0,z=0,F=c.length;z<F;z++){var ne=c[z];if(te=te&&!ne.independent,G>-1&&P<ne.start)break;var ce=ne.loaded;!ce&&(X||ne.independent||te)&&ne.fragment===S&&(G=z),X=ce}return G},a.loadedEndOfParts=function(c,S){var P=c[c.length-1];return P&&S>P.start&&P.loaded},a.getInitialLiveFragment=function(c,S){var P=this.fragPrevious,G=null;if(P){if(c.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),G=Object(w.findFragmentByPDT)(S,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var X=P.sn+1;if(X>=c.startSN&&X<=c.endSN){var te=S[X-c.startSN];P.cc===te.cc&&(G=te,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(w.findFragWithCC)(S,P.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?c.fragmentEnd:c.edge,c))}return G},a.getFragmentAtPosition=function(c,S,P){var G=this.config,X=this.fragPrevious,te=P.fragments,z=P.endSN,F=P.fragmentHint,ne=G.maxFragLookUpTolerance,ce=!!(G.lowLatencyMode&&P.partList&&F);ce&&F&&!this.bitrateTest&&(te=te.concat(F),z=F.sn);var ge;if(c<S){var xe=c>S-ne?0:ne;ge=Object(w.findFragmentByPTS)(X,te,c,xe)}else ge=te[te.length-1];if(ge){var Ie=ge.sn-P.startSN,Te=X&&ge.level===X.level,Oe=te[Ie+1],Ce=this.fragmentTracker.getState(ge);if(Ce===D.FragmentState.BACKTRACKED){ge=null;for(var Ae=Ie;te[Ae]&&this.fragmentTracker.getState(te[Ae])===D.FragmentState.BACKTRACKED;)X?ge=te[Ae--]:ge=te[--Ae];ge||(ge=Oe)}else X&&ge.sn===X.sn&&!ce&&(Te&&(ge.sn<z&&this.fragmentTracker.getState(Oe)!==D.FragmentState.OK?(this.log("SN "+ge.sn+" just loaded, load next one: "+Oe.sn),ge=Oe):ge=null))}return ge},a.synchronizeToLiveEdge=function(c){var S=this.config,P=this.media;if(!P)return;var G=this.hls.liveSyncPosition,X=P.currentTime,te=c.fragments[0].start,z=c.edge,F=X>=te-S.maxFragLookUpTolerance&&X<=z;if(G!==null&&P.duration>G&&(X<G||!F)){var ne=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*c.targetduration;(!F&&P.readyState<4||X<z-ne)&&(this.loadedmetadata||(this.nextLoadPosition=G),P.readyState&&(this.warn("Playback: "+X.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),P.currentTime=G))}},a.alignPlaylists=function(c,S){var P=this.levels,G=this.levelLastLoaded,X=this.fragPrevious,te=G!==null?P[G]:null,z=c.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var F=c.fragments[0].start,ne=!S,ce=c.alignedSliding&&Object(V.isFiniteNumber)(F);if(ne||!ce&&!F){Object(R.alignStream)(X,te,c);var ge=c.fragments[0].start;return this.log("Live playlist sliding: "+ge.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+c.startSN+" prev-sn: "+(X?X.sn:"na")+" fragments: "+z),ge}return F},a.waitForCdnTuneIn=function(c){var S=3;return c.live&&c.canBlockReload&&c.tuneInGoal>Math.max(c.partHoldBack,c.partTarget*S)},a.setStartPosition=function(c,S){var P=this.startPosition;if(P<S&&(P=-1),P===-1||this.lastCurrentTime===-1){var G=c.startTimeOffset;Object(V.isFiniteNumber)(G)?(P=S+G,G<0&&(P+=c.totalduration),P=Math.min(Math.max(S,P),S+c.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+P),this.startPosition=P):c.live?P=this.hls.liveSyncPosition||S:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},a.getLoadPosition=function(){var c=this.media,S=0;return this.loadedmetadata&&c?S=c.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(c,S){this.transmuxer&&c.sn!=="initSegment"&&c.stats.aborted&&(this.warn("Fragment "+c.sn+(S?" part"+S.index:"")+" of level "+c.level+" was aborted"),this.resetFragmentLoading(c))},a.resetFragmentLoading=function(c){(!this.fragCurrent||!this.fragContextChanged(c))&&(this.state=E.IDLE)},a.onFragmentOrKeyLoadError=function(c,S){if(S.fatal)return;var P=S.frag;if(!P||P.type!==c)return;var G=this.fragCurrent;console.assert(G&&P.sn===G.sn&&P.level===G.level&&P.urlId===G.urlId,"Frag load error must match current frag to retry");var X=this.config;if(this.fragLoadError+1<=X.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var te=Math.min(Math.pow(2,this.fragLoadError)*X.fragLoadingRetryDelay,X.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+c+" "+P.level+" failed to load, retrying in "+te+"ms"),this.retryDate=self.performance.now()+te,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(c===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(U.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)},a.afterBufferFlushed=function(c,S,P){if(!c)return;var G=j.BufferHelper.getBuffered(c);this.fragmentTracker.detectEvictedFragments(S,G,P),this.state===E.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},a.resetLiveStartWhenNotLoaded=function(c){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[c].details:null;if(S!=null&&S.live)return this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(c,S,P,G){var X=this,te=P.details;console.assert(!!te,"level.details must be defined");var z=Object.keys(c.elementaryStreams).reduce(function(F,ne){var ce=c.elementaryStreams[ne];if(ce){var ge=ce.endPTS-ce.startPTS;if(ge<=0)return X.warn("Could not parse fragment "+c.sn+" "+ne+" duration reliably ("+ge+") resetting transmuxer to fallback to playlist timing"),X.resetTransmuxer(),F||!1;var xe=G?0:Object(b.updateFragPTSDTS)(te,c,ce.startPTS,ce.endPTS,ce.startDTS,ce.endDTS);return X.hls.trigger(I.Events.LEVEL_PTS_UPDATED,{details:te,level:P,drift:xe,type:ne,frag:c,start:ce.startPTS,end:ce.endPTS}),!0}return F},!1);z?(this.state=E.PARSED,this.hls.trigger(I.Events.FRAG_PARSED,{frag:c,part:S})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C(u,[{key:"state",get:function(){return this._state},set:function(c){var S=this._state;S!==c&&(this._state=c,this.log(S+"->"+c))}}]),u}(M.default)},"./src/controller/buffer-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return w});var V=_("./src/polyfills/number.ts"),M=_("./src/events.ts"),D=_("./src/utils/logger.ts"),j=_("./src/errors.ts"),U=_("./src/utils/buffer-helper.ts"),I=_("./src/utils/mediasource-helper.ts"),O=_("./src/loader/fragment.ts"),v=_("./src/controller/buffer-operation-queue.ts"),g=Object(I.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,w=function(){function b(l){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,h=o.media,C=o.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),s.trigger(M.Events.MEDIA_ATTACHED,{media:h})),C&&C.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=l,this._initSourceBuffer(),this.registerListeners()}var x=b.prototype;return x.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},x.destroy=function(){this.unregisterListeners(),this.details=null},x.registerListeners=function(){var o=this.hls;o.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(M.Events.BUFFER_RESET,this.onBufferReset,this),o.on(M.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(M.Events.BUFFER_EOS,this.onBufferEos,this),o.on(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(M.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(M.Events.FRAG_PARSED,this.onFragParsed,this),o.on(M.Events.FRAG_CHANGED,this.onFragChanged,this)},x.unregisterListeners=function(){var o=this.hls;o.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(M.Events.BUFFER_RESET,this.onBufferReset,this),o.off(M.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(M.Events.BUFFER_EOS,this.onBufferEos,this),o.off(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(M.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(M.Events.FRAG_PARSED,this.onFragParsed,this),o.off(M.Events.FRAG_CHANGED,this.onFragChanged,this)},x._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},x.onManifestParsed=function(o,s){var h=2;(s.audio&&!s.video||!s.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},x.onMediaAttaching=function(o,s){var h=this.media=s.media;if(h&&g){var C=this.mediaSource=new g;C.addEventListener("sourceopen",this._onMediaSourceOpen),C.addEventListener("sourceended",this._onMediaSourceEnded),C.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(C),this._objectUrl=h.src}},x.onMediaDetaching=function(){var o=this.media,s=this.mediaSource,h=this._objectUrl;if(s){if(D.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(C){D.logger.warn("[buffer-controller]: onMediaDetaching: "+C.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(h&&self.URL.revokeObjectURL(h),o.src===h?(o.removeAttribute("src"),o.load()):D.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(M.Events.MEDIA_DETACHED,void 0)},x.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(s){var h=o.sourceBuffer[s];try{h&&(o.removeBufferListeners(s),o.mediaSource&&o.mediaSource.removeSourceBuffer(h),o.sourceBuffer[s]=void 0)}catch(C){D.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",C)}}),this._initSourceBuffer()},x.onBufferCodecs=function(o,s){var h=this,C=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(m){if(C){var p=h.tracks[m];if(p&&typeof p.buffer.changeType=="function"){var A=s[m],E=A.codec,f=A.levelCodec,d=A.container,u=(p.levelCodec||p.codec).replace(R,"$1"),a=(f||E).replace(R,"$1");if(u!==a){var y=d+";codecs="+(f||E);h.appendChangeType(m,y)}}}else h.pendingTracks[m]=s[m]}),C)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},x.appendChangeType=function(o,s){var h=this,C=this.operationQueue,m={execute:function(){var A=h.sourceBuffer[o];A&&(D.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+s),A.changeType(s)),C.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(A){D.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",A)}};C.append(m,o)},x.onBufferAppending=function(o,s){var h=this,C=this.hls,m=this.operationQueue,p=this.tracks,A=s.data,E=s.type,f=s.frag,d=s.part,u=s.chunkMeta,a=u.buffering[E],y=self.performance.now();a.start=y;var c=f.stats.buffering,S=d?d.stats.buffering:null;c.start===0&&(c.start=y),S&&S.start===0&&(S.start=y);var P=p.audio,G=E==="audio"&&u.id===1&&(P==null?void 0:P.container)==="audio/mpeg",X={execute:function(){if(a.executeStart=self.performance.now(),G){var z=h.sourceBuffer[E];if(z){var F=f.start-z.timestampOffset;Math.abs(F)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+F+") sn: "+f.sn+")"),z.timestampOffset=f.start)}}h.appendExecutor(A,E)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,c.first===0&&(c.first=z),S&&S.first===0&&(S.first=z);var F=h.sourceBuffer,ne={};for(var ce in F)ne[ce]=U.BufferHelper.getBuffered(F[ce]);h.appendError=0,h.hls.trigger(M.Events.BUFFER_APPENDED,{type:E,frag:f,part:d,chunkMeta:u,parent:f.type,timeRanges:ne})},onError:function(z){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",z);var F={type:j.ErrorTypes.MEDIA_ERROR,parent:f.type,details:j.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=j.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,F.details=j.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>C.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),C.trigger(M.Events.ERROR,F)}};m.append(X,E)},x.onBufferFlushing=function(o,s){var h=this,C=this.operationQueue,m=function(A){return{execute:h.removeExecutor.bind(h,A,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(M.Events.BUFFER_FLUSHED,{type:A})},onError:function(f){D.logger.warn("[buffer-controller]: Failed to remove from "+A+" SourceBuffer",f)}}};s.type?C.append(m(s.type),s.type):this.getSourceBufferTypes().forEach(function(p){C.append(m(p),p)})},x.onFragParsed=function(o,s){var h=this,C=s.frag,m=s.part,p=[],A=m?m.elementaryStreams:C.elementaryStreams;A[O.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(A[O.ElementaryStreamTypes.AUDIO]&&p.push("audio"),A[O.ElementaryStreamTypes.VIDEO]&&p.push("video"));var E=function(){var d=self.performance.now();C.stats.buffering.end=d,m&&(m.stats.buffering.end=d);var u=m?m.stats:C.stats;h.hls.trigger(M.Events.FRAG_BUFFERED,{frag:C,part:m,stats:u,id:C.type})};p.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+C.type+" level: "+C.level+" sn: "+C.sn),this.blockBuffers(E,p)},x.onFragChanged=function(o,s){this.flushBackBuffer()},x.onBufferEos=function(o,s){var h=this,C=this.getSourceBufferTypes().reduce(function(m,p){var A=h.sourceBuffer[p];return(!s.type||s.type===p)&&(A&&!A.ended&&(A.ended=!0,D.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),m&&!!(!A||A.ended)},!0);C&&this.blockBuffers(function(){var m=h.mediaSource;if(!m||m.readyState!=="open")return;m.endOfStream()})},x.onLevelUpdated=function(o,s){var h=s.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},x.flushBackBuffer=function(){var o=this.hls,s=this.details,h=this.media,C=this.sourceBuffer;if(!h||s===null)return;var m=this.getSourceBufferTypes();if(!m.length)return;var p=s.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(V.isFiniteNumber)(p)||p<0)return;var A=h.currentTime,E=s.levelTargetDuration,f=Math.max(p,E),d=Math.floor(A/E)*E-f;m.forEach(function(u){var a=C[u];if(a){var y=U.BufferHelper.getBuffered(a);y.length>0&&d>y.start(0)&&(o.trigger(M.Events.BACK_BUFFER_REACHED,{bufferEnd:d}),s.live&&o.trigger(M.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d}),o.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:u}))}})},x.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,s=this.hls,h=this.media,C=this.mediaSource,m=o.fragments[0].start+o.totalduration,p=h.duration,A=Object(V.isFiniteNumber)(C.duration)?C.duration:0;o.live&&s.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),C.duration=Infinity,this.updateSeekableRange(o)):(m>A&&m>p||!Object(V.isFiniteNumber)(p))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+m.toFixed(3)),C.duration=m)},x.updateSeekableRange=function(o){var s=this.mediaSource,h=o.fragments,C=h.length;if(C&&o.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var m=Math.max(0,h[0].start),p=Math.max(m,m+o.totalduration);s.setLiveSeekableRange(m,p)}},x.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,s=this.operationQueue,h=this.pendingTracks,C=Object.keys(h).length;if(C&&!o||C===2){this.createSourceBuffers(h),this.pendingTracks={};var m=this.getSourceBufferTypes();if(m.length===0){this.hls.trigger(M.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}m.forEach(function(p){s.executeNext(p)})}},x.createSourceBuffers=function(o){var s=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var C=0;for(var m in o)if(!s[m]){var p=o[m];if(!p)throw Error("source buffer exists for track "+m+", however track does not");var A=p.levelCodec||p.codec,E=p.container+";codecs="+A;D.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var f=s[m]=h.addSourceBuffer(E),d=m;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[m]={buffer:f,codec:A,container:p.container,levelCodec:p.levelCodec,id:p.id},C++}catch(u){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(M.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:E})}}C&&this.hls.trigger(M.Events.BUFFER_CREATED,{tracks:this.tracks})},x._onSBUpdateStart=function(o){var s=this.operationQueue,h=s.current(o);h.onStart()},x._onSBUpdateEnd=function(o){var s=this.operationQueue,h=s.current(o);h.onComplete(),s.shiftAndExecuteNext(o)},x._onSBUpdateError=function(o,s){D.logger.error("[buffer-controller]: "+o+" SourceBuffer error",s),this.hls.trigger(M.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(o);h&&h.onError(s)},x.removeExecutor=function(o,s,h){var C=this.media,m=this.mediaSource,p=this.operationQueue,A=this.sourceBuffer,E=A[o];if(!C||!m||!E){D.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var f=Object(V.isFiniteNumber)(C.duration)?C.duration:Infinity,d=Object(V.isFiniteNumber)(m.duration)?m.duration:Infinity,u=Math.max(0,s),a=Math.min(h,f,d);a>u?(D.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+o+" SourceBuffer"),console.assert(!E.updating,o+" sourceBuffer must not be updating"),E.remove(u,a)):p.shiftAndExecuteNext(o)},x.appendExecutor=function(o,s){var h=this.operationQueue,C=this.sourceBuffer,m=C[s];if(!m){D.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(s);return}m.ended=!1,console.assert(!m.updating,s+" sourceBuffer must not be updating"),m.appendBuffer(o)},x.blockBuffers=function(o,s){var h=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 C=this.operationQueue,m=s.map(function(p){return C.appendBlocker(p)});Promise.all(m).then(function(){o(),s.forEach(function(p){var A=h.sourceBuffer[p];(!A||!A.updating)&&C.shiftAndExecuteNext(p)})})},x.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},x.addBufferListener=function(o,s,h){var C=this.sourceBuffer[o];if(!C)return;var m=h.bind(this,o);this.listeners[o].push({event:s,listener:m}),C.addEventListener(s,m)},x.removeBufferListeners=function(o){var s=this.sourceBuffer[o];if(!s)return;this.listeners[o].forEach(function(h){s.removeEventListener(h.event,h.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return M});var V=_("./src/utils/logger.ts"),M=function(){function D(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var j=D.prototype;return j.append=function(I,O){var v=this.queues[O];v.push(I),v.length===1&&this.buffers[O]&&this.executeNext(O)},j.insertAbort=function(I,O){var v=this.queues[O];v.unshift(I),this.executeNext(O)},j.appendBlocker=function(I){var O,v=new Promise(function(R){O=R}),g={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(g,I),v},j.executeNext=function(I){var O=this.buffers,v=this.queues,g=O[I],R=v[I];if(R.length){var w=R[0];try{w.execute()}catch(b){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),w.onError(b),(!g||!g.updating)&&(R.shift(),this.executeNext(I))}}},j.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},j.current=function(I){return this.queues[I][0]},D}()},"./src/controller/cap-level-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts");function M(U,I){for(var O=0;O<I.length;O++){var v=I[O];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(U,v.key,v)}}function D(U,I,O){return I&&M(U.prototype,I),O&&M(U,O),U}var j=function(){function U(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 I=U.prototype;return I.setStreamController=function(v){this.streamController=v},I.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},I.registerListeners=function(){var v=this.hls;v.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.unregisterListener=function(){var v=this.hls;v.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.onFpsDropLevelCapping=function(v,g){U.isLevelAllowed(g.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(g.droppedLevel)},I.onMediaAttaching=function(v,g){this.media=g.media instanceof HTMLVideoElement?g.media:null},I.onManifestParsed=function(v,g){var R=this.hls;this.restrictedLevels=[],this.firstLevel=g.firstLevel,R.config.capLevelToPlayerSize&&g.video&&this.startCapping()},I.onBufferCodecs=function(v,g){var R=this.hls;R.config.capLevelToPlayerSize&&g.video&&this.startCapping()},I.onMediaDetaching=function(){this.stopCapping()},I.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var g=this.hls;g.autoLevelCapping=this.getMaxLevel(v.length-1),g.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=g.autoLevelCapping}}},I.getMaxLevel=function(v){var g=this,R=this.hls.levels;if(!R.length)return-1;var w=R.filter(function(b,x){return U.isLevelAllowed(x,g.restrictedLevels)&&x<=v});return this.clientRect=null,U.getMaxLevelByMediaSize(w,this.mediaWidth,this.mediaHeight)},I.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()},I.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},I.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,g={width:0,height:0};if(v){var R=v.getBoundingClientRect();g.width=R.width,g.height=R.height,!g.width&&!g.height&&(g.width=R.right-R.left||v.width||0,g.height=R.bottom-R.top||v.height||0)}return this.clientRect=g,g},U.isLevelAllowed=function(v,g){return g===void 0&&(g=[]),g.indexOf(v)===-1},U.getMaxLevelByMediaSize=function(v,g,R){if(!v||!v.length)return-1;for(var w=function(s,h){return h?s.width!==h.width||s.height!==h.height:!0},b=v.length-1,x=0;x<v.length;x+=1){var l=v[x];if((l.width>=g||l.height>=R)&&w(l,v[x+1])){b=x;break}}return b},D(U,[{key:"mediaWidth",get:function(){return this.getDimensions().width*U.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*U.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(g){}return v}}]),U}();$.default=j},"./src/controller/cmcd-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return w});var V=_("./src/events.ts"),M=_("./src/types/cmcd.ts"),D=_("./src/utils/buffer-helper.ts"),j=_("./src/utils/logger.ts");function U(b,x){for(var l=0;l<x.length;l++){var o=x[l];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(b,o.key,o)}}function I(b,x,l){return x&&U(b.prototype,x),l&&U(b,l),b}function O(b,x){var l=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(l)return(l=l.call(b)).next.bind(l);if(Array.isArray(b)||(l=v(b))||x&&b&&typeof b.length=="number"){l&&(b=l);var o=0;return function(){return o>=b.length?{done:!0}:{done:!1,value:b[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(b,x){if(!b)return;if(typeof b=="string")return g(b,x);var l=Object.prototype.toString.call(b).slice(8,-1);if(l==="Object"&&b.constructor&&(l=b.constructor.name),l==="Map"||l==="Set")return Array.from(b);if(l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return g(b,x)}function g(b,x){(x==null||x>b.length)&&(x=b.length);for(var l=0,o=new Array(x);l<x;l++)o[l]=b[l];return o}function R(){return R=Object.assign||function(b){for(var x=1;x<arguments.length;x++){var l=arguments[x];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(b[o]=l[o])}return b},R.apply(this,arguments)}var w=function(){function b(l){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(C){try{o.apply(C,{ot:M.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(m){j.logger.warn("Could not generate manifest CMCD data.",m)}},this.applyFragmentData=function(C){try{var m=C.frag,p=o.hls.levels[m.level],A=o.getObjectType(m),E={d:m.duration*1e3,ot:A};(A===M.CMCDObjectType.VIDEO||A===M.CMCDObjectType.AUDIO||A==M.CMCDObjectType.MUXED)&&(E.br=p.bitrate/1e3,E.tb=o.getTopBandwidth(A),E.bl=o.getBufferLength(A)),o.apply(C,E)}catch(f){j.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=l;var s=this.config=l.config,h=s.cmcd;h!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||b.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var x=b.prototype;return x.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)},x.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()},x.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},x.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},x.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},x.onBufferCreated=function(o,s){var h,C;this.audioBuffer=(h=s.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(C=s.tracks.video)===null||C===void 0?void 0:C.buffer},x.createData=function(){var o;return{v:M.CMCDVersion,sf:M.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}},x.apply=function(o,s){s===void 0&&(s={}),R(s,this.createData());var h=s.ot===M.CMCDObjectType.INIT||s.ot===M.CMCDObjectType.VIDEO||s.ot===M.CMCDObjectType.MUXED;if(this.starved&&h&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var C=b.toHeaders(s);if(!Object.keys(C).length)return;o.headers||(o.headers={}),R(o.headers,C)}else{var m=b.toQuery(s);if(!m)return;o.url=b.appendQueryToUri(o.url,m)}},x.getObjectType=function(o){var s=o.type;return s==="subtitle"?M.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?M.CMCDObjectType.INIT:s==="audio"?M.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?M.CMCDObjectType.VIDEO:M.CMCDObjectType.MUXED:void 0},x.getTopBandwidth=function(o){for(var s=0,h=o===M.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,C=O(h),m;!(m=C()).done;){var p=m.value;p.bitrate>s&&(s=p.bitrate)}return s>0?s:NaN},x.getBufferLength=function(o){var s=this.hls.media,h=o===M.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!s)return NaN;var C=D.BufferHelper.bufferInfo(h,s.currentTime,this.config.maxBufferHole);return C.len*1e3},x.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,h=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new h(p)}var m=C.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(A,E,f){s(A),this.loader.load(A,E,f)},I(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},x.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,h=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new h(p)}var m=C.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(A,E,f){s(A),this.loader.load(A,E,f)},I(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},b.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.substr(s.lastIndexOf("/")+1)},b.serialize=function(o){for(var s=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},C=function(G){return Math.round(G)},m=function(G){return C(G/100)*100},p=function(G){return encodeURIComponent(G)},A={br:C,d:C,bl:m,dl:m,mtp:m,nor:p,rtp:m,tb:C},E=Object.keys(o||{}).sort(),f=O(E),d;!(d=f()).done;){var u=d.value,a=o[u];if(!h(a))continue;if(u==="v"&&a===1)continue;if(u=="pr"&&a===1)continue;var y=A[u];y&&(a=y(a));var c=typeof a,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+a:c==="boolean"?S=u:c==="number"?S=u+"="+a:S=u+"="+JSON.stringify(a),s.push(S)}return s.join(",")},b.toHeaders=function(o){for(var s=Object.keys(o),h={},C=["Object","Request","Session","Status"],m=[{},{},{},{}],p={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},A=0,E=s;A<E.length;A++){var f=E[A],d=p[f]!=null?p[f]:1;m[d][f]=o[f]}for(var u=0;u<m.length;u++){var a=b.serialize(m[u]);a&&(h["CMCD-"+C[u]]=a)}return h},b.toQuery=function(o){return"CMCD="+encodeURIComponent(b.serialize(o))},b.appendQueryToUri=function(o,s){if(!s)return o;var h=o.includes("?")?"&":"?";return""+o+h+s},b}()},"./src/controller/eme-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts"),M=_("./src/errors.ts"),D=_("./src/utils/logger.ts"),j=_("./src/utils/mediakeys-helper.ts");function U(w,b){for(var x=0;x<b.length;x++){var l=b[x];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(w,l.key,l)}}function I(w,b,x){return b&&U(w.prototype,b),x&&U(w,x),w}var O=3,v=function(b,x,l){var o={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(s){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:l.audioRobustness||""})}),x.forEach(function(s){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:l.videoRobustness||""})}),[o]},g=function(b,x,l,o){switch(b){case j.KeySystems.WIDEVINE:return v(x,l,o);default:throw new Error("Unknown key-system: "+b)}},R=function(){function w(x){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=x,this._config=x.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 b=w.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._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)},b._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)},b.getLicenseServerUrl=function(l){switch(l){case j.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+l+'"')},b._attemptKeySystemAccess=function(l,o,s){var h=this,C=g(l,o,s,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var m=this.requestMediaKeySystemAccess(l,C);this.mediaKeysPromise=m.then(function(p){return h._onMediaKeySystemAccessObtained(l,p)}),m.catch(function(p){D.logger.error('Failed to obtain key-system "'+l+'" access:',p)})},b._onMediaKeySystemAccessObtained=function(l,o){var s=this;D.logger.log('Access for key-system "'+l+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:l};this._mediaKeysList.push(h);var C=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(m){return h.mediaKeys=m,D.logger.log('Media-keys created for key-system "'+l+'"'),s._onMediaKeysCreated(),m});return C.catch(function(m){D.logger.error("Failed to create media-keys:",m)}),C},b._onMediaKeysCreated=function(){var l=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),l._onNewMediaKeySession(o.mediaKeysSession))})},b._onNewMediaKeySession=function(l){var o=this;D.logger.log("New key-system session "+l.sessionId),l.addEventListener("message",function(s){o._onKeySessionMessage(l,s.message)},!1)},b._onKeySessionMessage=function(l,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"),l.update(s)})},b.onMediaEncrypted=function(l){var o=this;if(D.logger.log('Media is encrypted using "'+l.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:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(C){if(!o._media)return;o._attemptSetMediaKeys(C),o._generateRequestWithPreferredKeySession(l.initDataType,l.initData)};this.mediaKeysPromise.then(s).catch(s)},b._attemptSetMediaKeys=function(l){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:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(l,o){var s=this,h=this._mediaKeysList[0];if(!h){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var C=h.mediaKeysSession;if(!C){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.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:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+l+'" init data type'),h.mediaKeysSessionInitialized=!0,C.generateRequest(l,o).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(m){D.logger.error("Error generating key-session request:",m),s.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(l,o,s){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,l,o,s);var C=this._licenseXhrSetup;if(C)try{C.call(this.hls,h,l),C=void 0}catch(m){D.logger.error(m)}try{h.readyState||h.open("POST",l,!0),C&&C.call(this.hls,h,l)}catch(m){throw new Error("issue setting up KeySystem license XHR "+m)}return h},b._onLicenseRequestReadyStageChange=function(l,o,s,h){switch(l.readyState){case 4:if(l.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var C=l.response,m=this._licenseResponseCallback;if(m)try{C=m.call(this.hls,l,o)}catch(A){D.logger.error(A)}h(C)}else{if(D.logger.error("License Request XHR failed ("+o+"). Status: "+l.status+" ("+l.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>O){this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var p=O-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(s,h)}break}},b._generateLicenseRequestChallenge=function(l,o){switch(l.mediaKeySystemDomain){case j.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+l.mediaKeySystemDomain)},b._requestLicense=function(l,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:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(s.mediaKeySystemDomain),C=this._createLicenseXhr(h,l,o);D.logger.log("Sending license request to URL: "+h);var m=this._generateLicenseRequestChallenge(s,l);C.send(m)}catch(p){D.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.KEY_SYSTEM_ERROR,details:M.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(l,o){if(!this._emeEnabled)return;var s=o.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},b.onMediaDetached=function(){var l=this._media,o=this._mediaKeysList;if(!l)return;l.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 l.setMediaKeys(null)}).catch(function(){})},b.onManifestParsed=function(l,o){if(!this._emeEnabled)return;var s=o.levels.map(function(C){return C.audioCodec}).filter(function(C){return!!C}),h=o.levels.map(function(C){return C.videoCodec}).filter(function(C){return!!C});this._attemptKeySystemAccess(j.KeySystems.WIDEVINE,s,h)},I(w,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),w}();$.default=R},"./src/controller/fps-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts"),M=_("./src/utils/logger.ts"),D=function(){function j(I){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=I,this.registerListeners()}var U=j.prototype;return U.setStreamController=function(O){this.streamController=O},U.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},U.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},U.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},U.onMediaAttaching=function(O,v){var g=this.hls.config;if(g.capLevelOnFPSDrop){var R=v.media instanceof self.HTMLVideoElement?v.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),g.fpsDroppedMonitoringPeriod)}},U.checkFPS=function(O,v,g){var R=performance.now();if(v){if(this.lastTime){var w=R-this.lastTime,b=g-this.lastDroppedFrames,x=v-this.lastDecodedFrames,l=1e3*b/w,o=this.hls;if(o.trigger(V.Events.FPS_DROP,{currentDropped:b,currentDecoded:x,totalDroppedFrames:g}),l>0&&b>o.config.fpsDroppedMonitoringThreshold*x){var s=o.currentLevel;M.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=g,this.lastDecodedFrames=v}},U.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var v=O.getVideoPlaybackQuality();this.checkFPS(O,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},j}();$.default=D},"./src/controller/fragment-finders.ts":function(fe,$,_){"use strict";_.r($),_.d($,"findFragmentByPDT",function(){return D}),_.d($,"findFragmentByPTS",function(){return j}),_.d($,"fragmentWithinToleranceTest",function(){return U}),_.d($,"pdtWithinToleranceTest",function(){return I}),_.d($,"findFragWithCC",function(){return O});var V=_("./src/polyfills/number.ts"),M=_("./src/utils/binary-search.ts");function D(v,g,R){if(g===null||!Array.isArray(v)||!v.length||!Object(V.isFiniteNumber)(g))return null;var w=v[0].programDateTime;if(g<(w||0))return null;var b=v[v.length-1].endProgramDateTime;if(g>=(b||0))return null;R=R||0;for(var x=0;x<v.length;++x){var l=v[x];if(I(g,R,l))return l}return null}function j(v,g,R,w){R===void 0&&(R=0),w===void 0&&(w=0);var b=null;if(v?b=g[v.sn-g[0].sn+1]||null:R===0&&g[0].start===0&&(b=g[0]),b&&U(R,w,b)===0)return b;var x=M.default.search(g,U.bind(null,R,w));return x||b}function U(v,g,R){v===void 0&&(v=0),g===void 0&&(g=0);var w=Math.min(g,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-w<=v?1:R.start-w>v&&R.start?-1:0}function I(v,g,R){var w=Math.min(g,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,b=R.endProgramDateTime||0;return b-w>v}function O(v,g){return M.default.search(v,function(R){return R.cc<g?1:R.cc>g?-1:0})}},"./src/controller/fragment-tracker.ts":function(fe,$,_){"use strict";_.r($),_.d($,"FragmentState",function(){return D}),_.d($,"FragmentTracker",function(){return j});var V=_("./src/events.ts"),M=_("./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(g){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=g,this._registerListeners()}var v=O.prototype;return v._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)},v._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)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(R,w){if(w===M.PlaylistLevelType.MAIN){var b=this.activeFragment,x=this.activeParts;if(!b)return null;if(x)for(var l=x.length;l--;){var o=x[l],s=o?o.end:b.appendedPTS;if(o.start<=R&&s!==void 0&&R<=s)return l>9&&(this.activeParts=x.slice(l-9)),o}else if(b.start<=R&&b.appendedPTS!==void 0&&R<=b.appendedPTS)return b}return this.getBufferedFrag(R,w)},v.getBufferedFrag=function(R,w){for(var b=this.fragments,x=Object.keys(b),l=x.length;l--;){var o=b[x[l]];if((o==null?void 0:o.body.type)===w&&o.buffered){var s=o.body;if(s.start<=R&&R<=s.end)return s}}return null},v.detectEvictedFragments=function(R,w,b){var x=this;Object.keys(this.fragments).forEach(function(l){var o=x.fragments[l];if(!o)return;if(!o.buffered){o.body.type===b&&x.removeFragment(o.body);return}var s=o.range[R];if(!s)return;s.time.some(function(h){var C=!x.isTimeBuffered(h.startPTS,h.endPTS,w);return C&&x.removeFragment(o.body),C})})},v.detectPartialFragments=function(R){var w=this,b=this.timeRanges,x=R.frag,l=R.part;if(!b||x.sn==="initSegment")return;var o=I(x),s=this.fragments[o];if(!s)return;Object.keys(b).forEach(function(h){var C=x.elementaryStreams[h];if(!C)return;var m=b[h],p=l!==null||C.partial===!0;s.range[h]=w.getBufferedTimes(x,l,p,m)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},v.fragBuffered=function(R){var w=I(R),b=this.fragments[w];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},v.getBufferedTimes=function(R,w,b,x){for(var l={time:[],partial:b},o=w?w.start:R.start,s=w?w.end:R.end,h=R.minEndPTS||s,C=R.maxStartPTS||o,m=0;m<x.length;m++){var p=x.start(m)-this.bufferPadding,A=x.end(m)+this.bufferPadding;if(C>=p&&h<=A){l.time.push({startPTS:Math.max(o,x.start(m)),endPTS:Math.min(s,x.end(m))});break}else if(o<A&&s>p)l.partial=!0,l.time.push({startPTS:Math.max(o,x.start(m)),endPTS:Math.min(s,x.end(m))});else if(s<=p)break}return l},v.getPartialFragment=function(R){var w=null,b,x,l,o=0,s=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(C){var m=h[C];if(!m)return;U(m)&&(x=m.body.start-s,l=m.body.end+s,R>=x&&R<=l&&(b=Math.min(R-x,l-R),o<=b&&(w=m.body,o=b)))}),w},v.getState=function(R){var w=I(R),b=this.fragments[w];return b?b.buffered?U(b)?D.PARTIAL:D.OK:b.backtrack?D.BACKTRACKED:D.APPENDING:D.NOT_LOADED},v.backtrack=function(R,w){var b=I(R),x=this.fragments[b];if(!x||x.backtrack)return null;var l=x.backtrack=w||x.loaded;return x.loaded=null,l},v.getBacktrackData=function(R){var w=I(R),b=this.fragments[w];if(b){var x,l=b.backtrack;if(l!=null&&(x=l.payload)!==null&&x!==void 0&&x.byteLength)return l;this.removeFragment(R)}return null},v.isTimeBuffered=function(R,w,b){for(var x,l,o=0;o<b.length;o++){if(x=b.start(o)-this.bufferPadding,l=b.end(o)+this.bufferPadding,R>=x&&w<=l)return!0;if(w<=x)return!1}return!1},v.onFragLoaded=function(R,w){var b=w.frag,x=w.part;if(b.sn==="initSegment"||b.bitrateTest||x)return;var l=I(b);this.fragments[l]={body:b,loaded:w,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(R,w){var b=this,x=w.frag,l=w.part,o=w.timeRanges;if(x.type===M.PlaylistLevelType.MAIN)if(this.activeFragment=x,l){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(l)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var C=o[h];if(b.detectEvictedFragments(h,C),!l)for(var m=0;m<C.length;m++)x.appendedPTS=Math.max(C.end(m),x.appendedPTS||0)})},v.onFragBuffered=function(R,w){this.detectPartialFragments(w)},v.hasFragment=function(R){var w=I(R);return!!this.fragments[w]},v.removeFragmentsInRange=function(R,w,b){var x=this;Object.keys(this.fragments).forEach(function(l){var o=x.fragments[l];if(!o)return;if(o.buffered){var s=o.body;s.type===b&&s.start<w&&s.end>R&&x.removeFragment(s)}})},v.removeFragment=function(R){var w=I(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[w]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function U(O){var v,g;return O.buffered&&(((v=O.range.video)===null||v===void 0?void 0:v.partial)||((g=O.range.audio)===null||g===void 0?void 0:g.partial))}function I(O){return O.type+"_"+O.level+"_"+O.urlId+"_"+O.sn}},"./src/controller/gap-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"STALL_MINIMUM_DURATION_MS",function(){return U}),_.d($,"MAX_START_GAP_JUMP",function(){return I}),_.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),_.d($,"SKIP_BUFFER_RANGE_START",function(){return v}),_.d($,"default",function(){return g});var V=_("./src/utils/buffer-helper.ts"),M=_("./src/errors.ts"),D=_("./src/events.ts"),j=_("./src/utils/logger.ts"),U=250,I=2,O=.1,v=.05,g=function(){function R(b,x,l,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=b,this.media=x,this.fragmentTracker=l,this.hls=o}var w=R.prototype;return w.destroy=function(){this.hls=this.fragmentTracker=this.media=null},w.poll=function(x){var l=this.config,o=this.media,s=this.stalled,h=o.currentTime,C=o.seeking,m=this.seeking&&!C,p=!this.seeking&&C;if(this.seeking=C,h!==x){if(this.moved=!0,s!==null){if(this.stallReported){var A=self.performance.now()-s;j.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(A)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||m)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!V.BufferHelper.getBuffered(o).length)return;var E=V.BufferHelper.bufferInfo(o,h,0),f=E.len>0,d=E.nextStart||0;if(!f&&!d)return;if(C){var u=E.len>I,a=!d||d-h>I&&!this.fragmentTracker.getPartialFragment(h);if(u||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var y,c=Math.max(d,E.start||0)-h,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=S==null||((y=S.details)===null||y===void 0)?void 0:y.live,G=P?S.details.targetduration*2:I;if(c>0&&c<=G){this._trySkipBufferHole(null);return}}var X=self.performance.now();if(s===null){this.stalled=X;return}var te=X-s;!C&&te>=U&&this._reportStall(E.len);var z=V.BufferHelper.bufferInfo(o,h,l.maxBufferHole);this._tryFixBufferStall(z,te)},w._tryFixBufferStall=function(x,l){var o=this.config,s=this.fragmentTracker,h=this.media,C=h.currentTime,m=s.getPartialFragment(C);if(m){var p=this._trySkipBufferHole(m);if(p)return}x.len>o.maxBufferHole&&l>o.highBufferWatchdogPeriod*1e3&&(j.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},w._reportStall=function(x){var l=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="+x+")"),l.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:x}))},w._trySkipBufferHole=function(x){for(var l=this.config,o=this.hls,s=this.media,h=s.currentTime,C=0,m=V.BufferHelper.getBuffered(s),p=0;p<m.length;p++){var A=m.start(p);if(h+l.maxBufferHole>=C&&h<A){var E=Math.max(A+v,s.currentTime+O);return j.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+E),this.moved=!0,this.stalled=null,s.currentTime=E,x&&o.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+E,frag:x}),E}C=m.end(p)}return 0},w._tryNudgeBuffer=function(){var x=this.config,l=this.hls,o=this.media,s=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<x.nudgeMaxRetry){var C=s+h*x.nudgeOffset;j.logger.warn("Nudging 'currentTime' from "+s+" to "+C),o.currentTime=C,l.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else j.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+x.nudgeMaxRetry+" nudges"),l.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts"),M=_("./src/utils/texttrack-utils.ts"),D=_("./src/demux/id3.ts"),j=.25,U=function(){function I(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var O=I.prototype;return O.destroy=function(){this._unregisterListeners()},O._registerListeners=function(){var g=this.hls;g.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),g.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O._unregisterListeners=function(){var g=this.hls;g.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),g.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O.onMediaAttached=function(g,R){this.media=R.media},O.onMediaDetaching=function(){if(!this.id3Track)return;Object(M.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},O.getID3Track=function(g){if(!this.media)return;for(var R=0;R<g.length;R++){var w=g[R];if(w.kind==="metadata"&&w.label==="id3")return Object(M.sendAddTrackEvent)(w,this.media),w}return this.media.addTextTrack("metadata","id3")},O.onFragParsingMetadata=function(g,R){if(!this.media)return;var w=R.frag,b=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var x=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,l=0;l<b.length;l++){var o=D.getID3Frames(b[l].data);if(o){var s=b[l].pts,h=l<b.length-1?b[l+1].pts:w.end,C=h-s;C<=0&&(h=s+j);for(var m=0;m<o.length;m++){var p=o[m];if(!D.isTimeStampFrame(p)){var A=new x(s,h,"");A.value=p,this.id3Track.addCue(A)}}}}},O.onBufferFlushing=function(g,R){var w=R.startOffset,b=R.endOffset,x=R.type;if(!x||x==="audio"){var l=this.id3Track;l&&Object(M.removeCuesInRange)(l,w,b)}},I}();$.default=U},"./src/controller/latency-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return I});var V=_("./src/errors.ts"),M=_("./src/events.ts"),D=_("./src/utils/logger.ts");function j(O,v){for(var g=0;g<v.length;g++){var R=v[g];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function U(O,v,g){return v&&j(O.prototype,v),g&&j(O,g),O}var I=function(){function O(g){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=g,this.config=g.config,this.registerListeners()}var v=O.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(M.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(M.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(M.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(M.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(M.Events.ERROR,this.onError)},v.onMediaAttached=function(R,w){this.media=w.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},v.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},v.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},v.onLevelUpdated=function(R,w){var b=w.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(R,w){if(w.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var R=this.media,w=this.levelDetails;if(!R||!w)return;this.currentTime=R.currentTime;var b=this.computeLatency();if(b===null)return;this._latency=b;var x=this.config,l=x.lowLatencyMode,o=x.maxLiveSyncPlaybackRate;if(!l||o===1)return;var s=this.targetLatency;if(s===null)return;var h=b-s,C=Math.min(this.maxLatency,s+w.targetduration),m=h<C;if(w.live&&m&&h>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),A=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;R.playbackRate=Math.min(p,Math.max(1,A))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},v.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},v.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},U(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,w=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:w?R.liveMaxLatencyDurationCount*w.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var w=R.holdBack,b=R.partHoldBack,x=R.targetduration,l=this.config,o=l.liveSyncDuration,s=l.liveSyncDurationCount,h=l.lowLatencyMode,C=this.hls.userConfig,m=h&&b||w;(C.liveSyncDuration||C.liveSyncDurationCount||m===0)&&(m=o!==void 0?o:s*x);var p=x,A=1;return m+Math.min(this.stallCount*A,p)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),w=this.targetLatency,b=this.levelDetails;if(R===null||w===null||b===null)return null;var x=b.edge,l=R-w-this.edgeStalled,o=x-b.totalduration,s=x-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(o,l),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 w=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-w,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,w=this.levelDetails;if(!R||!w)return 0;var b=R.buffered.length;return b?R.buffered.end(b-1):w.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return l});var V=_("./src/types/level.ts"),M=_("./src/events.ts"),D=_("./src/errors.ts"),j=_("./src/utils/codecs.ts"),U=_("./src/controller/level-helper.ts"),I=_("./src/controller/base-playlist-controller.ts"),O=_("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var s=1;s<arguments.length;s++){var h=arguments[s];for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(o[C]=h[C])}return o},v.apply(this,arguments)}function g(o,s){for(var h=0;h<s.length;h++){var C=s[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function R(o,s,h){return s&&g(o.prototype,s),h&&g(o,h),o}function w(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,b(o,s)}function b(o,s){return b=Object.setPrototypeOf||function(C,m){return C.__proto__=m,C},b(o,s)}var x=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),l=function(o){w(s,o);function s(C){var m;return m=o.call(this,C,"[level-controller]")||this,m._levels=[],m._firstLevel=-1,m._startLevel=void 0,m.currentLevelIndex=-1,m.manualLevelIndex=-1,m.onParsedComplete=void 0,m._registerListeners(),m}var h=s.prototype;return h._registerListeners=function(){var m=this.hls;m.on(M.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),m.on(M.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var m=this.hls;m.off(M.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),m.off(M.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},h.startLoad=function(){var m=this._levels;m.forEach(function(p){p.loadError=0}),o.prototype.startLoad.call(this)},h.onManifestLoaded=function(m,p){var A=[],E=[],f=[],d,u={},a,y=!1,c=!1,S=!1;if(p.levels.forEach(function(te){var z=te.attrs;y=y||!!(te.width&&te.height),c=c||!!te.videoCodec,S=S||!!te.audioCodec,x&&te.audioCodec&&te.audioCodec.indexOf("mp4a.40.34")!==-1&&(te.audioCodec=void 0);var F=te.bitrate+"-"+te.attrs.RESOLUTION+"-"+te.attrs.CODECS;a=u[F],a?a.url.push(te.url):(a=new V.Level(te),u[F]=a,A.push(a)),z&&(z.AUDIO&&Object(U.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(U.addGroupId)(a,"text",z.SUBTITLES))}),(y||c)&&S&&(A=A.filter(function(te){var z=te.videoCodec,F=te.width,ne=te.height;return!!z||!!(F&&ne)})),A=A.filter(function(te){var z=te.audioCodec,F=te.videoCodec;return(!z||Object(j.isCodecSupportedInMp4)(z,"audio"))&&(!F||Object(j.isCodecSupportedInMp4)(F,"video"))}),p.audioTracks&&(E=p.audioTracks.filter(function(te){return!te.audioCodec||Object(j.isCodecSupportedInMp4)(te.audioCodec,"audio")}),Object(U.assignTrackIdsByGroup)(E)),p.subtitles&&(f=p.subtitles,Object(U.assignTrackIdsByGroup)(f)),A.length>0){d=A[0].bitrate,A.sort(function(te,z){return te.bitrate-z.bitrate}),this._levels=A;for(var P=0;P<A.length;P++)if(A[P].bitrate===d){this._firstLevel=P,this.log("manifest loaded, "+A.length+" level(s) found, first bitrate: "+d);break}var G=S&&!c,X={levels:A,audioTracks:E,subtitleTracks:f,firstLevel:this._firstLevel,stats:p.stats,audio:S,video:c,altAudio:!G&&E.some(function(te){return!!te.url})};this.hls.trigger(M.Events.MANIFEST_PARSED,X),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(m,p){if(o.prototype.onError.call(this,m,p),p.fatal)return;var A=p.context,E=this._levels[this.currentLevelIndex];if(A&&(A.type===O.PlaylistContextType.AUDIO_TRACK&&E.audioGroupIds&&A.groupId===E.audioGroupIds[E.urlId]||A.type===O.PlaylistContextType.SUBTITLE_TRACK&&E.textGroupIds&&A.groupId===E.textGroupIds[E.urlId])){this.redundantFailover(this.currentLevelIndex);return}var f=!1,d=!0,u;switch(p.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(u=p.frag.level)):u=p.frag.level}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:A&&(A.deliveryDirectives&&(d=!1),u=A.level),f=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:u=p.level,f=!0;break}u!==void 0&&this.recoverLevel(p,u,f,d)},h.recoverLevel=function(m,p,A,E){var f=m.details,d=this._levels[p];if(d.loadError++,A){var u=this.retryLoadingOrFail(m);if(u)m.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var a=d.url.length;if(a>1&&d.loadError<a)m.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var y=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==y&&this._levels[y].loadError===0&&(this.warn(f+": switch to "+y),m.levelRetry=!0,this.hls.nextAutoLevel=y)}}},h.redundantFailover=function(m){var p=this._levels[m],A=p.url.length;if(A>1){var E=(p.urlId+1)%A;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(f){f.urlId=E}),this.level=m}},h.onFragLoaded=function(m,p){var A=p.frag;if(A!==void 0&&A.type===O.PlaylistLevelType.MAIN){var E=this._levels[A.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},h.onLevelLoaded=function(m,p){var A,E=p.level,f=p.details,d=this._levels[E];if(!d){var u;this.warn("Invalid level index "+E),(u=p.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(f.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0,this.retryCount=0),this.playlistLoaded(E,p,d.details)):(A=p.deliveryDirectives)!==null&&A!==void 0&&A.skip&&(f.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(m,p){var A=this.hls.levels[this.currentLevelIndex];if(!A)return;if(A.audioGroupIds){for(var E=-1,f=this.hls.audioTracks[p.id].groupId,d=0;d<A.audioGroupIds.length;d++)if(A.audioGroupIds[d]===f){E=d;break}E!==A.urlId&&(A.urlId=E,this.startLoad())}},h.loadPlaylist=function(m){var p=this.currentLevelIndex,A=this._levels[p];if(this.canLoad&&A&&A.url.length>0){var E=A.urlId,f=A.url[E];if(m)try{f=m.addDirectives(f)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("Attempt loading level index "+p+(m?" at sn "+m.msn+" part "+m.part:"")+" with URL-id "+E+" "+f),this.clearTimer(),this.hls.trigger(M.Events.LEVEL_LOADING,{url:f,level:p,id:E,deliveryDirectives:m||null})}},h.removeLevel=function(m,p){var A=function(d,u){return u!==p},E=this._levels.filter(function(f,d){return d!==m?!0:f.url.length>1&&p!==void 0?(f.url=f.url.filter(A),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(A)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(A)),f.urlId=0,!0):!1}).map(function(f,d){var u=f.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=d}),f});this._levels=E,this.hls.trigger(M.Events.LEVELS_UPDATED,{levels:E})},R(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(m){var p,A=this._levels;if(A.length===0)return;if(this.currentLevelIndex===m&&(p=A[m])!==null&&p!==void 0&&p.details)return;if(m<0||m>=A.length){var E=m<0;if(this.hls.trigger(M.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:m,fatal:E,reason:"invalid level idx"}),E)return;m=Math.min(m,A.length-1)}this.clearTimer();var f=this.currentLevelIndex,d=A[f],u=A[m];this.log("switching to level "+m+" from "+f),this.currentLevelIndex=m;var a=v({},u,{level:m,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(M.Events.LEVEL_SWITCHING,a);var y=u.details;if(!y||y.live){var c=this.switchParams(u.uri,d==null?void 0:d.details);this.loadPlaylist(c)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(m){this.manualLevelIndex=m,this._startLevel===void 0&&(this._startLevel=m),m!==-1&&(this.level=m)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(m){this._firstLevel=m}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var m=this.hls.config.startLevel;return m!==void 0?m:this._firstLevel}else return this._startLevel},set:function(m){this._startLevel=m}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(m){this.level=m,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=m)}}]),s}(I.default)},"./src/controller/level-helper.ts":function(fe,$,_){"use strict";_.r($),_.d($,"addGroupId",function(){return D}),_.d($,"assignTrackIdsByGroup",function(){return j}),_.d($,"updatePTS",function(){return U}),_.d($,"updateFragPTSDTS",function(){return O}),_.d($,"mergeDetails",function(){return v}),_.d($,"mapPartIntersection",function(){return g}),_.d($,"mapFragmentIntersection",function(){return R}),_.d($,"adjustSliding",function(){return w}),_.d($,"addSliding",function(){return b}),_.d($,"computeReloadInterval",function(){return x}),_.d($,"getFragmentWithSN",function(){return l}),_.d($,"getPartWith",function(){return o});var V=_("./src/polyfills/number.ts"),M=_("./src/utils/logger.ts");function D(s,h,C){switch(h){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(C);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(C);break}}function j(s){var h={};s.forEach(function(C){var m=C.groupId||"";C.id=h[m]=h[m]||0,h[m]++})}function U(s,h,C){var m=s[h],p=s[C];I(m,p)}function I(s,h){var C=h.startPTS;if(Object(V.isFiniteNumber)(C)){var m=0,p;h.sn>s.sn?(m=C-s.start,p=s):(m=s.start-C,p=h),p.duration!==m&&(p.duration=m)}else if(h.sn>s.sn){var A=s.cc===h.cc;A&&s.minEndPTS?h.start=s.start+(s.minEndPTS-s.start):h.start=s.start+s.duration}else h.start=Math.max(s.start-h.duration,0)}function O(s,h,C,m,p,A){var E=m-C;E<=0&&(M.logger.warn("Fragment should have a positive duration",h),m=C+h.duration,A=p+h.duration);var f=C,d=m,u=h.startPTS,a=h.endPTS;if(Object(V.isFiniteNumber)(u)){var y=Math.abs(u-C);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(y,h.deltaPTS):h.deltaPTS=y,f=Math.max(C,u),C=Math.min(C,u),p=Math.min(p,h.startDTS),d=Math.min(m,a),m=Math.max(m,a),A=Math.max(A,h.endDTS)}h.duration=m-C;var c=C-h.start;h.appendedPTS=m,h.start=h.startPTS=C,h.maxStartPTS=f,h.startDTS=p,h.endPTS=m,h.minEndPTS=d,h.endDTS=A;var S=h.sn;if(!s||S<s.startSN||S>s.endSN)return 0;var P,G=S-s.startSN,X=s.fragments;for(X[G]=h,P=G;P>0;P--)I(X[P],X[P-1]);for(P=G;P<X.length-1;P++)I(X[P],X[P+1]);return s.fragmentHint&&I(X[X.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function v(s,h){for(var C=null,m=s.fragments,p=m.length-1;p>=0;p--){var A=m[p].initSegment;if(A){C=A;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var E=0,f;if(R(s,h,function(P,G){P.relurl&&(E=P.cc-G.cc),Object(V.isFiniteNumber)(P.startPTS)&&Object(V.isFiniteNumber)(P.endPTS)&&(G.start=G.startPTS=P.startPTS,G.startDTS=P.startDTS,G.appendedPTS=P.appendedPTS,G.maxStartPTS=P.maxStartPTS,G.endPTS=P.endPTS,G.endDTS=P.endDTS,G.minEndPTS=P.minEndPTS,G.duration=P.endPTS-P.startPTS,G.duration&&(f=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=P.elementaryStreams,G.loader=P.loader,G.stats=P.stats,G.urlId=P.urlId,P.initSegment&&(G.initSegment=P.initSegment,C=P.initSegment)}),C){var d=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;d.forEach(function(P){var G;(!P.initSegment||P.initSegment.relurl===((G=C)===null||G===void 0?void 0:G.relurl))&&(P.initSegment=C)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(P){return!P}),h.deltaUpdateFailed)){M.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=h.skippedSegments;u--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var a=h.fragments;if(E){M.logger.warn("discontinuity sliding from playlist, take drift into account");for(var y=0;y<a.length;y++)a[y].cc+=E}h.skippedSegments&&(h.startCC=h.fragments[0].cc),g(s.partList,h.partList,function(P,G){G.elementaryStreams=P.elementaryStreams,G.stats=P.stats}),f?O(h,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):w(s,h),a.length&&(h.totalduration=h.edge-a[0].start),h.driftStartTime=s.driftStartTime,h.driftStart=s.driftStart;var c=h.advancedDateTime;if(h.advanced&&c){var S=h.edge;h.driftStart||(h.driftStartTime=c,h.driftStart=S),h.driftEndTime=c,h.driftEnd=S}else h.driftEndTime=s.driftEndTime,h.driftEnd=s.driftEnd,h.advancedDateTime=s.advancedDateTime}function g(s,h,C){if(s&&h)for(var m=0,p=0,A=s.length;p<=A;p++){var E=s[p],f=h[p+m];E&&f&&E.index===f.index&&E.fragment.sn===f.fragment.sn?C(E,f):m--}}function R(s,h,C){for(var m=h.skippedSegments,p=Math.max(s.startSN,h.startSN)-h.startSN,A=(s.fragmentHint?1:0)+(m?h.endSN:Math.min(s.endSN,h.endSN))-h.startSN,E=h.startSN-s.startSN,f=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,d=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,u=p;u<=A;u++){var a=d[E+u],y=f[u];m&&!y&&u<m&&(y=h.fragments[u]=a),a&&y&&C(a,y)}}function w(s,h){var C=h.startSN+h.skippedSegments-s.startSN,m=s.fragments;if(C<0||C>=m.length)return;b(h,m[C].start)}function b(s,h){if(h){for(var C=s.fragments,m=s.skippedSegments;m<C.length;m++)C[m].start+=h;s.fragmentHint&&(s.fragmentHint.start+=h)}}function x(s,h){var C=1e3*s.levelTargetDuration,m=C/2,p=s.age,A=p>0&&p<C*3,E=h.loading.end-h.loading.start,f,d=s.availabilityDelay;if(s.updated===!1)if(A){var u=333*s.misses;f=Math.max(Math.min(m,E*2),u),s.availabilityDelay=(s.availabilityDelay||0)+f}else f=m;else A?(d=Math.min(d||C/2,p),s.availabilityDelay=d,f=d+C-p):f=C-E;return Math.round(f)}function l(s,h,C){if(!s||!s.details)return null;var m=s.details,p=m.fragments[h-m.startSN];return p||(p=m.fragmentHint,p&&p.sn===h?p:h<m.startSN&&C&&C.sn===h?C:null)}function o(s,h,C){if(!s||!s.details)return null;var m=s.details.partList;if(m)for(var p=m.length;p--;){var A=m[p];if(A.index===C&&A.fragment.sn===h)return A}return null}},"./src/controller/stream-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return m});var V=_("./src/polyfills/number.ts"),M=_("./src/controller/base-stream-controller.ts"),D=_("./src/is-supported.ts"),j=_("./src/events.ts"),U=_("./src/utils/buffer-helper.ts"),I=_("./src/controller/fragment-tracker.ts"),O=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),g=_("./src/demux/transmuxer-interface.ts"),R=_("./src/types/transmuxer.ts"),w=_("./src/controller/gap-controller.ts"),b=_("./src/errors.ts"),x=_("./src/utils/logger.ts");function l(p,A){for(var E=0;E<A.length;E++){var f=A[E];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(p,f.key,f)}}function o(p,A,E){return A&&l(p.prototype,A),E&&l(p,E),p}function s(p,A){p.prototype=Object.create(A.prototype),p.prototype.constructor=p,h(p,A)}function h(p,A){return h=Object.setPrototypeOf||function(f,d){return f.__proto__=d,f},h(p,A)}var C=100,m=function(p){s(A,p);function A(f,d){var u;return u=p.call(this,f,d,"[stream-controller]")||this,u.audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.stalled=!1,u.couldBacktrack=!1,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}var E=A.prototype;return E._registerListeners=function(){var d=this.hls;d.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),d.on(j.Events.ERROR,this.onError,this),d.on(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(j.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),d.on(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var d=this.hls;d.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),d.off(j.Events.ERROR,this.onError,this),d.off(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(j.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),d.off(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},E.startLoad=function(d){if(this.levels){var u=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(C),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}u>0&&d===-1&&(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),d=u),this.state=M.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()}else this._forceStartLoad=!0,this.state=M.State.STOPPED},E.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},E.doTick=function(){switch(this.state){case M.State.IDLE:this.doTickIdle();break;case M.State.WAITING_LEVEL:{var d,u=this.levels,a=this.level,y=u==null||((d=u[a])===null||d===void 0)?void 0:d.details;if(y&&(!y.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(y))break;this.state=M.State.IDLE;break}break}case M.State.FRAG_LOADING_WAITING_RETRY:{var c,S=self.performance.now(),P=this.retryDate;(!P||S>=P||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=M.State.IDLE)}break;default:break}this.onTickEnd()},E.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},E.doTickIdle=function(){var d,u,a=this.hls,y=this.levelLastLoaded,c=this.levels,S=this.media,P=a.config,G=a.nextLoadLevel;if(y===null||!S&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!c||!c[G])return;var X=c[G];this.level=a.nextLoadLevel=G;var te=X.details;if(!te||this.state===M.State.WAITING_LEVEL||te.live&&this.levelLastLoaded!==G){this.state=M.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:S,O.PlaylistLevelType.MAIN);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(X.maxBitrate);if(F>=ne)return;if(this._streamEnded(z,te)){var ce={};this.altAudio&&(ce.type="video"),this.hls.trigger(j.Events.BUFFER_EOS,ce),this.state=M.State.ENDED;return}var ge=z.end,xe=this.getNextFragment(ge,te);if(this.couldBacktrack&&!this.fragPrevious&&xe&&xe.sn!=="initSegment"){var Ie=xe.sn-te.startSN;Ie>1&&(xe=te.fragments[Ie-1],this.fragmentTracker.removeFragment(xe))}if(xe&&this.fragmentTracker.getState(xe)===I.FragmentState.OK&&this.nextLoadPosition>ge){var Te=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(S,Te,O.PlaylistLevelType.MAIN),xe=this.getNextFragment(this.nextLoadPosition,te)}if(!xe)return;xe.initSegment&&!xe.initSegment.data&&!this.bitrateTest&&(xe=xe.initSegment),((d=xe.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((u=xe.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(xe,te):this.loadFragment(xe,te,ge)},E.loadFragment=function(d,u,a){var y,c=this.fragmentTracker.getState(d);if(this.fragCurrent=d,c===I.FragmentState.BACKTRACKED){var S=this.fragmentTracker.getBacktrackData(d);if(S){this._handleFragmentLoadProgress(S),this._handleFragmentLoadComplete(S);return}else c=I.FragmentState.NOT_LOADED}c===I.FragmentState.NOT_LOADED||c===I.FragmentState.PARTIAL?d.sn==="initSegment"?this._loadInitSegment(d):this.bitrateTest?(d.bitrateTest=!0,this.log("Fragment "+d.sn+" of level "+d.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(d)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,d,u,a)):c===I.FragmentState.APPENDING?this.reduceMaxBufferLength(d.duration)&&this.fragmentTracker.removeFragment(d):((y=this.media)===null||y===void 0?void 0:y.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},E.getAppendedFrag=function(d){var u=this.fragmentTracker.getAppendedFrag(d,O.PlaylistLevelType.MAIN);return u&&"fragment"in u?u.fragment:u},E.getBufferedFrag=function(d){return this.fragmentTracker.getBufferedFrag(d,O.PlaylistLevelType.MAIN)},E.followingBufferedFrag=function(d){return d?this.getBufferedFrag(d.end+.5):null},E.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},E.nextLevelSwitch=function(){var d=this.levels,u=this.media;if(u!=null&&u.readyState){var a,y=this.getAppendedFrag(u.currentTime);if(y&&y.start>1&&this.flushMainBuffer(0,y.start-1),!u.paused&&d){var c=this.hls.nextLoadLevel,S=d[c],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*S.maxBitrate/(1e3*P)+1:a=0}else a=0;var G=this.getBufferedFrag(u.currentTime+a);if(G){var X=this.followingBufferedFrag(G);if(X){this.abortCurrentFrag();var te=X.maxStartPTS?X.maxStartPTS:X.start,z=X.duration,F=Math.max(G.end,te+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},E.abortCurrentFrag=function(){var d=this.fragCurrent;this.fragCurrent=null,d!=null&&d.loader&&d.loader.abort(),this.state===M.State.KEY_LOADING&&(this.state=M.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},E.flushMainBuffer=function(d,u){p.prototype.flushMainBuffer.call(this,d,u,this.altAudio?"video":null)},E.onMediaAttached=function(d,u){p.prototype.onMediaAttached.call(this,d,u);var a=u.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new w.default(this.config,a,this.fragmentTracker,this.hls)},E.onMediaDetaching=function(){var d=this.media;d&&(d.removeEventListener("playing",this.onvplaying),d.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),p.prototype.onMediaDetaching.call(this)},E.onMediaPlaying=function(){this.tick()},E.onMediaSeeked=function(){var d=this.media,u=d?d.currentTime:null;Object(V.isFiniteNumber)(u)&&this.log("Media seeked to "+u.toFixed(3)),this.tick()},E.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},E.onManifestParsed=function(d,u){var a=!1,y=!1,c;u.levels.forEach(function(S){c=S.audioCodec,c&&(c.indexOf("mp4a.40.2")!==-1&&(a=!0),c.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=u.levels,this.startFragRequested=!1},E.onLevelLoading=function(d,u){var a=this.levels;if(!a||this.state!==M.State.IDLE)return;var y=a[u.level];(!y.details||y.details.live&&this.levelLastLoaded!==u.level||this.waitForCdnTuneIn(y.details))&&(this.state=M.State.WAITING_LEVEL)},E.onLevelLoaded=function(d,u){var a,y=this.levels,c=u.level,S=u.details,P=S.totalduration;if(!y){this.warn("Levels were reset while loading level "+c);return}this.log("Level "+c+" loaded ["+S.startSN+","+S.endSN+"], cc ["+S.startCC+", "+S.endCC+"] duration:"+P);var G=this.fragCurrent;G&&(this.state===M.State.FRAG_LOADING||this.state===M.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==u.level&&G.loader&&(this.state=M.State.IDLE,G.loader.abort()));var X=y[c],te=0;if(S.live||(a=X.details)!==null&&a!==void 0&&a.live){if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed)return;te=this.alignPlaylists(S,X.details)}if(X.details=S,this.levelLastLoaded=c,this.hls.trigger(j.Events.LEVEL_UPDATED,{details:S,level:c}),this.state===M.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(S))return;this.state=M.State.IDLE}this.startFragRequested?S.live&&this.synchronizeToLiveEdge(S):this.setStartPosition(S,te),this.tick()},E._handleFragmentLoadProgress=function(d){var u,a=d.frag,y=d.part,c=d.payload,S=this.levels;if(!S){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var P=S[a.level],G=P.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var X=P.videoCodec,te=G.PTSKnown||!G.live,z=(u=a.initSegment)===null||u===void 0?void 0:u.data,F=this._getAudioCodec(P),ne=this.transmuxer=this.transmuxer||new g.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ce=y?y.index:-1,ge=ce!==-1,xe=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,c.byteLength,ce,ge),Ie=this.initPTS[a.cc];ne.push(c,z,F,X,a,y,G.totalduration,te,xe,Ie)},E.onAudioTrackSwitching=function(d,u){var a=this.altAudio,y=!!u.url,c=u.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 S=this.fragCurrent;S!=null&&S.loader&&(this.log("Switching to main audio track, cancel main fragment load"),S.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;a&&P.trigger(j.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(j.Events.AUDIO_TRACK_SWITCHED,{id:c})}},E.onAudioTrackSwitched=function(d,u){var a=u.id,y=!!this.hls.audioTracks[a].url;if(y){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=y,this.tick()},E.onBufferCreated=function(d,u){var a=u.tracks,y,c,S=!1;for(var P in a){var G=a[P];if(G.id==="main"){if(c=P,y=G,P==="video"){var X=a[P];X&&(this.videoBuffer=X.buffer)}}else S=!0}S&&y?(this.log("Alternate track found, use "+c+".buffered to schedule main fragment loading"),this.mediaBuffer=y.buffer):this.mediaBuffer=this.media},E.onFragBuffered=function(d,u){var a=u.frag,y=u.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===M.State.PARSED&&(this.state=M.State.IDLE);return}var c=y?y.stats:a.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,y)},E.onError=function(d,u){switch(u.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.MAIN,u);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==M.State.ERROR&&(u.fatal?(this.warn(""+u.details),this.state=M.State.ERROR):!u.levelRetry&&this.state===M.State.WAITING_LEVEL&&(this.state=M.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="main"&&(this.state===M.State.PARSING||this.state===M.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}},E.checkBuffer=function(){var d=this.media,u=this.gapController;if(!d||!u||!d.readyState)return;var a=U.BufferHelper.getBuffered(d);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):u.poll(this.lastCurrentTime),this.lastCurrentTime=d.currentTime},E.onFragLoadEmergencyAborted=function(){this.state=M.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},E.onBufferFlushed=function(d,u){var a=u.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var y=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(y,a,O.PlaylistLevelType.MAIN)}},E.onLevelsUpdated=function(d,u){this.levels=u.levels},E.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},E.seekToStartPos=function(){var d=this.media,u=d.currentTime,a=this.startPosition;if(a>=0&&u<a){if(d.seeking){x.logger.log("could not seek to "+a+", already seeking at "+u);return}var y=U.BufferHelper.getBuffered(d),c=y.length?y.start(0):0,S=c-a;S>0&&(S<this.config.maxBufferHole||S<this.config.maxFragLookUpTolerance)&&(x.logger.log("adjusting start position by "+S+" to match buffer start"),a+=S,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+u),d.currentTime=a}},E._getAudioCodec=function(d){var u=this.config.defaultAudioCodec||d.audioCodec;return this.audioCodecSwap&&u&&(this.log("Swapping audio codec"),u.indexOf("mp4a.40.5")!==-1?u="mp4a.40.2":u="mp4a.40.5"),u},E._loadBitrateTestFrag=function(d){var u=this;this._doFragLoad(d).then(function(a){var y=u.hls;if(!a||y.nextLoadLevel||u.fragContextChanged(d))return;u.fragLoadError=0,u.state=M.State.IDLE,u.startFragRequested=!1,u.bitrateTest=!1;var c=d.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),y.trigger(j.Events.FRAG_LOADED,a)})},E._handleTransmuxComplete=function(d){var u,a="main",y=this.hls,c=d.remuxResult,S=d.chunkMeta,P=this.getCurrentContext(S);if(!P){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(S.level);return}var G=P.frag,X=P.part,te=P.level,z=c.video,F=c.text,ne=c.id3,ce=c.initSegment,ge=this.altAudio?void 0:c.audio;if(this.fragContextChanged(G))return;if(this.state=M.State.PARSING,ce){ce.tracks&&(this._bufferInitSegment(te,ce.tracks,G,S),y.trigger(j.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ce.tracks}));var xe=ce.initPTS,Ie=ce.timescale;Object(V.isFiniteNumber)(xe)&&(this.initPTS[G.cc]=xe,y.trigger(j.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:xe,timescale:Ie}))}if(z&&c.independent!==!1){if(te.details){var Te=z.startPTS,Oe=z.endPTS,Ce=z.startDTS,Ae=z.endDTS;if(X)X.elementaryStreams[z.type]={startPTS:Te,endPTS:Oe,startDTS:Ce,endDTS:Ae};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,Oe,G.start,Ae,!0)}G.setElementaryStreamInfo(z.type,Te,Oe,Ce,Ae),this.bufferFragmentData(z,G,X,S)}}else if(c.independent===!1){this.backtrack(G);return}if(ge){var W=ge.startPTS,L=ge.endPTS,k=ge.startDTS,H=ge.endDTS;X&&(X.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:L,startDTS:k,endDTS:H}),G.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,W,L,k,H),this.bufferFragmentData(ge,G,X,S)}if(ne!=null&&(u=ne.samples)!==null&&u!==void 0&&u.length){var q={frag:G,id:a,samples:ne.samples};y.trigger(j.Events.FRAG_PARSING_METADATA,q)}if(F){var B={frag:G,id:a,samples:F.samples};y.trigger(j.Events.FRAG_PARSING_USERDATA,B)}},E._bufferInitSegment=function(d,u,a,y){var c=this;if(this.state!==M.State.PARSING)return;this.audioOnly=!!u.audio&&!u.video,this.altAudio&&!this.audioOnly&&delete u.audio;var S=u.audio,P=u.video,G=u.audiovideo;if(S){var X=d.audioCodec,te=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(X&&(X.indexOf("mp4a.40.5")!==-1?X="mp4a.40.2":X="mp4a.40.5"),S.metadata.channelCount!==1&&te.indexOf("firefox")===-1&&(X="mp4a.40.5")),te.indexOf("android")!==-1&&S.container!=="audio/mpeg"&&(X="mp4a.40.2",this.log("Android: force audio codec to "+X)),d.audioCodec&&d.audioCodec!==X&&this.log('Swapping manifest audio codec "'+d.audioCodec+'" for "'+X+'"'),S.levelCodec=X,S.id="main",this.log("Init audio buffer, container:"+S.container+", codecs[selected/level/parsed]=["+(X||"")+"/"+(d.audioCodec||"")+"/"+S.codec+"]")}P&&(P.levelCodec=d.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(d.videoCodec||"")+"/"+P.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(d.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(j.Events.BUFFER_CODECS,u),Object.keys(u).forEach(function(z){var F=u[z],ne=F.initSegment;ne!=null&&ne.byteLength&&c.hls.trigger(j.Events.BUFFER_APPENDING,{type:z,data:ne,frag:a,part:null,chunkMeta:y,parent:a.type})}),this.tick()},E.backtrack=function(d){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(d);var u=this.fragmentTracker.backtrack(d);this.fragPrevious=null,this.nextLoadPosition=d.start,u?this.resetFragmentLoading(d):this.state=M.State.BACKTRACKING},E.checkFragmentChanged=function(){var d=this.media,u=null;if(d&&d.readyState>1&&d.seeking===!1){var a=d.currentTime;if(U.BufferHelper.isBuffered(d,a)?u=this.getAppendedFrag(a):U.BufferHelper.isBuffered(d,a+.1)&&(u=this.getAppendedFrag(a+.1)),u){var y=this.fragPlaying,c=u.level;(!y||u.sn!==y.sn||y.level!==c||u.urlId!==y.urlId)&&(this.hls.trigger(j.Events.FRAG_CHANGED,{frag:u}),(!y||y.level!==c)&&this.hls.trigger(j.Events.LEVEL_SWITCHED,{level:c}),this.fragPlaying=u)}}},o(A,[{key:"nextLevel",get:function(){var d=this.nextBufferedFrag;return d?d.level:-1}},{key:"currentLevel",get:function(){var d=this.media;if(d){var u=this.getAppendedFrag(d.currentTime);if(u)return u.level}return-1}},{key:"nextBufferedFrag",get:function(){var d=this.media;if(d){var u=this.getAppendedFrag(d.currentTime);return this.followingBufferedFrag(u)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),A}(M.default)},"./src/controller/subtitle-stream-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"SubtitleStreamController",function(){return s});var V=_("./src/events.ts"),M=_("./src/utils/logger.ts"),D=_("./src/utils/buffer-helper.ts"),j=_("./src/controller/fragment-finders.ts"),U=_("./src/utils/discontinuities.ts"),I=_("./src/controller/level-helper.ts"),O=_("./src/controller/fragment-tracker.ts"),v=_("./src/controller/base-stream-controller.ts"),g=_("./src/types/loader.ts"),R=_("./src/types/level.ts");function w(h,C){for(var m=0;m<C.length;m++){var p=C[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(h,p.key,p)}}function b(h,C,m){return C&&w(h.prototype,C),m&&w(h,m),h}function x(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,l(h,C)}function l(h,C){return l=Object.setPrototypeOf||function(p,A){return p.__proto__=A,p},l(h,C)}var o=500,s=function(h){x(C,h);function C(p,A){var E;return E=h.call(this,p,A,"[subtitle-stream-controller]")||this,E.levels=[],E.currentTrackId=-1,E.tracksBuffered=[],E.mainDetails=null,E._registerListeners(),E}var m=C.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var A=this.hls;A.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),A.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),A.on(V.Events.ERROR,this.onError,this),A.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),A.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),A.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),A.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),A.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m._unregisterListeners=function(){var A=this.hls;A.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),A.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),A.off(V.Events.ERROR,this.onError,this),A.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),A.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),A.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),A.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),A.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m.startLoad=function(){this.stopLoad(),this.state=v.State.IDLE,this.setInterval(o),this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},m.onLevelLoaded=function(A,E){this.mainDetails=E.details},m.onSubtitleFragProcessed=function(A,E){var f=E.frag,d=E.success;if(this.fragPrevious=f,this.state=v.State.IDLE,!d)return;var u=this.tracksBuffered[this.currentTrackId];if(!u)return;for(var a,y=f.start,c=0;c<u.length;c++)if(y>=u[c].start&&y<=u[c].end){a=u[c];break}var S=f.start+f.duration;a?a.end=S:(a={start:y,end:S},u.push(a)),this.fragmentTracker.fragBuffered(f)},m.onBufferFlushing=function(A,E){var f=E.startOffset,d=E.endOffset;if(f===0&&d!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var y=a[u].details,c=y.targetduration,S=d-c;if(S<=0)return;E.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(P){for(var G=0;G<P.length;){if(P[G].end<=S){P.shift();continue}else if(P[G].start<S)P[G].start=S;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(f,S,g.PlaylistLevelType.SUBTITLE)}},m.onError=function(A,E){var f,d=E.frag;if(!d||d.type!==g.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},m.onSubtitleTracksUpdated=function(A,E){var f=this,d=E.subtitleTracks;this.tracksBuffered=[],this.levels=d.map(function(u){return new R.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){f.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(A,E){if(this.currentTrackId=E.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var f=this.levels[this.currentTrackId];f!=null&&f.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,f&&this.setInterval(o)},m.onSubtitleTrackLoaded=function(A,E){var f,d=E.details,u=E.id,a=this.currentTrackId,y=this.levels;if(!y.length)return;var c=y[a];if(u>=y.length||u!==a||!c)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,d.live||(f=c.details)!==null&&f!==void 0&&f.live){var S=this.mainDetails;if(d.deltaUpdateFailed||!S)return;var P=S.fragments[0];if(!c.details)d.hasProgramDateTime&&S.hasProgramDateTime?Object(U.alignMediaPlaylistByPDT)(d,S):P&&Object(I.addSliding)(d,P.start);else{var G=this.alignPlaylists(d,c.details);G===0&&P&&Object(I.addSliding)(d,P.start)}}if(c.details=d,this.levelLastLoaded=u,this.tick(),d.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var X=Object(j.findFragmentByPTS)(null,d.fragments,this.media.currentTime,0);X||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)}},m._handleFragmentLoadComplete=function(A){var E=A.frag,f=A.payload,d=E.decryptdata,u=this.hls;if(this.fragContextChanged(E))return;if(f&&f.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),d.key.buffer,d.iv.buffer).then(function(y){var c=performance.now();u.trigger(V.Events.FRAG_DECRYPTED,{frag:E,payload:y,stats:{tstart:a,tdecrypt:c}})})}},m.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var A,E=this.currentTrackId,f=this.levels;if(!f.length||!f[E]||!f[E].details)return;var d=f[E].details,u=d.targetduration,a=this.config,y=this.media,c=D.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,y.currentTime-u,a.maxBufferHole),S=c.end,P=c.len,G=this.getMaxBufferLength()+u;if(P>G)return;console.assert(d,"Subtitle track details are defined on idle subtitle stream controller tick");var X=d.fragments,te=X.length,z=d.edge,F,ne=this.fragPrevious;if(S<z){var ce=a.maxFragLookUpTolerance;ne&&d.hasProgramDateTime&&(F=Object(j.findFragmentByPDT)(X,ne.endProgramDateTime,ce)),F||(F=Object(j.findFragmentByPTS)(ne,X,S,ce),!F&&ne&&ne.start<X[0].start&&(F=X[0]))}else F=X[te-1];(A=F)!==null&&A!==void 0&&A.encrypted?(M.logger.log("Loading key for "+F.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:F})):F&&this.fragmentTracker.getState(F)===O.FragmentState.NOT_LOADED&&this.loadFragment(F,d,S)}},m.loadFragment=function(A,E,f){this.fragCurrent=A,h.prototype.loadFragment.call(this,A,E,f)},b(C,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),C}(v.default)},"./src/controller/subtitle-track-controller.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/events.ts"),M=_("./src/utils/texttrack-utils.ts"),D=_("./src/controller/base-playlist-controller.ts"),j=_("./src/types/loader.ts");function U(w,b){for(var x=0;x<b.length;x++){var l=b[x];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(w,l.key,l)}}function I(w,b,x){return b&&U(w.prototype,b),x&&U(w,x),w}function O(w,b){w.prototype=Object.create(b.prototype),w.prototype.constructor=w,v(w,b)}function v(w,b){return v=Object.setPrototypeOf||function(l,o){return l.__proto__=o,l},v(w,b)}var g=function(w){O(b,w);function b(l){var o;return o=w.call(this,l,"[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 x=b.prototype;return x.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,w.prototype.destroy.call(this)},x.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)},x.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)},x.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)},x.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},x.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(M.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},x.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},x.onManifestParsed=function(o,s){this.tracks=s.subtitleTracks},x.onSubtitleTrackLoaded=function(o,s){var h=s.id,C=s.details,m=this.trackId,p=this.tracksInGroup[m];if(!p){this.warn("Invalid subtitle track id "+h);return}var A=p.details;p.details=s.details,this.log("subtitle track "+h+" loaded ["+C.startSN+"-"+C.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,s,A))},x.onLevelLoading=function(o,s){this.switchLevel(s.level)},x.onLevelSwitching=function(o,s){this.switchLevel(s.level)},x.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.textGroupIds))return;var h=s.textGroupIds[s.urlId];if(this.groupId!==h){var C=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,m=this.tracks.filter(function(E){return!h||E.groupId===h});this.tracksInGroup=m;var p=this.findTrackId(C==null?void 0:C.name)||this.findTrackId();this.groupId=h;var A={subtitleTracks:m};this.log("Updating subtitle tracks, "+m.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,A),p!==-1&&this.setSubtitleTrack(p,C)}},x.findTrackId=function(o){for(var s=this.tracksInGroup,h=0;h<s.length;h++){var C=s[h];if((!this.selectDefaultTrack||C.default)&&(!o||o===C.name))return C.id}return-1},x.onError=function(o,s){if(w.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)},x.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var h=s.id,C=s.groupId,m=s.url;if(o)try{m=o.addDirectives(m)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:m,id:h,groupId:C,deliveryDirectives:o||null})}},x.toggleTrackModes=function(o){var s=this,h=this.media,C=this.subtitleDisplay,m=this.trackId;if(!h)return;var p=R(h.textTracks),A=p.filter(function(d){return d.groupId===s.groupId});if(o===-1)[].slice.call(p).forEach(function(d){d.mode="disabled"});else{var E=A[m];E&&(E.mode="disabled")}var f=A[o];f&&(f.mode=C?"showing":"hidden")},x.setSubtitleTrack=function(o,s){var h,C=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(h=C[o])!==null&&h!==void 0&&h.details)||o<-1||o>=C.length)return;this.clearTimer();var m=C[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,m){var p=m.id,A=m.groupId,E=A===void 0?"":A,f=m.name,d=m.type,u=m.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:E,name:f,type:d,url:u});var a=this.switchParams(m.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:o})},x.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),h=0;h<s.length;h++)if(s[h].mode==="hidden")o=h;else if(s[h].mode==="showing"){o=h;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},I(b,[{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)}}]),b}(D.default);function R(w){for(var b=[],x=0;x<w.length;x++){var l=w[x];l.kind==="subtitles"&&l.label&&b.push(w[x])}return b}$.default=g},"./src/controller/timeline-controller.ts":function(fe,$,_){"use strict";_.r($),_.d($,"TimelineController",function(){return R});var V=_("./src/polyfills/number.ts"),M=_("./src/events.ts"),D=_("./src/utils/cea-608-parser.ts"),j=_("./src/utils/output-filter.ts"),U=_("./src/utils/webvtt-parser.ts"),I=_("./src/utils/texttrack-utils.ts"),O=_("./src/utils/imsc1-ttml-parser.ts"),v=_("./src/types/loader.ts"),g=_("./src/utils/logger.ts"),R=function(){function l(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=x(),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 h=new j.default(this,"textTrack1"),C=new j.default(this,"textTrack2"),m=new j.default(this,"textTrack3"),p=new j.default(this,"textTrack4");this.cea608Parser1=new D.default(1,h,C),this.cea608Parser2=new D.default(3,m,p)}s.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(M.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(M.Events.FRAG_LOADING,this.onFragLoading,this),s.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(M.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(M.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(M.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=l.prototype;return o.destroy=function(){var h=this.hls;h.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(M.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(M.Events.FRAG_LOADING,this.onFragLoading,this),h.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(M.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(M.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(M.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(h,C,m,p,A){for(var E=!1,f=A.length;f--;){var d=A[f],u=b(d[0],d[1],C,m);if(u>=0&&(d[0]=Math.min(d[0],C),d[1]=Math.max(d[1],m),E=!0,u/(m-C)>.5))return}if(E||A.push([C,m]),this.config.renderTextTracksNatively){var a=this.captionsTracks[h];this.Cues.newCue(a,C,m,p)}else{var y=this.Cues.newCue(null,C,m,p);this.hls.trigger(M.Events.CUES_PARSED,{type:"captions",cues:y,track:h})}},o.onInitPtsFound=function(h,C){var m=this,p=C.frag,A=C.id,E=C.initPTS,f=C.timescale,d=this.unparsedVttFrags;A==="main"&&(this.initPTS[p.cc]=E,this.timescale[p.cc]=f),d.length&&(this.unparsedVttFrags=[],d.forEach(function(u){m.onFragLoaded(M.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(h){var C=this.media;if(C)for(var m=0;m<C.textTracks.length;m++){var p=C.textTracks[m];if(p[h])return p}return null},o.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},o.createNativeTrack=function(h){if(this.captionsTracks[h])return;var C=this.captionsProperties,m=this.captionsTracks,p=this.media,A=C[h],E=A.label,f=A.languageCode,d=this.getExistingTrack(h);if(d)m[h]=d,Object(I.clearCurrentCues)(m[h]),Object(I.sendAddTrackEvent)(m[h],p);else{var u=this.createTextTrack("captions",E,f);u&&(u[h]=!0,m[h]=u)}},o.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var C=this.captionsProperties[h];if(!C)return;var m=C.label,p={_id:h,label:m,kind:"captions",default:C.media?!!C.media.default:!1,closedCaptions:C.media};this.nonNativeCaptionsTracks[h]=p,this.hls.trigger(M.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[p]})},o.createTextTrack=function(h,C,m){var p=this.media;return p?p.addTextTrack(h,C,m):void 0},o.onMediaAttaching=function(h,C){this.media=C.media,this._cleanTracks()},o.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(C){Object(I.clearCurrentCues)(h[C]),delete h[C]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=x(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var h=this.media;if(!h)return;var C=h.textTracks;if(C)for(var m=0;m<C.length;m++)Object(I.clearCurrentCues)(C[m])},o.onSubtitleTracksUpdated=function(h,C){var m=this;this.textTracks=[];var p=C.subtitleTracks||[],A=p.some(function(u){return u.textCodec===O.IMSC1_CODEC});if(this.config.enableWebVTT||A&&this.config.enableIMSC1){var E=this.tracks&&p&&this.tracks.length===p.length;if(this.tracks=p||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,a){var y;if(a<f.length){for(var c=null,S=0;S<f.length;S++)if(w(f[S],u)){c=f[S];break}c&&(y=c)}y?Object(I.clearCurrentCues)(y):(y=m.createTextTrack("subtitles",u.name,u.lang),y&&(y.mode="disabled")),y&&(y.groupId=u.groupId,m.textTracks.push(y))})}else if(!E&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(M.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},o.onManifestLoaded=function(h,C){var m=this;this.config.enableCEA708Captions&&C.captions&&C.captions.forEach(function(p){var A=/(?:CC|SERVICE)([1-4])/.exec(p.instreamId);if(!A)return;var E="textTrack"+A[1],f=m.captionsProperties[E];if(!f)return;f.label=p.name,p.lang&&(f.languageCode=p.lang),f.media=p})},o.onFragLoading=function(h,C){var m=this.cea608Parser1,p=this.cea608Parser2,A=this.lastSn,E=this.lastPartIndex;if(!this.enabled||!(m&&p))return;if(C.frag.type===v.PlaylistLevelType.MAIN){var f,d,u=C.frag.sn,a=(f=C==null||((d=C.part)===null||d===void 0)?void 0:d.index)!=null?f:-1;u===A+1||u===A&&a===E+1||(m.reset(),p.reset()),this.lastSn=u,this.lastPartIndex=a}},o.onFragLoaded=function(h,C){var m=C.frag,p=C.payload,A=this.initPTS,E=this.unparsedVttFrags;if(m.type===v.PlaylistLevelType.SUBTITLE)if(p.byteLength){if(!Object(V.isFiniteNumber)(A[m.cc])){E.push(C),A.length&&this.hls.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Missing initial subtitle PTS")});return}var f=m.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var d=this.tracks[m.level],u=this.vttCCs;u[m.cc]||(u[m.cc]={start:m.start,prevCC:this.prevCC,new:!0},this.prevCC=m.cc),d&&d.textCodec===O.IMSC1_CODEC?this._parseIMSC1(m,p):this._parseVTTs(m,p,u)}}else this.hls.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(h,C){var m=this,p=this.hls;Object(O.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(A){m._appendCues(A,h.level),p.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(A){g.logger.log("Failed to parse IMSC1: "+A),p.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:A})})},o._parseVTTs=function(h,C,m){var p=this,A=this.hls;Object(U.parseWebVTT)(C,this.initPTS[h.cc],this.timescale[h.cc],m,h.cc,h.start,function(E){p._appendCues(E,h.level),A.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(E){p._fallbackToIMSC1(h,C),g.logger.log("Failed to parse VTT cue: "+E),A.trigger(M.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:E})})},o._fallbackToIMSC1=function(h,C){var m=this,p=this.tracks[h.level];p.textCodec||Object(O.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(){p.textCodec=O.IMSC1_CODEC,m._parseIMSC1(h,C)},function(){p.textCodec="wvtt"})},o._appendCues=function(h,C){var m=this.hls;if(this.config.renderTextTracksNatively){var p=this.textTracks[C];if(p.mode==="disabled")return;h.forEach(function(f){return Object(I.addCueToTrack)(p,f)})}else{var A=this.tracks[C],E=A.default?"default":"subtitles"+C;m.trigger(M.Events.CUES_PARSED,{type:"subtitles",cues:h,track:E})}},o.onFragDecrypted=function(h,C){var m=C.frag;if(m.type===v.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[m.cc])){this.unparsedVttFrags.push(C);return}this.onFragLoaded(M.Events.FRAG_LOADED,C)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(h,C){var m=this.cea608Parser1,p=this.cea608Parser2;if(!this.enabled||!(m&&p))return;for(var A=0;A<C.samples.length;A++){var E=C.samples[A].bytes;if(E){var f=this.extractCea608Data(E);m.addData(C.samples[A].pts,f[0]),p.addData(C.samples[A].pts,f[1])}}},o.onBufferFlushing=function(h,C){var m=C.startOffset,p=C.endOffset,A=C.endOffsetSubtitles,E=C.type,f=this.media;if(!f||f.currentTime<p)return;if(!E||E==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(a){return Object(I.removeCuesInRange)(d[a],m,p)})}if(this.config.renderTextTracksNatively&&(m===0&&A!==void 0)){var u=this.textTracks;Object.keys(u).forEach(function(a){return Object(I.removeCuesInRange)(u[a],m,A)})}},o.extractCea608Data=function(h){for(var C=h[0]&31,m=2,p=[[],[]],A=0;A<C;A++){var E=h[m++],f=127&h[m++],d=127&h[m++],u=(4&E)!==0,a=3&E;if(f===0&&d===0)continue;u&&((a===0||a===1)&&(p[a].push(f),p[a].push(d)))}return p},l}();function w(l,o){return l&&l.label===o.name&&!(l.textTrack1||l.textTrack2)}function b(l,o,s,h){return Math.min(o,h)-Math.max(l,s)}function x(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function M(j,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=j,this.aesIV=U}var D=M.prototype;return D.decrypt=function(U,I){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},I,U)},M}()},"./src/crypt/aes-decryptor.ts":function(fe,$,_){"use strict";_.r($),_.d($,"removePadding",function(){return M}),_.d($,"default",function(){return D});var V=_("./src/utils/typed-array.ts");function M(j){var U=j.byteLength,I=U&&new DataView(j.buffer).getUint8(U-1);return I?Object(V.sliceUint8)(j,0,U-I):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 U=j.prototype;return U.uint8ArrayToUint32Array_=function(O){for(var v=new DataView(O),g=new Uint32Array(4),R=0;R<4;R++)g[R]=v.getUint32(R*4);return g},U.initTable=function(){var O=this.sBox,v=this.invSBox,g=this.subMix,R=g[0],w=g[1],b=g[2],x=g[3],l=this.invSubMix,o=l[0],s=l[1],h=l[2],C=l[3],m=new Uint32Array(256),p=0,A=0,E=0;for(E=0;E<256;E++)E<128?m[E]=E<<1:m[E]=E<<1^283;for(E=0;E<256;E++){var f=A^A<<1^A<<2^A<<3^A<<4;f=f>>>8^f&255^99,O[p]=f,v[f]=p;var d=m[p],u=m[d],a=m[u],y=m[f]*257^f*16843008;R[p]=y<<24|y>>>8,w[p]=y<<16|y>>>16,b[p]=y<<8|y>>>24,x[p]=y,y=a*16843009^u*65537^d*257^p*16843008,o[f]=y<<24|y>>>8,s[f]=y<<16|y>>>16,h[f]=y<<8|y>>>24,C[f]=y,p?(p=d^m[m[m[a^d]]],A^=m[m[A]]):p=A=1}},U.expandKey=function(O){for(var v=this.uint8ArrayToUint32Array_(O),g=!0,R=0;R<v.length&&g;)g=v[R]===this.key[R],R++;if(g)return;this.key=v;var w=this.keySize=v.length;if(w!==4&&w!==6&&w!==8)throw new Error("Invalid aes key size="+w);var b=this.ksRows=(w+6+1)*4,x,l,o=this.keySchedule=new Uint32Array(b),s=this.invKeySchedule=new Uint32Array(b),h=this.sBox,C=this.rcon,m=this.invSubMix,p=m[0],A=m[1],E=m[2],f=m[3],d,u;for(x=0;x<b;x++){if(x<w){d=o[x]=v[x];continue}u=d,x%w===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=C[x/w|0]<<24):w>6&&x%w===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),o[x]=d=(o[x-w]^u)>>>0}for(l=0;l<b;l++)x=b-l,l&3?u=o[x]:u=o[x-4],l<4||x<=4?s[l]=u:s[l]=p[h[u>>>24]]^A[h[u>>>16&255]]^E[h[u>>>8&255]]^f[h[u&255]],s[l]=s[l]>>>0},U.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},U.decrypt=function(O,v,g){for(var R=this.keySize+6,w=this.invKeySchedule,b=this.invSBox,x=this.invSubMix,l=x[0],o=x[1],s=x[2],h=x[3],C=this.uint8ArrayToUint32Array_(g),m=C[0],p=C[1],A=C[2],E=C[3],f=new Int32Array(O),d=new Int32Array(f.length),u,a,y,c,S,P,G,X,te,z,F,ne,ce,ge,xe=this.networkToHostOrderSwap;v<f.length;){for(te=xe(f[v]),z=xe(f[v+1]),F=xe(f[v+2]),ne=xe(f[v+3]),S=te^w[0],P=ne^w[1],G=F^w[2],X=z^w[3],ce=4,ge=1;ge<R;ge++)u=l[S>>>24]^o[P>>16&255]^s[G>>8&255]^h[X&255]^w[ce],a=l[P>>>24]^o[G>>16&255]^s[X>>8&255]^h[S&255]^w[ce+1],y=l[G>>>24]^o[X>>16&255]^s[S>>8&255]^h[P&255]^w[ce+2],c=l[X>>>24]^o[S>>16&255]^s[P>>8&255]^h[G&255]^w[ce+3],S=u,P=a,G=y,X=c,ce=ce+4;u=b[S>>>24]<<24^b[P>>16&255]<<16^b[G>>8&255]<<8^b[X&255]^w[ce],a=b[P>>>24]<<24^b[G>>16&255]<<16^b[X>>8&255]<<8^b[S&255]^w[ce+1],y=b[G>>>24]<<24^b[X>>16&255]<<16^b[S>>8&255]<<8^b[P&255]^w[ce+2],c=b[X>>>24]<<24^b[S>>16&255]<<16^b[P>>8&255]<<8^b[G&255]^w[ce+3],d[v]=xe(u^m),d[v+1]=xe(c^p),d[v+2]=xe(y^A),d[v+3]=xe(a^E),m=te,p=z,A=F,E=ne,v=v+4}return d.buffer},j}()},"./src/crypt/decrypter.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return v});var V=_("./src/crypt/aes-crypto.ts"),M=_("./src/crypt/fast-aes-key.ts"),D=_("./src/crypt/aes-decryptor.ts"),j=_("./src/utils/logger.ts"),U=_("./src/utils/mp4-tools.ts"),I=_("./src/utils/typed-array.ts"),O=16,v=function(){function g(w,b,x){var l=x===void 0?{}:x,o=l.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=w,this.config=b,this.removePKCS7Padding=s,s)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(C){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=g.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var x=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(x):x},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(b,x,l,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),x,l);var s=this.flush();s&&o(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),x,l).then(o)},R.softwareDecrypt=function(b,x,l){var o=this.currentIV,s=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(b=Object(U.appendUint8Array)(h,b),this.remainderData=null);var C=this.getValidChunk(b);if(!C.length)return null;o&&(l=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new D.default),m.expandKey(x);var p=s;return this.currentResult=m.decrypt(C.buffer,0,l),this.currentIV=Object(I.sliceUint8)(C,-16).buffer,p||null},R.webCryptoDecrypt=function(b,x,l){var o=this,s=this.subtle;return(this.key!==x||!this.fastAesKey)&&(this.key=x,this.fastAesKey=new M.default(s,x)),this.fastAesKey.expandKey().then(function(h){if(!s)return Promise.reject(new Error("web crypto not initialized"));var C=new V.default(s,l);return C.decrypt(b.buffer,h)}).catch(function(h){return o.onWebCryptoError(h,b,x,l)})},R.onWebCryptoError=function(b,x,l,o){return j.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(x,l,o)},R.getValidChunk=function(b){var x=b,l=b.length-b.length%O;return l!==b.length&&(x=Object(I.sliceUint8)(b,0,l),this.remainderData=Object(I.sliceUint8)(b,l)),x},R.logOnce=function(b){if(!this.logEnabled)return;j.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1},g}()},"./src/crypt/fast-aes-key.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function M(j,U){this.subtle=void 0,this.key=void 0,this.subtle=j,this.key=U}var D=M.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},M}()},"./src/demux/aacdemuxer.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/demux/base-audio-demuxer.ts"),M=_("./src/demux/adts.ts"),D=_("./src/utils/logger.ts"),j=_("./src/demux/id3.ts");function U(v,g){v.prototype=Object.create(g.prototype),v.prototype.constructor=v,I(v,g)}function I(v,g){return I=Object.setPrototypeOf||function(w,b){return w.__proto__=b,w},I(v,g)}var O=function(v){U(g,v);function g(w,b){var x;return x=v.call(this)||this,x.observer=void 0,x.config=void 0,x.observer=w,x.config=b,x}var R=g.prototype;return R.resetInitSegment=function(b,x,l){v.prototype.resetInitSegment.call(this,b,x,l),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:l,inputTimeScale:9e4,dropped:0}},g.probe=function(b){if(!b)return!1;for(var x=j.getID3Data(b,0)||[],l=x.length,o=b.length;l<o;l++)if(M.probe(b,l))return D.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(b,x){return M.canParse(b,x)},R.appendFrame=function(b,x,l){M.initTrackConfig(b,this.observer,x,l,b.manifestCodec);var o=M.appendFrame(b,x,l,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},g}(V.default);O.minProbeByteLength=9,$.default=O},"./src/demux/adts.ts":function(fe,$,_){"use strict";_.r($),_.d($,"getAudioConfig",function(){return j}),_.d($,"isHeaderPattern",function(){return U}),_.d($,"getHeaderLength",function(){return I}),_.d($,"getFullFrameLength",function(){return O}),_.d($,"canGetFrameLength",function(){return v}),_.d($,"isHeader",function(){return g}),_.d($,"canParse",function(){return R}),_.d($,"probe",function(){return w}),_.d($,"initTrackConfig",function(){return b}),_.d($,"getFrameDuration",function(){return x}),_.d($,"parseFrameHeader",function(){return l}),_.d($,"appendFrame",function(){return o});var V=_("./src/utils/logger.ts"),M=_("./src/errors.ts"),D=_("./src/events.ts");function j(s,h,C,m){var p,A,E,f,d=navigator.userAgent.toLowerCase(),u=m,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=((h[C+2]&192)>>>6)+1;var y=(h[C+2]&60)>>>2;if(y>a.length-1){s.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+y});return}return E=(h[C+2]&1)<<2,E|=(h[C+3]&192)>>>6,V.logger.log("manifest codec:"+m+", ADTS type:"+p+", samplingIndex:"+y),/firefox/i.test(d)?y>=6?(p=5,f=new Array(4),A=y-3):(p=2,f=new Array(2),A=y):d.indexOf("android")!==-1?(p=2,f=new Array(2),A=y):(p=5,f=new Array(4),m&&(m.indexOf("mp4a.40.29")!==-1||m.indexOf("mp4a.40.5")!==-1)||!m&&y>=6?A=y-3:((m&&m.indexOf("mp4a.40.2")!==-1&&(y>=6&&E===1||/vivaldi/i.test(d))||!m&&E===1)&&(p=2,f=new Array(2)),A=y)),f[0]=p<<3,f[0]|=(y&14)>>1,f[1]|=(y&1)<<7,f[1]|=E<<3,p===5&&(f[1]|=(A&14)>>1,f[2]=(A&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:a[y],channelCount:E,codec:"mp4a.40."+p,manifestCodec:u}}function U(s,h){return s[h]===255&&(s[h+1]&246)===240}function I(s,h){return s[h+1]&1?7:9}function O(s,h){return(s[h+3]&3)<<11|s[h+4]<<3|(s[h+5]&224)>>>5}function v(s,h){return h+5<s.length}function g(s,h){return h+1<s.length&&U(s,h)}function R(s,h){return v(s,h)&&U(s,h)&&O(s,h)<=s.length-h}function w(s,h){if(g(s,h)){var C=I(s,h);if(h+C>=s.length)return!1;var m=O(s,h);if(m<=C)return!1;var p=h+m;return p===s.length||g(s,p)}return!1}function b(s,h,C,m,p){if(!s.samplerate){var A=j(h,C,m,p);if(!A)return;s.config=A.config,s.samplerate=A.samplerate,s.channelCount=A.channelCount,s.codec=A.codec,s.manifestCodec=A.manifestCodec,V.logger.log("parsed codec:"+s.codec+", rate:"+A.samplerate+", channels:"+A.channelCount)}}function x(s){return 1024*9e4/s}function l(s,h,C,m,p){var A=I(s,h),E=O(s,h);if(E-=A,E>0){var f=C+m*p;return{headerLength:A,frameLength:E,stamp:f}}}function o(s,h,C,m,p){var A=x(s.samplerate),E=l(h,C,m,p,A);if(E){var f=E.frameLength,d=E.headerLength,u=E.stamp,a=d+f,y=Math.max(0,C+a-h.length),c;y?(c=new Uint8Array(a-d),c.set(h.subarray(C+d,h.length),0)):c=h.subarray(C+d,C+a);var S={unit:c,pts:u};return y||s.samples.push(S),{sample:S,length:a,missing:y}}}},"./src/demux/base-audio-demuxer.ts":function(fe,$,_){"use strict";_.r($),_.d($,"initPTSFn",function(){return O});var V=_("./src/polyfills/number.ts"),M=_("./src/demux/id3.ts"),D=_("./src/demux/dummy-demuxed-track.ts"),j=_("./src/utils/mp4-tools.ts"),U=_("./src/utils/typed-array.ts"),I=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var g=v.prototype;return g.resetInitSegment=function(w,b,x){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},g.resetTimeStamp=function(){},g.resetContiguity=function(){},g.canParse=function(w,b){return!1},g.appendFrame=function(w,b,x){},g.demux=function(w,b){this.cachedData&&(w=Object(j.appendUint8Array)(this.cachedData,w),this.cachedData=null);var x=M.getID3Data(w,0),l=x?x.length:0,o,s,h=this._audioTrack,C=this._id3Track,m=x?M.getTimeStamp(x):void 0,p=w.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(m,b)),x&&x.length>0&&C.samples.push({pts:this.initPTS,dts:this.initPTS,data:x}),s=this.initPTS;l<p;){if(this.canParse(w,l)){var A=this.appendFrame(h,w,l);A?(this.frameIndex++,s=A.sample.pts,l+=A.length,o=l):l=p}else M.canParse(w,l)?(x=M.getID3Data(w,l),C.samples.push({pts:s,dts:s,data:x}),l+=x.length,o=l):l++;if(l===p&&o!==p){var E=Object(U.sliceUint8)(w,o);this.cachedData?this.cachedData=Object(j.appendUint8Array)(this.cachedData,E):this.cachedData=E}}return{audioTrack:h,avcTrack:Object(D.dummyTrack)(),id3Track:C,textTrack:Object(D.dummyTrack)()}},g.demuxSampleAes=function(w,b,x){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},g.flush=function(w){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(D.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(D.dummyTrack)()}},g.destroy=function(){},v}(),O=function(g,R){return Object(V.isFiniteNumber)(g)?g*90:R*9e4};$.default=I},"./src/demux/chunk-cache.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function D(){this.chunks=[],this.dataLength=0}var j=D.prototype;return j.push=function(I){this.chunks.push(I),this.dataLength+=I.length},j.flush=function(){var I=this.chunks,O=this.dataLength,v;if(I.length)I.length===1?v=I[0]:v=M(I,O);else return new Uint8Array(0);return this.reset(),v},j.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function M(D,j){for(var U=new Uint8Array(j),I=0,O=0;O<D.length;O++){var v=D[O];U.set(v,I),I+=v.length}return U}},"./src/demux/dummy-demuxed-track.ts":function(fe,$,_){"use strict";_.r($),_.d($,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/utils/logger.ts"),M=function(){function D(U){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=U,this.bytesAvailable=U.byteLength,this.word=0,this.bitsAvailable=0}var j=D.prototype;return j.loadWord=function(){var I=this.data,O=this.bytesAvailable,v=I.byteLength-O,g=new Uint8Array(4),R=Math.min(4,O);if(R===0)throw new Error("no bytes available");g.set(I.subarray(v,v+R)),this.word=new DataView(g.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},j.skipBits=function(I){var O;this.bitsAvailable>I?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,O=I>>3,I-=O>>3,this.bytesAvailable-=O,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},j.readBits=function(I){var O=Math.min(this.bitsAvailable,I),v=this.word>>>32-O;return I>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=I-O,O>0&&this.bitsAvailable?v<<O|this.readBits(O):v},j.skipLZ=function(){var I;for(I=0;I<this.bitsAvailable;++I)if((this.word&2147483648>>>I)!==0)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},j.skipUEG=function(){this.skipBits(1+this.skipLZ())},j.skipEG=function(){this.skipBits(1+this.skipLZ())},j.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},j.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>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(I){for(var O=8,v=8,g,R=0;R<I;R++)v!==0&&(g=this.readEG(),v=(O+g+256)%256),O=v===0?O:v},j.readSPS=function(){var I=0,O=0,v=0,g=0,R,w,b,x=this.readUByte.bind(this),l=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),h=this.skipBits.bind(this),C=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);x();var A=x();if(l(5),h(3),x(),m(),A===100||A===110||A===122||A===244||A===44||A===83||A===86||A===118||A===128){var E=o();if(E===3&&h(1),m(),m(),h(1),s())for(w=E!==3?8:12,b=0;b<w;b++)s()&&(b<6?p(16):p(64))}m();var f=o();if(f===0)o();else if(f===1)for(h(1),C(),C(),R=o(),b=0;b<R;b++)C();m(),h(1);var d=o(),u=o(),a=l(1);a===0&&h(1),h(1),s()&&(I=o(),O=o(),v=o(),g=o());var y=[1,1];if(s()&&s()){var c=x();switch(c){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=[x()<<8|x(),x()<<8|x()];break}}}return{width:Math.ceil((d+1)*16-I*2-O*2),height:(2-a)*(u+1)*16-(a?2:4)*(v+g),pixelRatio:y}},j.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();$.default=M},"./src/demux/id3.ts":function(fe,$,_){"use strict";_.r($),_.d($,"isHeader",function(){return V}),_.d($,"isFooter",function(){return M}),_.d($,"getID3Data",function(){return D}),_.d($,"canParse",function(){return U}),_.d($,"getTimeStamp",function(){return I}),_.d($,"isTimeStampFrame",function(){return O}),_.d($,"getID3Frames",function(){return g}),_.d($,"decodeFrame",function(){return R}),_.d($,"utf8ArrayToStr",function(){return o}),_.d($,"testables",function(){return s});var V=function(p,A){return A+10<=p.length&&(p[A]===73&&p[A+1]===68&&p[A+2]===51&&(p[A+3]<255&&p[A+4]<255&&(p[A+6]<128&&p[A+7]<128&&p[A+8]<128&&p[A+9]<128)))},M=function(p,A){return A+10<=p.length&&(p[A]===51&&p[A+1]===68&&p[A+2]===73&&(p[A+3]<255&&p[A+4]<255&&(p[A+6]<128&&p[A+7]<128&&p[A+8]<128&&p[A+9]<128)))},D=function(p,A){for(var E=A,f=0;V(p,A);){f+=10;var d=j(p,A+6);f+=d,M(p,A+10)&&(f+=10),A+=f}return f>0?p.subarray(E,E+f):void 0},j=function(p,A){var E=0;return E=(p[A]&127)<<21,E|=(p[A+1]&127)<<14,E|=(p[A+2]&127)<<7,E|=p[A+3]&127,E},U=function(p,A){return V(p,A)&&j(p,A+6)+10<=p.length-A},I=function(p){for(var A=g(p),E=0;E<A.length;E++){var f=A[E];if(O(f))return l(f)}return},O=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},v=function(p){var A=String.fromCharCode(p[0],p[1],p[2],p[3]),E=j(p,4),f=10;return{type:A,size:E,data:p.subarray(f,f+E)}},g=function(p){for(var A=0,E=[];V(p,A);){var f=j(p,A+6);A+=10;for(var d=A+f;A+8<d;){var u=v(p.subarray(A)),a=R(u);a&&E.push(a),A+=u.size+10}M(p,A)&&(A+=10)}return E},R=function(p){return p.type==="PRIV"?w(p):p.type[0]==="W"?x(p):b(p)},w=function(p){if(p.size<2)return;var A=o(p.data,!0),E=new Uint8Array(p.data.subarray(A.length+1));return{key:p.type,info:A,data:E.buffer}},b=function(p){if(p.size<2)return;if(p.type==="TXXX"){var A=1,E=o(p.data.subarray(A),!0);A+=E.length+1;var f=o(p.data.subarray(A));return{key:p.type,info:E,data:f}}var d=o(p.data.subarray(1));return{key:p.type,data:d}},x=function(p){if(p.type==="WXXX"){if(p.size<2)return;var A=1,E=o(p.data.subarray(A),!0);A+=E.length+1;var f=o(p.data.subarray(A));return{key:p.type,info:E,data:f}}var d=o(p.data);return{key:p.type,data:d}},l=function(p){if(p.data.byteLength===8){var A=new Uint8Array(p.data),E=A[3]&1,f=(A[4]<<23)+(A[5]<<15)+(A[6]<<7)+A[7];return f/=45,E&&(f+=4772185884e-2),Math.round(f)}return},o=function(p,A){A===void 0&&(A=!1);var E=C();if(E){var f=E.decode(p);if(A){var d=f.indexOf("\0");return d!==-1?f.substring(0,d):f}return f.replace(/\0/g,"")}for(var u=p.length,a,y,c,S="",P=0;P<u;){if(a=p[P++],a===0&&A)return S;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:S+=String.fromCharCode(a);break;case 12:case 13:y=p[P++],S+=String.fromCharCode((a&31)<<6|y&63);break;case 14:y=p[P++],c=p[P++],S+=String.fromCharCode((a&15)<<12|(y&63)<<6|(c&63)<<0);break;default:}}return S},s={decodeTextFrame:b},h;function C(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/demux/base-audio-demuxer.ts"),M=_("./src/demux/id3.ts"),D=_("./src/utils/logger.ts"),j=_("./src/demux/mpegaudio.ts");function U(v,g){v.prototype=Object.create(g.prototype),v.prototype.constructor=v,I(v,g)}function I(v,g){return I=Object.setPrototypeOf||function(w,b){return w.__proto__=b,w},I(v,g)}var O=function(v){U(g,v);function g(){return v.apply(this,arguments)||this}var R=g.prototype;return R.resetInitSegment=function(b,x,l){v.prototype.resetInitSegment.call(this,b,x,l),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:l,inputTimeScale:9e4,dropped:0}},g.probe=function(b){if(!b)return!1;for(var x=M.getID3Data(b,0)||[],l=x.length,o=b.length;l<o;l++)if(j.probe(b,l))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(b,x){return j.canParse(b,x)},R.appendFrame=function(b,x,l){return this.initPTS===null?void 0:j.appendFrame(b,x,l,this.initPTS,this.frameIndex)},g}(V.default);O.minProbeByteLength=4,$.default=O},"./src/demux/mp4demuxer.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/utils/mp4-tools.ts"),M=_("./src/demux/dummy-demuxed-track.ts"),D=function(){function j(I,O){this.remainderData=null,this.config=void 0,this.config=O}var U=j.prototype;return U.resetTimeStamp=function(){},U.resetInitSegment=function(){},U.resetContiguity=function(){},j.probe=function(O){return Object(V.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},U.demux=function(O){var v=O,g=Object(M.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(V.appendUint8Array)(this.remainderData,O));var R=Object(V.segmentValidRange)(v);this.remainderData=R.remainder,g.samples=R.valid||new Uint8Array}else g.samples=v;return{audioTrack:Object(M.dummyTrack)(),avcTrack:g,id3Track:Object(M.dummyTrack)(),textTrack:Object(M.dummyTrack)()}},U.flush=function(){var O=Object(M.dummyTrack)();return O.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(M.dummyTrack)(),avcTrack:O,id3Track:Object(M.dummyTrack)(),textTrack:Object(M.dummyTrack)()}},U.demuxSampleAes=function(O,v,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},U.destroy=function(){},j}();D.minProbeByteLength=1024,$.default=D},"./src/demux/mpegaudio.ts":function(fe,$,_){"use strict";_.r($),_.d($,"appendFrame",function(){return I}),_.d($,"parseHeader",function(){return O}),_.d($,"isHeaderPattern",function(){return v}),_.d($,"isHeader",function(){return g}),_.d($,"canParse",function(){return R}),_.d($,"probe",function(){return w});var V=null,M=[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]],U=[0,1,1,4];function I(b,x,l,o,s){if(l+24>x.length)return;var h=O(x,l);if(h&&l+h.frameLength<=x.length){var C=h.samplesPerFrame*9e4/h.sampleRate,m=o+s*C,p={unit:x.subarray(l,l+h.frameLength),pts:m,dts:m};return b.config=[],b.channelCount=h.channelCount,b.samplerate=h.sampleRate,b.samples.push(p),{sample:p,length:h.frameLength,missing:0}}}function O(b,x){var l=b[x+1]>>3&3,o=b[x+1]>>1&3,s=b[x+2]>>4&15,h=b[x+2]>>2&3;if(l!==1&&s!==0&&s!==15&&h!==3){var C=b[x+2]>>1&1,m=b[x+3]>>6,p=l===3?3-o:o===3?3:4,A=M[p*14+s-1]*1e3,E=l===3?0:l===2?1:2,f=D[E*3+h],d=m===3?1:2,u=j[l][o],a=U[o],y=u*8*a,c=Math.floor(u*A/f+C)*a;if(V===null){var S=navigator.userAgent||"",P=S.match(/Chrome\/(\d+)/i);V=P?parseInt(P[1]):0}var G=!!V&&V<=87;return G&&o===2&&A>=224e3&&m===0&&(b[x+3]=b[x+3]|128),{sampleRate:f,channelCount:d,frameLength:c,samplesPerFrame:y}}}function v(b,x){return b[x]===255&&(b[x+1]&224)===224&&(b[x+1]&6)!==0}function g(b,x){return x+1<b.length&&v(b,x)}function R(b,x){var l=4;return v(b,x)&&l<=b.length-x}function w(b,x){if(x+1<b.length&&v(b,x)){var l=4,o=O(b,x),s=l;o!=null&&o.frameLength&&(s=o.frameLength);var h=x+s;return h===b.length||g(b,h)}return!1}},"./src/demux/sample-aes.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/crypt/decrypter.ts"),M=_("./src/demux/tsdemuxer.ts"),D=function(){function j(I,O,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new V.default(I,O,{removePKCS7Padding:!1})}var U=j.prototype;return U.decryptBuffer=function(O,v){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,v)},U.decryptAacSample=function(O,v,g,R){var w=O[v].unit,b=w.subarray(16,w.length-w.length%16),x=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),l=this;this.decryptBuffer(x,function(o){var s=new Uint8Array(o);w.set(s,16),R||l.decryptAacSamples(O,v+1,g)})},U.decryptAacSamples=function(O,v,g){for(;;v++){if(v>=O.length){g();return}if(O[v].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(O,v,g,R),!R)return}},U.getAvcEncryptedData=function(O){for(var v=Math.floor((O.length-48)/160)*16+16,g=new Int8Array(v),R=0,w=32;w<=O.length-16;w+=160,R+=16)g.set(O.subarray(w,w+16),R);return g},U.getAvcDecryptedUnit=function(O,v){for(var g=new Uint8Array(v),R=0,w=32;w<=O.length-16;w+=160,R+=16)O.set(g.subarray(R,R+16),w);return O},U.decryptAvcSample=function(O,v,g,R,w,b){var x=Object(M.discardEPB)(w.data),l=this.getAvcEncryptedData(x),o=this;this.decryptBuffer(l.buffer,function(s){w.data=o.getAvcDecryptedUnit(x,s),b||o.decryptAvcSamples(O,v,g+1,R)})},U.decryptAvcSamples=function(O,v,g,R){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,g=0){if(v>=O.length){R();return}for(var w=O[v].units;!(g>=w.length);g++){var b=w[g];if(b.data.length<=48||b.type!==1&&b.type!==5)continue;var x=this.decrypter.isSync();if(this.decryptAvcSample(O,v,g,R,b,x),!x)return}}},j}();$.default=D},"./src/demux/transmuxer-interface.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return w});var V=_("./node_modules/webworkify-webpack/index.js"),M=_.n(V),D=_("./src/events.ts"),j=_("./src/demux/transmuxer.ts"),U=_("./src/utils/logger.ts"),I=_("./src/errors.ts"),O=_("./src/utils/mediasource-helper.ts"),v=_("./node_modules/eventemitter3/index.js"),g=_.n(v),R=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},w=function(){function b(l,o,s,h){var C=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=l,this.id=o,this.onTransmuxComplete=s,this.onFlush=h;var m=l.config,p=function(u,a){a=a||{},a.frag=C.frag,a.id=C.id,l.trigger(u,a)};this.observer=new v.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,p),this.observer.on(D.Events.ERROR,p);var A={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},E=navigator.vendor;if(m.enableWorker&&typeof Worker!="undefined"){U.logger.log("demuxing in webworker");var f;try{f=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(d){l.trigger(D.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(d.message+" ("+d.filename+":"+d.lineno+")")})},f.postMessage({cmd:"init",typeSupported:A,vendor:E,id:o,config:JSON.stringify(m)})}catch(d){U.logger.warn("Error in worker:",d),U.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new j.default(this.observer,A,m,E,o),this.worker=null}}else this.transmuxer=new j.default(this.observer,A,m,E,o)}var x=b.prototype;return x.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 h=this.observer;h&&h.removeAllListeners(),this.observer=null},x.push=function(o,s,h,C,m,p,A,E,f,d){var u=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,y=this.worker,c=p?p.start:m.start,S=m.decryptdata,P=this.frag,G=!(P&&m.cc===P.cc),X=!(P&&f.level===P.level),te=P?f.sn-P.sn:-1,z=this.part?f.part-this.part.index:1,F=!X&&(te===1||te===0&&z===1),ne=self.performance.now();(X||te||m.stats.parsing.start===0)&&(m.stats.parsing.start=ne),p&&(z||!F)&&(p.stats.parsing.start=ne);var ce=new j.TransmuxState(G,F,E,X,c);if(!F||G){U.logger.log("[transmuxer-interface, "+m.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
discontinuity: `+G+`
trackSwitch: `+X+`
contiguous: `+F+`
accurateTimeOffset: `+E+`
timeOffset: `+c);var ge=new j.TransmuxConfig(h,C,s,A,d);this.configureTransmuxer(ge)}if(this.frag=m,this.part=p,y)y.postMessage({cmd:"demux",data:o,decryptdata:S,chunkMeta:f,state:ce},o instanceof ArrayBuffer?[o]:[]);else if(a){var xe=a.push(o,S,f,ce);Object(j.isPromise)(xe)?xe.then(function(Ie){u.handleTransmuxComplete(Ie)}):this.handleTransmuxComplete(xe)}},x.flush=function(o){var s=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,C=this.worker;if(C)C.postMessage({cmd:"flush",chunkMeta:o});else if(h){var m=h.flush(o);Object(j.isPromise)(m)?m.then(function(p){s.handleFlushResult(p,o)}):this.handleFlushResult(m,o)}},x.handleFlushResult=function(o,s){var h=this;o.forEach(function(C){h.handleTransmuxComplete(C)}),this.onFlush(s)},x.onWorkerMessage=function(o){var s=o.data,h=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,h.trigger(s.event,s.data);break}}},x.configureTransmuxer=function(o){var s=this.worker,h=this.transmuxer;s?s.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},x.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},b}()},"./src/demux/transmuxer-worker.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return I});var V=_("./src/demux/transmuxer.ts"),M=_("./src/events.ts"),D=_("./src/utils/logger.ts"),j=_("./node_modules/eventemitter3/index.js"),U=_.n(j);function I(w){var b=new j.EventEmitter,x=function(o,s){w.postMessage({event:o,data:s})};b.on(M.Events.FRAG_DECRYPTED,x),b.on(M.Events.ERROR,x),w.addEventListener("message",function(l){var o=l.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);w.transmuxer=new V.default(b,o.typeSupported,s,o.vendor,o.id),Object(D.enableLogs)(s.debug),x("init",null);break}case"configure":{w.transmuxer.configure(o.config);break}case"demux":{var h=w.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(V.isPromise)(h)?h.then(function(p){O(w,p)}):O(w,h);break}case"flush":{var C=o.chunkMeta,m=w.transmuxer.flush(C);Object(V.isPromise)(m)?m.then(function(p){g(w,p,C)}):g(w,m,C);break}default:break}})}function O(w,b){if(R(b.remuxResult))return;var x=[],l=b.remuxResult,o=l.audio,s=l.video;o&&v(x,o),s&&v(x,s),w.postMessage({event:"transmuxComplete",data:b},x)}function v(w,b){b.data1&&w.push(b.data1.buffer),b.data2&&w.push(b.data2.buffer)}function g(w,b,x){b.forEach(function(l){O(w,l)}),w.postMessage({event:"flush",data:x})}function R(w){return!w.audio&&!w.video&&!w.text&&!w.id3&&!w.initSegment}},"./src/demux/transmuxer.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return s}),_.d($,"isPromise",function(){return m}),_.d($,"TransmuxConfig",function(){return p}),_.d($,"TransmuxState",function(){return A});var V=_("./src/events.ts"),M=_("./src/errors.ts"),D=_("./src/crypt/decrypter.ts"),j=_("./src/demux/aacdemuxer.ts"),U=_("./src/demux/mp4demuxer.ts"),I=_("./src/demux/tsdemuxer.ts"),O=_("./src/demux/mp3demuxer.ts"),v=_("./src/remux/mp4-remuxer.ts"),g=_("./src/remux/passthrough-remuxer.ts"),R=_("./src/demux/chunk-cache.ts"),w=_("./src/utils/mp4-tools.ts"),b=_("./src/utils/logger.ts"),x;try{x=self.performance.now.bind(self.performance)}catch(E){b.logger.debug("Unable to use Performance API on this environment"),x=self.Date.now}var l=[{demux:I.default,remux:v.default},{demux:U.default,remux:g.default},{demux:j.default,remux:v.default},{demux:O.default,remux:v.default}],o=1024;l.forEach(function(E){var f=E.demux;o=Math.max(o,f.minProbeByteLength)});var s=function(){function E(d,u,a,y,c){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=d,this.typeSupported=u,this.config=a,this.vendor=y,this.id=c}var f=E.prototype;return f.configure=function(u){this.transmuxConfig=u,this.decrypter&&this.decrypter.reset()},f.push=function(u,a,y,c){var S=this,P=y.transmuxing;P.executeStart=x();var G=new Uint8Array(u),X=this.cache,te=this.config,z=this.currentTransmuxState,F=this.transmuxConfig;c&&(this.currentTransmuxState=c);var ne=h(G,a);if(ne&&ne.method==="AES-128"){var ce=this.getDecrypter();if(te.enableSoftwareAES){var ge=ce.softwareDecrypt(G,ne.key.buffer,ne.iv.buffer);if(!ge)return P.executeEnd=x(),C(y);G=new Uint8Array(ge)}else return this.decryptionPromise=ce.webCryptoDecrypt(G,ne.key.buffer,ne.iv.buffer).then(function(be){var we=S.push(be,null,y);return S.decryptionPromise=null,we}),this.decryptionPromise}var xe=c||z,Ie=xe.contiguous,Te=xe.discontinuity,Oe=xe.trackSwitch,Ce=xe.accurateTimeOffset,Ae=xe.timeOffset,ve=F.audioCodec,W=F.videoCodec,L=F.defaultInitPts,k=F.duration,H=F.initSegmentData;if((Te||Oe)&&this.resetInitSegment(H,ve,W,k),Te&&this.resetInitialTimestamp(L),Ie||this.resetContiguity(),this.needsProbing(G,Te,Oe)){if(X.dataLength){var q=X.flush();G=Object(w.appendUint8Array)(q,G)}this.configureTransmuxer(G,F)}var B=this.transmux(G,ne,Ae,Ce,y),ue=this.currentTransmuxState;return ue.contiguous=!0,ue.discontinuity=!1,ue.trackSwitch=!1,P.executeEnd=x(),B},f.flush=function(u){var a=this,y=u.transmuxing;y.executeStart=x();var c=this.decrypter,S=this.cache,P=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(u)});var X=[],te=P.timeOffset;if(c){var z=c.flush();z&&X.push(this.push(z,null,u))}var F=S.dataLength;S.reset();var ne=this.demuxer,ce=this.remuxer;if(!ne||!ce)return F>=o&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),y.executeEnd=x(),[C(u)];var ge=ne.flush(te);return m(ge)?ge.then(function(xe){return a.flushRemux(X,xe,u),X}):(this.flushRemux(X,ge,u),X)},f.flushRemux=function(u,a,y){var c=a.audioTrack,S=a.avcTrack,P=a.id3Track,G=a.textTrack,X=this.currentTransmuxState,te=X.accurateTimeOffset,z=X.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+y.sn+(y.part>-1?" p: "+y.part:"")+" of level "+y.level);var F=this.remuxer.remux(c,S,P,G,z,te,!0,this.id);u.push({remuxResult:F,chunkMeta:y}),y.transmuxing.executeEnd=x()},f.resetInitialTimestamp=function(u){var a=this.demuxer,y=this.remuxer;if(!a||!y)return;a.resetTimeStamp(u),y.resetTimeStamp(u)},f.resetContiguity=function(){var u=this.demuxer,a=this.remuxer;if(!u||!a)return;u.resetContiguity(),a.resetNextTimestamp()},f.resetInitSegment=function(u,a,y,c){var S=this.demuxer,P=this.remuxer;if(!S||!P)return;S.resetInitSegment(a,y,c),P.resetInitSegment(u,a,y)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(u,a,y,c,S){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(u,a,y,c,S):P=this.transmuxUnencrypted(u,y,c,S),P},f.transmuxUnencrypted=function(u,a,y,c){var S=this.demuxer.demux(u,a,!1,!this.config.progressive),P=S.audioTrack,G=S.avcTrack,X=S.id3Track,te=S.textTrack,z=this.remuxer.remux(P,G,X,te,a,y,!1,this.id);return{remuxResult:z,chunkMeta:c}},f.transmuxSampleAes=function(u,a,y,c,S){var P=this;return this.demuxer.demuxSampleAes(u,a,y).then(function(G){var X=P.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,y,c,!1,P.id);return{remuxResult:X,chunkMeta:S}})},f.configureTransmuxer=function(u,a){for(var y=this.config,c=this.observer,S=this.typeSupported,P=this.vendor,G=a.audioCodec,X=a.defaultInitPts,te=a.duration,z=a.initSegmentData,F=a.videoCodec,ne,ce=0,ge=l.length;ce<ge;ce++)if(l[ce].demux.probe(u)){ne=l[ce];break}ne||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ne={demux:U.default,remux:g.default});var xe=this.demuxer,Ie=this.remuxer,Te=ne.remux,Oe=ne.demux;(!Ie||!(Ie instanceof Te))&&(this.remuxer=new Te(c,y,S,P)),(!xe||!(xe instanceof Oe))&&(this.demuxer=new Oe(c,y,S),this.probe=Oe.probe),this.resetInitSegment(z,G,F,te),this.resetInitialTimestamp(X)},f.needsProbing=function(u,a,y){return!this.demuxer||!this.remuxer||a||y},f.getDecrypter=function(){var u=this.decrypter;return u||(u=this.decrypter=new D.default(this.observer,this.config)),u},E}();function h(E,f){var d=null;return E.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(d=f),d}var C=function(f){return{remuxResult:{},chunkMeta:f}};function m(E){return"then"in E&&E.then instanceof Function}var p=function(f,d,u,a,y){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=d,this.initSegmentData=u,this.duration=a,this.defaultInitPts=y},A=function(f,d,u,a,y){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=d,this.accurateTimeOffset=u,this.trackSwitch=a,this.timeOffset=y}},"./src/demux/tsdemuxer.ts":function(fe,$,_){"use strict";_.r($),_.d($,"discardEPB",function(){return C});var V=_("./src/demux/adts.ts"),M=_("./src/demux/mpegaudio.ts"),D=_("./src/demux/exp-golomb.ts"),j=_("./src/demux/id3.ts"),U=_("./src/demux/sample-aes.ts"),I=_("./src/events.ts"),O=_("./src/utils/mp4-tools.ts"),v=_("./src/utils/logger.ts"),g=_("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},w=function(){function m(A,E,f){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=A,this.config=E,this.typeSupported=f}m.probe=function(E){var f=m.syncOffset(E);return f<0?!1:(f&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},m.syncOffset=function(E){for(var f=Math.min(1e3,E.length-3*188),d=0;d<f;){if(E[d]===71&&E[d+188]===71&&E[d+2*188]===71)return d;d++}return-1},m.createTrack=function(E,f){return{container:E==="video"||E==="audio"?"video/mp2t":void 0,type:E,id:R[E],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:E==="audio"?f:void 0}};var p=m.prototype;return p.resetInitSegment=function(E,f,d){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=m.createTrack("video",d),this._audioTrack=m.createTrack("audio",d),this._id3Track=m.createTrack("id3",d),this._txtTrack=m.createTrack("text",d),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=E,this.videoCodec=f,this._duration=d},p.resetTimeStamp=function(){},p.resetContiguity=function(){var E=this._audioTrack,f=this._avcTrack,d=this._id3Track;E&&(E.pesData=null),f&&(f.pesData=null),d&&(d.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},p.demux=function(E,f,d,u){d===void 0&&(d=!1),u===void 0&&(u=!1),d||(this.sampleAes=null);var a,y=this._avcTrack,c=this._audioTrack,S=this._id3Track,P=y.pid,G=y.pesData,X=c.pid,te=S.pid,z=c.pesData,F=S.pesData,ne=!1,ce=this.pmtParsed,ge=this._pmtId,xe=E.length;if(this.remainderData&&(E=Object(O.appendUint8Array)(this.remainderData,E),xe=E.length,this.remainderData=null),xe<188&&!u)return this.remainderData=E,{audioTrack:c,avcTrack:y,id3Track:S,textTrack:this._txtTrack};var Ie=Math.max(0,m.syncOffset(E));xe-=(xe+Ie)%188,xe<E.byteLength&&!u&&(this.remainderData=new Uint8Array(E.buffer,xe,E.buffer.byteLength-xe));for(var Te=Ie;Te<xe;Te+=188)if(E[Te]===71){var Oe=!!(E[Te+1]&64),Ce=((E[Te+1]&31)<<8)+E[Te+2],Ae=(E[Te+3]&48)>>4,ve=void 0;if(Ae>1){if(ve=Te+5+E[Te+4],ve===Te+188)continue}else ve=Te+4;switch(Ce){case P:Oe&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(E.subarray(ve,Te+188)),G.size+=Te+188-ve);break;case X:Oe&&(z&&(a=o(z))&&(c.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(E.subarray(ve,Te+188)),z.size+=Te+188-ve);break;case te:Oe&&(F&&(a=o(F))&&this.parseID3PES(a),F={data:[],size:0}),F&&(F.data.push(E.subarray(ve,Te+188)),F.size+=Te+188-ve);break;case 0:Oe&&(ve+=E[ve]+1),ge=this._pmtId=x(E,ve);break;case ge:{Oe&&(ve+=E[ve]+1);var W=l(E,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,d);P=W.avc,P>0&&(y.pid=P),X=W.audio,X>0&&(c.pid=X,c.isAAC=W.isAAC),te=W.id3,te>0&&(S.pid=te),ne&&!ce&&(v.logger.log("reparse from beginning"),ne=!1,Te=Ie-188),ce=this.pmtParsed=!0;break}case 17:case 8191:break;default:ne=!0;break}}else this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:g.ErrorTypes.MEDIA_ERROR,details:g.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});y.pesData=G,c.pesData=z,S.pesData=F;var L={audioTrack:c,avcTrack:y,id3Track:S,textTrack:this._txtTrack};return u&&this.extractRemainingSamples(L),L},p.flush=function(){var E=this.remainderData;this.remainderData=null;var f;return E?f=this.demux(E,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},p.extractRemainingSamples=function(E){var f=E.audioTrack,d=E.avcTrack,u=E.id3Track,a=d.pesData,y=f.pesData,c=u.pesData,S;a&&(S=o(a))?(this.parseAVCPES(S,!0),d.pesData=null):d.pesData=a,y&&(S=o(y))?(f.isAAC?this.parseAACPES(S):this.parseMPEGPES(S),f.pesData=null):(y!=null&&y.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=y),c&&(S=o(c))?(this.parseID3PES(S),u.pesData=null):u.pesData=c},p.demuxSampleAes=function(E,f,d){var u=this.demux(E,d,!0,!this.config.progressive),a=this.sampleAes=new U.default(this.observer,this.config,f);return this.decrypt(u,a)},p.decrypt=function(E,f){return new Promise(function(d){var u=E.audioTrack,a=E.avcTrack;u.samples&&u.isAAC?f.decryptAacSamples(u.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){d(E)}):d(E)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){d(E)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(E,f){var d=this,u=this._avcTrack,a=this.parseAVCNALu(E.data),y=!1,c=this.avcSample,S,P=!1;E.data=null,c&&a.length&&!u.audFound&&(s(c,u),c=this.avcSample=b(!1,E.pts,E.dts,"")),a.forEach(function(G){switch(G.type){case 1:{S=!0,c||(c=d.avcSample=b(!0,E.pts,E.dts,"")),y&&(c.debug+="NDR "),c.frame=!0;var X=G.data;if(P&&X.length>4){var te=new D.default(X).readSliceType();(te===2||te===4||te===7||te===9)&&(c.key=!0)}break}case 5:S=!0,c||(c=d.avcSample=b(!0,E.pts,E.dts,"")),y&&(c.debug+="IDR "),c.key=!0,c.frame=!0;break;case 6:{S=!0,y&&c&&(c.debug+="SEI ");var z=new D.default(C(G.data));z.readUByte();for(var F=0,ne=0,ce=!1,ge=0;!ce&&z.bytesAvailable>1;){F=0;do ge=z.readUByte(),F+=ge;while(ge===255);ne=0;do ge=z.readUByte(),ne+=ge;while(ge===255);if(F===4&&z.bytesAvailable!==0){ce=!0;var xe=z.readUByte();if(xe===181){var Ie=z.readUShort();if(Ie===49){var Te=z.readUInt();if(Te===1195456820){var Oe=z.readUByte();if(Oe===3){for(var Ce=z.readUByte(),Ae=z.readUByte(),ve=31&Ce,W=[Ce,Ae],L=0;L<ve;L++)W.push(z.readUByte()),W.push(z.readUByte()),W.push(z.readUByte());h(d._txtTrack.samples,{type:3,pts:E.pts,bytes:W})}}}}}else if(F===5&&z.bytesAvailable!==0){if(ce=!0,ne>16){for(var k=[],H=0;H<16;H++)k.push(z.readUByte().toString(16)),(H===3||H===5||H===7||H===9)&&k.push("-");for(var q=ne-16,B=new Uint8Array(q),ue=0;ue<q;ue++)B[ue]=z.readUByte();h(d._txtTrack.samples,{pts:E.pts,payloadType:F,uuid:k.join(""),userData:Object(j.utf8ArrayToStr)(B),userDataBytes:B})}}else if(ne<z.bytesAvailable)for(var be=0;be<ne;be++)z.readUByte()}break}case 7:if(S=!0,P=!0,y&&c&&(c.debug+="SPS "),!u.sps){var we=new D.default(G.data),Pe=we.readSPS();u.width=Pe.width,u.height=Pe.height,u.pixelRatio=Pe.pixelRatio,u.sps=[G.data],u.duration=d._duration;for(var _e=G.data.subarray(1,4),De="avc1.",Me=0;Me<3;Me++){var We=_e[Me].toString(16);We.length<2&&(We="0"+We),De+=We}u.codec=De}break;case 8:S=!0,y&&c&&(c.debug+="PPS "),u.pps||(u.pps=[G.data]);break;case 9:S=!1,u.audFound=!0,c&&s(c,u),c=d.avcSample=b(!1,E.pts,E.dts,y?"AUD ":"");break;case 12:S=!1;break;default:S=!1,c&&(c.debug+="unknown NAL "+G.type+" ");break}if(c&&S){var ze=c.units;ze.push(G)}}),f&&c&&(s(c,u),this.avcSample=null)},p.getLastNalUnit=function(){var E,f=this.avcSample,d;if(!f||f.units.length===0){var u=this._avcTrack.samples;f=u[u.length-1]}if((E=f)!==null&&E!==void 0&&E.units){var a=f.units;d=a[a.length-1]}return d},p.parseAVCNALu=function(E){var f=E.byteLength,d=this._avcTrack,u=d.naluState||0,a=u,y=[],c=0,S,P,G,X=-1,te=0;for(u===-1&&(X=0,te=E[0]&31,u=0,c=1);c<f;){if(S=E[c++],!u){u=S?0:1;continue}if(u===1){u=S?0:2;continue}if(!S)u=3;else if(S===1){if(X>=0){var z={data:E.subarray(X,c-u-1),type:te};y.push(z)}else{var F=this.getLastNalUnit();if(F&&(a&&c<=4-a&&(F.state&&(F.data=F.data.subarray(0,F.data.byteLength-a))),P=c-u-1,P>0)){var ne=new Uint8Array(F.data.byteLength+P);ne.set(F.data,0),ne.set(E.subarray(0,P),F.data.byteLength),F.data=ne,F.state=0}}c<f?(G=E[c]&31,X=c,te=G,u=0):u=-1}else u=0}if(X>=0&&u>=0){var ce={data:E.subarray(X,f),type:te,state:u};y.push(ce)}if(y.length===0){var ge=this.getLastNalUnit();if(ge){var xe=new Uint8Array(ge.data.byteLength+E.byteLength);xe.set(ge.data,0),xe.set(E,ge.data.byteLength),ge.data=xe}}return d.naluState=u,y},p.parseAACPES=function(E){var f=0,d=this._audioTrack,u=this.aacOverFlow,a=E.data;if(u){this.aacOverFlow=null;var y=u.sample.unit.byteLength,c=Math.min(u.missing,y),S=y-c;u.sample.unit.set(a.subarray(0,c),S),d.samples.push(u.sample),f=u.missing}var P,G;for(P=f,G=a.length;P<G-1&&!V.isHeader(a,P);P++);if(P!==f){var X,te;if(P<G-1?(X="AAC PES did not start with ADTS header,offset:"+P,te=!1):(X="no ADTS header found in AAC PES",te=!0),v.logger.warn("parsing error:"+X),this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:g.ErrorTypes.MEDIA_ERROR,details:g.ErrorDetails.FRAG_PARSING_ERROR,fatal:te,reason:X}),te)return}V.initTrackConfig(d,this.observer,a,P,this.audioCodec);var z;if(E.pts!==void 0)z=E.pts;else if(u){var F=V.getFrameDuration(d.samplerate);z=u.sample.pts+F}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ne=0;P<G;)if(V.isHeader(a,P)){if(P+5<G){var ce=V.appendFrame(d,a,P,z,ne);if(ce)if(ce.missing)this.aacOverFlow=ce;else{P+=ce.length,ne++;continue}}break}else P++},p.parseMPEGPES=function(E){var f=E.data,d=f.length,u=0,a=0,y=E.pts;if(y===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<d;)if(M.isHeader(f,a)){var c=M.appendFrame(this._audioTrack,f,a,y,u);if(c)a+=c.length,u++;else break}else a++},p.parseID3PES=function(E){if(E.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(E)},m}();w.minProbeByteLength=188;function b(m,p,A,E){return{key:m,frame:!1,pts:p,dts:A,units:[],debug:E,length:0}}function x(m,p){return(m[p+10]&31)<<8|m[p+11]}function l(m,p,A,E){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},d=(m[p+1]&15)<<8|m[p+2],u=p+3+d-4,a=(m[p+10]&15)<<8|m[p+11];for(p+=12+a;p<u;){var y=(m[p+1]&31)<<8|m[p+2];switch(m[p]){case 207:if(!E){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=y);break;case 21:f.id3===-1&&(f.id3=y);break;case 219:if(!E){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=y);break;case 3:case 4:A?f.audio===-1&&(f.audio=y,f.isAAC=!1):v.logger.log("MPEG audio found, not supported in this browser");break;case 36:v.logger.warn("Unsupported HEVC stream type found");break;default:break}p+=((m[p+3]&15)<<8|m[p+4])+5}return f}function o(m){var p=0,A,E,f,d,u,a=m.data;if(!m||m.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)}A=a[0];var c=(A[0]<<16)+(A[1]<<8)+A[2];if(c===1){if(E=(A[4]<<8)+A[5],E&&E>m.size-6)return null;var S=A[7];S&192&&(d=(A[9]&14)*536870912+(A[10]&255)*4194304+(A[11]&254)*16384+(A[12]&255)*128+(A[13]&254)/2,S&64?(u=(A[14]&14)*536870912+(A[15]&255)*4194304+(A[16]&254)*16384+(A[17]&255)*128+(A[18]&254)/2,d-u>60*9e4&&(v.logger.warn(Math.round((d-u)/9e4)+"s delta between PTS and DTS, align them"),d=u)):u=d),f=A[8];var P=f+9;if(m.size<=P)return null;m.size-=P;for(var G=new Uint8Array(m.size),X=0,te=a.length;X<te;X++){A=a[X];var z=A.byteLength;if(P)if(P>z){P-=z;continue}else A=A.subarray(P),z-=P,P=0;G.set(A,p),p+=z}return E&&(E-=f+3),{data:G,pts:d,dts:u,len:E}}return null}function s(m,p){if(m.units.length&&m.frame){if(m.pts===void 0){var A=p.samples,E=A.length;if(E){var f=A[E-1];m.pts=f.pts,m.dts=f.dts}else{p.dropped++;return}}p.samples.push(m)}m.debug.length&&v.logger.log(m.pts+"/"+m.dts+":"+m.debug)}function h(m,p){var A=m.length;if(A>0){if(p.pts>=m[A-1].pts)m.push(p);else for(var E=A-1;E>=0;E--)if(p.pts<m[E].pts){m.splice(E,0,p);break}}else m.push(p)}function C(m){for(var p=m.byteLength,A=[],E=1;E<p-2;)m[E]===0&&m[E+1]===0&&m[E+2]===3?(A.push(E+2),E+=2):E++;if(A.length===0)return m;var f=p-A.length,d=new Uint8Array(f),u=0;for(E=0;E<f;u++,E++)u===A[0]&&(u++,A.shift()),d[E]=m[u];return d}$.default=w},"./src/errors.ts":function(fe,$,_){"use strict";_.r($),_.d($,"ErrorTypes",function(){return V}),_.d($,"ErrorDetails",function(){return M});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 M;(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"})(M||(M={}))},"./src/events.ts":function(fe,$,_){"use strict";_.r($),_.d($,"Events",function(){return V});var V;(function(M){M.MEDIA_ATTACHING="hlsMediaAttaching",M.MEDIA_ATTACHED="hlsMediaAttached",M.MEDIA_DETACHING="hlsMediaDetaching",M.MEDIA_DETACHED="hlsMediaDetached",M.BUFFER_RESET="hlsBufferReset",M.BUFFER_CODECS="hlsBufferCodecs",M.BUFFER_CREATED="hlsBufferCreated",M.BUFFER_APPENDING="hlsBufferAppending",M.BUFFER_APPENDED="hlsBufferAppended",M.BUFFER_EOS="hlsBufferEos",M.BUFFER_FLUSHING="hlsBufferFlushing",M.BUFFER_FLUSHED="hlsBufferFlushed",M.MANIFEST_LOADING="hlsManifestLoading",M.MANIFEST_LOADED="hlsManifestLoaded",M.MANIFEST_PARSED="hlsManifestParsed",M.LEVEL_SWITCHING="hlsLevelSwitching",M.LEVEL_SWITCHED="hlsLevelSwitched",M.LEVEL_LOADING="hlsLevelLoading",M.LEVEL_LOADED="hlsLevelLoaded",M.LEVEL_UPDATED="hlsLevelUpdated",M.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",M.LEVELS_UPDATED="hlsLevelsUpdated",M.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",M.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",M.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",M.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",M.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",M.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",M.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",M.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",M.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",M.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",M.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",M.CUES_PARSED="hlsCuesParsed",M.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",M.INIT_PTS_FOUND="hlsInitPtsFound",M.FRAG_LOADING="hlsFragLoading",M.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",M.FRAG_LOADED="hlsFragLoaded",M.FRAG_DECRYPTED="hlsFragDecrypted",M.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",M.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",M.FRAG_PARSING_METADATA="hlsFragParsingMetadata",M.FRAG_PARSED="hlsFragParsed",M.FRAG_BUFFERED="hlsFragBuffered",M.FRAG_CHANGED="hlsFragChanged",M.FPS_DROP="hlsFpsDrop",M.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",M.ERROR="hlsError",M.DESTROYING="hlsDestroying",M.KEY_LOADING="hlsKeyLoading",M.KEY_LOADED="hlsKeyLoaded",M.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",M.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return m});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(V),D=_("./src/loader/playlist-loader.ts"),j=_("./src/loader/key-loader.ts"),U=_("./src/controller/id3-track-controller.ts"),I=_("./src/controller/latency-controller.ts"),O=_("./src/controller/level-controller.ts"),v=_("./src/controller/fragment-tracker.ts"),g=_("./src/controller/stream-controller.ts"),R=_("./src/is-supported.ts"),w=_("./src/utils/logger.ts"),b=_("./src/config.ts"),x=_("./node_modules/eventemitter3/index.js"),l=_.n(x),o=_("./src/events.ts"),s=_("./src/errors.ts");function h(p,A){for(var E=0;E<A.length;E++){var f=A[E];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(p,f.key,f)}}function C(p,A,E){return A&&h(p.prototype,A),E&&h(p,E),p}var m=function(){p.isSupported=function(){return Object(R.isSupported)()};function p(E){E===void 0&&(E={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new x.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var f=this.config=Object(b.mergeConfig)(p.DefaultConfig,E);this.userConfig=E,Object(w.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(b.enableStreamingMode)(f);var d=f.abrController,u=f.bufferController,a=f.capLevelController,y=f.fpsController,c=this.abrController=new d(this),S=this.bufferController=new u(this),P=this.capLevelController=new a(this),G=new y(this),X=new D.default(this),te=new j.default(this),z=new U.default(this),F=this.levelController=new O.default(this),ne=new v.FragmentTracker(this),ce=this.streamController=new g.default(this,ne);P.setStreamController(ce),G.setStreamController(ce);var ge=[F,ce];this.networkControllers=ge;var xe=[X,te,c,S,P,G,z,ne];this.audioTrackController=this.createController(f.audioTrackController,null,ge),this.createController(f.audioStreamController,ne,ge),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,ge),this.createController(f.subtitleStreamController,ne,ge),this.createController(f.timelineController,null,xe),this.emeController=this.createController(f.emeController,null,xe),this.cmcdController=this.createController(f.cmcdController,null,xe),this.latencyController=this.createController(I.default,null,xe),this.coreComponents=xe}var A=p.prototype;return A.createController=function(f,d,u){if(f){var a=d?new f(this,d):new f(this);return u&&u.push(a),a}return null},A.on=function(f,d,u){u===void 0&&(u=this),this._emitter.on(f,d,u)},A.once=function(f,d,u){u===void 0&&(u=this),this._emitter.once(f,d,u)},A.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},A.off=function(f,d,u,a){u===void 0&&(u=this),this._emitter.off(f,d,u,a)},A.listeners=function(f){return this._emitter.listeners(f)},A.emit=function(f,d,u){return this._emitter.emit(f,d,u)},A.trigger=function(f,d){if(this.config.debug)return this.emit(f,f,d);try{return this.emit(f,f,d)}catch(u){w.logger.error("An internal error happened while handling event "+f+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(o.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:f,error:u})}return!1},A.listenerCount=function(f){return this._emitter.listenerCount(f)},A.destroy=function(){w.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(f){return f.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(f){return f.destroy()}),this.coreComponents.length=0},A.attachMedia=function(f){w.logger.log("attachMedia"),this._media=f,this.trigger(o.Events.MEDIA_ATTACHING,{media:f})},A.detachMedia=function(){w.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},A.loadSource=function(f){this.stopLoad();var d=this.media,u=this.url,a=this.url=V.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});w.logger.log("loadSource:"+a),d&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(d)),this.trigger(o.Events.MANIFEST_LOADING,{url:f})},A.startLoad=function(f){f===void 0&&(f=-1),w.logger.log("startLoad("+f+")"),this.networkControllers.forEach(function(d){d.startLoad(f)})},A.stopLoad=function(){w.logger.log("stopLoad"),this.networkControllers.forEach(function(f){f.stopLoad()})},A.swapAudioCodec=function(){w.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},A.recoverMediaError=function(){w.logger.log("recoverMediaError");var f=this._media;this.detachMedia(),f&&this.attachMedia(f)},A.removeLevel=function(f,d){d===void 0&&(d=0),this.levelController.removeLevel(f,d)},C(p,[{key:"levels",get:function(){var f=this.levelController.levels;return f||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(f){w.logger.log("set currentLevel:"+f),this.loadLevel=f,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(f){w.logger.log("set nextLevel:"+f),this.levelController.manualLevel=f,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(f){w.logger.log("set loadLevel:"+f),this.levelController.manualLevel=f}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(f){this.levelController.nextLoadLevel=f}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(f){w.logger.log("set firstLevel:"+f),this.levelController.firstLevel=f}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(f){w.logger.log("set startLevel:"+f),f!==-1&&(f=Math.max(f,this.minAutoLevel)),this.levelController.startLevel=f}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(f){var d=!!f;d!==this.config.capLevelToPlayerSize&&(d?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=d)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(f){this._autoLevelCapping!==f&&(w.logger.log("set autoLevelCapping:"+f),this._autoLevelCapping=f)}},{key:"bandwidthEstimate",get:function(){var f=this.abrController.bwEstimator;return f?f.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var f=this.levels,d=this.config.minAutoBitrate;if(!f)return 0;for(var u=f.length,a=0;a<u;a++)if(f[a].maxBitrate>d)return a;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,d=this.autoLevelCapping,u;return d===-1&&f&&f.length?u=f.length-1:u=d,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var d=this.audioTrackController;d&&(d.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var d=this.subtitleTrackController;d&&(d.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var d=this.subtitleTrackController;d&&(d.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:b.hlsDefaultConfig},set:function(f){p.defaultConfig=f}}]),p}();m.defaultConfig=void 0},"./src/is-supported.ts":function(fe,$,_){"use strict";_.r($),_.d($,"isSupported",function(){return D}),_.d($,"changeTypeSupported",function(){return j});var V=_("./src/utils/mediasource-helper.ts");function M(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var U=Object(V.getMediaSource)();if(!U)return!1;var I=M(),O=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!I||I.prototype&&typeof I.prototype.appendBuffer=="function"&&typeof I.prototype.remove=="function";return!!O&&!!v}function j(){var U,I=M();return typeof(I==null||((U=I.prototype)===null||U===void 0)?void 0:U.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return w}),_.d($,"LoadError",function(){return x});var V=_("./src/polyfills/number.ts"),M=_("./src/errors.ts");function D(l,o){l.prototype=Object.create(o.prototype),l.prototype.constructor=l,v(l,o)}function j(l){var o=typeof Map=="function"?new Map:void 0;return j=function(h){if(h===null||!O(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(h))return o.get(h);o.set(h,C)}function C(){return U(h,arguments,g(this).constructor)}return C.prototype=Object.create(h.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),v(C,h)},j(l)}function U(l,o,s){return I()?U=Reflect.construct:U=function(C,m,p){var A=[null];A.push.apply(A,m);var E=Function.bind.apply(C,A),f=new E;return p&&v(f,p.prototype),f},U.apply(null,arguments)}function I(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(l){return!1}}function O(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function v(l,o){return v=Object.setPrototypeOf||function(h,C){return h.__proto__=C,h},v(l,o)}function g(l){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},g(l)}var R=Math.pow(2,17),w=function(){function l(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var o=l.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(h,C){var m=this,p=h.url;if(!p)return Promise.reject(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var A=this.config,E=A.fLoader,f=A.loader;return new Promise(function(d,u){m.loader&&m.loader.destroy();var a=m.loader=h.loader=E?new E(A):new f(A),y=b(h),c={timeout:A.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:A.fragLoadingMaxRetryTimeout,highWaterMark:R};h.stats=a.stats,a.load(y,c,{onSuccess:function(P,G,X,te){m.resetLoader(h,a),d({frag:h,part:null,payload:P.data,networkDetails:te})},onError:function(P,G,X){m.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:P,networkDetails:X}))},onAbort:function(P,G,X){m.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:X}))},onTimeout:function(P,G,X){m.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:X}))},onProgress:function(P,G,X,te){C&&C({frag:h,part:null,payload:X,networkDetails:te})}})})},o.loadPart=function(h,C,m){var p=this;this.abort();var A=this.config,E=A.fLoader,f=A.loader;return new Promise(function(d,u){p.loader&&p.loader.destroy();var a=p.loader=h.loader=E?new E(A):new f(A),y=b(h,C),c={timeout:A.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:A.fragLoadingMaxRetryTimeout,highWaterMark:R};C.stats=a.stats,a.load(y,c,{onSuccess:function(P,G,X,te){p.resetLoader(h,a),p.updateStatsFromPart(h,C);var z={frag:h,part:C,payload:P.data,networkDetails:te};m(z),d(z)},onError:function(P,G,X){p.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:C,response:P,networkDetails:X}))},onAbort:function(P,G,X){h.stats.aborted=C.stats.aborted,p.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:C,networkDetails:X}))},onTimeout:function(P,G,X){p.resetLoader(h,a),u(new x({type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:C,networkDetails:X}))}})})},o.updateStatsFromPart=function(h,C){var m=h.stats,p=C.stats,A=p.total;if(m.loaded+=p.loaded,A){var E=Math.round(h.duration/C.duration),f=Math.min(Math.round(m.loaded/A),E),d=E-f,u=d*Math.round(m.loaded/f);m.total=m.loaded+u}else m.total=Math.max(m.loaded,m.total);var a=m.loading,y=p.loading;a.start?a.first+=y.first-y.start:(a.start=y.start,a.first=y.first),a.end=y.end},o.resetLoader=function(h,C){h.loader=null,this.loader===C&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),C.destroy()},l}();function b(l,o){o===void 0&&(o=null);var s=o||l,h={frag:l,part:o,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},C=s.byteRangeStartOffset,m=s.byteRangeEndOffset;return Object(V.isFiniteNumber)(C)&&Object(V.isFiniteNumber)(m)&&(h.rangeStart=C,h.rangeEnd=m),h}var x=function(l){D(o,l);function o(s){for(var h,C=arguments.length,m=new Array(C>1?C-1:0),p=1;p<C;p++)m[p-1]=arguments[p];return h=l.call.apply(l,[this].concat(m))||this,h.data=void 0,h.data=s,h}return o}(j(Error))},"./src/loader/fragment.ts":function(fe,$,_){"use strict";_.r($),_.d($,"ElementaryStreamTypes",function(){return w}),_.d($,"BaseSegment",function(){return b}),_.d($,"Fragment",function(){return x}),_.d($,"Part",function(){return l});var V=_("./src/polyfills/number.ts"),M=_("./node_modules/url-toolkit/src/url-toolkit.js"),D=_.n(M),j=_("./src/utils/logger.ts"),U=_("./src/loader/level-key.ts"),I=_("./src/loader/load-stats.ts");function O(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,v(o,s)}function v(o,s){return v=Object.setPrototypeOf||function(C,m){return C.__proto__=m,C},v(o,s)}function g(o,s){for(var h=0;h<s.length;h++){var C=s[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function R(o,s,h){return s&&g(o.prototype,s),h&&g(o,h),o}var w;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(w||(w={}));var b=function(){function o(h){var C;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(C={},C[w.AUDIO]=null,C[w.VIDEO]=null,C[w.AUDIOVIDEO]=null,C),this.baseurl=h}var s=o.prototype;return s.setByteRange=function(C,m){var p=C.split("@",2),A=[];p.length===1?A[0]=m?m.byteRangeEndOffset:0:A[0]=parseInt(p[1]),A[1]=parseInt(p[0])+A[0],this._byteRange=A},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(M.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(C){this._url=C}}]),o}(),x=function(o){O(s,o);function s(C,m){var p;return p=o.call(this,m)||this,p._decryptdata=null,p.rawProgramDateTime=null,p.programDateTime=null,p.tagList=[],p.duration=0,p.sn=0,p.levelkey=void 0,p.type=void 0,p.loader=null,p.level=-1,p.cc=0,p.startPTS=void 0,p.endPTS=void 0,p.appendedPTS=void 0,p.startDTS=void 0,p.endDTS=void 0,p.start=0,p.deltaPTS=void 0,p.maxStartPTS=void 0,p.minEndPTS=void 0,p.stats=new I.LoadStats,p.urlId=0,p.data=void 0,p.bitrateTest=!1,p.title=null,p.initSegment=null,p.type=C,p}var h=s.prototype;return h.createInitializationVector=function(m){for(var p=new Uint8Array(16),A=12;A<16;A++)p[A]=m>>8*(15-A)&255;return p},h.setDecryptDataFromLevelKey=function(m,p){var A=m;return(m==null?void 0:m.method)==="AES-128"&&m.uri&&!m.iv&&(A=U.LevelKey.fromURI(m.uri),A.method=m.method,A.iv=this.createInitializationVector(p),A.keyFormat="identity"),A},h.setElementaryStreamInfo=function(m,p,A,E,f,d){d===void 0&&(d=!1);var u=this.elementaryStreams,a=u[m];if(!a){u[m]={startPTS:p,endPTS:A,startDTS:E,endDTS:f,partial:d};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,A),a.startDTS=Math.min(a.startDTS,E),a.endDTS=Math.max(a.endDTS,f)},h.clearElementaryStreamInfo=function(){var m=this.elementaryStreams;m[w.AUDIO]=null,m[w.VIDEO]=null,m[w.AUDIOVIDEO]=null},R(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var m=this.sn;typeof m!="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'),m=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,m)}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 m=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+m*1e3}},{key:"encrypted",get:function(){var m;return!!((m=this.decryptdata)!==null&&m!==void 0&&m.keyFormat&&this.decryptdata.uri)}}]),s}(b),l=function(o){O(s,o);function s(h,C,m,p,A){var E;E=o.call(this,m)||this,E.fragOffset=0,E.duration=0,E.gap=!1,E.independent=!1,E.relurl=void 0,E.fragment=void 0,E.index=void 0,E.stats=new I.LoadStats,E.duration=h.decimalFloatingPoint("DURATION"),E.gap=h.bool("GAP"),E.independent=h.bool("INDEPENDENT"),E.relurl=h.enumeratedString("URI"),E.fragment=C,E.index=p;var f=h.enumeratedString("BYTERANGE");return f&&E.setByteRange(f,A),A&&(E.fragOffset=A.fragOffset+A.duration),E}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 C=this.elementaryStreams;return!!(C.audio||C.video||C.audiovideo)}}]),s}(b)},"./src/loader/key-loader.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return j});var V=_("./src/events.ts"),M=_("./src/errors.ts"),D=_("./src/utils/logger.ts"),j=function(){function U(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var I=U.prototype;return I._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},I._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},I.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var g=this.loaders[v];g&&g.destroy()}this.loaders={}},I.onKeyLoading=function(v,g){var R=g.frag,w=R.type,b=this.loaders[w];if(!R.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var x=R.decryptdata.uri;if(x!==this.decrypturl||this.decryptkey===null){var l=this.hls.config;if(b&&(D.logger.warn("abort previous key loader for type:"+w),b.abort()),!x){D.logger.warn("key uri is falsy");return}var o=l.loader,s=R.loader=this.loaders[w]=new o(l);this.decrypturl=x,this.decryptkey=null;var h={url:x,frag:R,responseType:"arraybuffer"},C={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(h,C,m)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:R}))},I.loadsuccess=function(v,g,R){var w=R.frag;if(!w.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=w.decryptdata.key=new Uint8Array(v.data),w.loader=null,delete this.loaders[w.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:w})},I.loaderror=function(v,g){var R=g.frag,w=R.loader;w&&w.abort(),delete this.loaders[R.type],this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:v})},I.loadtimeout=function(v,g){var R=g.frag,w=R.loader;w&&w.abort(),delete this.loaders[R.type],this.hls.trigger(V.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},U}()},"./src/loader/level-details.ts":function(fe,$,_){"use strict";_.r($),_.d($,"LevelDetails",function(){return U});var V=_("./src/polyfills/number.ts");function M(I,O){for(var v=0;v<O.length;v++){var g=O[v];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(I,g.key,g)}}function D(I,O,v){return O&&M(I.prototype,O),v&&M(I,v),I}var j=10,U=function(){function I(v){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=v}var O=I.prototype;return O.reloaded=function(g){if(!g){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-g.lastPartSn,w=this.lastPartIndex-g.lastPartIndex;this.updated=this.endSN!==g.endSN||!!w||!!R,this.advanced=this.endSN>g.endSN||R>0||R===0&&w>0,this.updated||this.advanced?this.misses=Math.floor(g.misses*.6):this.misses=g.misses+1,this.availabilityDelay=g.availabilityDelay},D(I,[{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 g=this.driftEndTime-this.driftStartTime;if(g>0){var R=this.driftEnd-this.driftStart;return R*1e3/g}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var g;return(g=this.fragments)!==null&&g!==void 0&&g.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 g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),I}()},"./src/loader/level-key.ts":function(fe,$,_){"use strict";_.r($),_.d($,"LevelKey",function(){return U});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(V);function D(I,O){for(var v=0;v<O.length;v++){var g=O[v];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(I,g.key,g)}}function j(I,O,v){return O&&D(I.prototype,O),v&&D(I,v),I}var U=function(){I.fromURL=function(v,g){return new I(v,g)},I.fromURI=function(v){return new I(v)};function I(O,v){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,v?this._uri=Object(V.buildAbsoluteURL)(O,v,{alwaysNormalize:!0}):this._uri=O}return j(I,[{key:"uri",get:function(){return this._uri}}]),I}()},"./src/loader/load-stats.ts":function(fe,$,_){"use strict";_.r($),_.d($,"LoadStats",function(){return V});var V=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return s});var V=_("./src/polyfills/number.ts"),M=_("./node_modules/url-toolkit/src/url-toolkit.js"),D=_.n(M),j=_("./src/loader/fragment.ts"),U=_("./src/loader/level-details.ts"),I=_("./src/loader/level-key.ts"),O=_("./src/utils/attr-list.ts"),v=_("./src/utils/logger.ts"),g=_("./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,w=/#EXT-X-MEDIA:(.*)/g,b=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),x=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("|")),l=/\.(mp4|m4s|m4v|m4a)$/i;function o(A){var E,f;return l.test((E=(f=M.parseURL(A))===null||f===void 0?void 0:f.path)!=null?E:"")}var s=function(){function A(){}return A.findGroup=function(f,d){for(var u=0;u<f.length;u++){var a=f[u];if(a.id===d)return a}},A.convertAVC1ToAVCOTI=function(f){var d=f.split(".");if(d.length>2){var u=d.shift()+".";return u+=parseInt(d.shift()).toString(16),u+=("000"+parseInt(d.shift()).toString(16)).substr(-4),u}return f},A.resolve=function(f,d){return M.buildAbsoluteURL(d,f,{alwaysNormalize:!0})},A.parseMasterPlaylist=function(f,d){var u=[],a={},y=!1;R.lastIndex=0;for(var c;(c=R.exec(f))!=null;)if(c[1]){var S=new O.AttrList(c[1]),P={attrs:S,bitrate:S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),name:S.NAME,url:A.resolve(c[2],d)},G=S.decimalResolution("RESOLUTION");G&&(P.width=G.width,P.height=G.height),h((S.CODECS||"").split(/[ ,]+/).filter(function(te){return te}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=A.convertAVC1ToAVCOTI(P.videoCodec)),u.push(P)}else if(c[3]){var X=new O.AttrList(c[3]);X["DATA-ID"]&&(y=!0,a[X["DATA-ID"]]=X)}return{levels:u,sessionData:y?a:null}},A.parseMasterPlaylistMedia=function(f,d,u,a){a===void 0&&(a=[]);var y,c=[],S=0;for(w.lastIndex=0;(y=w.exec(f))!==null;){var P=new O.AttrList(y[1]);if(P.TYPE===u){var G={attrs:P,bitrate:0,id:S++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:u,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?A.resolve(P.URI,d):""};if(a.length){var X=A.findGroup(a,G.groupId)||a[0];C(G,X,"audioCodec"),C(G,X,"textCodec")}c.push(G)}}return c},A.parseLevelPlaylist=function(f,d,u,a,y){var c=new U.LevelDetails(d),S=c.fragments,P=null,G=0,X=0,te=0,z=0,F=null,ne=new j.Fragment(a,d),ce,ge,xe,Ie=-1,Te=!1;for(b.lastIndex=0,c.m3u8=f;(ce=b.exec(f))!==null;){Te&&(Te=!1,ne=new j.Fragment(a,d),ne.start=te,ne.sn=G,ne.cc=z,ne.level=u,P&&(ne.initSegment=P,ne.rawProgramDateTime=P.rawProgramDateTime));var Oe=ce[1];if(Oe){ne.duration=parseFloat(Oe);var Ce=(" "+ce[2]).slice(1);ne.title=Ce||null,ne.tagList.push(Ce?["INF",Oe,Ce]:["INF",Oe])}else if(ce[3])Object(V.isFiniteNumber)(ne.duration)&&(ne.start=te,xe&&(ne.levelkey=xe),ne.sn=G,ne.level=u,ne.cc=z,ne.urlId=y,S.push(ne),ne.relurl=(" "+ce[3]).slice(1),p(ne,F),F=ne,te+=ne.duration,G++,X=0,Te=!0);else if(ce[4]){var Ae=(" "+ce[4]).slice(1);F?ne.setByteRange(Ae,F):ne.setByteRange(Ae)}else if(ce[5])ne.rawProgramDateTime=(" "+ce[5]).slice(1),ne.tagList.push(["PROGRAM-DATE-TIME",ne.rawProgramDateTime]),Ie===-1&&(Ie=S.length);else{if(ce=ce[0].match(x),!ce){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ge=1;ge<ce.length&&!(typeof ce[ge]!="undefined");ge++);var ve=(" "+ce[ge]).slice(1),W=(" "+ce[ge+1]).slice(1),L=ce[ge+2]?(" "+ce[ge+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":c.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":G=c.startSN=parseInt(W);break;case"SKIP":{var k=new O.AttrList(W),H=k.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(H)){c.skippedSegments=H;for(var q=H;q--;)S.unshift(null);G+=H}var B=k.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(c.recentlyRemovedDateranges=B.split(" "));break}case"TARGETDURATION":c.targetduration=parseFloat(W);break;case"VERSION":c.version=parseInt(W);break;case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(W||L)&&ne.tagList.push(L?[W,L]:[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 ue,be=new O.AttrList(W),we=be.enumeratedString("METHOD"),Pe=be.URI,_e=be.hexadecimalInteger("IV"),De=be.enumeratedString("KEYFORMATVERSIONS"),Me=be.enumeratedString("KEYID"),We=(ue=be.enumeratedString("KEYFORMAT"))!=null?ue:"identity",ze=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ze.indexOf(We)>-1){v.logger.warn("Keyformat "+We+" is not supported from the manifest");continue}else if(We!=="identity")continue;we&&(xe=I.LevelKey.fromURL(d,Pe),Pe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(we)>=0&&(xe.method=we,xe.keyFormat=We,Me&&(xe.keyID=Me),De&&(xe.keyFormatVersions=De),xe.iv=_e));break}case"START":{var Xe=new O.AttrList(W),Ge=Xe.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(Ge)&&(c.startTimeOffset=Ge);break}case"MAP":{var at=new O.AttrList(W);ne.relurl=at.URI,at.BYTERANGE&&ne.setByteRange(at.BYTERANGE),ne.level=u,ne.sn="initSegment",xe&&(ne.levelkey=xe),ne.initSegment=null,P=ne,Te=!0;break}case"SERVER-CONTROL":{var $e=new O.AttrList(W);c.canBlockReload=$e.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=$e.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&$e.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=$e.optionalFloat("PART-HOLD-BACK",0),c.holdBack=$e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Ve=new O.AttrList(W);c.partTarget=Ve.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Le=c.partList;Le||(Le=c.partList=[]);var tt=X>0?Le[Le.length-1]:void 0,qe=X++,ae=new j.Part(new O.AttrList(W),ne,d,qe,tt);Le.push(ae),ne.duration+=ae.duration;break}case"PRELOAD-HINT":{var J=new O.AttrList(W);c.preloadHint=J;break}case"RENDITION-REPORT":{var Z=new O.AttrList(W);c.renditionReports=c.renditionReports||[],c.renditionReports.push(Z);break}default:v.logger.warn("line parsed but not handled: "+ce);break}}}F&&!F.relurl?(S.pop(),te-=F.duration,c.partList&&(c.fragmentHint=F)):c.partList&&(p(ne,F),ne.cc=z,c.fragmentHint=ne);var ie=S.length,oe=S[0],Q=S[ie-1];if(te+=c.skippedSegments*c.targetduration,te>0&&ie&&Q){c.averagetargetduration=te/ie;var re=Q.sn;c.endSN=re!=="initSegment"?re:0,oe&&(c.startCC=oe.cc,oe.initSegment||c.fragments.every(function(se){return se.relurl&&o(se.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ne=new j.Fragment(a,d),ne.relurl=Q.relurl,ne.level=u,ne.sn="initSegment",oe.initSegment=ne,c.needSidxRanges=!0))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(te+=c.fragmentHint.duration),c.totalduration=te,c.endCC=z,Ie>0&&m(S,Ie),c},A}();function h(A,E){["video","audio","text"].forEach(function(f){var d=A.filter(function(a){return Object(g.isCodecType)(a,f)});if(d.length){var u=d.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});E[f+"Codec"]=u.length>0?u[0]:d[0],A=A.filter(function(a){return d.indexOf(a)===-1})}}),E.unknownCodecs=A}function C(A,E,f){var d=E[f];d&&(A[f]=d)}function m(A,E){for(var f=A[E],d=E;d--;){var u=A[d];if(!u)return;u.programDateTime=f.programDateTime-u.duration*1e3,f=u}}function p(A,E){A.rawProgramDateTime?A.programDateTime=Date.parse(A.rawProgramDateTime):E!=null&&E.programDateTime&&(A.programDateTime=E.endProgramDateTime),Object(V.isFiniteNumber)(A.programDateTime)||(A.programDateTime=null,A.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),M=_("./src/events.ts"),D=_("./src/errors.ts"),j=_("./src/utils/logger.ts"),U=_("./src/utils/mp4-tools.ts"),I=_("./src/loader/m3u8-parser.ts"),O=_("./src/types/loader.ts"),v=_("./src/utils/attr-list.ts");function g(b){var x=b.type;switch(x){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(b,x){var l=b.url;return(l===void 0||l.indexOf("data:")===0)&&(l=x.url),l}var w=function(){function b(l){this.hls=void 0,this.loaders=Object.create(null),this.hls=l,this.registerListeners()}var x=b.prototype;return x.registerListeners=function(){var o=this.hls;o.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(M.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(M.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},x.unregisterListeners=function(){var o=this.hls;o.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(M.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(M.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},x.createInternalLoader=function(o){var s=this.hls.config,h=s.pLoader,C=s.loader,m=h||C,p=new m(s);return o.loader=p,this.loaders[o.type]=p,p},x.getInternalLoader=function(o){return this.loaders[o.type]},x.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},x.destroyInternalLoaders=function(){for(var o in this.loaders){var s=this.loaders[o];s&&s.destroy(),this.resetInternalLoader(o)}},x.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},x.onManifestLoading=function(o,s){var h=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},x.onLevelLoading=function(o,s){var h=s.id,C=s.level,m=s.url,p=s.deliveryDirectives;this.load({id:h,groupId:null,level:C,responseType:"text",type:O.PlaylistContextType.LEVEL,url:m,deliveryDirectives:p})},x.onAudioTrackLoading=function(o,s){var h=s.id,C=s.groupId,m=s.url,p=s.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:m,deliveryDirectives:p})},x.onSubtitleTrackLoading=function(o,s){var h=s.id,C=s.groupId,m=s.url,p=s.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:m,deliveryDirectives:p})},x.load=function(o){var s,h=this.hls.config,C=this.getInternalLoader(o);if(C){var m=C.context;if(m&&m.url===o.url){j.logger.trace("[playlist-loader]: playlist request ongoing");return}j.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),C.abort()}var p,A,E,f;switch(o.type){case O.PlaylistContextType.MANIFEST:p=h.manifestLoadingMaxRetry,A=h.manifestLoadingTimeOut,E=h.manifestLoadingRetryDelay,f=h.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:p=0,A=h.levelLoadingTimeOut;break;default:p=h.levelLoadingMaxRetry,A=h.levelLoadingTimeOut,E=h.levelLoadingRetryDelay,f=h.levelLoadingMaxRetryTimeout;break}if(C=this.createInternalLoader(o),(s=o.deliveryDirectives)!==null&&s!==void 0&&s.part){var d;if(o.type===O.PlaylistContextType.LEVEL&&o.level!==null?d=this.hls.levels[o.level].details:o.type===O.PlaylistContextType.AUDIO_TRACK&&o.id!==null?d=this.hls.audioTracks[o.id].details:o.type===O.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(d=this.hls.subtitleTracks[o.id].details),d){var u=d.partTarget,a=d.targetduration;u&&a&&(A=Math.min(Math.max(u*3,a*.8)*1e3,A))}}var y={timeout:A,maxRetry:p,retryDelay:E,maxRetryDelay:f,highWaterMark:0},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};C.load(o,y,c)},x.loadsuccess=function(o,s,h,C){if(C===void 0&&(C=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,s,h,C);return}this.resetInternalLoader(h.type);var m=o.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",C);return}s.parsing.start=performance.now(),m.indexOf("#EXTINF:")>0||m.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,s,h,C):this.handleMasterPlaylist(o,s,h,C)},x.loaderror=function(o,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!1,o)},x.loadtimeout=function(o,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!0)},x.handleMasterPlaylist=function(o,s,h,C){var m=this.hls,p=o.data,A=R(o,h),E=I.default.parseMasterPlaylist(p,A),f=E.levels,d=E.sessionData;if(!f.length){this.handleManifestParsingError(o,h,"no level found in manifest",C);return}var u=f.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=f.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),y=I.default.parseMasterPlaylistMedia(p,A,"AUDIO",u),c=I.default.parseMasterPlaylistMedia(p,A,"SUBTITLES",a),S=I.default.parseMasterPlaylistMedia(p,A,"CLOSED-CAPTIONS");if(y.length){var P=y.some(function(G){return!G.url});!P&&f[0].audioCodec&&!f[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 v.AttrList({}),bitrate:0,url:""}))}m.trigger(M.Events.MANIFEST_LOADED,{levels:f,audioTracks:y,subtitles:c,captions:S,url:A,stats:s,networkDetails:C,sessionData:d})},x.handleTrackOrLevelPlaylist=function(o,s,h,C){var m=this.hls,p=h.id,A=h.level,E=h.type,f=R(o,h),d=Object(V.isFiniteNumber)(p)?p:0,u=Object(V.isFiniteNumber)(A)?A:d,a=g(h),y=I.default.parseLevelPlaylist(o.data,f,u,a,d);if(!y.fragments.length){m.trigger(M.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(E===O.PlaylistContextType.MANIFEST){var c={attrs:new v.AttrList({}),bitrate:0,details:y,name:"",url:f};m.trigger(M.Events.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:f,stats:s,networkDetails:C,sessionData:null})}if(s.parsing.end=performance.now(),y.needSidxRanges){var S,P=(S=y.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:P,isSidxRequest:!0,type:E,level:A,levelDetails:y,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=y,this.handlePlaylistLoaded(o,s,h,C)},x.handleSidxRequest=function(o,s){var h=Object(U.parseSegmentIndex)(new Uint8Array(o.data));if(!h)return;var C=h.references,m=s.levelDetails;C.forEach(function(p,A){var E=p.info,f=m.fragments[A];f.byteRange.length===0&&f.setByteRange(String(1+E.end-E.start)+"@"+String(E.start)),f.initSegment&&f.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},x.handleManifestParsingError=function(o,s,h,C){this.hls.trigger(M.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===O.PlaylistContextType.MANIFEST,url:o.url,reason:h,response:o,context:s,networkDetails:C})},x.handleNetworkError=function(o,s,h,C){h===void 0&&(h=!1),j.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var m=D.ErrorDetails.UNKNOWN,p=!1,A=this.getInternalLoader(o);switch(o.type){case O.PlaylistContextType.MANIFEST:m=h?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case O.PlaylistContextType.LEVEL:m=h?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case O.PlaylistContextType.AUDIO_TRACK:m=h?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:m=h?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}A&&this.resetInternalLoader(o.type);var E={type:D.ErrorTypes.NETWORK_ERROR,details:m,fatal:p,url:o.url,loader:A,context:o,networkDetails:s};C&&(E.response=C),this.hls.trigger(M.Events.ERROR,E)},x.handlePlaylistLoaded=function(o,s,h,C){var m=h.type,p=h.level,A=h.id,E=h.groupId,f=h.loader,d=h.levelDetails,u=h.deliveryDirectives;if(!(d!=null&&d.targetduration)){this.handleManifestParsingError(o,h,"invalid target duration",C);return}if(!f)return;d.live&&(f.getCacheAge&&(d.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(d.ageHeader))&&(d.ageHeader=0));switch(m){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(M.Events.LEVEL_LOADED,{details:d,level:p||0,id:A||0,stats:s,networkDetails:C,deliveryDirectives:u});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(M.Events.AUDIO_TRACK_LOADED,{details:d,id:A||0,groupId:E||"",stats:s,networkDetails:C,deliveryDirectives:u});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(M.Events.SUBTITLE_TRACK_LOADED,{details:d,id:A||0,groupId:E||"",stats:s,networkDetails:C,deliveryDirectives:u});break}},b}();$.default=w},"./src/polyfills/number.ts":function(fe,$,_){"use strict";_.r($),_.d($,"isFiniteNumber",function(){return V}),_.d($,"MAX_SAFE_INTEGER",function(){return M});var V=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},M=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(fe,$,_){"use strict";_.r($);var V=function(){function M(){}return M.getSilentFrame=function(j,U){switch(j){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===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(U===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(U===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(U===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(U===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},M}();$.default=V},"./src/remux/mp4-generator.ts":function(fe,$,_){"use strict";_.r($);var V=Math.pow(2,32)-1,M=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 U;for(U in D.types)D.types.hasOwnProperty(U)&&(D.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var I=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:I,audio:O};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),g=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=g,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]),w=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,R,b,R,w),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,v))},D.box=function(U){for(var I=8,O=arguments.length,v=new Array(O>1?O-1:0),g=1;g<O;g++)v[g-1]=arguments[g];for(var R=v.length,w=R;R--;)I+=v[R].byteLength;var b=new Uint8Array(I);for(b[0]=I>>24&255,b[1]=I>>16&255,b[2]=I>>8&255,b[3]=I&255,b.set(U,4),R=0,I=8;R<w;R++)b.set(v[R],I),I+=v[R].byteLength;return b},D.hdlr=function(U){return D.box(D.types.hdlr,D.HDLR_TYPES[U])},D.mdat=function(U){return D.box(D.types.mdat,U)},D.mdhd=function(U,I){I*=U;var O=Math.floor(I/(V+1)),v=Math.floor(I%(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,U>>24&255,U>>16&255,U>>8&255,U&255,O>>24,O>>16&255,O>>8&255,O&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},D.mdia=function(U){return D.box(D.types.mdia,D.mdhd(U.timescale,U.duration),D.hdlr(U.type),D.minf(U))},D.mfhd=function(U){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]))},D.minf=function(U){return U.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(U)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(U))},D.moof=function(U,I,O){return D.box(D.types.moof,D.mfhd(U),D.traf(O,I))},D.moov=function(U){for(var I=U.length,O=[];I--;)O[I]=D.trak(U[I]);return D.box.apply(null,[D.types.moov,D.mvhd(U[0].timescale,U[0].duration)].concat(O).concat(D.mvex(U)))},D.mvex=function(U){for(var I=U.length,O=[];I--;)O[I]=D.trex(U[I]);return D.box.apply(null,[D.types.mvex].concat(O))},D.mvhd=function(U,I){I*=U;var O=Math.floor(I/(V+1)),v=Math.floor(I%(V+1)),g=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,O>>24,O>>16&255,O>>8&255,O&255,v>>24,v>>16&255,v>>8&255,v&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,g)},D.sdtp=function(U){var I=U.samples||[],O=new Uint8Array(4+I.length),v,g;for(v=0;v<I.length;v++)g=I[v].flags,O[v+4]=g.dependsOn<<4|g.isDependedOn<<2|g.hasRedundancy;return D.box(D.types.sdtp,O)},D.stbl=function(U){return D.box(D.types.stbl,D.stsd(U),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(U){var I=[],O=[],v,g,R;for(v=0;v<U.sps.length;v++)g=U.sps[v],R=g.byteLength,I.push(R>>>8&255),I.push(R&255),I=I.concat(Array.prototype.slice.call(g));for(v=0;v<U.pps.length;v++)g=U.pps[v],R=g.byteLength,O.push(R>>>8&255),O.push(R&255),O=O.concat(Array.prototype.slice.call(g));var w=D.box(D.types.avcC,new Uint8Array([1,I[3],I[4],I[5],252|3,224|U.sps.length].concat(I).concat([U.pps.length]).concat(O))),b=U.width,x=U.height,l=U.pixelRatio[0],o=U.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,b>>8&255,b&255,x>>8&255,x&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]),w,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([l>>24,l>>16&255,l>>8&255,l&255,o>>24,o>>16&255,o>>8&255,o&255])))},D.esds=function(U){var I=U.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(U.config).concat([6,1,2]))},D.mp4a=function(U){var I=U.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,U.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]),D.box(D.types.esds,D.esds(U)))},D.mp3=function(U){var I=U.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,U.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]))},D.stsd=function(U){return U.type==="audio"?!U.isAAC&&U.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(U)):D.box(D.types.stsd,D.STSD,D.mp4a(U)):D.box(D.types.stsd,D.STSD,D.avc1(U))},D.tkhd=function(U){var I=U.id,O=U.duration*U.timescale,v=U.width,g=U.height,R=Math.floor(O/(V+1)),w=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,I>>24&255,I>>16&255,I>>8&255,I&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,w>>24,w>>16&255,w>>8&255,w&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,v>>8&255,v&255,0,0,g>>8&255,g&255,0,0]))},D.traf=function(U,I){var O=D.sdtp(U),v=U.id,g=Math.floor(I/(V+1)),R=Math.floor(I%(V+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,g>>24,g>>16&255,g>>8&255,g&255,R>>24,R>>16&255,R>>8&255,R&255])),D.trun(U,O.length+16+20+8+16+8+8),O)},D.trak=function(U){return U.duration=U.duration||4294967295,D.box(D.types.trak,D.tkhd(U),D.mdia(U))},D.trex=function(U){var I=U.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,I&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(U,I){var O=U.samples||[],v=O.length,g=12+16*v,R=new Uint8Array(g),w,b,x,l,o,s;for(I+=8+g,R.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255],0),w=0;w<v;w++)b=O[w],x=b.duration,l=b.size,o=b.flags,s=b.cts,R.set([x>>>24&255,x>>>16&255,x>>>8&255,x&255,l>>>24&255,l>>>16&255,l>>>8&255,l&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*w);return D.box(D.types.trun,R)},D.initSegment=function(U){D.types||D.init();var I=D.moov(U),O=new Uint8Array(D.FTYP.byteLength+I.byteLength);return O.set(D.FTYP),O.set(I,D.FTYP.byteLength),O},D}();M.types=void 0,M.HDLR_TYPES=void 0,M.STTS=void 0,M.STSC=void 0,M.STCO=void 0,M.STSZ=void 0,M.VMHD=void 0,M.SMHD=void 0,M.STSD=void 0,M.FTYP=void 0,M.DINF=void 0,$.default=M},"./src/remux/mp4-remuxer.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return s}),_.d($,"normalizePts",function(){return h});var V=_("./src/polyfills/number.ts"),M=_("./src/remux/aac-helper.ts"),D=_("./src/remux/mp4-generator.ts"),j=_("./src/events.ts"),U=_("./src/errors.ts"),I=_("./src/utils/logger.ts"),O=_("./src/types/loader.ts"),v=_("./src/utils/timescale-conversion.ts");function g(){return g=Object.assign||function(A){for(var E=1;E<arguments.length;E++){var f=arguments[E];for(var d in f)Object.prototype.hasOwnProperty.call(f,d)&&(A[d]=f[d])}return A},g.apply(this,arguments)}var R=10*1e3,w=1024,b=1152,x=null,l=null,o=!1,s=function(){function A(f,d,u,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=d,this.typeSupported=u,this.ISGenerated=!1,x===null){var y=navigator.userAgent||"",c=y.match(/Chrome\/(\d+)/i);x=c?parseInt(c[1]):0}if(l===null){var S=navigator.userAgent.match(/Safari\/(\d+)/i);l=S?parseInt(S[1]):0}o=!!x&&x<75||!!l&&l<600}var E=A.prototype;return E.destroy=function(){},E.resetTimeStamp=function(d){I.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},E.resetNextTimestamp=function(){I.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},E.resetInitSegment=function(){I.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},E.getVideoStartPts=function(d){var u=!1,a=d.reduce(function(y,c){var S=c.pts-y;return S<-4294967296?(u=!0,h(y,c.pts)):S>0?y:c.pts},d[0].pts);return u&&I.logger.debug("PTS rollover detected"),a},E.remux=function(d,u,a,y,c,S,P,G){var X,te,z,F,ne,ce,ge=c,xe=c,Ie=d.pid>-1,Te=u.pid>-1,Oe=u.samples.length,Ce=d.samples.length>0,Ae=Oe>1,ve=(!Ie||Ce)&&(!Te||Ae)||this.ISGenerated||P;if(ve){this.ISGenerated||(z=this.generateIS(d,u,c));var W=this.isVideoContiguous,L=-1;if(Ae&&(L=C(u.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(ce=!0,L>0){I.logger.warn("[mp4-remuxer]: Dropped "+L+" out of "+Oe+" video samples due to a missing keyframe");var k=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(L),u.dropped+=L,xe+=(u.samples[0].pts-k)/(u.timescale||9e4)}else L===-1&&(I.logger.warn("[mp4-remuxer]: No keyframe found out of "+Oe+" video samples"),ce=!1);if(this.ISGenerated){if(Ce&&Ae){var H=this.getVideoStartPts(u.samples),q=h(d.samples[0].pts,H)-H,B=q/u.inputTimeScale;ge+=Math.max(0,B),xe+=Math.max(0,-B)}if(Ce){if(d.samplerate||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(d,u,c)),te=this.remuxAudio(d,ge,this.isAudioContiguous,S,Te||Ae||G===O.PlaylistLevelType.AUDIO?xe:void 0),Ae){var ue=te?te.endPTS-te.startPTS:0;u.inputTimeScale||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(d,u,c)),X=this.remuxVideo(u,xe,W,ue)}}else Ae&&(X=this.remuxVideo(u,xe,W,0));X&&(X.firstKeyFrame=L,X.independent=L!==-1)}}return this.ISGenerated&&(a.samples.length&&(ne=this.remuxID3(a,c)),y.samples.length&&(F=this.remuxText(y,c))),{audio:te,video:X,initSegment:z,independent:ce,text:F,id3:ne}},E.generateIS=function(d,u,a){var y=d.samples,c=u.samples,S=this.typeSupported,P={},G=!Object(V.isFiniteNumber)(this._initPTS),X="audio/mp4",te,z,F;if(G&&(te=z=Infinity),d.config&&y.length&&(d.timescale=d.samplerate,d.isAAC||(S.mpeg?(X="audio/mpeg",d.codec=""):S.mp3&&(d.codec="mp3")),P.audio={id:"audio",container:X,codec:d.codec,initSegment:!d.isAAC&&S.mpeg?new Uint8Array(0):D.default.initSegment([d]),metadata:{channelCount:d.channelCount}},G&&(F=d.inputTimeScale,te=z=y[0].pts-Math.round(F*a))),u.sps&&u.pps&&c.length&&(u.timescale=u.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:D.default.initSegment([u]),metadata:{width:u.width,height:u.height}},G)){F=u.inputTimeScale;var ne=this.getVideoStartPts(c),ce=Math.round(F*a);z=Math.min(z,h(c[0].dts,ne)-ce),te=Math.min(te,ne-ce)}if(Object.keys(P).length)return this.ISGenerated=!0,G&&(this._initPTS=te,this._initDTS=z),{tracks:P,initPTS:te,timescale:F}},E.remuxVideo=function(d,u,a,y){var c=d.inputTimeScale,S=d.samples,P=[],G=S.length,X=this._initPTS,te=this.nextAvcDts,z=8,F,ne,ce,ge=Number.POSITIVE_INFINITY,xe=Number.NEGATIVE_INFINITY,Ie=0,Te=!1;if(!a||te===null){var Oe=u*c,Ce=S[0].pts-h(S[0].dts,S[0].pts);te=Oe-Ce}for(var Ae=0;Ae<G;Ae++){var ve=S[Ae];if(ve.pts=h(ve.pts-X,te),ve.dts=h(ve.dts-X,te),ve.dts>ve.pts){var W=9e4*.2;Ie=Math.max(Math.min(Ie,ve.pts-ve.dts),-1*W)}ve.dts<S[Ae>0?Ae-1:Ae].dts&&(Te=!0)}Te&&S.sort(function(lt,it){var Ye=lt.dts-it.dts,wt=lt.pts-it.pts;return Ye||wt}),ne=S[0].dts,ce=S[S.length-1].dts;var L=Math.round((ce-ne)/(G-1));if(Ie<0){if(Ie<L*-2){I.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-L,!0)+" ms");for(var k=Ie,H=0;H<G;H++)S[H].dts=k=Math.max(k,S[H].pts-L),S[H].pts=Math.max(k,S[H].pts)}else{I.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(Ie,!0)+" ms to overcome this issue");for(var q=0;q<G;q++)S[q].dts=S[q].dts+Ie}ne=S[0].dts}if(a){var B=ne-te,ue=B>L,be=B<-1;if(ue||be){ue?I.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(B,!0)+" ms ("+B+"dts) hole between fragments detected, filling it"):I.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-B,!0)+" ms ("+B+"dts) overlapping between fragments detected"),ne=te;var we=S[0].pts-B;S[0].dts=ne,S[0].pts=we,I.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(we,!0)+"/"+Object(v.toMsFromMpegTsClock)(ne,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(B,!0)+" ms")}}o&&(ne=Math.max(0,ne));for(var Pe=0,_e=0,De=0;De<G;De++){for(var Me=S[De],We=Me.units,ze=We.length,Xe=0,Ge=0;Ge<ze;Ge++)Xe+=We[Ge].data.length;_e+=Xe,Pe+=ze,Me.length=Xe,Me.dts=Math.max(Me.dts,ne),Me.pts=Math.max(Me.pts,Me.dts,0),ge=Math.min(Me.pts,ge),xe=Math.max(Me.pts,xe)}ce=S[G-1].dts;var at=_e+4*Pe+8,$e;try{$e=new Uint8Array(at)}catch(lt){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:at,reason:"fail allocating video mdat "+at});return}var Ve=new DataView($e.buffer);Ve.setUint32(0,at),$e.set(D.default.types.mdat,4);for(var Le=0;Le<G;Le++){for(var tt=S[Le],qe=tt.units,ae=0,J=0,Z=qe.length;J<Z;J++){var ie=qe[J],oe=ie.data,Q=ie.data.byteLength;Ve.setUint32(z,Q),z+=4,$e.set(oe,z),z+=Q,ae+=4+Q}if(Le<G-1)F=S[Le+1].dts-tt.dts;else{var re=this.config,se=tt.dts-S[Le>0?Le-1:Le].dts;if(re.stretchShortVideoTrack&&this.nextAudioPts!==null){var he=Math.floor(re.maxBufferHole*c),pe=(y?ge+y*c:this.nextAudioPts)-tt.pts;pe>he?(F=pe-se,F<0&&(F=se),I.logger.log("[mp4-remuxer]: It is approximately "+pe/90+" ms to the next segment; using duration "+F/90+" ms for the last video frame.")):F=se}else F=se}var ye=Math.round(tt.pts-tt.dts);P.push(new m(tt.key,F,ae,ye))}if(P.length&&x&&x<70){var ke=P[0].flags;ke.dependsOn=2,ke.isNonSync=0}console.assert(F!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=te=ce+F,this.isVideoContiguous=!0;var Ne=D.default.moof(d.sequenceNumber++,ne,g({},d,{samples:P})),Ze="video",Ke={data1:Ne,data2:$e,startPTS:ge/c,endPTS:(xe+F)/c,startDTS:ne/c,endDTS:te/c,type:Ze,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert($e.length,"MDAT length must not be zero"),Ke},E.remuxAudio=function(d,u,a,y,c){var S=d.inputTimeScale,P=d.samplerate?d.samplerate:S,G=S/P,X=d.isAAC?w:b,te=X*G,z=this._initPTS,F=!d.isAAC&&this.typeSupported.mpeg,ne=[],ce=d.samples,ge=F?0:8,xe=this.nextAudioPts||-1,Ie=u*S;if(this.isAudioContiguous=a=a||ce.length&&xe>0&&(y&&Math.abs(Ie-xe)<9e3||Math.abs(h(ce[0].pts-z,Ie)-xe)<20*te),ce.forEach(function(oe){oe.pts=h(oe.pts-z,Ie)}),!a||xe<0){if(ce=ce.filter(function(oe){return oe.pts>=0}),!ce.length)return;c===0?xe=0:y?xe=Math.max(0,Ie):xe=ce[0].pts}if(d.isAAC)for(var Te=c!==void 0,Oe=this.config.maxAudioFramesDrift,Ce=0,Ae=xe;Ce<ce.length;Ce++){var ve=ce[Ce],W=ve.pts,L=W-Ae,k=Math.abs(1e3*L/S);if(L<=-Oe*te&&Te)Ce===0&&(I.logger.warn("Audio frame @ "+(W/S).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*L/S)+" ms."),this.nextAudioPts=xe=Ae=W);else if(L>=Oe*te&&k<R&&Te){var H=Math.round(L/te);Ae=W-H*te,Ae<0&&(H--,Ae+=te),Ce===0&&(this.nextAudioPts=xe=Ae),I.logger.warn("[mp4-remuxer]: Injecting "+H+" audio frame @ "+(Ae/S).toFixed(3)+"s due to "+Math.round(1e3*L/S)+" ms gap.");for(var q=0;q<H;q++){var B=Math.max(Ae,0),ue=M.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);ue||(I.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ue=ve.unit.subarray()),ce.splice(Ce,0,{unit:ue,pts:B}),Ae+=te,Ce++}}ve.pts=Ae,Ae+=te}for(var be=null,we=null,Pe,_e=0,De=ce.length;De--;)_e+=ce[De].unit.byteLength;for(var Me=0,We=ce.length;Me<We;Me++){var ze=ce[Me],Xe=ze.unit,Ge=ze.pts;if(we!==null){var at=ne[Me-1];at.duration=Math.round((Ge-we)/G)}else if(a&&d.isAAC&&(Ge=xe),be=Ge,_e>0){_e+=ge;try{Pe=new Uint8Array(_e)}catch(oe){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating audio mdat "+_e});return}if(!F){var $e=new DataView(Pe.buffer);$e.setUint32(0,_e),Pe.set(D.default.types.mdat,4)}}else return;Pe.set(Xe,ge);var Ve=Xe.byteLength;ge+=Ve,ne.push(new m(!0,X,Ve,0)),we=Ge}var Le=ne.length;if(!Le)return;var tt=ne[ne.length-1];this.nextAudioPts=xe=we+G*tt.duration;var qe=F?new Uint8Array(0):D.default.moof(d.sequenceNumber++,be/G,g({},d,{samples:ne}));d.samples=[];var ae=be/S,J=xe/S,Z="audio",ie={data1:qe,data2:Pe,startPTS:ae,endPTS:J,startDTS:ae,endDTS:J,type:Z,hasAudio:!0,hasVideo:!1,nb:Le};return this.isAudioContiguous=!0,console.assert(Pe.length,"MDAT length must not be zero"),ie},E.remuxEmptyAudio=function(d,u,a,y){var c=d.inputTimeScale,S=d.samplerate?d.samplerate:c,P=c/S,G=this.nextAudioPts,X=(G!==null?G:y.startDTS*c)+this._initDTS,te=y.endDTS*c+this._initDTS,z=P*w,F=Math.ceil((te-X)/z),ne=M.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(I.logger.warn("[mp4-remuxer]: remux empty Audio"),!ne){I.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ce=[],ge=0;ge<F;ge++){var xe=X+ge*z;ce.push({unit:ne,pts:xe,dts:xe})}return d.samples=ce,this.remuxAudio(d,u,a,!1)},E.remuxID3=function(d,u){var a=d.samples.length;if(!a)return;for(var y=d.inputTimeScale,c=this._initPTS,S=this._initDTS,P=0;P<a;P++){var G=d.samples[P];G.pts=h(G.pts-c,u*y)/y,G.dts=h(G.dts-S,u*y)/y}var X=d.samples;return d.samples=[],{samples:X}},E.remuxText=function(d,u){var a=d.samples.length;if(!a)return;for(var y=d.inputTimeScale,c=this._initPTS,S=0;S<a;S++){var P=d.samples[S];P.pts=h(P.pts-c,u*y)/y}d.samples.sort(function(X,te){return X.pts-te.pts});var G=d.samples;return d.samples=[],{samples:G}},A}();function h(A,E){var f;if(E===null)return A;for(E<A?f=-8589934592:f=8589934592;Math.abs(A-E)>4294967296;)A+=f;return A}function C(A){for(var E=0;E<A.length;E++)if(A[E].key)return E;return-1}var m=function(E,f,d,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=d,this.cts=u,this.flags=new p(E)},p=function(E){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=E?2:1,this.isNonSync=E?0:1}},"./src/remux/passthrough-remuxer.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),M=_("./src/utils/mp4-tools.ts"),D=_("./src/loader/fragment.ts"),j=_("./src/utils/logger.ts"),U=function(){function v(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var g=v.prototype;return g.destroy=function(){},g.resetTimeStamp=function(w){this.initPTS=w,this.lastEndDTS=null},g.resetNextTimestamp=function(){this.lastEndDTS=null},g.resetInitSegment=function(w,b,x){this.audioCodec=b,this.videoCodec=x,this.generateInitSegment(w),this.emitInitSegment=!0},g.generateInitSegment=function(w){var b=this.audioCodec,x=this.videoCodec;if(!w||!w.byteLength){this.initTracks=void 0,this.initData=void 0;return}var l=this.initData=Object(M.parseInitSegment)(w);b||(b=O(l.audio,D.ElementaryStreamTypes.AUDIO)),x||(x=O(l.video,D.ElementaryStreamTypes.VIDEO));var o={};l.audio&&l.video?o.audiovideo={container:"video/mp4",codec:b+","+x,initSegment:w,id:"main"}:l.audio?o.audio={container:"audio/mp4",codec:b,initSegment:w,id:"audio"}:l.video?o.video={container:"video/mp4",codec:x,initSegment:w,id:"main"}:j.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},g.remux=function(w,b,x,l,o){var s=this.initPTS,h=this.lastEndDTS,C={audio:void 0,video:void 0,text:l,id3:x,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var m=b.samples;if(!m||!m.length)return C;var p={initPTS:void 0,timescale:1},A=this.initData;if((!A||!A.length)&&(this.generateInitSegment(m),A=this.initData),!A||!A.length)return j.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),C;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(s)||(this.initPTS=p.initPTS=s=I(A,m,h));var E=Object(M.getDuration)(m,A),f=h,d=E+f;Object(M.offsetStartDTS)(A,m,s),E>0?this.lastEndDTS=d:(j.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!A.audio,a=!!A.video,y="";u&&(y+="audio"),a&&(y+="video");var c={data1:m,startPTS:f,startDTS:f,endPTS:d,endDTS:d,type:y,hasAudio:u,hasVideo:a,nb:1,dropped:0};return C.audio=c.type==="audio"?c:void 0,C.video=c.type!=="audio"?c:void 0,C.text=l,C.id3=x,C.initSegment=p,C},v}(),I=function(g,R,w){return Object(M.getStartDTS)(g,R)-w};function O(v,g){var R=v==null?void 0:v.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||g===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=U},"./src/task-loop.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function M(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=M.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(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!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(){},M}()},"./src/types/cmcd.ts":function(fe,$,_){"use strict";_.r($),_.d($,"CMCDVersion",function(){return V}),_.d($,"CMCDObjectType",function(){return M}),_.d($,"CMCDStreamingFormat",function(){return D}),_.d($,"CMCDStreamType",function(){return j});var V=1,M;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(M||(M={}));var D;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(D||(D={}));var j;(function(U){U.VOD="v",U.LIVE="l"})(j||(j={}))},"./src/types/level.ts":function(fe,$,_){"use strict";_.r($),_.d($,"HlsSkip",function(){return D}),_.d($,"getSkipValue",function(){return j}),_.d($,"HlsUrlParameters",function(){return U}),_.d($,"Level",function(){return I});function V(O,v){for(var g=0;g<v.length;g++){var R=v[g];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function M(O,v,g){return v&&V(O.prototype,v),g&&V(O,g),O}var D;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(D||(D={}));function j(O,v){var g=O.canSkipUntil,R=O.canSkipDateRanges,w=O.endSN,b=v!==void 0?v-w:0;return g&&b<g?R?D.v2:D.Yes:D.No}var U=function(){function O(g,R,w){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=g,this.part=R,this.skip=w}var v=O.prototype;return v.addDirectives=function(R){var w=new self.URL(R);return this.msn!==void 0&&w.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&w.searchParams.set("_HLS_part",this.part.toString()),this.skip&&w.searchParams.set("_HLS_skip",this.skip),w.toString()},O}(),I=function(){function O(v){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[v.url],this.attrs=v.attrs,this.bitrate=v.bitrate,v.details&&(this.details=v.details),this.id=v.id||0,this.name=v.name,this.width=v.width||0,this.height=v.height||0,this.audioCodec=v.audioCodec,this.videoCodec=v.videoCodec,this.unknownCodecs=v.unknownCodecs,this.codecSet=[v.videoCodec,v.audioCodec].filter(function(g){return g}).join(",").replace(/\.[^.,]+/g,"")}return M(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(g){var R=g%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),O}()},"./src/types/loader.ts":function(fe,$,_){"use strict";_.r($),_.d($,"PlaylistContextType",function(){return V}),_.d($,"PlaylistLevelType",function(){return M});var V;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var M;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(M||(M={}))},"./src/types/transmuxer.ts":function(fe,$,_){"use strict";_.r($),_.d($,"ChunkMetadata",function(){return V});var V=function(j,U,I,O,v,g){O===void 0&&(O=0),v===void 0&&(v=-1),g===void 0&&(g=!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=M(),this.buffering={audio:M(),video:M(),audiovideo:M()},this.level=j,this.sn=U,this.id=I,this.size=O,this.part=v,this.partial=g};function M(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(fe,$,_){"use strict";_.r($),_.d($,"AttrList",function(){return D});var V=/^(\d+)x(\d+)$/,M=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function j(I){typeof I=="string"&&(I=j.parseAttrList(I));for(var O in I)I.hasOwnProperty(O)&&(this[O]=I[O])}var U=j.prototype;return U.decimalInteger=function(O){var v=parseInt(this[O],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},U.hexadecimalInteger=function(O){if(this[O]){var v=(this[O]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var g=new Uint8Array(v.length/2),R=0;R<v.length/2;R++)g[R]=parseInt(v.slice(R*2,R*2+2),16);return g}else return null},U.hexadecimalIntegerAsNumber=function(O){var v=parseInt(this[O],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},U.decimalFloatingPoint=function(O){return parseFloat(this[O])},U.optionalFloat=function(O,v){var g=this[O];return g?parseFloat(g):v},U.enumeratedString=function(O){return this[O]},U.bool=function(O){return this[O]==="YES"},U.decimalResolution=function(O){var v=V.exec(this[O]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},j.parseAttrList=function(O){var v,g={},R='"';for(M.lastIndex=0;(v=M.exec(O))!==null;){var w=v[2];w.indexOf(R)===0&&w.lastIndexOf(R)===w.length-1&&(w=w.slice(1,-1)),g[v[1]]=w}return g},j}()},"./src/utils/binary-search.ts":function(fe,$,_){"use strict";_.r($);var V={search:function(D,j){for(var U=0,I=D.length-1,O=null,v=null;U<=I;){O=(U+I)/2|0,v=D[O];var g=j(v);if(g>0)U=O+1;else if(g<0)I=O-1;else return v}return null}};$.default=V},"./src/utils/buffer-helper.ts":function(fe,$,_){"use strict";_.r($),_.d($,"BufferHelper",function(){return D});var V=_("./src/utils/logger.ts"),M={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function j(){}return j.isBuffered=function(I,O){try{if(I){for(var v=j.getBuffered(I),g=0;g<v.length;g++)if(O>=v.start(g)&&O<=v.end(g))return!0}}catch(R){}return!1},j.bufferInfo=function(I,O,v){try{if(I){var g=j.getBuffered(I),R=[],w;for(w=0;w<g.length;w++)R.push({start:g.start(w),end:g.end(w)});return this.bufferedInfo(R,O,v)}}catch(b){}return{len:0,start:O,end:O,nextStart:void 0}},j.bufferedInfo=function(I,O,v){O=Math.max(0,O),I.sort(function(p,A){var E=p.start-A.start;return E||A.end-p.end});var g=[];if(v)for(var R=0;R<I.length;R++){var w=g.length;if(w){var b=g[w-1].end;I[R].start-b<v?I[R].end>b&&(g[w-1].end=I[R].end):g.push(I[R])}else g.push(I[R])}else g=I;for(var x=0,l,o=O,s=O,h=0;h<g.length;h++){var C=g[h].start,m=g[h].end;if(O+v>=C&&O<m)o=C,s=m,x=s-O;else if(O+v<C){l=C;break}}return{len:x,start:o||0,end:s||0,nextStart:l}},j.getBuffered=function(I){try{return I.buffered}catch(O){return V.logger.log("failed to get media.buffered",O),M}},j}()},"./src/utils/cea-608-parser.ts":function(fe,$,_){"use strict";_.r($),_.d($,"Row",function(){return s}),_.d($,"CaptionScreen",function(){return h});var V=_("./src/utils/logger.ts"),M={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(d){var u=d;return M.hasOwnProperty(d)&&(u=M[d]),String.fromCharCode(u)},j=15,U=100,I={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},v={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},g={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],w;(function(f){f[f.ERROR=0]="ERROR",f[f.TEXT=1]="TEXT",f[f.WARNING=2]="WARNING",f[f.INFO=2]="INFO",f[f.DEBUG=3]="DEBUG",f[f.DATA=3]="DATA"})(w||(w={}));var b=function(){function f(){this.time=null,this.verboseLevel=w.ERROR}var d=f.prototype;return d.log=function(a,y){this.verboseLevel>=a&&V.logger.log(this.time+" ["+a+"] "+y)},f}(),x=function(d){for(var u=[],a=0;a<d.length;a++)u.push(d[a].toString(16));return u},l=function(){function f(u,a,y,c,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=a||!1,this.italics=y||!1,this.background=c||"black",this.flash=S||!1}var d=f.prototype;return d.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},d.setStyles=function(a){for(var y=["foreground","underline","italics","background","flash"],c=0;c<y.length;c++){var S=y[c];a.hasOwnProperty(S)&&(this[S]=a[S])}},d.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},d.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},d.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},d.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),o=function(){function f(u,a,y,c,S,P){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new l(a,y,c,S,P)}var d=f.prototype;return d.reset=function(){this.uchar=" ",this.penState.reset()},d.setChar=function(a,y){this.uchar=a,this.penState.copy(y)},d.setPenState=function(a){this.penState.copy(a)},d.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},d.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},d.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},f}(),s=function(){function f(u){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<U;a++)this.chars.push(new o);this.logger=u,this.pos=0,this.currPenState=new l}var d=f.prototype;return d.equals=function(a){for(var y=!0,c=0;c<U;c++)if(!this.chars[c].equals(a.chars[c])){y=!1;break}return y},d.copy=function(a){for(var y=0;y<U;y++)this.chars[y].copy(a.chars[y])},d.isEmpty=function(){for(var a=!0,y=0;y<U;y++)if(!this.chars[y].isEmpty()){a=!1;break}return a},d.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(w.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(w.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},d.moveCursor=function(a){var y=this.pos+a;if(a>1)for(var c=this.pos+1;c<y+1;c++)this.chars[c].setPenState(this.currPenState);this.setCursor(y)},d.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},d.insertChar=function(a){a>=144&&this.backSpace();var y=D(a);if(this.pos>=U){this.logger.log(w.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)},d.clearFromPos=function(a){var y;for(y=a;y<U;y++)this.chars[y].reset()},d.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},d.clearToEndOfRow=function(){this.clearFromPos(this.pos)},d.getTextString=function(){for(var a=[],y=!0,c=0;c<U;c++){var S=this.chars[c].uchar;S!==" "&&(y=!1),a.push(S)}return y?"":a.join("")},d.setPenStyles=function(a){this.currPenState.setStyles(a);var y=this.chars[this.pos];y.setPenState(this.currPenState)},f}(),h=function(){function f(u){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(u));this.logger=u,this.currRow=j-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var d=f.prototype;return d.reset=function(){for(var a=0;a<j;a++)this.rows[a].clear();this.currRow=j-1},d.equals=function(a){for(var y=!0,c=0;c<j;c++)if(!this.rows[c].equals(a.rows[c])){y=!1;break}return y},d.copy=function(a){for(var y=0;y<j;y++)this.rows[y].copy(a.rows[y])},d.isEmpty=function(){for(var a=!0,y=0;y<j;y++)if(!this.rows[y].isEmpty()){a=!1;break}return a},d.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},d.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},d.insertChar=function(a){var y=this.rows[this.currRow];y.insertChar(a)},d.setPen=function(a){var y=this.rows[this.currRow];y.setPenStyles(a)},d.moveCursor=function(a){var y=this.rows[this.currRow];y.moveCursor(a)},d.setCursor=function(a){this.logger.log(w.INFO,"setCursor: "+a);var y=this.rows[this.currRow];y.setCursor(a)},d.setPAC=function(a){this.logger.log(w.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 c=0;c<j;c++)this.rows[c].clear();var S=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var G=P.rows[S].cueStartTime,X=this.logger.time;if(G&&X!==null&&G<X)for(var te=0;te<this.nrRollUpRows;te++)this.rows[y-this.nrRollUpRows+te+1].copy(P.rows[S+te])}}this.currRow=y;var z=this.rows[this.currRow];if(a.indent!==null){var F=a.indent,ne=Math.max(F-1,0);z.setCursor(a.indent),a.color=z.chars[ne].penState.foreground}var ce={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ce)},d.setBkgData=function(a){this.logger.log(w.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},d.setRollUpRows=function(a){this.nrRollUpRows=a},d.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(w.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(w.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(w.INFO,"Rolling up")},d.getDisplayText=function(a){a=a||!1;for(var y=[],c="",S=-1,P=0;P<j;P++){var G=this.rows[P].getTextString();G&&(S=P+1,a?y.push("Row "+S+": '"+G+"'"):y.push(G.trim()))}return y.length>0&&(a?c="["+y.join(" | ")+"]":c=y.join(`
`)),c},d.getTextAndFormat=function(){return this.rows},f}(),C=function(){function f(u,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=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(y),this.nonDisplayedMemory=new h(y),this.lastOutputScreen=new h(y),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=y}var d=f.prototype;return d.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},d.getHandler=function(){return this.outputFilter},d.setHandler=function(a){this.outputFilter=a},d.setPAC=function(a){this.writeScreen.setPAC(a)},d.setBkgData=function(a){this.writeScreen.setBkgData(a)},d.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(w.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},d.insertChars=function(a){for(var y=0;y<a.length;y++)this.writeScreen.insertChar(a[y]);var c=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(w.INFO,c+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(w.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},d.ccRCL=function(){this.logger.log(w.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},d.ccBS=function(){if(this.logger.log(w.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},d.ccAOF=function(){},d.ccAON=function(){},d.ccDER=function(){this.logger.log(w.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},d.ccRU=function(a){this.logger.log(w.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},d.ccFON=function(){this.logger.log(w.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},d.ccRDC=function(){this.logger.log(w.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},d.ccTR=function(){this.logger.log(w.INFO,"TR"),this.setMode("MODE_TEXT")},d.ccRTD=function(){this.logger.log(w.INFO,"RTD"),this.setMode("MODE_TEXT")},d.ccEDM=function(){this.logger.log(w.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},d.ccCR=function(){this.logger.log(w.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},d.ccENM=function(){this.logger.log(w.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},d.ccEOC=function(){if(this.logger.log(w.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(w.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},d.ccTO=function(a){this.logger.log(w.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},d.ccMIDROW=function(a){var y={flash:!1};if(y.underline=a%2===1,y.italics=a>=46,y.italics)y.foreground="white";else{var c=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];y.foreground=S[c]}this.logger.log(w.INFO,"MIDROW: "+JSON.stringify(y)),this.writeScreen.setPen(y)},d.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))},d.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),m=function(){function f(u,a,y){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var c=new b;this.channels=[null,new C(u,a,c),new C(u+1,y,c)],this.cmdHistory=E(),this.logger=c}var d=f.prototype;return d.getHandler=function(a){return this.channels[a].getHandler()},d.setHandler=function(a,y){this.channels[a].setHandler(y)},d.addData=function(a,y){var c,S,P,G=!1;this.logger.time=a;for(var X=0;X<y.length;X+=2){if(S=y[X]&127,P=y[X+1]&127,S===0&&P===0)continue;if(this.logger.log(w.DATA,"["+x([y[X],y[X+1]])+"] -> ("+x([S,P])+")"),c=this.parseCmd(S,P),c||(c=this.parseMidrow(S,P)),c||(c=this.parsePAC(S,P)),c||(c=this.parseBackgroundAttributes(S,P)),!c&&(G=this.parseChars(S,P),G)){var te=this.currentChannel;if(te&&te>0){var z=this.channels[te];z.insertChars(G)}else this.logger.log(w.WARNING,"No channel found yet. TEXT-MODE?")}!c&&!G&&this.logger.log(w.WARNING,"Couldn't parse cleaned data "+x([S,P])+" orig: "+x([y[X],y[X+1]]))}},d.parseCmd=function(a,y){var c=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&y>=32&&y<=47,P=(a===23||a===31)&&y>=33&&y<=35;if(!(S||P))return!1;if(A(a,y,c))return p(null,null,c),this.logger.log(w.DEBUG,"Repeated command ("+x([a,y])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,X=this.channels[G];return a===20||a===21||a===28||a===29?y===32?X.ccRCL():y===33?X.ccBS():y===34?X.ccAOF():y===35?X.ccAON():y===36?X.ccDER():y===37?X.ccRU(2):y===38?X.ccRU(3):y===39?X.ccRU(4):y===40?X.ccFON():y===41?X.ccRDC():y===42?X.ccTR():y===43?X.ccRTD():y===44?X.ccEDM():y===45?X.ccCR():y===46?X.ccENM():y===47&&X.ccEOC():X.ccTO(y-32),p(a,y,c),this.currentChannel=G,!0},d.parseMidrow=function(a,y){var c=0;if((a===17||a===25)&&y>=32&&y<=47){if(a===17?c=1:c=2,c!==this.currentChannel)return this.logger.log(w.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[c];return S?(S.ccMIDROW(y),this.logger.log(w.DEBUG,"MIDROW ("+x([a,y])+")"),!0):!1}return!1},d.parsePAC=function(a,y){var c,S=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&y>=64&&y<=127,G=(a===16||a===24)&&y>=64&&y<=95;if(!(P||G))return!1;if(A(a,y,S))return p(null,null,S),!0;var X=a<=23?1:2;y>=64&&y<=95?c=X===1?I[a]:v[a]:c=X===1?O[a]:g[a];var te=this.channels[X];return te?(te.setPAC(this.interpretPAC(c,y)),p(a,y,S),this.currentChannel=X,!0):!1},d.interpretPAC=function(a,y){var c,S={color:null,italics:!1,indent:null,underline:!1,row:a};return y>95?c=y-96:c=y-64,S.underline=(c&1)===1,c<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(c/2)]:c<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((c-16)/2)*4,S},d.parseChars=function(a,y){var c,S=null,P=null;if(a>=25?(c=2,P=a-8):(c=1,P=a),P>=17&&P<=19){var G;P===17?G=y+80:P===18?G=y+112:G=y+144,this.logger.log(w.INFO,"Special char '"+D(G)+"' in channel "+c),S=[G]}else a>=32&&a<=127&&(S=y===0?[a]:[a,y]);if(S){var X=x(S);this.logger.log(w.DEBUG,"Char codes = "+X.join(",")),p(a,y,this.cmdHistory)}return S},d.parseBackgroundAttributes=function(a,y){var c=(a===16||a===24)&&y>=32&&y<=47,S=(a===23||a===31)&&y>=45&&y<=47;if(!(c||S))return!1;var P,G={};a===16||a===24?(P=Math.floor((y-32)/2),G.background=R[P],y%2===1&&(G.background=G.background+"_semi")):y===45?G.background="transparent":(G.foreground="black",y===47&&(G.underline=!0));var X=a<=23?1:2,te=this.channels[X];return te.setBkgData(G),p(a,y,this.cmdHistory),!0},d.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var y=this.channels[a];y&&y.reset()}this.cmdHistory=E()},d.cueSplitAtTime=function(a){for(var y=0;y<this.channels.length;y++){var c=this.channels[y];c&&c.cueSplitAtTime(a)}},f}();function p(f,d,u){u.a=f,u.b=d}function A(f,d,u){return u.a===f&&u.b===d}function E(){return{a:null,b:null}}$.default=m},"./src/utils/codecs.ts":function(fe,$,_){"use strict";_.r($),_.d($,"isCodecType",function(){return M}),_.d($,"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 M(j,U){var I=V[U];return!!I&&I[j.slice(0,4)]===!0}function D(j,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+j+'"')}},"./src/utils/cues.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/utils/vttparser.ts"),M=_("./src/utils/webvtt-parser.ts"),D=_("./src/utils/texttrack-utils.ts"),j=/\s/,U={newCue:function(O,v,g,R){for(var w=[],b,x,l,o,s,h=self.VTTCue||self.TextTrackCue,C=0;C<R.rows.length;C++)if(b=R.rows[C],l=!0,o=0,s="",!b.isEmpty()){for(var m=0;m<b.chars.length;m++)j.test(b.chars[m].uchar)&&l?o++:(s+=b.chars[m].uchar,l=!1);b.cueStartTime=v,v===g&&(g+=1e-4),o>=16?o--:o++;var p=Object(V.fixLineBreaks)(s.trim()),A=Object(M.generateCueId)(v,g,p);(!O||!O.cues||!O.cues.getCueById(A))&&(x=new h(v,g,p),x.id=A,x.line=C+1,x.align="left",x.position=10+Math.min(80,Math.floor(o*8/32)*10),w.push(x))}return O&&w.length&&(w.sort(function(E,f){return E.line==="auto"||f.line==="auto"?0:E.line>8&&f.line>8?f.line-E.line:E.line-f.line}),w.forEach(function(E){return Object(D.addCueToTrack)(O,E)})),w}};$.default=U},"./src/utils/discontinuities.ts":function(fe,$,_){"use strict";_.r($),_.d($,"findFirstFragWithCC",function(){return j}),_.d($,"shouldAlignOnDiscontinuities",function(){return U}),_.d($,"findDiscontinuousReferenceFrag",function(){return I}),_.d($,"adjustSlidingStart",function(){return v}),_.d($,"alignStream",function(){return g}),_.d($,"alignPDT",function(){return w}),_.d($,"alignFragmentByPDTDelta",function(){return b}),_.d($,"alignMediaPlaylistByPDT",function(){return x});var V=_("./src/polyfills/number.ts"),M=_("./src/utils/logger.ts"),D=_("./src/controller/level-helper.ts");function j(l,o){for(var s=null,h=0,C=l.length;h<C;h++){var m=l[h];if(m&&m.cc===o){s=m;break}}return s}function U(l,o,s){return!!(o.details&&(s.endCC>s.startCC||l&&l.cc<s.startCC))}function I(l,o){var s=l.fragments,h=o.fragments;if(!h.length||!s.length){M.logger.log("No fragments to align");return}var C=j(s,h[0].cc);if(!C||C&&!C.startPTS){M.logger.log("No frag in previous level to align on");return}return C}function O(l,o){if(l){var s=l.start+o;l.start=l.startPTS=s,l.endPTS=s+l.duration}}function v(l,o){for(var s=o.fragments,h=0,C=s.length;h<C;h++)O(s[h],l);o.fragmentHint&&O(o.fragmentHint,l),o.alignedSliding=!0}function g(l,o,s){if(!o)return;R(l,s,o),!s.alignedSliding&&o.details&&w(s,o.details),!s.alignedSliding&&o.details&&!s.skippedSegments&&Object(D.adjustSliding)(o.details,s)}function R(l,o,s){if(U(l,s,o)){var h=I(s.details,o);h&&Object(V.isFiniteNumber)(h.start)&&(M.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(h.start,o))}}function w(l,o){if(!o.fragments.length||!l.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,h=l.fragments[0].programDateTime,C=(h-s)/1e3+o.fragments[0].start;C&&Object(V.isFiniteNumber)(C)&&(M.logger.log("Adjusting PTS using programDateTime delta "+(h-s)+"ms, sliding:"+C.toFixed(3)+" "+l.url+" "),v(C,l))}function b(l,o){var s=l.programDateTime;if(!s)return;var h=(s-o)/1e3;l.start=l.startPTS=h,l.endPTS=h+l.duration}function x(l,o){if(!o.fragments.length||!l.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,h=o.fragments[0].start,C=s-h*1e3;l.fragments.forEach(function(m){b(m,C)}),l.fragmentHint&&b(l.fragmentHint,C),l.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/utils/ewma.ts"),M=function(){function D(U,I,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(U),this.fast_=new V.default(I)}var j=D.prototype;return j.update=function(I,O){var v=this.slow_,g=this.fast_;this.slow_.halfLife!==I&&(this.slow_=new V.default(I,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==O&&(this.fast_=new V.default(O,g.getEstimate(),g.getTotalWeight()))},j.sample=function(I,O){I=Math.max(I,this.minDelayMs_);var v=8*O,g=I/1e3,R=v/g;this.fast_.sample(g,R),this.slow_.sample(g,R)},j.canEstimate=function(){var I=this.fast_;return I&&I.getTotalWeight()>=this.minWeight_},j.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},j.destroy=function(){},D}();$.default=M},"./src/utils/ewma.ts":function(fe,$,_){"use strict";_.r($);var V=function(){function M(j,U,I){U===void 0&&(U=0),I===void 0&&(I=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_=U,this.totalWeight_=I}var D=M.prototype;return D.sample=function(U,I){var O=Math.pow(this.alpha_,U);this.estimate_=I*(1-O)+O*this.estimate_,this.totalWeight_+=U},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var U=1-Math.pow(this.alpha_,this.totalWeight_);if(U)return this.estimate_/U}return this.estimate_},M}();$.default=V},"./src/utils/fetch-loader.ts":function(fe,$,_){"use strict";_.r($),_.d($,"fetchSupported",function(){return b});var V=_("./src/polyfills/number.ts"),M=_("./src/loader/load-stats.ts"),D=_("./src/demux/chunk-cache.ts");function j(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,g(h,C)}function U(h){var C=typeof Map=="function"?new Map:void 0;return U=function(p){if(p===null||!v(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof C!="undefined"){if(C.has(p))return C.get(p);C.set(p,A)}function A(){return I(p,arguments,R(this).constructor)}return A.prototype=Object.create(p.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),g(A,p)},U(h)}function I(h,C,m){return O()?I=Reflect.construct:I=function(A,E,f){var d=[null];d.push.apply(d,E);var u=Function.bind.apply(A,d),a=new u;return f&&g(a,f.prototype),a},I.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function v(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function g(h,C){return g=Object.setPrototypeOf||function(p,A){return p.__proto__=A,p},g(h,C)}function R(h){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)},R(h)}function w(){return w=Object.assign||function(h){for(var C=1;C<arguments.length;C++){var m=arguments[C];for(var p in m)Object.prototype.hasOwnProperty.call(m,p)&&(h[p]=m[p])}return h},w.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var x=function(){function h(m){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=m.fetchSetup||o,this.controller=new self.AbortController,this.stats=new M.LoadStats}var C=h.prototype;return C.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},C.abortInternal=function(){var p=this.response;(!p||!p.ok)&&(this.stats.aborted=!0,this.controller.abort())},C.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},C.load=function(p,A,E){var f=this,d=this.stats;if(d.loading.start)throw new Error("Loader can only be used once.");d.loading.start=self.performance.now();var u=l(p,this.controller.signal),a=E.onProgress,y=p.responseType==="arraybuffer",c=y?"byteLength":"length";this.context=p,this.config=A,this.callbacks=E,this.request=this.fetchSetup(p,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),E.onTimeout(d,p,f.response)},A.timeout),self.fetch(this.request).then(function(S){if(f.response=f.loader=S,!S.ok){var P=S.status,G=S.statusText;throw new s(G||"fetch, bad network response",P,S)}return d.loading.first=Math.max(self.performance.now(),d.loading.start),d.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(V.isFiniteNumber)(A.highWaterMark)?f.loadProgressively(S,d,p,A.highWaterMark,a):y?S.arrayBuffer():S.text()}).then(function(S){var P=f.response;self.clearTimeout(f.requestTimeout),d.loading.end=Math.max(self.performance.now(),d.loading.first),d.loaded=d.total=S[c];var G={url:P.url,data:S};a&&!Object(V.isFiniteNumber)(A.highWaterMark)&&a(d,p,S,P),E.onSuccess(G,d,p,P)}).catch(function(S){if(self.clearTimeout(f.requestTimeout),d.aborted)return;var P=S.code||0;E.onError({code:P,text:S.message},p,S.details)})},C.getCacheAge=function(){var p=null;if(this.response){var A=this.response.headers.get("age");p=A?parseFloat(A):null}return p},C.loadProgressively=function(p,A,E,f,d){f===void 0&&(f=0);var u=new D.default,a=p.body.getReader(),y=function c(){return a.read().then(function(S){if(S.done)return u.dataLength&&d(A,E,u.flush(),p),Promise.resolve(new ArrayBuffer(0));var P=S.value,G=P.length;return A.loaded+=G,G<f||u.dataLength?(u.push(P),u.dataLength>=f&&d(A,E,u.flush(),p)):d(A,E,P,p),c()}).catch(function(){return Promise.reject()})};return y()},h}();function l(h,C){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:C,headers:new self.Headers(w({},h.headers))};return h.rangeEnd&&m.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),m}function o(h,C){return new self.Request(h.url,C)}var s=function(h){j(C,h);function C(m,p,A){var E;return E=h.call(this,m)||this,E.code=void 0,E.details=void 0,E.code=p,E.details=A,E}return C}(U(Error));$.default=x},"./src/utils/imsc1-ttml-parser.ts":function(fe,$,_){"use strict";_.r($),_.d($,"IMSC1_CODEC",function(){return v}),_.d($,"parseIMSC1",function(){return b});var V=_("./src/utils/mp4-tools.ts"),M=_("./src/utils/vttparser.ts"),D=_("./src/utils/vttcue.ts"),j=_("./src/demux/id3.ts"),U=_("./src/utils/timescale-conversion.ts"),I=_("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(f[a]=u[a])}return f},O.apply(this,arguments)}var v="stpp.ttml.im1t",g=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,w={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(f,d,u,a,y){var c=Object(V.findBox)(new Uint8Array(f),["mdat"]);if(c.length===0){y(new Error("Could not parse IMSC1 mdat"));return}var S=c[0],P=Object(j.utf8ArrayToStr)(new Uint8Array(f,S.start,S.end-S.start)),G=Object(U.toTimescaleFromScale)(d,1,u);try{a(x(P,G))}catch(X){y(X)}}function x(f,d){var u=new DOMParser,a=u.parseFromString(f,"text/xml"),y=a.getElementsByTagName("tt")[0];if(!y)throw new Error("Invalid ttml");var c={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(c).reduce(function(z,F){return z[F]=y.getAttribute("ttp:"+F)||c[F],z},{}),P=y.getAttribute("xml:space")!=="preserve",G=o(l(y,"styling","style")),X=o(l(y,"layout","region")),te=l(y,"body","[begin]");return[].map.call(te,function(z){var F=s(z,P);if(!F||!z.hasAttribute("begin"))return null;var ne=p(z.getAttribute("begin"),S),ce=p(z.getAttribute("dur"),S),ge=p(z.getAttribute("end"),S);if(ne===null)throw m(z);if(ge===null){if(ce===null)throw m(z);ge=ne+ce}var xe=new D.default(ne-d,ge-d,F);xe.id=Object(I.generateCueId)(xe.startTime,xe.endTime,xe.text);var Ie=X[z.getAttribute("region")],Te=G[z.getAttribute("style")];xe.position=10,xe.size=80;var Oe=h(Ie,Te),Ce=Oe.textAlign;if(Ce){var Ae=w[Ce];Ae&&(xe.lineAlign=Ae),xe.align=Ce}return O(xe,Oe),xe}).filter(function(z){return z!==null})}function l(f,d,u){var a=f.getElementsByTagName(d)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function o(f){return f.reduce(function(d,u){var a=u.getAttribute("xml:id");return a&&(d[a]=u),d},{})}function s(f,d){return[].slice.call(f.childNodes).reduce(function(u,a,y){var c;return a.nodeName==="br"&&y?u+`
`:(c=a.childNodes)!==null&&c!==void 0&&c.length?s(a,d):d?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function h(f,d){var u="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(y,c){var S=C(d,u,c)||C(f,u,c);return S&&(y[c]=S),y},{})}function C(f,d,u){return f.hasAttributeNS(d,u)?f.getAttributeNS(d,u):null}function m(f){return new Error("Could not parse ttml timestamp "+f)}function p(f,d){if(!f)return null;var u=Object(M.parseTimeStamp)(f);return u===null&&(g.test(f)?u=A(f,d):R.test(f)&&(u=E(f,d))),u}function A(f,d){var u=g.exec(f),a=(u[4]|0)+(u[5]|0)/d.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/d.frameRate}function E(f,d){var u=R.exec(f),a=Number(u[1]),y=u[2];switch(y){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/d.frameRate;case"t":return a/d.tickRate}return a}},"./src/utils/logger.ts":function(fe,$,_){"use strict";_.r($),_.d($,"enableLogs",function(){return I}),_.d($,"logger",function(){return O});var V=function(){},M={trace:V,debug:V,log:V,warn:V,info:V,error:V},D=M;function j(v){var g=self.console[v];return g?g.bind(self.console,"["+v+"] >"):V}function U(v){for(var g=arguments.length,R=new Array(g>1?g-1:0),w=1;w<g;w++)R[w-1]=arguments[w];R.forEach(function(b){D[b]=v[b]?v[b].bind(v):j(b)})}function I(v){if(self.console&&v===!0||typeof v=="object"){U(v,"debug","log","info","warn","error");try{D.log()}catch(g){D=M}}else D=M}var O=D},"./src/utils/mediakeys-helper.ts":function(fe,$,_){"use strict";_.r($),_.d($,"KeySystems",function(){return V}),_.d($,"requestMediaKeySystemAccess",function(){return M});var V;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})(V||(V={}));var M=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(fe,$,_){"use strict";_.r($),_.d($,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(fe,$,_){"use strict";_.r($),_.d($,"bin2str",function(){return U}),_.d($,"readUint16",function(){return I}),_.d($,"readUint32",function(){return O}),_.d($,"writeUint32",function(){return v}),_.d($,"findBox",function(){return g}),_.d($,"parseSegmentIndex",function(){return R}),_.d($,"parseInitSegment",function(){return w}),_.d($,"getStartDTS",function(){return b}),_.d($,"getDuration",function(){return x}),_.d($,"computeRawDurationFromSamples",function(){return l}),_.d($,"offsetStartDTS",function(){return o}),_.d($,"segmentValidRange",function(){return s}),_.d($,"appendUint8Array",function(){return h});var V=_("./src/utils/typed-array.ts"),M=_("./src/loader/fragment.ts"),D=Math.pow(2,32)-1,j=[].push;function U(C){return String.fromCharCode.apply(null,C)}function I(C,m){"data"in C&&(m+=C.start,C=C.data);var p=C[m]<<8|C[m+1];return p<0?65536+p:p}function O(C,m){"data"in C&&(m+=C.start,C=C.data);var p=C[m]<<24|C[m+1]<<16|C[m+2]<<8|C[m+3];return p<0?4294967296+p:p}function v(C,m,p){"data"in C&&(m+=C.start,C=C.data),C[m]=p>>24,C[m+1]=p>>16&255,C[m+2]=p>>8&255,C[m+3]=p&255}function g(C,m){var p=[];if(!m.length)return p;var A,E,f;"data"in C?(A=C.data,E=C.start,f=C.end):(A=C,E=0,f=A.byteLength);for(var d=E;d<f;){var u=O(A,d),a=U(A.subarray(d+4,d+8)),y=u>1?d+u:f;if(a===m[0])if(m.length===1)p.push({data:A,start:d+8,end:y});else{var c=g({data:A,start:d+8,end:y},m.slice(1));c.length&&j.apply(p,c)}d=y}return p}function R(C){var m=g(C,["moov"]),p=m[0],A=p?p.end:null,E=g(C,["sidx"]);if(!E||!E[0])return null;var f=[],d=E[0],u=d.data[0],a=u===0?8:16,y=O(d,a);a+=4;var c=0,S=0;u===0?a+=8:a+=16,a+=2;var P=d.end+S,G=I(d,a);a+=2;for(var X=0;X<G;X++){var te=a,z=O(d,te);te+=4;var F=z&2147483647,ne=(z&2147483648)>>>31;if(ne===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ce=O(d,te);te+=4,f.push({referenceSize:F,subsegmentDuration:ce,info:{duration:ce/y,start:P,end:P+F-1}}),P+=F,te+=4,a=te}return{earliestPresentationTime:c,timescale:y,version:u,referencesCount:G,references:f,moovEndOffset:A}}function w(C){for(var m=[],p=g(C,["moov","trak"]),A=0;A<p.length;A++){var E=p[A],f=g(E,["tkhd"])[0];if(f){var d=f.data[f.start],u=d===0?12:20,a=O(f,u),y=g(E,["mdia","mdhd"])[0];if(y){d=y.data[y.start],u=d===0?12:20;var c=O(y,u),S=g(E,["mdia","hdlr"])[0];if(S){var P=U(S.data.subarray(S.start+8,S.start+12)),G={soun:M.ElementaryStreamTypes.AUDIO,vide:M.ElementaryStreamTypes.VIDEO}[P];if(G){var X=g(E,["mdia","minf","stbl","stsd"])[0],te=void 0;X&&(te=U(X.data.subarray(X.start+12,X.start+16))),m[a]={timescale:c,type:G},m[G]={timescale:c,id:a,codec:te}}}}}}var z=g(C,["moov","mvex","trex"]);return z.forEach(function(F){var ne=O(F,4),ce=m[ne];ce&&(ce.default={duration:O(F,12),flags:O(F,20)})}),m}function b(C,m){return g(m,["moof","traf"]).reduce(function(p,A){var E=g(A,["tfdt"])[0],f=E.data[E.start],d=g(A,["tfhd"]).reduce(function(u,a){var y=O(a,4),c=C[y];if(c){var S=O(E,4);f===1&&(S*=Math.pow(2,32),S+=O(E,8));var P=c.timescale||9e4,G=S/P;if(isFinite(G)&&(u===null||G<u))return G}return u},null);return d!==null&&isFinite(d)&&(p===null||d<p)?d:p},null)||0}function x(C,m){for(var p=0,A=0,E=0,f=g(C,["moof","traf"]),d=0;d<f.length;d++){var u=f[d],a=g(u,["tfhd"])[0],y=O(a,4),c=m[y];if(!c)continue;var S=c.default,P=O(a,0)|(S==null?void 0:S.flags),G=S==null?void 0:S.duration;P&8&&(P&2?G=O(a,12):G=O(a,8));for(var X=c.timescale||9e4,te=g(u,["trun"]),z=0;z<te.length;z++){if(G){var F=O(te[z],4);p=G*F}else p=l(te[z]);c.type===M.ElementaryStreamTypes.VIDEO?A+=p/X:c.type===M.ElementaryStreamTypes.AUDIO&&(E+=p/X)}}if(A===0&&E===0){var ne=R(C);if(ne!=null&&ne.references)return ne.references.reduce(function(ce,ge){return ce+ge.info.duration||0},0)}return A||E}function l(C){var m=O(C,0),p=8;m&1&&(p+=4),m&4&&(p+=4);for(var A=0,E=O(C,4),f=0;f<E;f++){if(m&256){var d=O(C,p);A+=d,p+=4}m&512&&(p+=4),m&1024&&(p+=4),m&2048&&(p+=4)}return A}function o(C,m,p){g(m,["moof","traf"]).forEach(function(A){g(A,["tfhd"]).forEach(function(E){var f=O(E,4),d=C[f];if(!d)return;var u=d.timescale||9e4;g(A,["tfdt"]).forEach(function(a){var y=a.data[a.start],c=O(a,4);if(y===0)v(a,4,c-p*u);else{c*=Math.pow(2,32),c+=O(a,8),c-=p*u,c=Math.max(c,0);var S=Math.floor(c/(D+1)),P=Math.floor(c%(D+1));v(a,4,S),v(a,8,P)}})})})}function s(C){var m={valid:null,remainder:null},p=g(C,["moof"]);if(p){if(p.length<2)return m.remainder=C,m}else return m;var A=p[p.length-1];return m.valid=Object(V.sliceUint8)(C,0,A.start-8),m.remainder=Object(V.sliceUint8)(C,A.start-8),m}function h(C,m){var p=new Uint8Array(C.length+m.length);return p.set(C),p.set(m,C.length),p}},"./src/utils/output-filter.ts":function(fe,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function M(j,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=j,this.trackName=U}var D=M.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(U,I,O){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=I,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[]},M}()},"./src/utils/texttrack-utils.ts":function(fe,$,_){"use strict";_.r($),_.d($,"sendAddTrackEvent",function(){return M}),_.d($,"addCueToTrack",function(){return D}),_.d($,"clearCurrentCues",function(){return j}),_.d($,"removeCuesInRange",function(){return U}),_.d($,"getCuesInRange",function(){return O});var V=_("./src/utils/logger.ts");function M(v,g){var R;try{R=new Event("addtrack")}catch(w){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=v,g.dispatchEvent(R)}function D(v,g){var R=v.mode;if(R==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(g.id))try{if(v.addCue(g),!v.cues.getCueById(g.id))throw new Error("addCue is failed for: "+g)}catch(b){V.logger.debug("[texttrack-utils]: "+b);var w=new self.TextTrackCue(g.startTime,g.endTime,g.text);w.id=g.id,v.addCue(w)}R==="disabled"&&(v.mode=R)}function j(v){var g=v.mode;if(g==="disabled"&&(v.mode="hidden"),v.cues)for(var R=v.cues.length;R--;)v.removeCue(v.cues[R]);g==="disabled"&&(v.mode=g)}function U(v,g,R){var w=v.mode;if(w==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var b=O(v.cues,g,R),x=0;x<b.length;x++)v.removeCue(b[x]);w==="disabled"&&(v.mode=w)}function I(v,g){if(g<v[0].startTime)return 0;var R=v.length-1;if(g>v[R].endTime)return-1;for(var w=0,b=R;w<=b;){var x=Math.floor((b+w)/2);if(g<v[x].startTime)b=x-1;else if(g>v[x].startTime&&w<R)w=x+1;else return x}return v[w].startTime-g<g-v[b].startTime?w:b}function O(v,g,R){var w=[],b=I(v,g);if(b>-1)for(var x=b,l=v.length;x<l;x++){var o=v[x];if(o.startTime>=g&&o.endTime<=R)w.push(o);else if(o.startTime>R)return w}return w}},"./src/utils/time-ranges.ts":function(fe,$,_){"use strict";_.r($);var V={toString:function(D){for(var j="",U=D.length,I=0;I<U;I++)j+="["+D.start(I).toFixed(3)+","+D.end(I).toFixed(3)+"]";return j}};$.default=V},"./src/utils/timescale-conversion.ts":function(fe,$,_){"use strict";_.r($),_.d($,"toTimescaleFromBase",function(){return M}),_.d($,"toTimescaleFromScale",function(){return D}),_.d($,"toMsFromMpegTsClock",function(){return j}),_.d($,"toMpegTsClockFromTimescale",function(){return U});var V=9e4;function M(I,O,v,g){v===void 0&&(v=1),g===void 0&&(g=!1);var R=I*O*v;return g?Math.round(R):R}function D(I,O,v,g){return v===void 0&&(v=1),g===void 0&&(g=!1),M(I,O,1/v,g)}function j(I,O){return O===void 0&&(O=!1),M(I,1e3,1/V,O)}function U(I,O){return O===void 0&&(O=1),M(I,V,1/O)}},"./src/utils/typed-array.ts":function(fe,$,_){"use strict";_.r($),_.d($,"sliceUint8",function(){return V});function V(M,D,j){return Uint8Array.prototype.slice?M.slice(D,j):new Uint8Array(Array.prototype.slice.call(M,D,j))}},"./src/utils/vttcue.ts":function(fe,$,_){"use strict";_.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],M=["start","middle","end","left","right"];function D(v,g){if(typeof g!="string")return!1;if(!Array.isArray(v))return!1;var R=g.toLowerCase();return~v.indexOf(R)?R:!1}function j(v){return D(V,v)}function U(v){return D(M,v)}function I(v){for(var g=arguments.length,R=new Array(g>1?g-1:0),w=1;w<g;w++)R[w-1]=arguments[w];for(var b=1;b<arguments.length;b++){var x=arguments[b];for(var l in x)v[l]=x[l]}return v}function O(v,g,R){var w=this,b={enumerable:!0};w.hasBeenReset=!1;var x="",l=!1,o=v,s=g,h=R,C=null,m="",p=!0,A="auto",E="start",f=50,d="middle",u=50,a="middle";Object.defineProperty(w,"id",I({},b,{get:function(){return x},set:function(c){x=""+c}})),Object.defineProperty(w,"pauseOnExit",I({},b,{get:function(){return l},set:function(c){l=!!c}})),Object.defineProperty(w,"startTime",I({},b,{get:function(){return o},set:function(c){if(typeof c!="number")throw new TypeError("Start time must be set to a number.");o=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"endTime",I({},b,{get:function(){return s},set:function(c){if(typeof c!="number")throw new TypeError("End time must be set to a number.");s=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"text",I({},b,{get:function(){return h},set:function(c){h=""+c,this.hasBeenReset=!0}})),Object.defineProperty(w,"region",I({},b,{get:function(){return C},set:function(c){C=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"vertical",I({},b,{get:function(){return m},set:function(c){var S=j(c);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");m=S,this.hasBeenReset=!0}})),Object.defineProperty(w,"snapToLines",I({},b,{get:function(){return p},set:function(c){p=!!c,this.hasBeenReset=!0}})),Object.defineProperty(w,"line",I({},b,{get:function(){return A},set:function(c){if(typeof c!="number"&&c!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");A=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"lineAlign",I({},b,{get:function(){return E},set:function(c){var S=U(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");E=S,this.hasBeenReset=!0}})),Object.defineProperty(w,"position",I({},b,{get:function(){return f},set:function(c){if(c<0||c>100)throw new Error("Position must be between 0 and 100.");f=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"positionAlign",I({},b,{get:function(){return d},set:function(c){var S=U(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(w,"size",I({},b,{get:function(){return u},set:function(c){if(c<0||c>100)throw new Error("Size must be between 0 and 100.");u=c,this.hasBeenReset=!0}})),Object.defineProperty(w,"align",I({},b,{get:function(){return a},set:function(c){var S=U(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),w.displayState=void 0}return O.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(fe,$,_){"use strict";_.r($),_.d($,"parseTimeStamp",function(){return D}),_.d($,"fixLineBreaks",function(){return g}),_.d($,"VTTParser",function(){return R});var V=_("./src/utils/vttcue.ts"),M=function(){function w(){}var b=w.prototype;return b.decode=function(l,o){if(!l)return"";if(typeof l!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(l))},w}();function D(w){function b(l,o,s,h){return(l|0)*3600+(o|0)*60+(s|0)+parseFloat(h||0)}var x=w.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return x?parseFloat(x[2])>59?b(x[2],x[3],0,x[4]):b(x[1],x[2],x[3],x[4]):null}var j=function(){function w(){this.values=Object.create(null)}var b=w.prototype;return b.set=function(l,o){!this.get(l)&&o!==""&&(this.values[l]=o)},b.get=function(l,o,s){return s?this.has(l)?this.values[l]:o[s]:this.has(l)?this.values[l]:o},b.has=function(l){return l in this.values},b.alt=function(l,o,s){for(var h=0;h<s.length;++h)if(o===s[h]){this.set(l,o);break}},b.integer=function(l,o){/^-?\d+$/.test(o)&&this.set(l,parseInt(o,10))},b.percent=function(l,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var s=parseFloat(o);if(s>=0&&s<=100)return this.set(l,s),!0}return!1},w}();function U(w,b,x,l){var o=l?w.split(l):[w];for(var s in o){if(typeof o[s]!="string")continue;var h=o[s].split(x);if(h.length!==2)continue;var C=h[0],m=h[1];b(C,m)}}var I=new V.default(0,0,""),O=I.align==="middle"?"middle":"center";function v(w,b,x){var l=w;function o(){var C=D(w);if(C===null)throw new Error("Malformed timestamp: "+l);return w=w.replace(/^[^\sa-zA-Z-]+/,""),C}function s(C,m){var p=new j;U(C,function(f,d){var u;switch(f){case"region":for(var a=x.length-1;a>=0;a--)if(x[a].id===d){p.set(f,x[a].region);break}break;case"vertical":p.alt(f,d,["rl","lr"]);break;case"line":u=d.split(","),p.integer(f,u[0]),p.percent(f,u[0])&&p.set("snapToLines",!1),p.alt(f,u[0],["auto"]),u.length===2&&p.alt("lineAlign",u[1],["start",O,"end"]);break;case"position":u=d.split(","),p.percent(f,u[0]),u.length===2&&p.alt("positionAlign",u[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":p.percent(f,d);break;case"align":p.alt(f,d,["start",O,"end","left","right"]);break}},/:/,/\s/),m.region=p.get("region",null),m.vertical=p.get("vertical","");var A=p.get("line","auto");A==="auto"&&I.line===-1&&(A=-1),m.line=A,m.lineAlign=p.get("lineAlign","start"),m.snapToLines=p.get("snapToLines",!0),m.size=p.get("size",100),m.align=p.get("align",O);var E=p.get("position","auto");E==="auto"&&I.position===50&&(E=m.align==="start"||m.align==="left"?0:m.align==="end"||m.align==="right"?100:50),m.position=E}function h(){w=w.replace(/^\s+/,"")}if(h(),b.startTime=o(),h(),w.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);w=w.substr(3),h(),b.endTime=o(),h(),s(w,b)}function g(w){return w.replace(/<br(?: \/)?>/gi,`
`)}var R=function(){function w(){this.state="INITIAL",this.buffer="",this.decoder=new M,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=w.prototype;return b.parse=function(l){var o=this;l&&(o.buffer+=o.decoder.decode(l,{stream:!0}));function s(){var E=o.buffer,f=0;for(E=g(E);f<E.length&&E[f]!=="\r"&&E[f]!==`
`;)++f;var d=E.substr(0,f);return E[f]==="\r"&&++f,E[f]===`
`&&++f,o.buffer=E.substr(f),d}function h(E){U(E,function(f,d){},/:/)}try{var C="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;C=s();var m=C.match(/^()?WEBVTT([ \t].*)?$/);if(!m||!m[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var p=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;p?p=!1:C=s();switch(o.state){case"HEADER":/:/.test(C)?h(C):C||(o.state="ID");continue;case"NOTE":C||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(C)){o.state="NOTE";break}if(!C)continue;if(o.cue=new V.default(0,0,""),o.state="CUE",C.indexOf("-->")===-1){o.cue.id=C;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(C,o.cue,o.regionList)}catch(E){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var A=C.indexOf("-->")!==-1;if(!C||A&&(p=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
`),o.cue.text+=C}continue;case"BADCUE":C||(o.state="ID")}}}catch(E){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var l=this;try{if((l.cue||l.state==="HEADER")&&(l.buffer+=`
`,l.parse()),l.state==="INITIAL"||l.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){l.onparsingerror&&l.onparsingerror(o)}return l.onflush&&l.onflush(),this},w}()},"./src/utils/webvtt-parser.ts":function(fe,$,_){"use strict";_.r($),_.d($,"generateCueId",function(){return R}),_.d($,"parseWebVTT",function(){return b});var V=_("./src/polyfills/number.ts"),M=_("./src/utils/vttparser.ts"),D=_("./src/demux/id3.ts"),j=_("./src/utils/timescale-conversion.ts"),U=_("./src/remux/mp4-remuxer.ts"),I=/\r\n|\n\r|\n|\r/g,O=function(l,o,s){return s===void 0&&(s=0),l.substr(s,o.length)===o},v=function(l){var o=parseInt(l.substr(-3)),s=parseInt(l.substr(-6,2)),h=parseInt(l.substr(-9,2)),C=l.length>9?parseInt(l.substr(0,l.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(o)||!Object(V.isFiniteNumber)(s)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(C))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+l);return o+=1e3*s,o+=60*1e3*h,o+=60*60*1e3*C,o},g=function(l){for(var o=5381,s=l.length;s;)o=o*33^l.charCodeAt(--s);return(o>>>0).toString()};function R(x,l,o){return g(x.toString())+g(l.toString())+g(o)}var w=function(l,o,s){var h=l[o],C=l[h.prevCC];if(!C||!C.new&&h.new){l.ccOffset=l.presentationOffset=h.start,h.new=!1;return}for(;(m=C)!==null&&m!==void 0&&m.new;){var m;l.ccOffset+=h.start-C.start,h.new=!1,h=C,C=l[h.prevCC]}l.presentationOffset=s};function b(x,l,o,s,h,C,m,p){var A=new M.VTTParser,E=Object(D.utf8ArrayToStr)(new Uint8Array(x)).trim().replace(I,`
`).split(`
`),f=[],d=Object(j.toMpegTsClockFromTimescale)(l,o),u="00:00.000",a=0,y=0,c,S=!0,P=!1;A.oncue=function(G){var X=s[h],te=s.ccOffset,z=(a-d)/9e4;if(X!=null&&X.new&&(y!==void 0?te=s.ccOffset=X.start:w(s,h,z)),z&&(te=z-s.presentationOffset),P){var F=G.endTime-G.startTime,ne=Object(U.normalizePts)((G.startTime+te-y)*9e4,C*9e4)/9e4;G.startTime=ne,G.endTime=ne+F}var ce=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ce)),G.id||(G.id=R(G.startTime,G.endTime,ce)),G.endTime>0&&f.push(G)},A.onparsingerror=function(G){c=G},A.onflush=function(){if(c){p(c);return}m(f)},E.forEach(function(G){if(S)if(O(G,"X-TIMESTAMP-MAP=")){S=!1,P=!0,G.substr(16).split(",").forEach(function(X){O(X,"LOCAL:")?u=X.substr(6):O(X,"MPEGTS:")&&(a=parseInt(X.substr(7)))});try{y=v(u)/1e3}catch(X){P=!1,c=X}return}else G===""&&(S=!1);A.parse(G+`
`)}),A.flush()}},"./src/utils/xhr-loader.ts":function(fe,$,_){"use strict";_.r($);var V=_("./src/utils/logger.ts"),M=_("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,j=function(){function U(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 M.LoadStats,this.retryDelay=0}var I=U.prototype;return I.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},I.abortInternal=function(){var v=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),v&&(v.onreadystatechange=null,v.onprogress=null,v.readyState!==4&&(this.stats.aborted=!0,v.abort()))},I.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},I.load=function(v,g,R){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=v,this.config=g,this.callbacks=R,this.retryDelay=g.retryDelay,this.loadInternal()},I.loadInternal=function(){var v=this.config,g=this.context;if(!v)return;var R=this.loader=new self.XMLHttpRequest,w=this.stats;w.loading.first=0,w.loaded=0;var b=this.xhrSetup;try{if(b)try{b(R,g.url)}catch(o){R.open("GET",g.url,!0),b(R,g.url)}R.readyState||R.open("GET",g.url,!0);var x=this.context.headers;if(x)for(var l in x)R.setRequestHeader(l,x[l])}catch(o){this.callbacks.onError({code:R.status,text:o.message},g,R);return}g.rangeEnd&&R.setRequestHeader("Range","bytes="+g.rangeStart+"-"+(g.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=g.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),R.send()},I.readystatechange=function(){var v=this.context,g=this.loader,R=this.stats;if(!v||!g)return;var w=g.readyState,b=this.config;if(R.aborted)return;if(w>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),w===4){g.onreadystatechange=null,g.onprogress=null;var x=g.status;if(x>=200&&x<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var l,o;if(v.responseType==="arraybuffer"?(l=g.response,o=l.byteLength):(l=g.responseText,o=l.length),R.loaded=R.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(R,v,l,g),!this.callbacks)return;var h={url:g.responseURL,data:l};this.callbacks.onSuccess(h,R,v,g)}else R.retry>=b.maxRetry||x>=400&&x<499?(V.logger.error(x+" while loading "+v.url),this.callbacks.onError({code:x,text:g.statusText},v,g)):(V.logger.warn(x+" while loading "+v.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,b.maxRetryDelay),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)},I.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},I.loadprogress=function(v){var g=this.stats;g.loaded=v.loaded,v.lengthComputable&&(g.total=v.total)},I.getCacheAge=function(){var v=null;if(this.loader&&D.test(this.loader.getAllResponseHeaders())){var g=this.loader.getResponseHeader("age");v=g?parseFloat(g):null}return v},U}();$.default=j}}).default})},vHTk:function(ct,rt,le){ct.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);